From patchwork Tue Jun 25 12:37:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13711072 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 D9B52C3065B for ; Tue, 25 Jun 2024 12:38:37 +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=7ZBGtwPpp3fcnbTHEZr175AqPgn1a6tgFjBT16keTNo=; b=DNzi6u0Ok5HWna4MfUN+8T0xt9 xuH0dzIQSH/DmeENkAo/P89VUSry3ZdN/XrRqwO6mgGZyaLKdxdNFaNpB3ieqLfPlJZLH/08ZMiC0 2N5+VZZoN3UeedZ+WXi5VIZXFDnRnZTGmzLU0W9BtZo4zGRZM/DCLv2m/DskHNjkFQ2VxcG93KkT8 km0xNOacLlrrwI/b4+Le+G7ATxgUYI44xKhsxOjsiFkZgkdB79TqnlcEwgJ7UgaKJBH4MHdf+zx9o H3d2IejHY28wB8fBGgBbSRz2ZfZLCnmVHVtTHkiKp39YmSSv6mLvKDmSX+UJ8sJjW59tAqr/4J/EK M/cGehsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM5RK-00000002o0V-37Lu; Tue, 25 Jun 2024 12:38:26 +0000 Received: from mail-dm6nam04on20600.outbound.protection.outlook.com ([2a01:111:f403:2409::600] helo=NAM04-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM5Qu-00000002nfA-4Bf6 for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 12:38:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RcEFPhu/OXwOTFxy1B/MiV9P+LHspN/bk2wmFNW3Lt8opmvuWutcl+SC2aKoYz1dlJW2bR58vWv90OsvxO5V2x3928WyFYwFboaWJsx3/Q2bmKwTNIvP08ybKsdjJLlOaMQp8MFoTu9Qn/uvmGui47eU/Ol0fFC5qXInEqXwuw28BnsJyf+Ozb5Wc1iLLoutFWilRlJ1KI9ZyZfGzzA6cxI1XSRwqXd/L5UWJHtGvHMa5GmzNxAqjcNDSlfqD/YHCj6efD1qrbl4KGuWdTxtHLD6vbr8+1ggLBh9lg4PXHoOemjXCrP0QzL73wZioG+/IDzIBwJCJMSNGzmryfTKSg== 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=7ZBGtwPpp3fcnbTHEZr175AqPgn1a6tgFjBT16keTNo=; b=IfQdpOi88MZCAUXMotqdSLtzVyt0v2LgT/p3a/3b3TqBt0xiULlmhA6oVzQXKonWo4q8kzZZF94Gw2Sr4uivm/B9y25YI8etBTgVfCE/SuaNSEx+WpYQcQP2yQi5eB0Mo8wj3RJdvytdpr/KsWCRI4VzhKGdK+g5lvuP+DCDKfEOnhXqyVFcO/sZ0fvaOVQY4MrQnJc6NxFJujBiYB2AjJN2VLg8NEoo/rt4waT9IrHIT6lHAb356K7HiCLQpRXeL1AcQ/wTijvZYLHBMHw3oo0W0qqyLKKfU8TPvM+1iSDtDApkirk8ftyXUNaCCVV5OE+a7pI9umEe/0Iq10JUoQ== 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=7ZBGtwPpp3fcnbTHEZr175AqPgn1a6tgFjBT16keTNo=; b=lkchFCSogxIzq22wOKPUq+tMycFgJ2xstiLlgTWpGlEjLbku62e7Q64XrtmVNy/U8II04cRWBw51iF4xbp5cdM/tkEjpwnu7zpGc3XiEMIGY7m3ZIz85QocAgc7x/sj/1YMZpt393FkQfx3dmr0wQhWMEDbYajQnL0uu3zbGhjUaPNT7tnSY2bcHUl0SsLdfocBXjBiYHs8cTBh0nbqB0IFkS6Sq3h7C3z3KjseTrXjzl2Em043woHXaejrgNf8hkHWLYhtutJ/UIbUCmLNbSerLgrdT2EQsiwoXLmqzuAA1Xc6GQYWj9adk4GhMp/+fjTAXSqGJlaVhC12mEa/x7Q== 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 SA1PR12MB8946.namprd12.prod.outlook.com (2603:10b6:806:375::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.26; Tue, 25 Jun 2024 12:37:49 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e%6]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 12:37:49 +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 , Jerry Snitselaar , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameerali Kolothum Thodi Subject: [PATCH v9 01/14] iommu/arm-smmu-v3: Convert to domain_alloc_sva() Date: Tue, 25 Jun 2024 09:37:32 -0300 Message-ID: <1-v9-5cd718286059+79186-smmuv3_newapi_p2b_jgg@nvidia.com> In-Reply-To: <0-v9-5cd718286059+79186-smmuv3_newapi_p2b_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0154.namprd03.prod.outlook.com (2603:10b6:208:32f::28) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|SA1PR12MB8946:EE_ X-MS-Office365-Filtering-Correlation-Id: f01a293c-a4d7-492d-2412-08dc95139e4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|7416011|366013|1800799021|376011; X-Microsoft-Antispam-Message-Info: IEv/8djGNtq2geRthekr27ObunvVo9TH7jilzisqUzoLVsr7ZfHAALmmN8cLJRNxHD+6LBcyQlJbEUVXSNdWvOeU2dOIxb7wCcMZxO/3mWcSxMuwKXIpYqUmXGTO0Mgb94rFoqsSQINc28SXy1jIBKzpxhrgroiE8Ym/pvnG3F1tPghAwifWVOYuz1FLqw9Mr1rMMjs+4YTXBy+9eK7SC4bOhCszXNiKACfqJ+/SpIiip2kWrlWHYmM+uAggTksyFL7HBm5pD7tVffv95GNnhXFpqTL5NG1AgIoyjpbdwOEJC3D6IjO4jU81w8VwviXGn7Lw85FeiKDpieT5GS4l4l9ySEoZIxgwHoncAdLVgF8etAqUEUVZ9KvKPw416T0u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VIhZIjn+mJiGtjULVf7OETPWSD7FU12zQDP5IpvH3JZa44YSK8SCKjXn+Fd9eWUxiWLDZLMdmQr0hVGbElr/wF/ewnfqWrOz4N+X8thzemHfJQnodExVHztTGuf/O4jI0jCwH+GhjnYwtpWTfoovgfy2Jkj8PDNnDCWcewKL+UH8Y6KiI0k3q/gfpQxEntBJZqEU4Xfl1jRJdT7hMUOynQRljO8j2/AX/9X07E2w7AgYO66cxNr5WlnDhKEfCS4sorytKQzRbEfhT2f4CpgNi7vtTzQUSb5hgsaYYEq7zIZGVtCdCdbE81PTGcA2mRYh5Q92pJoxz4XURJP0qsle32lN+v0fCQY/bO1xzURpZfI1brg7pQaFgleF0e/x/RiMh0CnmR3AltTm2bA3VYO6enGkm/UnIh3YM/9lQGw0Giv+9dWrpkaiIebOLuJPhHqmNw4Frc7XoBKxuiJ74PESRDzWwKYgC14psloGMP/m5W/Rr93uu7CwElFphBazsWr/AZPP0b3hQwtOVLwI9yshnX2CYK3yhaHK57ZieHeEYyG4tDaTCHQSykCKQxeWXfHjelgGvKD+6yD6Jsf1EMeZguEsjMtLgOBXEZroHikmOcI0AEDRm X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f01a293c-a4d7-492d-2412-08dc95139e4f X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 12:37:47.3789 (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: siTk4aJvrQsZ3ZZnoxVx0affdx0AxYIqnBP5Y9y1xF0LVez77ciRmONV9ktEzv5k X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8946 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_053801_115077_142ECE8F X-CRM114-Status: GOOD ( 11.94 ) 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 This allows the driver the receive the mm and always a device during allocation. Later patches need this to properly setup the notifier when the domain is first allocated. Remove ops->domain_alloc() as SVA was the only remaining purpose. Tested-by: Nicolin Chen Tested-by: Shameer Kolothum Reviewed-by: Michael Shavit Reviewed-by: Nicolin Chen Reviewed-by: Jerry Snitselaar Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 6 ++++-- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 +--------- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 8 +++----- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index e490ffb3801545..28f8bf4327f69a 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c @@ -656,13 +656,15 @@ static const struct iommu_domain_ops arm_smmu_sva_domain_ops = { .free = arm_smmu_sva_domain_free }; -struct iommu_domain *arm_smmu_sva_domain_alloc(void) +struct iommu_domain *arm_smmu_sva_domain_alloc(struct device *dev, + struct mm_struct *mm) { struct iommu_domain *domain; domain = kzalloc(sizeof(*domain), GFP_KERNEL); if (!domain) - return NULL; + return ERR_PTR(-ENOMEM); + domain->type = IOMMU_DOMAIN_SVA; domain->ops = &arm_smmu_sva_domain_ops; return domain; 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 ab415e107054c1..bd79422f7b6f50 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2237,14 +2237,6 @@ static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap) } } -static struct iommu_domain *arm_smmu_domain_alloc(unsigned type) -{ - - if (type == IOMMU_DOMAIN_SVA) - return arm_smmu_sva_domain_alloc(); - return ERR_PTR(-EOPNOTSUPP); -} - static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev) { struct arm_smmu_domain *smmu_domain; @@ -3097,8 +3089,8 @@ static struct iommu_ops arm_smmu_ops = { .identity_domain = &arm_smmu_identity_domain, .blocked_domain = &arm_smmu_blocked_domain, .capable = arm_smmu_capable, - .domain_alloc = arm_smmu_domain_alloc, .domain_alloc_paging = arm_smmu_domain_alloc_paging, + .domain_alloc_sva = arm_smmu_sva_domain_alloc, .probe_device = arm_smmu_probe_device, .release_device = arm_smmu_release_device, .device_group = arm_smmu_device_group, 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 1242a086c9f948..b10712d3de66a9 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -802,7 +802,8 @@ int arm_smmu_master_enable_sva(struct arm_smmu_master *master); int arm_smmu_master_disable_sva(struct arm_smmu_master *master); bool arm_smmu_master_iopf_supported(struct arm_smmu_master *master); void arm_smmu_sva_notifier_synchronize(void); -struct iommu_domain *arm_smmu_sva_domain_alloc(void); +struct iommu_domain *arm_smmu_sva_domain_alloc(struct device *dev, + struct mm_struct *mm); void arm_smmu_sva_remove_dev_pasid(struct iommu_domain *domain, struct device *dev, ioasid_t id); #else /* CONFIG_ARM_SMMU_V3_SVA */ @@ -838,10 +839,7 @@ static inline bool arm_smmu_master_iopf_supported(struct arm_smmu_master *master static inline void arm_smmu_sva_notifier_synchronize(void) {} -static inline struct iommu_domain *arm_smmu_sva_domain_alloc(void) -{ - return NULL; -} +#define arm_smmu_sva_domain_alloc NULL static inline void arm_smmu_sva_remove_dev_pasid(struct iommu_domain *domain, struct device *dev,