From patchwork Tue Feb 6 15:12:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13547494 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 F13A5C48297 for ; Tue, 6 Feb 2024 15:13:28 +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=6gimdU0yJBtFTqw5YJOV9S9RtcUOEl87hlGG4rgxk8s=; b=I1j5ROTrg0QAJb 2YfzYoz+7GetT/t37L31xdK42FNw1fjP3cB+BmLmb+Tn+4SQOhGlqzuuq7TVmzsikGhcfHAY69xk5 urXwFGUYEswjqor6Ss1gDWsI4W5vzrBepzlQaaC4qnmeetI5/i/mUbULfJghx8YvNHucqnhUe2bE4 EWKaqvv/y/di5Ax+jwBIVf58IC/AnsgxPyd2fgOftFJ3ZhwbpbjNuMHKa9TC1c5DBJ9gf/uHk82EZ E47lL5pGFpMyGduhtHvgAFKZQMxveX4DvzlLFuj+TC6WRczWaneYdk8xOT9QNnSU4LkHtSuP+o3+7 diCwx9C1P4eTkXxtlv+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXN8J-000000081M9-320t; Tue, 06 Feb 2024 15:13:11 +0000 Received: from mail-bn8nam12on20601.outbound.protection.outlook.com ([2a01:111:f403:2418::601] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXN8F-000000081Kg-3Ggr for linux-arm-kernel@lists.infradead.org; Tue, 06 Feb 2024 15:13:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H08100+VjsbtXQ4mz+DdE1SoVzOJ8QrLSIV86Pg2TFZjftXvvg7Bag6i0LLTS1hixT5h/Klm2GLlJc9QfoXjjPwrmHxcA2NaQnXL+MT7Hmz9J4vjcPhAskww8726DMnT+JU+V4ujnxzD5c0YZz1OT1rz0SZxNHn5i8zMbcSujejuBC5gBrqb9f+k7lIhcBLjqt3Z3rWeUx8K9WoLBplfHIbuoTO09OIfPMb1YZSsr+0mgOMuRnYdtF/4eCusOlgMLOQI7pQhwx9Iym9bLLizru5sPr84jbfEiXiWbiS5Izuyl88ujFxEyhomTq/On6sHkPf0s1XWzfVM999xV4ymxw== 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=jelnYfSZtSukW9U8Ez1I9xV3Nrrum3dHvFOiJLjtmCI=; b=oEnCF4e8alMwEXrkS3031YMijiCPOxBawMXMECjzkcxmCrVStFU99xUbdsaxHZUwiI0Jdv4BLmgxi1VJGssaNdm0ynUr1p3ZfgIz3xuCdv78IDKQgvd9SVSedjp2nrDSXBGgJXtVYRXD8wMxnzssIMMAgmsAyK/2LC2Wuyfrac2zXJmQ9i0mL6KFG3RXTEmLS3rU6tO9NcZGK7J6pZQL0m3di254sME/CH5bVH1bQ9z8z5MeqGx7SaOyrWZYU0badquubXYL78OEMlI6wjwMtOrJglQlUH2PXgfh3ToiTJbU3YTG6WQzoVA3g2VjC+lZzlMCxGx/31diy3MJ0IX6yw== 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=jelnYfSZtSukW9U8Ez1I9xV3Nrrum3dHvFOiJLjtmCI=; b=WgtjBNEMJUSTq5K3FfgE31h9vaAIFkAcV4kY43TYdZcbSHsByESQplWetNb3qkdZE6O4Cs9kGwk96C/ExlNUgBwt6J1qmuQaae+BrirCozcyNX7hjBG2fCNp2aNk3fmXDNX4Octit7FLJi4ftRWP2ahzuXd5rsAk6gHDCtQ/Hc3ea1DRMD/EUnWnwOHSmmSA43eV2CLqR1RxpMELhuRaux+DIowofBSJ8KsDiyT/FS/igmO4yQtk/9oa5pEomO7Tbblx33gOdrvmP88gHxdB/rETc+2JMIJAJQhBQWzmzevk8pvddiq0mLf3i8O1+3U7so3jgN1mMxv0AOjC1rkW9A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SJ0PR12MB6733.namprd12.prod.outlook.com (2603:10b6:a03:477::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.16; Tue, 6 Feb 2024 15:12:58 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::96dd:1160:6472:9873]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::96dd:1160:6472:9873%6]) with mapi id 15.20.7270.012; Tue, 6 Feb 2024 15:12:58 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Lu Baolu , Jean-Philippe Brucker , Joerg Roedel , Moritz Fischer , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameer Kolothum , Mostafa Saleh , Zhangfei Gao Subject: [PATCH v5 10/17] iommu/arm-smmu-v3: Pass smmu_domain to arm_enable/disable_ats() Date: Tue, 6 Feb 2024 11:12:47 -0400 Message-ID: <10-v5-cd1be8dd9c71+3fa-smmuv3_newapi_p1_jgg@nvidia.com> In-Reply-To: <0-v5-cd1be8dd9c71+3fa-smmuv3_newapi_p1_jgg@nvidia.com> References: X-ClientProxiedBy: BL1P222CA0001.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::6) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ0PR12MB6733:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ada73d9-c9c2-48bd-d1d3-08dc27261873 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NXxnyge+J66xwiRsOExetgromZ65I8koXHcafpStaYjTvn9ZpSjhxo2fZGglYJQ+NBXIEbLHEG3b5VJVxuLK0VOqF+h+djJyaGYuR+xNGqCC8HdaarCjG6PRGOpH0c9MZ/PzNlPvq4CAaZRRov2BkLoS/piuTpNRSEqiQPFvaVvhZ/GFDSPz8I5G/JTejfCdFdVqOYQEVTghTtoqmhTC0T1Cr/8kntTvzxKOShXLo6qxIB98jqeSQTlhibqtxrg986NvjqhA6Arl6Ftse0VlTljsFkYS39n0AnCRQx4b87cTaFPmJAnlGiIRVnhccbMH3YA2uEPr3WavnxPSl9vUPPna0Lf2ukGA70nNyKSmGD1dkZUXPAJIE+TA6GpLW6G73NprKYkmK7EsZzksgbVXApr4gw47EkVD06a0C50oYZo7rdiLmhv/kig0F3TAMgYTN+W0zaAbKdFpMSerbXywmBO7YKQwFM0pmhrv7agluGvgkY84XPU8Iky6p/U0Iboy76qlD3zPyOxigQmzzJ7abf08tHv0bNBy4l0nqVE4SUP3YTlyMqXoGXlLbRv4/PJf X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(39860400002)(366004)(376002)(396003)(136003)(230922051799003)(64100799003)(186009)(1800799012)(451199024)(54906003)(316002)(83380400001)(110136005)(38100700002)(2616005)(6506007)(6666004)(26005)(2906002)(7416002)(6512007)(6486002)(86362001)(5660300002)(478600001)(8676002)(66946007)(66556008)(4326008)(8936002)(36756003)(66476007)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BK6OBqmcVp5D7XgUddth32oThnV/VdK+kuIoMiDx7VxQD7BAqCnzOB7/fa4uDCtrLit98iv3sEgacaH85u/HmQDzGtbzj4I2d32jziFyLL9kPBRD3PU7pCOsTfKt30Nb7uYmq7geaioaTH08SeUkHBL55NEM9Ehs8IMu7SZhox8o5frBfvKHcg3XlsBXy/gBYBF3QsaBjvIXL7MaVDhHxFOzsxyUfZe7fN7OO+CEiaTsDb5SJHDccxgIu8ZgyYe3/yZVp7nroTs1yfCjfViZdobPQR8xEL/Cp+32o2Q+YcD+ujdPWgxzNI/vcWi6/4onm61fe9EbyEhQd1tW5Px7nh+z7SnPVVBCfhkGIN1jcGCMcho5uhJlletk/XnFI6UHSeEZghSjVAR7Wb20oJRJ2S5DLWOYPkIMACE0f4vQ391PlzHDlcWaAg1/160DnoGDLvpqP0U0Os8jJl1BB1v1UCbw1x4LjWLKSb1BBEUSFcp+wqoDIdeU8v1hpFQ781W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8R/HuAn X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ada73d9-c9c2-48bd-d1d3-08dc27261873 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2024 15:12:55.3336 (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: ptccVQrFt62fjOXCfDhE09ACaQJilwxJHRsr91dcrSt2mxanNM24zdA+aVnC5DML X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6733 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240206_071307_845098_DADD2DAF X-CRM114-Status: UNSURE ( 9.85 ) X-CRM114-Notice: Please train this message. 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 The caller already has the domain, just pass it in. A following patch will remove master->domain. Tested-by: Shameer Kolothum Tested-by: Nicolin Chen Tested-by: Moritz Fischer Reviewed-by: Nicolin Chen Signed-off-by: Jason Gunthorpe Reviewed-by: Mostafa Saleh --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 2a6ac0af932c54..133f13f33df124 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2474,12 +2474,12 @@ static bool arm_smmu_ats_supported(struct arm_smmu_master *master) return dev_is_pci(dev) && pci_ats_supported(to_pci_dev(dev)); } -static void arm_smmu_enable_ats(struct arm_smmu_master *master) +static void arm_smmu_enable_ats(struct arm_smmu_master *master, + struct arm_smmu_domain *smmu_domain) { size_t stu; struct pci_dev *pdev; struct arm_smmu_device *smmu = master->smmu; - struct arm_smmu_domain *smmu_domain = master->domain; /* Don't enable ATS at the endpoint if it's not enabled in the STE */ if (!master->ats_enabled) @@ -2495,10 +2495,9 @@ static void arm_smmu_enable_ats(struct arm_smmu_master *master) dev_err(master->dev, "Failed to enable ATS (STU %zu)\n", stu); } -static void arm_smmu_disable_ats(struct arm_smmu_master *master) +static void arm_smmu_disable_ats(struct arm_smmu_master *master, + struct arm_smmu_domain *smmu_domain) { - struct arm_smmu_domain *smmu_domain = master->domain; - if (!master->ats_enabled) return; @@ -2567,7 +2566,7 @@ static void arm_smmu_detach_dev(struct arm_smmu_master *master) if (!smmu_domain) return; - arm_smmu_disable_ats(master); + arm_smmu_disable_ats(master, smmu_domain); spin_lock_irqsave(&smmu_domain->devices_lock, flags); list_del(&master->domain_head); @@ -2689,7 +2688,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) break; } - arm_smmu_enable_ats(master); + arm_smmu_enable_ats(master, smmu_domain); goto out_unlock; out_list_del: