From patchwork Tue Jun 4 00:15:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13684507 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 F1FF9C25B75 for ; Tue, 4 Jun 2024 00:17:06 +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=wKRWkQBedf36XC6fno2dIuYTRPorwMz7FftQUl7Hqm0=; b=Ll4ewVwyT7h+mx HUri/yi/vZ9bvAVSXD381krdSoN6vWiUCX51KULPB3nNBhd1qxkHkFOqcxtRBHOnJXP/1zykTsxka yEh97VC0VzWWYPcZqYqhxgKhrICWsNdxdiZeU6sut4oGKe+VTkxt75FjSubRowTvPowNvfvFf30HZ 1eHl6PyTxYmCiDTSk3BYxGy48Z/ESpFw/xNxazXqSR4zDshLKnl42mwFof6gphdTQSyzCGGyQKrQU cVctB4R9HL2qXFLLJf8O5fhiA3gIBl1FCBrChBe9Ma+VdP02TFvMdhUDVN01WfS9TJKi91LORWRVd naS7vmJggOQdi4QUcBwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEHrD-00000000i7Q-03q2; Tue, 04 Jun 2024 00:16:55 +0000 Received: from mail-co1nam11on20600.outbound.protection.outlook.com ([2a01:111:f403:2416::600] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEHqh-00000000hZp-1y7E for linux-arm-kernel@lists.infradead.org; Tue, 04 Jun 2024 00:16:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mLccCi+LfVGcstxTvXOknJCg9MepLWrB1gLsdWOa0qaW0xDgK/Cyu+BkfDanKnYHhlu043QmC6Q0AYhTi73QG3FQJ6UBDkJmr84q1VcHymIcelci0xGpTHHZKCZ+d2pCqqNaUKlVp9ZAEx5jH1Filp3oivnZdAJldyulAlFAB+lFGrktPuyfw0rfAA5elWbJS+i8ci5UCmpr2T/LKZmZTSKwVZqpIKyZllIKQ0yPwpMHYLXCa+J/06QTdzT6A+hJ/MRkCFuwpgnaATig+MbLgA87p1UT1X9/ULCE1KlS5MVRZdUmyezeBW5sW+nOHDMFUQngSLLG/q6xXePvJVDKWQ== 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=XoqgZ1Hungdfk0zBr3VeYdSIqPlnOd92FRLm/zECP3w=; b=PwmxeeIXQzyQdrSAwyx3nOd+VDRyi7l6AfAOmJVUyDYDftdAU81RFl4HAmwsGnxI2o+ygUZV0XnQb/C322i7srI8Rh/oHq9qP4OotIFQ/45+/CDRhS4KRGh+omf1vmGwxioXCfL/OvUBd+nGdH83GSECanE/xrCZvCkljyUezaiZYY9A1eMvji1zlQ683vtgAoUyBTKvXKdid2MPMFB/r/OBB+ajLUUOxZkALwhVzqk15Vegxm/6MH7Z8xyOPbJxXLlT79oJNGZ9D2hHV4PtzAek9oca5Qe9MqgWhH2HdJclPZsClqJH6G9DI5QAYl/TqzpdDWURoIw3akT5EVbmmg== 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=XoqgZ1Hungdfk0zBr3VeYdSIqPlnOd92FRLm/zECP3w=; b=jJSbf79/RpjA9AB4TfnPQVBOWBR7RBUbX+9xjLmJpDFWwzp1P174prxKZty/UPEfP5TxHQM3NrfuofHu1jTDGGFCQZDZuS9iSnaoS18Ga7f+77HTEpaA8Z/ElYbG+jFstfJsgCBvl/K2pY9MBpxnkRwlmxtUm2fongI1oHve4rR0H/T5QcycH2MNGDVXqyH9niCT8Qkddrt4UrlYEujt9vF/G4A1jtX07iDMyymE3qO2MCVXO9I1qQAjS3mlNG1ynNemlMHO5E//GZPnbTUaM9xbu8NkgYx+hSH4IOP9Qb+AbTFED94F22wwD83SnXmoNmESSL3rdvy6CvOUu4wUig== 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 BL3PR12MB6451.namprd12.prod.outlook.com (2603:10b6:208:3ba::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.24; Tue, 4 Jun 2024 00:16:08 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e%4]) with mapi id 15.20.7633.021; Tue, 4 Jun 2024 00:16:08 +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, Shameer Kolothum Subject: [PATCH v8 01/14] iommu/arm-smmu-v3: Convert to domain_alloc_sva() Date: Mon, 3 Jun 2024 21:15:46 -0300 Message-ID: <1-v8-6f85cdc10ce7+563e-smmuv3_newapi_p2b_jgg@nvidia.com> In-Reply-To: <0-v8-6f85cdc10ce7+563e-smmuv3_newapi_p2b_jgg@nvidia.com> References: X-ClientProxiedBy: BLAP220CA0003.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::8) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|BL3PR12MB6451:EE_ X-MS-Office365-Filtering-Correlation-Id: 77b5f20f-df77-4817-a805-08dc842b880f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|366007|376005; X-Microsoft-Antispam-Message-Info: pHqrWkb4wBScz3/WtwIkwSrJuSW6XSzhR9jBf+46dexVTxemgHzBpjJOJaf3/lkgUVXoZD6NaRV+MwEI2vEZDq4il+dDz2H4gkqhhAyk7izfOisXBC+53RAIG0VsZYmScjushF7IexajtqCXKFaoRObh1E2lf3ImGPH7RMeZqIToItSbhH030n/FeW8sXKiFTr33NZyoEWGlmcAoZ9SpAKzB7c5Ee64SAFtJlH93F1Fwjnc5k8M7DqDhf5nG7J8gDM3vlP8kQ8rmxFsdqq5GIvMs7Q1v5P9G3X44IFGAkM593QOUdgY5+qkR7c/elXCJWu2JGjEmCzPqksPD77KOgyOGZNGShuiEzQb1z7hWoCVlNdB3H2XGhqVuQySE4lWIW3+AisjohUCo/CLhSUyD6kntVQGZANdrQ3/xNF4Z4p4MVcl+hI/q2EU/VrzNbW2p9q58KyOrGcfk6Q0dfThKulswKa6q+A92Le+8GsjFsehQiqWdW/xr0cW7yESlS699Y5uYS2fhxYtRuimAq88k3IpKNV5mRN4fhzt+JSRdblK7adYyKz7Mk37NJLcRNMTLrHMfm3oxHMCz7YqKR7OWLxlGs1rJh1qCEB776PDGY7Q++rlTiiOn0S2vxVHvJDFjjqpD6CutrXsrzzuYemIM9CJVKd5vt1yIHKaky/3toseX3z44h0+ObfmQ+WTaEZQZqtqonlkMIQiRJWyMNVvZ9LHJ4sBIp2npU9+JQlz/SQ6FEverZO2iFbeqOOlowUyg4fS6Aa5XdKhquhh7u8C1kFYThSEXm8BXdJTJJfi2ZIlQ3b2zaAF+XwGiWrEUgMheU2AE23LGKYUam3Y3BtnvLk2A/ypeKH8WeLyqwdCB2yU8X1dx9DzRoCcHvgOxEIJLsGwEhnksfbofOnpByNc8+mg24Ltbene6OMzTBpyzpVVjH4yflf5yrO4A/3i3AzPY0VNAlIDbCcUzOlNddlhyXFZgv2pXDOeLIjOrHWrRJU/WEQAf/DSRKY6oGik910EWZrkJ3Kqi49+aOMxpcAkZtDuzLmX1rDudEK8duwNqhMSQD0KOCZH+W2JmPjtOazXg0/clkLjVgsav/ehUIAOCOuHyrZ/VbisRC+jIYpPTnmIOyfuR+MXmwvag+Zso5Is8+OgygaM4S48eyoAA+j8Y0lM1z7Jcu6Y5lA4QAA/Y165Q346mnJRN5bq0iWBZ7L2kEhXxZL/5Q3ZQDjImQCzUMaLe78FRN8xeKMsvK12ZZeYtZhqoJ0L2XY39nAWKvXG0byMO/iyHy52pb9LI554aVw== 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)(7416005)(1800799015)(366007)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-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fm9rMi5QtENGS54j+ra+upI/9Ld8907pDU57vvKTyf+ucAT9h1QkD8pinzFcFjCfOk5WfKSAs6TxG4N2rLD5f8vOzWPRKmfkfdDdfxgXXSRjFXa9VTdOYeLH34P9wAfPQ4WXIhMpBzASdMC7Jb9xzQrk17pFLc4m4q9uvttGa3x/96pkbA018E9YiLmNwf3QkKB1WxdcVxvOR1b0FK84VLtCP0+kcqDGXZZdVDCUXh+LH07i26KmeoItgGTkvXZFiAaJSaxgrZcTKAlSjkWGvj2kiG8jIBvvKHx+mMhEOUSaGvmTaDTg33rERMdjVmhx4Gl/2nw2ibWJYFSG7TB4T1M5C3GGoirXdt7tWB52tD+4QVKd/YAYP8IUnZ8AIv1MEBtzLalmpTikfwYdAWyJC/KotlpNm80LBEgdr387X+EGjZPjC3eM5OiHhPAs+vyeVKbBuOQjIL8nElW+omKlDYHKiiMko/cG1JZI0Z59VQQ2pMFTo9Kp8D6mPk6rnfrc= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77b5f20f-df77-4817-a805-08dc842b880f X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2024 00:16:08.1865 (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: oN7mKBuWz0PPTiERzGwxt/3O/ogbcO6L7MAl7j6MLmNVnOSFBMmspd0qUXXVwqWg X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6451 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240603_171623_657636_19728E33 X-CRM114-Status: GOOD ( 12.16 ) 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 Signed-off-by: Jason Gunthorpe Reviewed-by: Nicolin Chen Reviewed-by: Jerry Snitselaar --- 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,