From patchwork Thu Dec 5 15:43:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13895640 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 489F3E77170 for ; Thu, 5 Dec 2024 15:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=kNYVzTqD67s/KKUJPEF43ljbroFCLLbV60xYQ6rEgkE=; b=yo0ro5o99M333yCHdalrWoBlAl ktMJnxEUL1mc+RMFUQiayrHaoSJWVID/aegwSGckj5aLvKESPKkW4pXKfekp82+qw9D4aOP5i9+rV zoK0645hHnWhSnT7zGaU44yel4fq3Y9aDSkbMhn+VU0kwk98t/+36/yNjL9KgjhYvT1vL1PySmEGG 8YiHAQYoAutkQSci/8m2BGWbfdGryz60eVltP9KhfqOEOa+d4Q4D2Cb8EUZtkCyb69KHU5uO42/4B YfDP7F1eIf15pnvaQUJGKXh/NrmC3RUDm5KH0AxuHPGS7+aybTS/atgNSG2Rh9WjST5Df7A91r1gW 7JcIkdAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJE4w-0000000GcgI-0Fp0; Thu, 05 Dec 2024 15:47:46 +0000 Received: from mail-dm6nam04on2061b.outbound.protection.outlook.com ([2a01:111:f403:2409::61b] helo=NAM04-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJE0y-0000000GbZZ-460g for linux-arm-kernel@lists.infradead.org; Thu, 05 Dec 2024 15:43:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AbvL/RB++alOaY/Sk9tN2EnrF5/gRy1gtGV64+zwo3HBsG1JW+JXVwDXUhQ2c2WXhETOURzWibHl8n4/trSrv2mPhmCl66YQW+tqto7OzbjIN6H3FgVn4SL2c1WUBHLYDhG+RKV0yAL2sFIcHVdEak0T3unImdB94G3AG9FEkfMSDM7D2ENddmlnDH8XpI+YlB3X1I4OeGWhhALeYel+/jl9MMPbl/8Tjv8rg+92JxTN1vj/hhM+0YjBhu0SFOihiDxUt4uPnJdagHeUGcEMWvWK0a8IZUkYArvdm47ndiO08DLQntxsbjQzeisiOHI3PgchLogsnBWJFzjxFd5pHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=kNYVzTqD67s/KKUJPEF43ljbroFCLLbV60xYQ6rEgkE=; b=ZeE37uPlfvvBdPXKCxYp+8DPFqsuWoNaX5CMT/MPxWGxeZY8Z0izKpxzSxZmO2hsZvywiXqYGWmkY2Drrn73qrNR9IL7zod48EdWXhXBjlfkA42GJGJpFAWrwTUkCXrsH6lOXZ3zyvLeCceKpeoDFxt3M3+3ymQnMXEjzCTW0XWV2Qu++i/iaeA1rlJ3nZPqqzRU0qbDw9lp979UvYWcjcNPR8u3u+Qea7MVQPRgB7yHvI/oz8fGo5V1Evm1jGfqm42JpsCpYJ+E8kama3i4207gPT5WwYHXtUCjUNqgLeyQLb81HiUTGhn2UYLD3BQfIT1OjL8/+F1CVazk8Fu/Kw== 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=kNYVzTqD67s/KKUJPEF43ljbroFCLLbV60xYQ6rEgkE=; b=nrfbfE/YQIWXeRwmzdK2NdfQyuGRrVBsVxBsjxkGg6gDHx2sKaBGGGtEMyg3Jy16rliC8RbKbDpblaBim2wyS2PYSw0jLPsJt5TykBDgfFJ4Kys/9woGac1A3jdkypbqzRWjGK9TsMhW4Tafk1psE8mlPvEmLWUOvdZmivb/NCbZBVwek+rG33WTU/Ktl4F1TmIdrvQzt80HABzVJJgjvtnnryvBVnPxC+QXKPWD5m5CaKunJagxRb/slFFYgSyLV66tHteMqSNJKCoMhYYMxIWtd6QY539xM2tFAj6QzxsYuJkp7T+CokCUrblY1ao9d/BX4vDHSz7eYuf2W9gsCw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) by SN7PR12MB6789.namprd12.prod.outlook.com (2603:10b6:806:26b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Thu, 5 Dec 2024 15:43:32 +0000 Received: from CH3PR12MB8659.namprd12.prod.outlook.com ([fe80::6eb6:7d37:7b4b:1732]) by CH3PR12MB8659.namprd12.prod.outlook.com ([fe80::6eb6:7d37:7b4b:1732%5]) with mapi id 15.20.8230.010; Thu, 5 Dec 2024 15:43:32 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: patches@lists.linux.dev Subject: [PATCH 1/3] iommu/arm-smmu-v3: Remove arm_smmu_domain_finalise() during attach Date: Thu, 5 Dec 2024 11:43:27 -0400 Message-ID: <1-v1-0bb8d5313a27+27b-smmuv3_paging_flags_jgg@nvidia.com> In-Reply-To: <0-v1-0bb8d5313a27+27b-smmuv3_paging_flags_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0054.namprd03.prod.outlook.com (2603:10b6:208:32d::29) To CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB8659:EE_|SN7PR12MB6789:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e4b1bf7-5ac2-41f6-2b77-08dd154391cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: YyyISp2Fzgfe1Ea+lF7xtcwPHeUUCS+oZo4h1NdEwelpKcvy5krJfvGVLtzcJEZJb0dkGlXe7CF0978+6wU2NS2ZOZ0XVTmg21vyJl4sVGr2IEZtzmNlv7VwJyWmKY6tQOX3L9YL3cIKuqvyVPLS8j51lv2t01SyaC6qZmO9RYzKmSqGffj/cg/qTfBscKLDO+SAzd1muk3lqUCg5JYzqVaKFu0DliCf2Zo4Dierf46c8e6EhJHrr2a6lB+Kg6ORr/iE1pzST4NIiQI9glZhIq/Y1/HDfkNbcNo5Uxvjn5BSB8E1S779onAWFTAqOtW3q7NIMLYbB0yU+LuqmMPKb0nhd27Ey1mY+VTiatZcafPYyI90o0QMuL1Mes/bCh8q1MCw4HjvzCgMYJXLnGI9ajneK/FolLbWvzoGDi0K7ey//KLCIFtEMxJfbH8QqBFb/3kdPR4gsEzDecOtaIDkEpyFVlULjm/ELPLBp4ctIhbprN4wS7WyRpCR/RaPrcgLNNn8/5xLhDeSwxkigoEx+JfvavRPRCW1BkCeY/IzyHTuKLTUAqOpBcm5mBBUx1lLjDlVVsIo4Up2HAPR86Oofa9iVYumC28QqzjW1/nJJykecAX12vCsXpG6NkSPDWwfFOeLsbmObQG4piijwXrJaAKQ54T2b0CpQoGx63cwLnrcA0Kpnfagk8iwZ/J7zBp+Svo/K6WSFX9V4pCo//Ck+oAO32VQJVci0M1l6xGNlYkpTbPbDLo6AjGSM6B9MnIPSV4v0I4DCi5MSOXTe+/JgE03DL3CgBa4rsOstQpd79Nn0wXwcn2uM58RaeXe/fHU8nkL6EvGWwEPnmQDPtydWzLg41CxoTDw2PEP2J2VY6K2F/NQtyINng8YqFIdD4iQ986R0sjqVxZnM+hrPFll5glHQ8VdvrnmCPec2aIkCjBAN8fWE/8HvxnlGxSWGwiUp1kWhdF99d4E7NE9qpgqn0CgA3PA8TTscKJ4yUbCBWoqJtIZN6paPBPdT81W75+vG5rvGH9gbo9o9OQCjobLSRwkjx4GwF4g/IWf+HPZRsB+NHjfElalBB29nj7sBtFPkR1bhcZk6h+e7Bg3vxT+Pp0Zl2M9KuZPfdKDQQmBiLQjLsk0XO0Qko6YBp1EVUJWHXTvcS2/2Y+G7ZG8ySmCA09ykqY3RJkIpXBrWzTVPua0gDrW7Q84CfYDAndq92i7mZLRzM8OBhaCDj/gm/GL5uiyMhExKAgIhU45YNImc1NxltnxIJxcROZ1cTIHIS5jeCXG2GiyahlFHpMkfwtv+vJCUaSyh1UXe82gVGfiM/F3i/NKG74kSQJ8ZW2oWSSBh061svc2nLcj8PrBOydyjg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR12MB8659.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-Ch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zyBsjNS8E174CPSSzQ/qOzgo6qwOUBqkB88C6GSAlN3SrcvyFcS94DJwbLovNJTZYB8wgTKSIzj8gbYcDjehrVkAE6jlzDGVcm2+KbiA1+Az1hsVMZChZXPkKTd+LBnENcV4Xfu3SOQ8yCmsT0iUJ+cRXSBtJ5b+78RhknBHIhTBlSTtpmq6XoCH4jhdC1jV/Bb/BUDwDf6sMkhgxdpHyzKtKCKMO1RJhlI1HspyYvR0BzM3WtM0730cStaweS4AsjgxdbLKR4ovPuDEPa4aJrgaR3IpsYXXv3fFftQkVGxCzF22I+Oz2UWVB2UYA2Nhbr1pemK2yyGvGlzZ5gbelQSw9WM+071yWGNlkwE6dv0YYR+qeLc9M6fNyrx/sWGSBdKljtjV9TXD3zhF1fAaYCe1GScFif95y4hKR83zcEBre29zmOmroVb0BgA2n9PcSh3FQbYZeNyDqYqk4BpL5AhTgZ1vDNFd8eOQglC2lGCDzIfEkouPgIPUSlWgR8mN02AoZuzodu2I1/fpmIlJ2xPr+XqnKa/SWHlNbUOIY98Ib+mEk X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e4b1bf7-5ac2-41f6-2b77-08dd154391cd X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB8659.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 15:43:31.1284 (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: XKG9iM5vzndA7GQpt2NO7IJe8ra8kmKdVchkhU4Vtg0wT8lmqZJVTosA4zosTGMl X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6789 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241205_074341_022740_A7508BAB X-CRM114-Status: GOOD ( 14.41 ) 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 Domains are now always finalized during allocation because the core code no longer permits a NULL dev argument to domain_alloc_paging/_flags(). Remove the late finalize during attach that supported domains that were not fully initialized. Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 37 +++++---------------- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 1 - 2 files changed, 9 insertions(+), 29 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 7605b264fbf983..e62c8d0f47a903 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2353,7 +2353,6 @@ struct arm_smmu_domain *arm_smmu_domain_alloc(void) if (!smmu_domain) return ERR_PTR(-ENOMEM); - mutex_init(&smmu_domain->init_mutex); INIT_LIST_HEAD(&smmu_domain->devices); spin_lock_init(&smmu_domain->devices_lock); @@ -2362,7 +2361,9 @@ struct arm_smmu_domain *arm_smmu_domain_alloc(void) static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev) { + struct arm_smmu_master *master = dev_iommu_priv_get(dev); struct arm_smmu_domain *smmu_domain; + int ret; /* * Allocate the domain and initialise some of its data structures. @@ -2373,15 +2374,10 @@ static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev) if (IS_ERR(smmu_domain)) return ERR_CAST(smmu_domain); - if (dev) { - struct arm_smmu_master *master = dev_iommu_priv_get(dev); - int ret; - - ret = arm_smmu_domain_finalise(smmu_domain, master->smmu, 0); - if (ret) { - kfree(smmu_domain); - return ERR_PTR(ret); - } + ret = arm_smmu_domain_finalise(smmu_domain, master->smmu, 0); + if (ret) { + kfree(smmu_domain); + return ERR_PTR(ret); } return &smmu_domain->domain; } @@ -2858,15 +2854,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) state.master = master = dev_iommu_priv_get(dev); smmu = master->smmu; - mutex_lock(&smmu_domain->init_mutex); - - if (!smmu_domain->smmu) { - ret = arm_smmu_domain_finalise(smmu_domain, smmu, 0); - } else if (smmu_domain->smmu != smmu) - ret = -EINVAL; - - mutex_unlock(&smmu_domain->init_mutex); - if (ret) + if (smmu_domain->smmu != smmu) return ret; if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) { @@ -2923,16 +2911,9 @@ static int arm_smmu_s1_set_dev_pasid(struct iommu_domain *domain, struct arm_smmu_master *master = dev_iommu_priv_get(dev); struct arm_smmu_device *smmu = master->smmu; struct arm_smmu_cd target_cd; - int ret = 0; - mutex_lock(&smmu_domain->init_mutex); - if (!smmu_domain->smmu) - ret = arm_smmu_domain_finalise(smmu_domain, smmu, 0); - else if (smmu_domain->smmu != smmu) - ret = -EINVAL; - mutex_unlock(&smmu_domain->init_mutex); - if (ret) - return ret; + if (smmu_domain->smmu != smmu) + return -EINVAL; if (smmu_domain->stage != ARM_SMMU_DOMAIN_S1) return -EINVAL; diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h index 0107d3f333a1cc..e121b30e612f64 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -813,7 +813,6 @@ enum arm_smmu_domain_stage { struct arm_smmu_domain { struct arm_smmu_device *smmu; - struct mutex init_mutex; /* Protects smmu pointer */ struct io_pgtable_ops *pgtbl_ops; atomic_t nr_ats_masters; From patchwork Thu Dec 5 15:43:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13895638 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 939CAE7716D for ; Thu, 5 Dec 2024 15:45: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=9nUTvbLqFG3P5dqEXf9s+/gQtk4LElMRnbl9rdSZqyg=; b=CMq3SVgihvh+GHEUfyqp6JTbkq QgGH1WdVOR0R4XM9QGw+SwNz8UpwhmIZLLXTCIotas+cNcwkTfYfPMSdUAL2hvyfS70t7RQ9Xcu4D wJSqXlconig+4YdYcpB+0Ee1Qka6nZ90w5ZhljwCmL4vBUdN+v57mZ/kCrni21HjF0EKLDBJVgYRF guZuJF8lRn0FpAsaVULNgu6WzuNuiZoKU+fLIaclCdoV1fwfyv54WRUoFItFray0TTc6xSzRYkphM VSCiHUCf73f10s7QOAmyITMmwE+CWaDbuFu+WI/TFRpLLdJKQRJ+XN62BrRzbmZK5Wiv9PhJGV9r0 Noi4vAIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJE2w-0000000GcDp-31Wc; Thu, 05 Dec 2024 15:45:42 +0000 Received: from mail-dm6nam04on2061b.outbound.protection.outlook.com ([2a01:111:f403:2409::61b] helo=NAM04-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJE0w-0000000GbZZ-1QPu for linux-arm-kernel@lists.infradead.org; Thu, 05 Dec 2024 15:43:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZD889nzeQp3MyjCmWvcl0DgX7OKwA1/zD3JXMWR0QYPFboLIQcNWl2walB94boQbyh32v5+jk8j19UQ+3YSRbUTrjpu8gZ30SwDwh8j56vhxC9cP5UjG7sorSE6Lah+Hhwh6xl5ab1hs0WZYpn616l0pNP+6hpEQHvxn5RvtzIVat2EQaJuCYi/HTUcWIhbYn/3H4nPLY7HQRZHeJ98CsAcB96SFtdxWtJ3MpWIUjNQPCXEiPWpPSW/ah1hNr5Q00Z7EAvEJWHVgMiIF78U+zjY6vDfjAJucT1fFbk6v8d773N7ecH2P7vZZ09wltDZMlXffClxkRHbTOUPhf5m2iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=9nUTvbLqFG3P5dqEXf9s+/gQtk4LElMRnbl9rdSZqyg=; b=ZhaQeoRPDK049t5MJtqZlqnzVUJhbZucAtLyecURH281e8DAlODipHStS8/JLmgTWa9jyGcKvHFP1wssVafyC7cWG2xL8HLhm9/iQHD/3CnT1umhM9OniSTmml/OprcVdpenJmqLmv7Z+T7vhv17Zjxs9wCe/IaJg3zsYx8vANraBrgoS65GHvR750k9b5H2QGfQAmopPB7ySKvpwA+1OMXk0ilOrfnGhCESjMUzDN6hDBFZLHKR/jYnWvI9ICYTVWuTZi50PqOEZtDnvBh5zM0D8IN1y1p+2VqEmm8FwP0ljhC/KiX7LS62A1KZ61pLRoO2I7TlMqWidPFOf5xhNw== 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=9nUTvbLqFG3P5dqEXf9s+/gQtk4LElMRnbl9rdSZqyg=; b=EroYZC6fAPmi3WIj2j7LEVreqP4z1G3kcX9au8wBazw69NmkSIsPDwV9OAo3K9ubXxAA4aMbcFgQ3AX3KdoYuaKwx3fQNBOBUD6OhlmLaRp19+cETdFnOMm59fUT5GwL180cEbBL7iq8TFUnf+SnqFQgR7BRn+X0Ces9z6mb96lIBpWb8FctHw7LHleVAU2YS/k/aNBGSRZD2v0/Ucx0GxSfYq3TPGeFcEN1JVMj1zYl9vRuSlPHODxSZ+Z9vLDE6iu2vWsrtp1kPYZPJYgeKDuwBoEbMdCEYPmdPQqegMdeA0dW9WQNSrbMr8nBrB2ArpXjjGXrUy8cKEq9tz0GHQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) by SN7PR12MB6789.namprd12.prod.outlook.com (2603:10b6:806:26b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Thu, 5 Dec 2024 15:43:32 +0000 Received: from CH3PR12MB8659.namprd12.prod.outlook.com ([fe80::6eb6:7d37:7b4b:1732]) by CH3PR12MB8659.namprd12.prod.outlook.com ([fe80::6eb6:7d37:7b4b:1732%5]) with mapi id 15.20.8230.010; Thu, 5 Dec 2024 15:43:32 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: patches@lists.linux.dev Subject: [PATCH 2/3] iommu/arm-smmu-v3: Make domain_alloc_paging_flags() directly determine the S1/S2 Date: Thu, 5 Dec 2024 11:43:28 -0400 Message-ID: <2-v1-0bb8d5313a27+27b-smmuv3_paging_flags_jgg@nvidia.com> In-Reply-To: <0-v1-0bb8d5313a27+27b-smmuv3_paging_flags_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0057.namprd03.prod.outlook.com (2603:10b6:208:32d::32) To CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB8659:EE_|SN7PR12MB6789:EE_ X-MS-Office365-Filtering-Correlation-Id: ef08b2b4-7366-4507-d776-08dd154391bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: C+BH2UvTSdk71V9zAANcybP/S9YNmnhp5ewKV6b7EFKCpoF7EKk/rJlOnwDq/johlL669mVh8zXHtZfB7wJjD4kH1IeX7zqKCRzQnj+lqfBpTFOCXrjV2G8toS3fiVZs0MzF149ZbYDvmFsYpi+7v71kqwQVkXSELw9cEhVuqfjl6EuVQM7tljNKucRgYPorlsUfXd2+oF8ft6n6+Nn6G7698MNP0ITfmfMdq+wvnSgbrbi2A+iQlvNttgsV+HB3GKeaqfYnAaWdIAB0ihqk1srXI4lJojb/Us4QzTzT36bHqBBFj6ExXf4uzVUwkTt+5bUhFegI77d67FAELafsQ589t0pdEOFruyOoGAE35R1hLGJ7Ynyk1iIvjLWS9mLisuFlz1pEYx9Esx7Iu2Wx1OZJ4/6+qejJOy4VHj86JUPvw4XAXPpyvHJX69ghFt856a6zLiXgUOEdYf/BwIb6uFwvkW8DrglHWUPFiP+G8n3V92wGpiXFZYK6Qd0Zs69ahqtms+WYgCVHPMZpHdDOMgMhol0HcR8wypx6QmmZcb7tGE/oDDJ5uflnIpT63rs2FoSK3RyyUNNtyW5T8aosLAeUudCqfF2Q947uKMe5mgDd51gxLvc/qXCdH0tlucadlYm+hctx5vWpnXf5Jw0HkPS6v0XU4rRbYrZkOom3DxuZUdJCwzQa+FlqPbJBq3fRuEUusTH2ocWR6wHxz1yE+7+wK/rzErPd/9eLgeYYVHjLpKHRwA6WfaEMbENdxLaXgX2JRnvzpFsXZzg5imjpjGQebOx8ru3yeZkgdxXpYsWl5PgM2BJ7H5tZ8wLqWQdRPZ2aka0D79yCb07JC19tn+Znso/hR73a0XWbSdPvYX0/xAobEBKpwECvvjbzUx9RziA2g7YyMkdq6gD6cDxC3knMsijubapVTEooaTjkqpDEvSd/YbsTUd4TjYdXJrJsNjBnRBOJ1iRkkl8y5vbXk06PLqWrmWn5z5CFrg6dbvjNlAZWJJqhmwpvQhKzeJbkc1Y/lVV0BdUGgIaVZWf1OANGv7atM1AEEnnRd3er8+V+BcPVBLxMSDxizCDoRVaDlFsrgP8iEx8MxL+MPaBhlNtB4nlydVFVSVS4Js5a0T3DtjBBn0u2OcVYHTK8JCT6fMBLc9xlBb7cWmoI0Ug0wD1GMay+eo/5zU5hk62FOsil/Baerq0XyvUG/MNDjFBrQLYvSLhipbL3/p8NUl4q1XOatSJhV0hiuuYeZmqFhJCPiDu5GmYXV2FXogc6hZg1m5D7nm0SYr8Az3yoG+a0BmqQZWhA1x2mXUSXo/NjwpPc1g7N7LC3lMIPHVQkxb47n1r/6RmBCjo8cxAo1Znyag== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR12MB8659.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSp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01a+ceor0uzf6yKjZXQzrqG32NJ3A3O9aYHWDoEa+hNeTm97yPgOKNMJIM6r/UbmeCfrNhNB9O8uoMR0fr1sFkK/9EiHmVAGbVFNYdHsAx++fhorTg9DXFIIxVF195behmX9FAc1TmWZn3d9vjHBp3OCxfYg9q2wffuoJMy+oVveep9xBot1zqAL+O6CSM5nm2PIxhp//uKv8vPMFToAZqy563ZpdVFlKk4vopfSmH9B1BDK90ggS00FvTxdSaZoe58AWvxVX3H9gCIzzXhrdnXkkJMkGvWwdFXZ3tXsHaWZfQJ5kvZ3igJ90Kd7b8YiMK1GXC4i/uzcHjAQ8Gm694laDzMFAE4+LByLXp6IrNsPwMgcw8OXql9WBwwlJGGaqQ/7fvhO3YiM7t1kA2xRQ5miaRw/U4dbHBmUBxqfnE6fofIclMPDpCEA7v1XrFNcq7l2PSUE7YJR3Gax+R/0eyFSlosLPCQKD8RAsQoIJObnJ2h0YmDoOPc/AQtS/yMYr9QCIMJR7PFgF5QYDdKb X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef08b2b4-7366-4507-d776-08dd154391bc X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB8659.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 15:43:31.0294 (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: CrAWvwRCpAOQNq3dgBCyV1qrOtFpwsAWF0gTety/hqlgL86QS3vUnKQefk6mOTT2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6789 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241205_074338_381745_04B0DC36 X-CRM114-Status: GOOD ( 15.20 ) 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 selection of S1/S2 is a bit indirect today, make domain_alloc_paging_flags() directly decode the flags and select the correct S1/S2 type. Directly reject flag combinations the HW doesn't support when processing the flags. Fix missing rejection of some flag combinations that are not supported today (ie NEST_PARENT | DIRTY_TRACKING) by using a switch statement to list out exactly the combinations that are currently supported. Move the determination of the stage out of arm_smmu_domain_finalise() and into both callers. As today the default stage is S1 if supported in HW. This makes arm_smmu_domain_alloc_paging_flags() self contained and no longer calling arm_smmu_domain_alloc_paging(). Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 42 +++++++++++++++------ 1 file changed, 30 insertions(+), 12 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 e62c8d0f47a903..00105ccadc8b2b 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2374,6 +2374,11 @@ static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev) if (IS_ERR(smmu_domain)) return ERR_CAST(smmu_domain); + if (master->smmu->features & ARM_SMMU_FEAT_TRANS_S1) + smmu_domain->stage = ARM_SMMU_DOMAIN_S1; + else + smmu_domain->stage = ARM_SMMU_DOMAIN_S2; + ret = arm_smmu_domain_finalise(smmu_domain, master->smmu, 0); if (ret) { kfree(smmu_domain); @@ -2447,12 +2452,6 @@ static int arm_smmu_domain_finalise(struct arm_smmu_domain *smmu_domain, struct arm_smmu_domain *smmu_domain); bool enable_dirty = flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING; - /* Restrict the stage to what we can actually support */ - if (!(smmu->features & ARM_SMMU_FEAT_TRANS_S1)) - smmu_domain->stage = ARM_SMMU_DOMAIN_S2; - if (!(smmu->features & ARM_SMMU_FEAT_TRANS_S2)) - smmu_domain->stage = ARM_SMMU_DOMAIN_S1; - pgtbl_cfg = (struct io_pgtable_cfg) { .pgsize_bitmap = smmu->pgsize_bitmap, .coherent_walk = smmu->features & ARM_SMMU_FEAT_COHERENCY, @@ -3124,6 +3123,7 @@ arm_smmu_domain_alloc_paging_flags(struct device *dev, u32 flags, const struct iommu_user_data *user_data) { struct arm_smmu_master *master = dev_iommu_priv_get(dev); + struct arm_smmu_device *smmu = master->smmu; const u32 PAGING_FLAGS = IOMMU_HWPT_ALLOC_DIRTY_TRACKING | IOMMU_HWPT_ALLOC_PASID | IOMMU_HWPT_ALLOC_NEST_PARENT; @@ -3135,25 +3135,43 @@ arm_smmu_domain_alloc_paging_flags(struct device *dev, u32 flags, if (user_data) return ERR_PTR(-EOPNOTSUPP); - if (flags & IOMMU_HWPT_ALLOC_PASID) - return arm_smmu_domain_alloc_paging(dev); - smmu_domain = arm_smmu_domain_alloc(); if (IS_ERR(smmu_domain)) return ERR_CAST(smmu_domain); - if (flags & IOMMU_HWPT_ALLOC_NEST_PARENT) { - if (!(master->smmu->features & ARM_SMMU_FEAT_NESTING)) { + switch (flags) { + case 0: + /* Prefer S1 if available */ + if (smmu->features & ARM_SMMU_FEAT_TRANS_S1) + smmu_domain->stage = ARM_SMMU_DOMAIN_S1; + else + smmu_domain->stage = ARM_SMMU_DOMAIN_S2; + break; + case IOMMU_HWPT_ALLOC_NEST_PARENT: + if (!(smmu->features & ARM_SMMU_FEAT_NESTING)) { ret = -EOPNOTSUPP; goto err_free; } smmu_domain->stage = ARM_SMMU_DOMAIN_S2; smmu_domain->nest_parent = true; + break; + case IOMMU_HWPT_ALLOC_DIRTY_TRACKING: + case IOMMU_HWPT_ALLOC_DIRTY_TRACKING | IOMMU_HWPT_ALLOC_PASID: + case IOMMU_HWPT_ALLOC_PASID: + if (!(smmu->features & ARM_SMMU_FEAT_TRANS_S1)) { + ret = -EOPNOTSUPP; + goto err_free; + } + smmu_domain->stage = ARM_SMMU_DOMAIN_S1; + break; + default: + ret = -EOPNOTSUPP; + goto err_free; } smmu_domain->domain.type = IOMMU_DOMAIN_UNMANAGED; smmu_domain->domain.ops = arm_smmu_ops.default_domain_ops; - ret = arm_smmu_domain_finalise(smmu_domain, master->smmu, flags); + ret = arm_smmu_domain_finalise(smmu_domain, smmu, flags); if (ret) goto err_free; return &smmu_domain->domain; From patchwork Thu Dec 5 15:43:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13895639 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 14B35E7716C for ; Thu, 5 Dec 2024 15:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=w4t+7LEKru34zt+XUKbuXCe37jNEAPuvOcwMVuCXbEY=; b=37qUl2l7nro/UWAHbmAlBuW1ke Ay6DeGtITii/RAK/KKcVGGxp5tVG+nQJilrc/I6yo6PbInvhUhYgMgmlWaiNbLJqNrhbPwsL5DIlV uUuIvAGX1YLGdLWaH4CKwR4U0A/ePI6kSCUqDRMo0qplnBT1YuF/6s5dtKsAXIwLe7ObLWVxiet/i In9FCJsyi7XrP+wCQqSPB3e6AOkPVFH5EV43kbIbsWXstraEM99hEHl1BKwQs5s/0Ywpc1VJlfcHk /pUGyiBmwZ1VxAuaTI45y17D2FTC/3yeKvQnm0339SkUYAXgvRcEvAs0Y85aHGy0PB0RMmFyQffIL +blRuQ1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJE3w-0000000GcTC-1ZCq; Thu, 05 Dec 2024 15:46:44 +0000 Received: from mail-dm6nam04on2061b.outbound.protection.outlook.com ([2a01:111:f403:2409::61b] helo=NAM04-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJE0x-0000000GbZZ-2nmT for linux-arm-kernel@lists.infradead.org; Thu, 05 Dec 2024 15:43:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d8xjkY3YrTvDJ2yJo0gZxgWXxU1ldlO7hK6Hz9P6OW02UMYmMVd5OI5P0QoD8QISxriQqJNKJBc56CewIBIHHRIG3VRBrZY3x+wOLw0+P9QU48YXooGRDBVvIFzWqTiGr7Vpr4HPXral/ytjnYePxngTOoNEB+3QjkfKZdq1O5jspWHRXiOfagpllOUU8OO3qAfwh0ResRPa+LBtIJitQq9doPHfVx3JjAdphOY4MbDSc71dA+MPG/Rsu+/ij97KN3q1+1fhJrgVfSfTfkTlMMe9HaTbRnIdfRpb2WOFiXFha8SeZIIaWJ8MgjHr4a6ANXJZQyz+0twxtLfGMwS44Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=w4t+7LEKru34zt+XUKbuXCe37jNEAPuvOcwMVuCXbEY=; b=hKb4JSmZxXGQhgkAo5JOaxB921q3Bc2feb4aaQuRCnWQf2pBuynQdHaKNFP/6OLfL/Gvx0gAphvjGPnYT29Z5KDJxfYPtVhRI5Ct4Yo9MEEGW2oi0x+ULpyFq03FLqiRTCf2bFLTiQPmYV+SKHUEo900P3ZmG5pg6ztzdpiUDYvT40exZ4c07gQws4JZpeoqvaNFo+2bHNZcTn0bWIJ5G/Ucd4OkHKCL70IPxMCDm8y2cUDsg803mtBq3hte3Ju8qn6m0lZE4Oq8yMbYsmzykg1a8i5CdiRsG8JBY3v7S+CeoIx4hBbVgjvAonoN7gzO2rOcTiBJeWbmsridWDeFMA== 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=w4t+7LEKru34zt+XUKbuXCe37jNEAPuvOcwMVuCXbEY=; b=IAgV648Gp74xWgb6EQnS3UlfDavEopTFAsHPvUBOSwCqVU0sqRSJOkzx6DO9Muu4mJnlblQWx5/IDScBkd1IzDML0mQkPrZULV5c88EqydwREAGClLQABhTAlObGDeagFKxtdKrLy0eLPMrUEjxskiZwm0EsKbXl65EaDSJE7dkeJKUCXGaw2DKJLuY6Et57o5HS9N78+jyphnDxjQmSNUlS9KBd4wzn/4VdyUMkbkNLnPkAGAU06XK7wxSGcx6gBso1CwfLWGZJ1tkb/VtcWo3INLUlus7nrNADQlkGZ2ZnvHFBzALuPZ2sKKRe+GbQlu+1J39FevzcL+i2Fb3SFw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) by SN7PR12MB6789.namprd12.prod.outlook.com (2603:10b6:806:26b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Thu, 5 Dec 2024 15:43:31 +0000 Received: from CH3PR12MB8659.namprd12.prod.outlook.com ([fe80::6eb6:7d37:7b4b:1732]) by CH3PR12MB8659.namprd12.prod.outlook.com ([fe80::6eb6:7d37:7b4b:1732%5]) with mapi id 15.20.8230.010; Thu, 5 Dec 2024 15:43:31 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: patches@lists.linux.dev Subject: [PATCH 3/3] iommu/arm-smmu-v3: Remove domain_alloc_paging() Date: Thu, 5 Dec 2024 11:43:29 -0400 Message-ID: <3-v1-0bb8d5313a27+27b-smmuv3_paging_flags_jgg@nvidia.com> In-Reply-To: <0-v1-0bb8d5313a27+27b-smmuv3_paging_flags_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0054.namprd03.prod.outlook.com (2603:10b6:208:32d::29) To CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB8659:EE_|SN7PR12MB6789:EE_ X-MS-Office365-Filtering-Correlation-Id: a09349ca-a929-43cb-ac95-08dd154391b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: 6y4rWdM22yP6U/xpIXuWZIYMVp6HgzTqGk8VyoKGH5btCQMTgAcdzeWe0xKEm8EvWC/J79iPzCLipCGxVK1m9++DBXm2x1N8f6BuCAlzbA9c1szmQJftpFyUMBYT+7CJVeqzg4fE9njGUu46EPkV0/F+ROUKWZiYXZE8yv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wfnW4W6HDTJqMgJ9ta6RmKecdyhbldjqHk/3WcKSgR3nB+pF/nGVqNVVOyMXmRk3eAgsk0UVvKMyH6lBlNXyro8UGOQLVAUCse/nSHc9FPFNcmdsNvSNbub29g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR12MB8659.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6B3cUovmQ19z0O4Ju0dSbxUAIKt9bSd/39Ooee2h1agt1HXsyB5gwEWNvKX7G6szEYCg95IqsLDX6v7TeO7aajlDp8XrkPSH9Zedokd/CSn4PglChwr+Mmxl85xzKxLzMhEB4i0Plr0MrWhGcBIq/lhpl6WOqIL1LQ9Jfzmeeicze1nuGCcqTKSZTjvAYO8SR+p3AG+TbZJf4q0hiNKUvUX5ScyCE+D+7cjxR6Iksud8CnU+uAUFgrrGSq93+rJ+dp38O91LDuR0ckqj9zjkT02W58XGB3vxbYqMdEwl9kdAa5CCtxJxMrQzyRid9zTKVNgAn0lHlfEV0K+HM0gUGrGM8eniQ//IhxZdnZZ3pUagbxnbeUd6zGua5szcOnuLEM7AD4IJzqWDm3cCu6zDyQD9Wb6no48ZnjkTrikxFECWo9Zj0tKHRa6ZcDVWssXRyq5otDK2g5EdUngEKPnzDCqHVhIUKS2bfZNA3J8hlcq7Yr+iCbLh4UmVcN+HCBw9olaTBIWvqyF1ljDwB5oWWCHxKESufclagdtO+eKmwfBS4eeP0Osh0nmW/tMZrRV/dmF9mh9/1ybbiZI82FXeHYCAjUJD5hV/SWpkPRG/EVChWE6tvAlGTnHLGc+mP1EmnxyVP1DDpzBtSiH4MhZJProD/qw+beLXdXCOCixREQxjLYtT6ZyBq9ZoCMSmELYbgUewrbqLZOQlRUnkzZfP57j2iBb1NoFDYuGalxMPjnTDqFMnupMbv0o2kkOZEwfDz0TOoFi0TrJKm7uuVK+FeKn7atEBc+KLHlQMYhOf9zlNBbK29pCP0fnDH1yndtTOtKkYmiUK2JE0pEPH5M4y1oMyKGzgFQSVGBC0O8j5z5qXij/irdMA2v4+0GYgQWzM5EDG1UcgzOOhH7/kOM0ZAz9r1KwtSN5f+NedytMP/2GSMbXA/bk9hFOFxMH/S79AYvo8qIrEQKmP6vXE3U3Nm/8RQHddZfWQA6DQI1JaEOzg+z3BJwGU+5bt1yIDXD5NGajyydK7Ld+HpXNRiVvZP4GEB3y9EXwQE+WtJf6YSmqpd0bm6J5uxNMDbcHwCn/qj6F6wiPHxTy4yd2qZVG4N0zyft4HRZyNYC+VeQg7KeEcVeHkPKL19uj45c4GTYvigEcqKuLV4wDDPWWJnLxLe35//cCZEfhP1nUHCicA7dJq+JJW40Mj2/sD268zw3nYsPMtVXTQjTnT6uqfRCa2O+THybxASqgTeLWBcJ6EALdYhvjHKEZTZjF3VmpUYJU/oN2eYEz8D9iJaBBY2RHgzXcr/aKSVZwUq9zHu7U0ubGDxYuTt+j1giK8hcKA56mSCvEVrtZdObddivIeK5bXnpR/GmOJ9pyzv3HgSI6qEbiVo8syulOHZj15kA2VEdISUAGJruvFHLKy8gBXFct+GamXlFDi47M3bpg0CiRoyAgGZREqZMkuOffBx8e3ZXSxaRys9LjmOB3EV5r0r6Xk9e3ei0aobus5ex4lhsRLiWQsCKuXgrVfdEEG2qhPEz9aHBIJq+YZpXWYjlLfdvWFRIrR/8qkVDW85SGU2yo5WcO3+ZgLveEH8BoR4DBUB19t X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a09349ca-a929-43cb-ac95-08dd154391b5 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB8659.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 15:43:30.9451 (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: FsOsZ1BVK/57eFnszqDgWNtVOdACr5rU1n1cKhXyST2ZaN03kF8VsW22XlHnr3vD X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6789 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241205_074339_705500_622ED0B1 X-CRM114-Status: UNSURE ( 9.70 ) 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 arm_smmu_domain_alloc_paging_flags() with a flags = 0 now does the same thing as arm_smmu_domain_alloc_paging(), remove arm_smmu_domain_alloc_paging(). Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 31 --------------------- 1 file changed, 31 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 00105ccadc8b2b..f285b98f982c14 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -83,8 +83,6 @@ static struct arm_smmu_option_prop arm_smmu_options[] = { { 0, NULL}, }; -static int arm_smmu_domain_finalise(struct arm_smmu_domain *smmu_domain, - struct arm_smmu_device *smmu, u32 flags); static int arm_smmu_alloc_cd_tables(struct arm_smmu_master *master); static void parse_driver_options(struct arm_smmu_device *smmu) @@ -2359,34 +2357,6 @@ struct arm_smmu_domain *arm_smmu_domain_alloc(void) return smmu_domain; } -static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev) -{ - struct arm_smmu_master *master = dev_iommu_priv_get(dev); - struct arm_smmu_domain *smmu_domain; - int ret; - - /* - * Allocate the domain and initialise some of its data structures. - * We can't really do anything meaningful until we've added a - * master. - */ - smmu_domain = arm_smmu_domain_alloc(); - if (IS_ERR(smmu_domain)) - return ERR_CAST(smmu_domain); - - if (master->smmu->features & ARM_SMMU_FEAT_TRANS_S1) - smmu_domain->stage = ARM_SMMU_DOMAIN_S1; - else - smmu_domain->stage = ARM_SMMU_DOMAIN_S2; - - ret = arm_smmu_domain_finalise(smmu_domain, master->smmu, 0); - if (ret) { - kfree(smmu_domain); - return ERR_PTR(ret); - } - return &smmu_domain->domain; -} - static void arm_smmu_domain_free_paging(struct iommu_domain *domain) { struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); @@ -3549,7 +3519,6 @@ static struct iommu_ops arm_smmu_ops = { .blocked_domain = &arm_smmu_blocked_domain, .capable = arm_smmu_capable, .hw_info = arm_smmu_hw_info, - .domain_alloc_paging = arm_smmu_domain_alloc_paging, .domain_alloc_sva = arm_smmu_sva_domain_alloc, .domain_alloc_paging_flags = arm_smmu_domain_alloc_paging_flags, .probe_device = arm_smmu_probe_device,