From patchwork Mon Mar 4 23:43:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13581390 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D589C48BF6 for ; Tue, 5 Mar 2024 00:50:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ttaDWcpQX29TjH9sQBfoij84WERM9bXkZNDQghHfEeM=; b=jvgug1OADTyCeP 4J4PJelCZ1DVgXA32zNt+u9QPF0K0LD2jXnnM0X4mNi8NhJhtpDgRmjkBOlh2HZbkn8QJF4PW0Seu zVdf4+Y1bCtnCntEs84MjMhBsrmJOM5W/AE7kEgpqzTXDhC+Qj4XMKXBmICjbFb7A86MdpIpXHNgC OiJ9V5Fi2WhzHgwfFJ57vPjl6dwYxLncReAgrrbidRdpwJElrJd0hdt8vySYsmo8auEOVSD2UL5nI eg+HcwE/6LP7E9YqUVErerrZH49UiUDTp6pvWEcWzHkcdMMDeXD+eP9SelWz4o1UP02+3yom3YJpw +3bKnNWV4oZbm7ouiEJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhJ1A-0000000BHVl-2jFk; Tue, 05 Mar 2024 00:50:52 +0000 Received: from mail-bn8nam11on20600.outbound.protection.outlook.com ([2a01:111:f403:2414::600] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhHz3-0000000B7Dn-3QZw for linux-arm-kernel@lists.infradead.org; Mon, 04 Mar 2024 23:44:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L7LGR0rh2fCpUj5KqlCNy8zNZtnV7puKxEN8ATcN8+lOqm507GhU4BXz3NyBOL65VW027sAOMfbyV/frIrK2qAq+6FBOrn7g7OcZ/amGoYdGZ0LtXxET6YNiso/uDXyPaeUalnL8PW1/QIYsr3HukXWNZwyFPu0B3TAyncqgS5uH1Py1b6EkpNh6CfKbR52q4ByOY/RMb0dKMqL6YK9YHqR/oTuUArwW/AVIwOvbssbGUxZkdoIKZrJFMgmB0i4RpDaiv5WwPFhAuo/+JJsuz62j6HKnGHpFPnUmZ+v6ZtkDscKebwuErBJ/5K79jZfrP3tKcmcn0iviC2Jk5wZniA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=btf4O+ezGIzXfytAvcnJywIDvOCH5fzF02YGRUrxWkg=; b=ezfDdRyvu8oT5aC7pJ7Fyi3KOkBc9KeTdpgOkb9kvtT6tunz1SNurhXvyFA1isf2ppLAPZknramEW1F3ZCE6rohLMGDFMSvPLlMXjRxmBsOMT2V3F0x0ObsIAaAftK+3QEzSr8hUkVbXH5nNVrTzgeCx92u5pbDGsTwkNZmUgY9ZoNiparsmei8hAhL7cWqTEJzcMY/e+yAgDbxQNhQD1q/109BlLeQvrWV+z8FizUJy6LzVhqvFCia9kfsdLvrgikyKvkwZAPTF4L7KaENm7NtMQpgBB+5hDeJOqDKpGP6jSz8IatJP1qQu5Mfvkj4xSUsJdFSO6bzm4ulLNdzFuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=btf4O+ezGIzXfytAvcnJywIDvOCH5fzF02YGRUrxWkg=; b=TgRznU/WSnfs8Yx5sV1U/ehUqbd+msbo/sZgxUFrS3/bn3PtD1qe2XkqSfRK2G0ImUCfLdrlznzjDzyXkILbuf/wacAewco4EAudY6tjZAyUZviHg4TbQhGloKBR4MTzqmFOvXHrqa47FKQzOIBsHhpMxmQ0SdPa/p1rX/0rMiXNMcNIWyHM70rXg5kQPsDQsfi2yTn6Gd016L6I0uP0ysG+caqKMjF/PXbgftTv3SwkNpG2e75ZO/j5issAdpT+ErElt0d0G8vYQ4xhMdBrDp5RIOOV45Dx/wf+rDlRWbCNKSJSl9tGAd8PB9U8VjX8afgEqtG2pzHhotziaCsqLA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by DS0PR12MB6584.namprd12.prod.outlook.com (2603:10b6:8:d0::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Mon, 4 Mar 2024 23:44:24 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c33c:18db:c570:33b3]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c33c:18db:c570:33b3%5]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 23:44:24 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Eric Auger , Jean-Philippe Brucker , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameerali Kolothum Thodi Subject: [PATCH v5 02/27] iommu/arm-smmu-v3: Do not ATC invalidate the entire domain Date: Mon, 4 Mar 2024 19:43:50 -0400 Message-ID: <2-v5-9a37e0c884ce+31e3-smmuv3_newapi_p2_jgg@nvidia.com> In-Reply-To: <0-v5-9a37e0c884ce+31e3-smmuv3_newapi_p2_jgg@nvidia.com> References: X-ClientProxiedBy: BL6PEPF00013DF7.NAMP222.PROD.OUTLOOK.COM (2603:10b6:22e:400:0:1001:0:9) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|DS0PR12MB6584:EE_ X-MS-Office365-Filtering-Correlation-Id: 22707f70-d680-4b62-c53e-08dc3ca501a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kiybZkTD8SMZ4LWLTQqk9lnPtu+HR6Ge2T5yWbbCAwiTJBKMkYL3vYcD+ZWXpx8b9S3uRRGnJA4Iz1uwzaCpabmSmcjsVJYZKqp94yh3wDZtEkPmpArjZRNT8CV1hMuqWgHFh38J6jI1lAe5AB6uuyqHlYUxpoCqLY3SoxriNv6IEgLwEl2a12PFyZd8pR0Rt9G9txplUgobuNCem43OOhaYNkD+6dv2zSMhDI3RkjYRsQwlozoiH8V6Cdf8+s+g7+u64cuUDodpXWoGyHFjTGdYKDZ53NoAVprY9KmiWDi2q8BjXc2FP740L71r9IQ2/F7USx/bgSJnPHtWwC3jEcsezDmZQ5E9lefBSZwmZU7AE5xJmVlOMVkYdOEmrliTCABsRaDYHY8THDuFoJbCX1zgfGY9/hMZX8cYbglnrCKGo37/zEYx674HXabmiWe5rQFOb67T5SapXnElp5CDCP5Bm52TsVLeG0q1FL9BmbwZfpKiGaMxHxwvmMU638JFdN/aCQQDRNBakAIVEuVxhcqXXiUytI4k5MKFSdGLb+k5LaBuuAh39nOKSCvNknuniu959IDQYVdSAz8Hrl6ys4EAEKcf1HCgmI1RwnaARJ2HAgdQ1iZyNP2QBIoNqk0xu2d4t3FiFw4P+dydWObn11PVKkk9+AYhDoK6nF1q5EM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VPOrc/5gkmZxSpm+ln1/xqjImqeXWOeXn6uMkaCzVzbmtmpUSVxLUS0uClSmCGUlPpOWGj/PY9ajEhvv3BlLboLdN1YYo0Lsmwo13KpCC9os5YPAhgRAKzezIHZCpB0YWrCn38s5KFnOTmGPvbmTLMYbiurCTFnKolG5i8+HPcukWswwKkxgQ8/s9vOdg5dFrC6Xk6cn4wCCTQLUmryyxPNDPlUhNS/1QgPj7K63broXnQoGGymTBeo1Nm9vsQfmVO0t2rJDg2TWi5aATTiZJEFu5CqV0jQtOTutRcvQ3/HPwSMgOaUbyMoYLczPX4nGWNiLQp4ddTRYyk063UIFkFzQTWvXq2ykRl0M20UxzI8+DK8dHEviRNca5zdxFs+6idJ1pmW+zqCV9ZP50wou2wgWP0pVeR2pHFqkApcltiOXeJ2xBmW//KLxRN3vF+VpCQrd+qghINQIf5cru6jaU1nLDkZ4XQ+RR32JDX2gXKJUf4ECay1iCfaAPgQJzxLM0vV47yTGrxt64GRmojQwC5Pj1/Oe6le+FRFbXYYuaWOnKDjDMun7u2VcVicdRBiW6byty5+JDQwVCXS1j5RC2rPN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501a3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 23:44:17.5423 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mlFaSGPUBM5kJOxYpsqMZEdWvZ4IehpcrbkrlSzokQV/9hLStgdTYz8/eGErh+Fo X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6584 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240304_154438_483260_B281C6E2 X-CRM114-Status: GOOD ( 11.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org At this point we know which master we are going to change the PCI config on, this is the only device we need to invalidate. Switch arm_smmu_atc_inv_domain() for arm_smmu_atc_inv_master(). Tested-by: Nicolin Chen Signed-off-by: Jason Gunthorpe Reviewed-by: Michael Shavit Reviewed-by: Nicolin Chen Reviewed-by: Moritz Fischer Reviewed-by: Mostafa Saleh --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index d1bc151a5dff8c..9e9233331c4636 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2447,7 +2447,10 @@ static void arm_smmu_enable_ats(struct arm_smmu_master *master, pdev = to_pci_dev(master->dev); atomic_inc(&smmu_domain->nr_ats_masters); - arm_smmu_atc_inv_domain(smmu_domain, IOMMU_NO_PASID, 0, 0); + /* + * ATC invalidation of PASID 0 causes the entire ATC to be flushed. + */ + arm_smmu_atc_inv_master(master); if (pci_enable_ats(pdev, stu)) dev_err(master->dev, "Failed to enable ATS (STU %zu)\n", stu); }