From patchwork Thu Jan 25 23:57:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13531903 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 0A634C47258 for ; Thu, 25 Jan 2024 23:58:11 +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=cBXz3hs7msB8ND/f9l4eZkMxqemo/A9zr18UIN1I55s=; b=a1+inj3kTly4PF rTXcteDYqJ8U2TRM/4wsFvgJaaGTpXkrY7wU4O4N+Lu948Le10J4TstjdVuuxXMeCh/CVbQOJW7OQ iajFs1UQFi92EC5vUYUaU5OGL0oGMdaFCj763JrIm6/2bNHAlWS+3tHzM0mor/xkl4j9x2B3xgXl9 1WhXpGAZjsGEYAS2i8PmieRtPjZpwKmxG+EuB8jEJ3qi38tPJu1GQON6ag+OPQJvE3jOnB0pwkUru VBOD4teSRj4IOMXK+OkUSKGDs/pgZSLHqjaz0zVA3WEo/CT8fAhr7wqm795J/9IAGR9mQcWNCaEDr 4wanBvkYyvqe2KA/q0GA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT9bY-00000002XKz-1UXh; Thu, 25 Jan 2024 23:57:56 +0000 Received: from mail-bn8nam11on20600.outbound.protection.outlook.com ([2a01:111:f400:7eae::600] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT9bM-00000002X9f-00Hl for linux-arm-kernel@lists.infradead.org; Thu, 25 Jan 2024 23:57:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nxpcB+XbUgsWLjKWlYIYDGrx3cbyeeX0jWr1agn9KB/yiv3F/CVzdrHkx7U0dXri8Iia4GCgCtU2Lj19pDWc1r18JBVTpaAFtkP0nIH4cx2sioxrW88J5JyywxLomdwVpMk6t5zlqhNh1cXKpqfvBKbX8+P5JMEaftY0VweVz9BuC1eEiGztsUIlMu+rkFWt4Qk2l2o2I14Q2h7iMpPetUGLl6VJIMHlzmODqVCs5Wx1yszqkixoV/F9zn+h7WgtCN+TTlIeJNTE1N8Or2qmZY+p2h/MShMR1U5EPKXnpn8GY5i2qG/HwJkllb8438pexFG3ftll/9i2e5hvjdbogQ== 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=anlqyL/gBdlqrW8QW8ZJOtrF9u/+OhbwSx5t9+yl6cg=; b=DraLtI/7cIIAGWJru2uL07rspE6O9RCfmZ95ntt6m8yHJDY7vESBdVVMOsdXD2uc0r2HWlZjvud+vvJaEsnpl8w2+9+CzxfcNsbf55wr7YodyNfZhcrlKvPc4ORdc29zMMQWVaAZcIJLG1GKqAN1sS0ejM3giFqDRC2INJGFGUz01PVd4vSn1R/lAvimyI86Ib4bm64hwdtB4VClhs+JWPL8Tq4Pn2CGN0NvXpBNPZzngTipfPJHQ87BPW9k6zqReT23bh3F4j/MtCXuzoU8JwtfGmQcboSr7rhN438uFlDWMsnF02mUTvabmmxDlZ2NfrsueY6B/6027/h9ezVCzg== 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=anlqyL/gBdlqrW8QW8ZJOtrF9u/+OhbwSx5t9+yl6cg=; b=oesfzA1jJpFSOCFSXBM9dKLdvPVyLQEjdKWHH8U3c21dB/G8oxvTJBHWkEv8snGZMygO91/0qBxMHeUL5pjC4PPMH2A+E2ybJro5Xvvz0T8WpaRoT+YGAcsmfHC/GUtXTK9d6hvOUN70NkJId/l3zAFfA/WLJnvcpqolqk36t7nKWDVypT+Ap9Ah6bDcHm5TuuhHiL0cleaQMI/Xl4C3ech84nvmUak9xboDHZjZUOCI59dg2cV2lIE0eAuRZdi1AzTsnT6i+72K6fgKpKketlMd4Z+XpdVEE3GcqJUx6jgL5B0ZiEmwo7Uz5+LinBk61c6FyWPhvcgNNZ0M+Jp61A== 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 SA1PR12MB7038.namprd12.prod.outlook.com (2603:10b6:806:24d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Thu, 25 Jan 2024 23:57:29 +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.7228.022; Thu, 25 Jan 2024 23:57:29 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Moritz Fischer , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameer Kolothum Subject: [PATCH v4 10/16] iommu/arm-smmu-v3: Pass smmu_domain to arm_enable/disable_ats() Date: Thu, 25 Jan 2024 19:57:20 -0400 Message-ID: <10-v4-c93b774edcc4+42d2b-smmuv3_newapi_p1_jgg@nvidia.com> In-Reply-To: <0-v4-c93b774edcc4+42d2b-smmuv3_newapi_p1_jgg@nvidia.com> References: X-ClientProxiedBy: SN7PR04CA0002.namprd04.prod.outlook.com (2603:10b6:806:f2::7) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB7038:EE_ X-MS-Office365-Filtering-Correlation-Id: fc9e6fed-180e-424a-709e-08dc1e0162e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l1wDlnF+LYVGrbJJrwp5XFfkjfAPJkazmMdrPXvuSQE9QNnPVfInfddLp/eyQuLfpkAzu02ZcA5aAyKnvy1hqFb8Jdmf+2eNqxOG1DZU/mamY5+emeyNLjMFHuIXEFFPU58CQ3fF6se8nCHa5bkl9F/ckfChnO/7OSJX/rUGKSA3qX1FpJ+qa69PW7uhWqNPIr+pACMJZ/Qj4jeUcPCqzva5LkE8wFqmJ5uOxKiqI3vSpr9c1WIO29KSCpLjbwzb4l/3wrAG8SQzs2HpvzSShL75ogXDfCEgd6kmLK/QBik8+s1AA8K3TWWXLkPhlzZhOT0tLAAQCeGwFtrFOkLBkIiZ55iX5B9ozteuO5zgHiUP52XuoHnT0LWYC0KD+l3XlWeiz1AszsoCIaJPw5V2kctoGrd0LkmQFPBX/PwoPLRtfCSApys1iJsXMRlsWKxg1SZhUHPkcseZ2aBT+XHKirK3PLyg2zqEp5vq2S/zId4dPBuqWWLKGodHUQW5IaXJyG7+uQ553UXF7fbh0I/40Fs1Ti7KlPQf5S64Kt+vYTvqTJSB+TOnngSDVKxeOwvs 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)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(66556008)(54906003)(66476007)(5660300002)(316002)(66946007)(8676002)(26005)(6666004)(4326008)(8936002)(2616005)(110136005)(7416002)(6512007)(83380400001)(2906002)(6506007)(478600001)(86362001)(36756003)(41300700001)(38100700002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RD2O8+f0H7ZBLIYmRUFEXj/xYz/yfLqHSofj8V1p5+E2smTuCB0+qHfkd5JQa3CkZoti0vEAsTdWWzZn+5z5IYiFnVQPvmrecs91v4Y96BDMuichrAQ4YW+Ei2jg6q7FHH2jcVDP3UDuQcU4/Cxckklo1geJHodRlxZVty5T1lpCE28NNYUDUKOP+aNJEljZuBZ1SiepMMMH97zBSuuHH4ylMuX2+imlwfNbx7H7yHh5fD1jrlBGVhiyWmBXmrd9sLSNJPEtGZNCs4gF9hFL+RVnFtHpMf9wjcALP2iGk7/1b1htWGOyz1VmpvUa9+S0kaHniuM4R1pDOFPKyC7hIE9umWFr/cYR/Ebi3bdK53FSaECs3bdUuBXpJJQ5XnnBZyjnh52VbWFVDcyZDLqZCCwQF++IXM1vzr+Hu778o0hEAmWeiy0aq1s+DCzGO/j/2s+djAqdpgrjwm4nI+6nQ4605r2gSJk82xKmBdKUrbZwNWc5MfZFR8yfZXSSFkHSrDfRfN4KqfZrgVG8Cm/RB2ezq+fOKyVo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-Exchange-CrossTenant-Network-Message-Id: fc9e6fed-180e-424a-709e-08dc1e0162e2 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 23:57:28.3646 (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: uiqFmpBjbSNCpJjlpDEBJ9HsAXLv+v5kS2KLkstR//UraWxkfPcmVcw8fJ2e2EzN X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7038 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240125_155744_105083_DED97B5F X-CRM114-Status: GOOD ( 10.31 ) 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 --- 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 09b40ba35a9cee..d7b0cea140f12b 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2447,12 +2447,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) @@ -2468,10 +2468,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; @@ -2540,7 +2539,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); @@ -2662,7 +2661,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: