Message ID | 11-v6-228e7adf25eb+4155-smmuv3_newapi_p2_jgg@nvidia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 6D3BDCD1283 for <linux-arm-kernel@archiver.kernel.org>; Wed, 27 Mar 2024 18:09:00 +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=qdRy5rGjpxASA9alW7lwdZneH+hRoFVj9z4b4oJ9MGo=; b=qouSkr+H3nXllu dDYNAMB2JmTz5bd8FBjqteYvS42r0+J3UmYzQapCL6e5MMcatXU/sVNRdVldhE4gdhxk2XR5UVbUP WZkZtEo7xXjm/cEQXfp8Nahdde8ZSFL08Pt3GEYWNd0/GKqiAeeP3omV/9xak/CcTe8XaOxKqr1Ro EeeQnTQdirgakf7K+X8LeC0IUxdF0ps+ZNnDAGhXjGUJyWTBnC8u8mqwdp8DjrJux9DYcDyZQqCim x77cXruY0xWzR0v5D6aG5y7eVPGPtgKzRWoQiQWUc/hK82kPPjUYELVTSlSVUfYjNlPz8Rfn7eQmq xOWKkbm7pDL8P9t4SilQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpXhd-0000000ATlG-1ns4; Wed, 27 Mar 2024 18:08:45 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpXhV-0000000ATe0-0oHX for linux-arm-kernel@bombadil.infradead.org; Wed, 27 Mar 2024 18:08:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=ZKIg8fkiyGwdfKLRu0dNuardwFyH3L09ZLZSUEodqQk=; b=QKj6Vro6OngVL9z0sqRmrdawSn 55ng5fc2rVgY8TnNWttHwZ+pvJL7myhl7DtvjuBUrqgZiXpnaMFIvZcZAQkfxV3dW2NaWq0ttSQNk NanTn0EkHclp5eEoAEA/hFp9ZqnX0JUcQ79O0rRpmHL9uww8rVuz53xhQt0R6760dv72gxl9zijCj jlabNBALOKjlDZ/Knd8qFKxVYXi5Ub7F4aDcZ4SrBqrX19KY+LIFBULmmavEe31HGSvqSnf8Mew9d hL3tjBZBRcDKAjvahGkdP1cOM94GcueyhdDGADsYsMWh/NSB3f+H0550GgsqwKIywRnkA3OkiJRoB zmKeLSLw==; Received: from mail-dm6nam10on2062e.outbound.protection.outlook.com ([2a01:111:f400:7e88::62e] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpXhR-00000000RvW-37BS for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 18:08:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cIpQcWfd3ZhknHeZAJtfd749zwHDt/SwfhqIO4seWLperwyiIK2/2dtjdWddvM11I8yCdlXjZPzxmeYaxgWFJiVGZJ1etq1IfebT04N3EznQy8id5reiaL9crWu3mNG0TW4jtlZaHa8828gXm9gyb+kXQcMoF3mI865b2CmMtd1F0h4Ie2DHqlUVOaylWc7tK/ODSuCrVasx1NGiOVBgssZ3JQ7LpW2orGHVHpwhxwOV91TTb0/s6cKuGKH6WnAWjFbuEdRT4WPpVDSTBh1BVQXB9ZwogoibFiW/hu9Q+43PIILb6r8MaAYIDbT6At0SC0qNlwjjPJUCr3A04H768w== 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=ZKIg8fkiyGwdfKLRu0dNuardwFyH3L09ZLZSUEodqQk=; b=MJDlE2Q09swmGvoijCX9hkWj3rai/tu+kPV4sKRv6NgvuF3EWcht4jQm28KYin3fE7+ZaoYpp+TA2qoHSI5f0TIgepZIZg/AIa1wz0MP1AA3aIEZygcBbe4aN3YDUM/l7ESZq4VWYXOymM/zo8kqBbMWP21cQZTe1zME5hL5E7MUptti2H+YC4mwRLY2uqVkVCO2qrE+XhTK7P1Z7qsLAIoxQiObIbD7+IWwNayRoZzAhjyv2nG4JFE07MWDsSAQbRZTSuMXCOAbaxTjfWjrt8LL8dUcizGnnEwKxJXMFm3fslDqlLLowPrg2UP5ee2cEh/joE4lMgp4vg713qM2TQ== 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=ZKIg8fkiyGwdfKLRu0dNuardwFyH3L09ZLZSUEodqQk=; b=DHTPa9JCUB+VyRyUbyuW3JWjYA+q/97aZPjr72nA+lzNx61/2CHUDvWb7u+E3WDFmLQFqHLR2MfRYRx/DFh+rFE3KCbkz1XN6/GuiGfz6kMQFJgLoI/8RdzBzYVyculb9tVWr6a8399ShP9mMnPDEJ+aQOt1P0hRT6qnL7O9dv1wNkf4yOd/nUh9PhtETmfi/LagWBkSwXME2v6bQgpqyimQgChzCcgXAzv4AxOIFrdzkx14RusdGbJq+MuZlm6xjWod9KOAe9VPS/Go/uQW+C5+S7DXqGqeoZVdU1FGJiPqvRfItV5Jpu3XVUmEkIHvm6t8m1iyVde45Csj4jeRmw== 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 CH0PR12MB8487.namprd12.prod.outlook.com (2603:10b6:610:18c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.32; Wed, 27 Mar 2024 18:08:18 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::6aec:dbca:a593:a222]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::6aec:dbca:a593:a222%5]) with mapi id 15.20.7409.031; Wed, 27 Mar 2024 18:08:18 +0000 From: Jason Gunthorpe <jgg@nvidia.com> To: iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>, linux-arm-kernel@lists.infradead.org, Robin Murphy <robin.murphy@arm.com>, Will Deacon <will@kernel.org> Cc: Lu Baolu <baolu.lu@linux.intel.com>, Eric Auger <eric.auger@redhat.com>, Jean-Philippe Brucker <jean-philippe@linaro.org>, Joerg Roedel <jroedel@suse.de>, Kevin Tian <kevin.tian@intel.com>, kernel test robot <lkp@intel.com>, Moritz Fischer <mdf@kernel.org>, Moritz Fischer <moritzf@google.com>, Michael Shavit <mshavit@google.com>, Nicolin Chen <nicolinc@nvidia.com>, patches@lists.linux.dev, Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>, Mostafa Saleh <smostafa@google.com>, Tony Zhu <tony.zhu@intel.com>, Yi Liu <yi.l.liu@intel.com>, Zhangfei Gao <zhangfei.gao@linaro.org> Subject: [PATCH v6 11/29] iommu/arm-smmu-v3: Allocate the CD table entry in advance Date: Wed, 27 Mar 2024 15:07:57 -0300 Message-ID: <11-v6-228e7adf25eb+4155-smmuv3_newapi_p2_jgg@nvidia.com> In-Reply-To: <0-v6-228e7adf25eb+4155-smmuv3_newapi_p2_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR05CA0039.namprd05.prod.outlook.com (2603:10b6:208:236::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_|CH0PR12MB8487:EE_ X-MS-Office365-Filtering-Correlation-Id: 3108e2cf-a03c-4fc9-4821-08dc4e88e0ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jjMZO2P4bQdn03/a51G9zOqoVtFfDvdoixoNV8PIeO2E+6YPclNYqSakuZl/qjp5mBEhA42m+FkWB94Z7zWbjvW1vkUnqDs4PcdGTjlQUS4Xzt+4Pd1eMp0YTF/l9JOp4z2XSB6OIp4L0QHexjsIJazD4t92889xhP9oxdVKQvHdsaHqFuvwZTjhrv8+SWtgDJKE/jbxVw0gN+q0nWjORegKyinZFcthBrdhrlab/nHE0Ojf1LKUmkneE2E8MqjbHJeEjWvp3ceOcNngDxtCMF61XlwOCq5rZTO+QoZZQs9CP0yTjCh/AvYkCVD59p1H79IqjG3gHRdEJJX9wD1GiMaxkl+7c9Df8B5QMGxeJB51NVt5GMTF29ZOUaIPfw8kvppMMGDSZUYWsTka6DyFAYhYzKD/T+VqIw8Av5ra6MJiDrfabq0+/677ZRVjH2veSqz1JsftI4s6I29U17gjFbKiMeXmyG/OB2zgHraPg3otkeoStWPVmHs6jtnYKV2J7wb/9bJKKs8J8FQfbTjKXmYbpRXSMqEGqYTejRd/r5fN6o7PCkegVTK8pp7y103aqQzKewzrUcvDlhVjo08O0zMbCa/KpxgLlQ8GPsl1lpxELyJw+TT54rBy/NlLs2Yi6P2F4w69hb2SZPlQfiMQY/hEL/1REieJf/+Ri3TgDdQ= 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)(376005)(366007)(1800799015)(7416005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dKj0VupSrK1Qd2Y42xnKuLdrYBrJ/NS9RB0lYhCuL97M9j9J3nqCIVXxu+QPrA8zpwb9LHoWuYivusKnpSN4kqZoaJJ32RAYnZ/Wcki7NTXbPiEVD5N/W/KggiZffLgT1XYxFP6As3RBDXZlNfLnOT8IQ8daCRw/MOaCM2sgQvHG9WalPtZs4oVnYeASsOwkI3C76fJF2GWe+R3wSBEdPjL5uqjj/JtI7bUYWnUJTV8Nbp/9Vw+k09fcZExfUUFlB08u3oOIZg55vvQgVnGHrFjsr+zb9mgBXBAyscPStzYQhUdDlR79B765G0g+2HoW3tq0DFfVnyxsd42L75jEPAAjXxisKSo+F88YsLaOvhLFHSm1fKOmAflyT4CtE3pTjlUIM/e42UePRrYrmaVKjrhPzn0SPJ1dFqUcf5swmknyIQ68FI0VoBgpY6BmMEtAitRqaB3qXySq0bgTz+ieyiWe/d48AT1+Uge8iV0OyNvSO3kGvbsqV3niU1c9o7g2YuztFgPkx+gm64hG0W16DXCJ7hmbegxB0z3CnljpHEiiXSBj2IDhcTcBPvj/ua1+zxEMmnaJJ2/gvTeC/s0vjJlLaKkcLwkfEDDMmLQVQhA3w8HVmGB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6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Mar 2024 18:08:17.3427 (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: TF79dbTXHpfZQfWvXZihvpsVUvza8dLJARCV45c+5aU+c5Yjttdsiz3reYs518Q0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8487 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_180834_064066_FB8D7585 X-CRM114-Status: GOOD ( 16.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
Update SMMUv3 to the modern iommu API (part 2/3)
|
expand
|
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 2ea4fe9d6594bc..2bf55ed4e32ced 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2663,6 +2663,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) struct arm_smmu_device *smmu; struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); struct arm_smmu_master *master; + struct arm_smmu_cd *cdptr; if (!fwspec) return -ENOENT; @@ -2691,6 +2692,12 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) if (ret) return ret; + if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) { + cdptr = arm_smmu_alloc_cd_ptr(master, IOMMU_NO_PASID); + if (!cdptr) + return -ENOMEM; + } + /* * Prevent arm_smmu_share_asid() from trying to change the ASID * of either the old or new domain while we are working on it. @@ -2710,13 +2717,6 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) switch (smmu_domain->stage) { case ARM_SMMU_DOMAIN_S1: { struct arm_smmu_cd target_cd; - struct arm_smmu_cd *cdptr; - - cdptr = arm_smmu_alloc_cd_ptr(master, IOMMU_NO_PASID); - if (!cdptr) { - ret = -ENOMEM; - goto out_list_del; - } arm_smmu_make_s1_cd(&target_cd, master, smmu_domain); arm_smmu_write_cd_entry(master, IOMMU_NO_PASID, cdptr, @@ -2733,16 +2733,8 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) } arm_smmu_enable_ats(master, smmu_domain); - goto out_unlock; - -out_list_del: - spin_lock_irqsave(&smmu_domain->devices_lock, flags); - list_del_init(&master->domain_head); - spin_unlock_irqrestore(&smmu_domain->devices_lock, flags); - -out_unlock: mutex_unlock(&arm_smmu_asid_lock); - return ret; + return 0; } static int arm_smmu_attach_dev_ste(struct device *dev,