From nobody Fri Dec 19 14:03:43 2025 Received: from SN4PR2101CU001.outbound.protection.outlook.com (mail-southcentralusazon11012007.outbound.protection.outlook.com [40.93.195.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91F482EDD7A; Sun, 12 Oct 2025 23:58:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.195.7 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760313484; cv=fail; b=TENodJu2p0Ikz4v9y7feuucrOeuOwT7YK2p0bSbMMQdONPbDwc/9H7QMq3VgyqEli+1tHLZ1ODAXtbCK/vEx8i5kJDk1431qI+Be7+IuL18HkoKiQBY7+Oos/hzL51d22fckAxqkK4Jrh2B6XJIuvc6OoIO/c0cko70gFac/Z2c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760313484; c=relaxed/simple; bh=Oovxc2xwQBxYwcT81UaZp4r5Cby3UMpyL2z6ZKVqPCU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gHiBAkdM9mglHBzlzcFPoj/PF2S88YZ5phR/4rREQs93cAJI3Pwt3z3b/R4HT3fxL5Kc90ZaeE1Lx87ZR4MRksI5jSxkNriV4UmoxiEmLmue/6/SeIqZ5RcBCmX8b90sPAM908wUhKz1qlRuTlHF+Hn08g7GejDXQsnmfxRIip0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=VMR/QVBB; arc=fail smtp.client-ip=40.93.195.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="VMR/QVBB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UYr+8Us3FYN8faq5vLcTrCg9LLeb0n2dJ3qek5dxVaMiCns8sdHkYJbdM9BDlzhaeWTCBDYSe5aNAGEFd18C8rnVYjMMMcS+CKXB5/q28JCJXDHi7yoFTRoLcw7PL4+GIzIWNJKpBBfpkWOxPhTjo65tk6Iea9bcet+W3nagh2FGfZop/WPD/Bq8hdftNA2iSlb1OWLQi+YoE39kryRqeiwPLCYvckKxvORDNjWNAoS2ysKiauv1I2b4St6YjHa2uPXKRmVmcS9DpSp5+ar5EfOslA/D2mex+p5z+rhG8RbQ6q0ok0WbDtVErCLLRRg51y3gBGCbanBOSz/kAE3IiQ== 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=iQbKQPGHHteriTFPWtmN0+oYPeNAZs7WnUqBuOXCIo4=; b=cJ8p7EZFlhjvpF6O8gRHNcup+XmGt7glgbHHCNRaIftYArP30QGm0pmgya6IIPfAmCYo1Zw+KdhLwE4K1SvuWoXDaKPiVpChgkJyDqx1YZ6EqUl8GgvZ//Pn5vwlkj7lq8yOPiK4WR/U7hifrpngyKI3dShR3xHwtKimSkq1o+TQO7AdaWsdNDIj/lJPO7cHZv8XkNLVx2uayD+f9nQjJuxNFn2e+BwKThfwz5SUo3AI+CnAdaBNYFp+/7tSJgEQ5GbmpZB0mD4Nc53li1HqqvTfADLMWcyyM7j3r1vHvNKmquCoxKjzX29w1YSR/ZO8LkzJRU8D7MCb/MhxQBlz2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=8bytes.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=iQbKQPGHHteriTFPWtmN0+oYPeNAZs7WnUqBuOXCIo4=; b=VMR/QVBBI4JmpTXcHjUJ+WvwCWm3Zhr+GST6IkTv9StMjV5cwh/4QqjsLRDk5A2x7nL22TvNM9HQ6QUMogfnqQTZcfQJel4XeQL9f5P/jaHUqbRSuVRUCtW2h8uwsB0hQn/A0wKhnHXADtJSFB6Ru8L7TxW5kvWm7mb0gaJDD54mteHBYwvV6vJMwSX/0PJx2isrDgoGqYAkUlqX5h1nXqqIFYZfjcZTuapLod5cfhQn1BDaW4f/YFbn25O+9DSKXGOJRWGZgkYkDx/tC+akectPQFFrIfyeeCUPgBfyUPdJdvyY8hjn8IpGBZFaa2MU0FxYQo33cAfLb6E2B5Rd5A== Received: from BN0PR04CA0035.namprd04.prod.outlook.com (2603:10b6:408:e8::10) by SJ1PR12MB6219.namprd12.prod.outlook.com (2603:10b6:a03:456::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.10; Sun, 12 Oct 2025 23:57:57 +0000 Received: from MN1PEPF0000F0E1.namprd04.prod.outlook.com (2603:10b6:408:e8:cafe::a4) by BN0PR04CA0035.outlook.office365.com (2603:10b6:408:e8::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9203.12 via Frontend Transport; Sun, 12 Oct 2025 23:57:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MN1PEPF0000F0E1.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.7 via Frontend Transport; Sun, 12 Oct 2025 23:57:57 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.34; Sun, 12 Oct 2025 16:57:51 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sun, 12 Oct 2025 16:57:51 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sun, 12 Oct 2025 16:57:48 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v1 1/6] iommu: Generic support for RMRs during device release Date: Sun, 12 Oct 2025 16:57:37 -0700 Message-ID: <631ef0483b8d1981d037131d0f342c6970ffc155.1760312540.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E1:EE_|SJ1PR12MB6219:EE_ X-MS-Office365-Filtering-Correlation-Id: 949994c1-c008-4e19-bea1-08de09eb2b00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?OVndwf61hCayzo9konwB9wH1Vw2u6HWwBOgvsd0u+kLr2G/AwVBhdd2gZsrU?= =?us-ascii?Q?rBhk0kIn4Iaw3y+pQHGOKLTaMqb9BpHS1hXfCHBMz//N5Cgk360UAQZmkX2D?= =?us-ascii?Q?CpyAaG49Fjam/pRa3AsdJ49RNVjmqQrKSihRsnzPknqxQr/hymgx7KsawcFC?= =?us-ascii?Q?xbrUTZRGenAqPwyCtEiCxnEuX8ZZQWC1nYgUtAGEbcQrgzKbZ/rTEe+sxJ+A?= =?us-ascii?Q?AanARun6DAci9qGoXvciuZ7kyiuTp5s51XPizqfDZuOVvs2kuc5GBnB4KvsF?= =?us-ascii?Q?pVU8DbOkNHVrKHJ3hli9ksR7E1hHZCEAjqN5uc/+adZUVEJM+yGERYB2j9VS?= =?us-ascii?Q?Xj9JzXPF5d0NIqpwEo0swEz5j+XUm2VUsVP0UZmBZaTVQSyojuEYTY2/Lxp8?= =?us-ascii?Q?ruztFFEkOtlu4+HR4KMyps89r9SeAJ5ZvDnSAtumA7jDFRqD3I27LsbmLqOA?= =?us-ascii?Q?Q07xYWh0ZVjP0CNS6RkKz1i9PchqlaEPFHk7kroFfHiRhdt5I1SPsEQXJu/I?= =?us-ascii?Q?U6KYW/Wl6Sg9wkMxAClD3uopVA4KIY8uk5HsF21H9KaFEXXxrdf491Co4KWR?= =?us-ascii?Q?VCIvdqQKPi8dJ1hhzDhiLBd2x8M4BcnTZQAdl0iNBLWFk1ceMD8+ODcNJriF?= =?us-ascii?Q?6Cmrr946MhXng7GM+RxNeQUJGWSRWSppvLWUr5DXGkjFs+zDzSdVOaRR5Eb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D?= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2025 23:57:57.5266 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 949994c1-c008-4e19-bea1-08de09eb2b00 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6219 Content-Type: text/plain; charset="utf-8" From: Jason Gunthorpe Generally an IOMMU driver should leave the translation as BLOCKED until the translation entry is probed onto a struct device. When the struct device is removed, the translation should be put back to BLOCKED. Drivers that are able to work like this can set their release_domain to the blocking domain, and the core code handles this work. The exception is when the device has an IOMMU_RESV_DIRECT region, in which case the OS should continuously allow translations for the given range. And the core code generally prevents using a BLOCKED domain with this device. Continue this logic for the device release and hoist some open coding from drivers. If the device has dev->iommu->require_direct and the driver uses a BLOCKED release_domain, override it to IDENTITY to preserve the semantics. The only remaining required driver code for IOMMU_RESV_DIRECT should preset an IDENTITY translation during early IOMMU startup for those devices. Signed-off-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommu.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 59244c744eabd..adef1a37f9311 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -542,8 +542,20 @@ static void iommu_deinit_device(struct device *dev) * Regardless, if a delayed attach never occurred, then the release * should still avoid touching any hardware configuration either. */ - if (!dev->iommu->attach_deferred && ops->release_domain) - ops->release_domain->ops->attach_dev(ops->release_domain, dev); + if (!dev->iommu->attach_deferred && ops->release_domain) { + struct iommu_domain *release_domain =3D ops->release_domain; + + /* + * If the device requires direct mappings then it should not + * be parked on a BLOCKED domain during release as that would + * break the direct mappings. + */ + if (dev->iommu->require_direct && ops->identity_domain && + release_domain =3D=3D ops->blocked_domain) + release_domain =3D ops->identity_domain; + + release_domain->ops->attach_dev(release_domain, dev); + } =20 if (ops->release_device) ops->release_device(dev); --=20 2.43.0 From nobody Fri Dec 19 14:03:43 2025 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013019.outbound.protection.outlook.com [40.93.201.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C75442ECD1B; Sun, 12 Oct 2025 23:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.201.19 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760313489; cv=fail; b=DIF41CgmCYgm/rUEYvgqcfBjRiGKJ84AANAlISZurk3nIXdVqlVZON6I5ov+IkxKdZ+oCpiItWLmK+DsIL8juOvDRd1sM+z21Ualm2n4A39B41oCRws8hpjmjRC4S83BCT5WoGlRaClxv1lkn9kMzRi5U4vpI7fjJNjbip2yEoQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760313489; c=relaxed/simple; bh=QiGloiQps2rvVKK8ogm2wOMu51TAIAw968Zu0/+1fbA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=plL0t9Obm9EfBut8YwQzopLx7rdoOVWqShFY6mYhnsQGCAxmkY3VHZzPCGWdkhjWY9Bdpfd3rDZADkWG5wCOLdUp9XCZpYYODrTZl7bWoWGcRi52iDyGQ6v6VKVixQeEvhVP6KkwhxA6oLSowmCvF9LMmjXzJGH83597HSWtPcg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=tO8hvCTo; arc=fail smtp.client-ip=40.93.201.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="tO8hvCTo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yhYA0cclAYLkqJJegWvVcUdpXkFe4k/Wghz9sd2prFvc6sEWU20CVgJfQBaWG6irLz3dYTTon/0FMxoTCic4uvcJ5VGFoYQM2LI/GZq3N93ph9PtbDwE4+t1HVtIIy+cK3coL7nbahzxpeN8jvkeq3NI3ijbDUQvjgRA1nAZY9MdDU9Upy3kJVMO6ZxIFUWFd09WPbdiZgxwHwGXZciVdiALvR+ULxbQaovB4CccA0TIi87qcovUaTjOS2aC0TmKmq4nYgJPEISNqpS2g0NkD3D8CbtTG6ReMkWB2yEYDbqxOKDBQpwKxmdvd8cLEANtRY5GCTh2jtRDKOnXqGggVQ== 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=4YO81xLfBndPql3ksnaEhkhGsOl6ICC/aKHg3dvP550=; b=jYcQ4c12esDRwAiE3nrv2C6RxHlhcRnqEam8pwdGHOJxE2HtC/8slPGJEuOrkYhzmXD1mUO+DUQeEWkvFboxvUKPuZuBb2JWdjoOQb4IE6a7xy92/IJWPiSFFE7FApgqt+QK2i3ohh8QAYqVqGatuwh3YL8kc1AFDTHLq/XYtnAhVpdspGr+VfGDm+hHeznkU3SFs/qTuvs/2vPx6+xVvkcvnC6B7yCcKYB4CxSejl4De+9NDBFgOy8GeRaZeAFZegxPG2z+I4O+/A/aPCktAkvgb4quZS1w8v+fY4zSlrzfYyh8D45skXaxMmRhXmk7R1d26zXuGwbtUhbZYl5Nfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=8bytes.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=4YO81xLfBndPql3ksnaEhkhGsOl6ICC/aKHg3dvP550=; b=tO8hvCToYmfoodfnL1p+yxG/vZXdBM1s9bC6QkfCR9YqRLnmtlXNfYXNEHmQ2rnDnXDU8aAkjuPOvd7wNldleXPAGwRJIwREWx72TOWuBj/IJntQk+IUbyZV14g49IBkNim6/N7c1DqhAOJup4nOcUb2R2cMzdhiGIE6qb29ivOonT6ygOWHa3WUa3XTzKOQ70rlW6TxR39YpPfHoKfeGPRMDFy3Ous3T6WuDruV5KI3UU4OauY4cLVVMbj3+HJ63Wa7aUiVjCJjIWLK706sHUCngnf/x/x077iEANbcIbdK+eTPOBKfBR3JmOKDvlcqEP3eBIJ8wdlWE2V/6N6YWg== Received: from BN9PR03CA0502.namprd03.prod.outlook.com (2603:10b6:408:130::27) by DS2PR12MB9710.namprd12.prod.outlook.com (2603:10b6:8:276::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.12; Sun, 12 Oct 2025 23:58:04 +0000 Received: from MN1PEPF0000F0E0.namprd04.prod.outlook.com (2603:10b6:408:130:cafe::33) by BN9PR03CA0502.outlook.office365.com (2603:10b6:408:130::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9203.12 via Frontend Transport; Sun, 12 Oct 2025 23:58:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MN1PEPF0000F0E0.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.7 via Frontend Transport; Sun, 12 Oct 2025 23:58:03 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.34; Sun, 12 Oct 2025 16:57:55 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sun, 12 Oct 2025 16:57:55 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sun, 12 Oct 2025 16:57:51 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v1 2/6] iommu/arm-smmu-v3: Set release_domain to arm_smmu_blocked_domain Date: Sun, 12 Oct 2025 16:57:38 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E0:EE_|DS2PR12MB9710:EE_ X-MS-Office365-Filtering-Correlation-Id: 4be9844b-6c84-47c3-bc2c-08de09eb2ea1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?63MKpHU8NWs2W/EIQISFsk7cEb5y4JsdrFtiG4yVBXqcVfign3zR9oxCao6l?= =?us-ascii?Q?u1QwMfQpfi+AJg9+DxigiQfYzgHSFd0eJHcBeAKj3g71l+Jh28CtznV9+JNR?= =?us-ascii?Q?4pzV25LISoOWuB/DEH95MQKDM6qBwgqtd23QHOzreoxOBm5vS9JC78WCWpZC?= =?us-ascii?Q?mGdORUGqhx6+zNYKLv6JWPyzA/7L3SbZPTpC9UJycwl3CttsgW+BJC8xmhzO?= =?us-ascii?Q?Eq8oyPKrNZXLju5o7WVOOGPnEOb0oPA8TkIPNtdtUSsj77Z7gXSeHk6/HceO?= =?us-ascii?Q?GwkfaFY2rPFya6ls1Xw9dBe/vzshXo8QrBvQMU1E1TjlEf0TTWmsEiKLX+4j?= =?us-ascii?Q?z7cTKRCPGp8MCgwikZO39zSbZF6sGDyDUfjCll2PVqawYRTBuZynjeI12jqV?= =?us-ascii?Q?o6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DEoNiBUYFQ0aEwOzq8zq+87Z?= =?us-ascii?Q?0ZlxNlsDiA5zk1uz2Pu0wn7PIQdUqfI1ZyReFifQxDT8fmSbNRoSZJK/x1VJ?= =?us-ascii?Q?QfZVKOfltmigpOE5djfl3Yd9yWsKLntvBorHp64Rprxpn/bbxucwzhlLqg5o?= =?us-ascii?Q?RUQweZKuaWt/EAhX4YuqdLNdg9LV21lnVs58mm2kt10E+97fZYqJhSSHHR5V?= =?us-ascii?Q?Z+su6+d6Ng+ZU3ciK4eK+vs0iuKe163cySneGyF0tTSEuHZOJbr2e0rkCSUn?= =?us-ascii?Q?6C08L1JsJeib49KwlnI=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2025 23:58:03.6020 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4be9844b-6c84-47c3-bc2c-08de09eb2ea1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E0.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS2PR12MB9710 Content-Type: text/plain; charset="utf-8" Since the core now takes care of the require_direct case for the release domain, simply use that via the release_domain op. Signed-off-by: Nicolin Chen Reviewed-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index 2a8b46b948f05..2125ebfc9a70e 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3582,12 +3582,6 @@ static void arm_smmu_release_device(struct device *d= ev) =20 WARN_ON(master->iopf_refcount); =20 - /* Put the STE back to what arm_smmu_init_strtab() sets */ - if (dev->iommu->require_direct) - arm_smmu_attach_dev_identity(&arm_smmu_identity_domain, dev); - else - arm_smmu_attach_dev_blocked(&arm_smmu_blocked_domain, dev); - arm_smmu_disable_pasid(master); arm_smmu_remove_master(master); if (arm_smmu_cdtab_allocated(&master->cd_table)) @@ -3678,6 +3672,7 @@ static int arm_smmu_def_domain_type(struct device *de= v) static const struct iommu_ops arm_smmu_ops =3D { .identity_domain =3D &arm_smmu_identity_domain, .blocked_domain =3D &arm_smmu_blocked_domain, + .release_domain =3D &arm_smmu_blocked_domain, .capable =3D arm_smmu_capable, .hw_info =3D arm_smmu_hw_info, .domain_alloc_sva =3D arm_smmu_sva_domain_alloc, --=20 2.43.0 From nobody Fri Dec 19 14:03:43 2025 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010004.outbound.protection.outlook.com [52.101.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C3CC2EC54C; Sun, 12 Oct 2025 23:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.85.4 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760313489; cv=fail; b=bOU/OH/nkkXxg7Nek7G56EAGII7JJe1TLdo5uZ4/x+Wfid3GF0A5FDuTgHOIyWMriCf/z+drXRQEw4DOkmSu26H/Aihu3CSksmP3pKT3GKlfIto3cceYFHxKh6fqCxz1WjPvsbHt96XuhgHjfnszb22fCbXGjP8Xok+TqX8Lq/g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760313489; c=relaxed/simple; bh=kCSbVwyS/dV9duyQucTy9V+pqkBtHIrMgDgvlD28y58=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RqB3TEWvfjtlUCp/QNNCePHlPOFdfR/ZS8T9jd2Ni9fx929+ZZ3a8zO1BY2DIAgDQxr8BWmG1FWeAClgBmFRxbYaqHWmAmV66pkaKukZkewDzxTDruRjGOUxyZikUyJeeLtMCod4U4HZcK/i2HIjtGDx7HfuosftkFzDq5jXBmE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=LsJWqmSp; arc=fail smtp.client-ip=52.101.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="LsJWqmSp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TrwMawDWQuymroLz9lHNG+8E5EOH3jehcfFjyh9DGUPX9whBQbfY8EwoXNb2zm5zO5UZTRVqoSYLgQulfsYoieSbyyBy4AMo1QEvVKF3gtnuwX8Eu9neySFzAUzjerA+rsQJgH/tjWH4w9/UFdsxIXoYPJMMF9G9a2R83de/NZ1tmkFl5Xgcm5ldcB81QC4cF2AutQoMBGm0brOizaFNAGDg9L0DeuLmwB7pEUPf1YfXvgqJ3jMMlktA4Zqv5pOKzJe0Ed0ketFkKLUN7VX1W+JVU+PD2YU7A/ukMC9ZS9FnISgxCCmG/jdmukbAiiFyalK65s5phUGf7PzT5OpNag== 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=NPoppCKHD8SPZBpqix/l4W3LqITOl3uJs5lCc1U1ve8=; b=CGlbli/3uDu2qxzJ3AVI6pSVR7VaIaWWTMme6BBkbBRnSKJUedyUC/Oe1uuCxIJg7R03MxHTijdnVxVDYk3TqjYvZzBql65A3mhI50sKmnrPRXQXqzaaCi6gR7XkQF1uVNYyRWw1ssXz/YYpv14J49ZRJG+ux+ZycbvBi0mb9FYwnF+ahV336RKQ5S9YcFShcxOKGYnwAKu6PqydqzYtAIDL3xaJK4ft3IVYpvQ+n/I/6GcPpD5go1Q8awqBY3yYqgNUcg4Drg09ln2T7xLtsBWqsD+JGCsnTk3IkWTweXfv30v3J+wSM9XsETocBJAd3ZkwiIT7FcXP0LenNqW4Nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=8bytes.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=NPoppCKHD8SPZBpqix/l4W3LqITOl3uJs5lCc1U1ve8=; b=LsJWqmSpCMW15XT5WNKQApHSHNDYRxNsNbcsYrvdorpLTGswS9FCx3sNJyrj9vAPM9G70KeGbSh9khdi8smDSxC62m4Pyr9nNInCrx2RPG5xMEYwmBFnvrcDYAjvckl2I2x6Ba6pRNsStPV9eHBmqhOW+6JvyJdXK4skXxVa+lKoiASUKtUhOTiUvTfQRYL1mkdVG/KlgYMEAV8En9P5cCPHQNfMXGbfAetF2mBpQUIDdz0b4FARlKbw1PWIcxVChhAO8GvRVUaBWFgrLAVJeOwCBsyMVkAFe+S9dJt2ChLB0tR1qSll7C+5zKdH/eJYRH60qFr8JmEmdLhzSlq8TQ== Received: from SN1PR12CA0070.namprd12.prod.outlook.com (2603:10b6:802:20::41) by DM6PR12MB4075.namprd12.prod.outlook.com (2603:10b6:5:21d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.12; Sun, 12 Oct 2025 23:58:04 +0000 Received: from SA2PEPF000015C6.namprd03.prod.outlook.com (2603:10b6:802:20:cafe::89) by SN1PR12CA0070.outlook.office365.com (2603:10b6:802:20::41) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9203.12 via Frontend Transport; Sun, 12 Oct 2025 23:58:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF000015C6.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.7 via Frontend Transport; Sun, 12 Oct 2025 23:58:03 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Sun, 12 Oct 2025 16:57:59 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sun, 12 Oct 2025 16:57:58 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sun, 12 Oct 2025 16:57:55 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v1 3/6] iommu/exynos-iommu: Set release_domain to exynos_identity_domain Date: Sun, 12 Oct 2025 16:57:39 -0700 Message-ID: <56175bec385d24af9eb2a38632e1d6ce889025e3.1760312540.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C6:EE_|DM6PR12MB4075:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f7ef840-c66a-48ba-6ce8-08de09eb2e97 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?O5ON+E57VtgaAvyRQrKFuVui5tOCkGZ2emh2s9achGkNkEjFgq9njENeor71?= =?us-ascii?Q?l4gP+TM5N2yRLQha1zcClg2MNvB8Pqis33thqTjrSG73S3MtuzfLqx5/22Rz?= =?us-ascii?Q?TyMDZBl2GGAEafO1zqwOSdKeefAhY3C881BiC5S/Ksa8hygjllriRpU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qpOAyhdqMYJAD4sDlpYZSLGp/2GZyrxMDRFFuK?= =?us-ascii?Q?/SA39M2/plBY9KnasGSlUkdhex3OIrcvv1jv8d8GZqYfz30nsNt5dIDINGHL?= =?us-ascii?Q?IzUPjLzxxLY2VY8yJ2oai7Ohmg1zQi/6UI/KCiHlhCcSWGHy4LmAOPrSvXH4?= =?us-ascii?Q?5zdAKomljAhNOmGy0miFO949/IBum6hS48Bx8U85jNY5ndAjuk9twZUVQDQS?= =?us-ascii?Q?xBFLjPxLRtIqLufyH5GCoyJZWsJbEqF5vplUGqj5jLJ6D4zVZdXd+b1irjrZ?= =?us-ascii?Q?Sw87bkA/Sm+hN5aRvdysxuNMAcQAKheAgr+lA3WF0aFQ3QVEMHJ397s9BWBY?= =?us-ascii?Q?65OsuDpwaexSyB0qRjJfXouxi8JkZLxcohxRofZKj0ktZ96gmqNLiODwX6sf?= =?us-ascii?Q?h1z8smqWpm+3tVfv1D9h3Swx/A1d4YJiKXeiBa5gb6Q4tpvnhomZkyXCfsv+?= =?us-ascii?Q?QIYpyS08gHCHnyyYosWEXiU0DUByNeOSfrl2QN4Jz4C+Lw6K3zxx1UOS44p8?= =?us-ascii?Q?CdNUFH1a53l5PRhvwZA=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2025 23:58:03.5731 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f7ef840-c66a-48ba-6ce8-08de09eb2e97 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015C6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4075 Content-Type: text/plain; charset="utf-8" Following a coming core change to pass in the old domain pointer into the attach_dev op and its callbacks, exynos_iommu_identity_attach() will need this new argument too, which the release_device op doesn't provide. Instead, the core provides a release_domain to attach to the device prior to invoking the release_device callback. Thus, simply use that. Signed-off-by: Nicolin Chen Acked-by: Marek Szyprowski Reviewed-by: Jason Gunthorpe --- drivers/iommu/exynos-iommu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index b6edd178fe25e..0857519ca7188 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1429,8 +1429,6 @@ static void exynos_iommu_release_device(struct device= *dev) struct exynos_iommu_owner *owner =3D dev_iommu_priv_get(dev); struct sysmmu_drvdata *data; =20 - WARN_ON(exynos_iommu_identity_attach(&exynos_identity_domain, dev)); - list_for_each_entry(data, &owner->controllers, owner_node) device_link_del(data->link); } @@ -1476,6 +1474,7 @@ static int exynos_iommu_of_xlate(struct device *dev, =20 static const struct iommu_ops exynos_iommu_ops =3D { .identity_domain =3D &exynos_identity_domain, + .release_domain =3D &exynos_identity_domain, .domain_alloc_paging =3D exynos_iommu_domain_alloc_paging, .device_group =3D generic_device_group, .probe_device =3D exynos_iommu_probe_device, --=20 2.43.0 From nobody Fri Dec 19 14:03:43 2025 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010014.outbound.protection.outlook.com [52.101.46.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AA122F3629; Sun, 12 Oct 2025 23:58:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.14 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760313493; cv=fail; b=oELRvWosSAdIfGX7LG09vlv6rRaxZPCth2xsmUhYJ0vsTPi1E/Lf/G4IyQV6iVM5U/xfu1SAm73SRY979btexOZcAQ1beeM0skRNkqIYOCEoReQnlQA6xKgVVyvLfTzuYVM38LeVFLIx++Tws/XpgV0OIySjaEznEpD4RhtDGow= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760313493; c=relaxed/simple; bh=1wWmng/dbm1dIY+qI2Pip3LdF/JubjVU0vl3poFoqRA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jTWk0O3jg6at/JTMpltY6QNNdU9TZm67XUyS1Fijlit9HWNipY/Tj4eNgnDoeKkZ2y7O/b7JkZQogAskye52c9JkNnDZY5gZBxvmn5AGaeNvJecNYRa0XK7+9I8GvWqH2pTsC7WEmdvr53me6042p0bWfvrmCZM3R8ku5xJmdas= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=KQRCLVsQ; arc=fail smtp.client-ip=52.101.46.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="KQRCLVsQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l19Ifqjyx4nfcoTf16qnpP/KTjrPRXkq9/zQ0o4daVNiPfIF9Qx70MWbZR3tIbNa85u903JL4swXiW4S5vCXBp8qZ/1qRXLe3Iyik400LOQqsC8uyvxn7ht/41BDKhxj0mFdMF2jrH92h6F8OY01DSZ2R1sVcYJUJuTEF8hGxX3T64CedW0wftWMIDSHbDHcBVMVSW8taafFuQO75Ujp4R38JQnw7iyuii5rIAFT4gCAV6JPxkaj35vwLYGzBsWpBtQB34+1CtVeauwHyDQO4m9qrqpKwvhK0DTIDz/sdJSCE3tzKz3sLDbfGDovRXeUMrYV6JrSQeSccZrgptvRUQ== 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=uC2XylywyGzSg9CgvBBdR9BLHfyJUKGprDQLZHxIsYk=; b=wLNiUj0D/5xcC5cCGyv5efLpGm16TEI7liiJOYyYhIlQK9JLeGvsiwL909LOKv3Llai05gjLJReirJH9dFpK3b23JflPTL4YZkPvlP9YfZwKcT95oBqDvEmocDIxUC4RmiruWhS20B0wFGWwPB4QAiLGirSz1JTj8imkeCJoJLyuP8YJNzcLcTHhKuWZ2jIvmya55r0RXUjILRPHqDvdHNx2N60wktjSadCcttSuZ8an+Mt6TwzsTrd/OhgiwyCZNRknNfWVtQQEYPCXmYUGrq6TP7roqerV+mP/qsFv0qROgjiubyhA92g2Zl+zfchc4MrRIWvFWcjCo/sC5BVFrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=8bytes.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=uC2XylywyGzSg9CgvBBdR9BLHfyJUKGprDQLZHxIsYk=; b=KQRCLVsQrBDSghm/okw9DIVrO0lYvCSedLYgb6FBo9Z9Xla1YXnZ7+mqnq1F/EWvwjLFuPfaRw/DE952qUY07frue+uTz203mPMcSD9atqlvC4+IOAZQWeeBXUseiM8bfrblBeWNrHPcA7p0+yMDMQOx4slVmAukPwIQEBqJIBWQEkNexrKDBBQFWvFl1nUhp+AUb4fuumF1Btnrq66FC+a539bboeV7D5oRJBe6odnF3Ryn69kDC/XojuZoXU+xK+iVrAc2pGQ3/w6R/gfzcQeVFCCMcNtv0fGXAUinHRoj9VskDGsNolxoSiE3n0Scgp1QCj70lFAlhzHNsSfw4w== Received: from PH1PEPF000132F8.NAMP220.PROD.OUTLOOK.COM (2603:10b6:518:1::29) by DM4PR12MB7624.namprd12.prod.outlook.com (2603:10b6:8:107::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.12; Sun, 12 Oct 2025 23:58:07 +0000 Received: from SA2PEPF000015CB.namprd03.prod.outlook.com (2a01:111:f403:c801::5) by PH1PEPF000132F8.outlook.office365.com (2603:1036:903:47::3) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9203.12 via Frontend Transport; Sun, 12 Oct 2025 23:58:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF000015CB.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.7 via Frontend Transport; Sun, 12 Oct 2025 23:58:07 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Sun, 12 Oct 2025 16:58:02 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sun, 12 Oct 2025 16:58:02 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sun, 12 Oct 2025 16:57:59 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v1 4/6] iommu/amd: Set release_domain to blocked_domain Date: Sun, 12 Oct 2025 16:57:40 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CB:EE_|DM4PR12MB7624:EE_ X-MS-Office365-Filtering-Correlation-Id: 83160ef4-418c-454a-3729-08de09eb30a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7SZ4tA5ik0iWRX4fFzg29Zap51vE3FR5QCHjAJ//3JzgH2LYpTCsEQitZQD0?= =?us-ascii?Q?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ffpZua5xQyqQE1hZfiH?= =?us-ascii?Q?kKBD/vsd6cXRz/CFoARehZ6292PL895ZMJetFWwH7U5mVvjQw0LULIpTuy4t?= =?us-ascii?Q?gdTOTK9vI1peYUKA0gyKbHjA1R4Bp6klbd0FNnhf/vZHEZhWwzaqII2lf5fD?= =?us-ascii?Q?uyTF73FIB9XUIekSIq0iHe9AzDb0pIIuXbV9hYCd9ZmIrRKASMBczDCugIlK?= =?us-ascii?Q?Y1W3MYvxrUY7AUxlSI6RouCb93mEmoNqDmqDM0HbyUt3gLsIxOjx76w2+2oJ?= =?us-ascii?Q?t8EBK+fx7xrSR820DnTyjInwUjhJ9aaGyLHVnRntC153GRqQT9dX0TXVpZEw?= =?us-ascii?Q?nDnDpYd4YRxjo0HYY4KNeqbS8GhRSUdZIGAf7qzdRU5bLYKKZ3F6pqa30bzc?= =?us-ascii?Q?//NCLbUAIoaQ8ZVKwW3gCccJYdU6BfdDaHxvgJNg56Tj62nlD9VzjmW3ZCs/?= =?us-ascii?Q?3nZOcU6RF8Z2WT8q4ZTVjJAup/ZRkPpda6UwOhBSSOrm9EtOgWToSKi67kk2?= =?us-ascii?Q?nTnuqFTlR/as7ET9+BwIk3JwZZVv9sziC24zqC/uDqJL1KXYxuLkGnWWgye4?= =?us-ascii?Q?oIvu2+O1Q4BqbDm9rnvJ5SRdDqfhist7QC5Bx8xDN+8d/RdvPKcoNUT1dl04?= =?us-ascii?Q?g27O6zS75GTz0kwAT54=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2025 23:58:07.0206 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83160ef4-418c-454a-3729-08de09eb30a3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015CB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7624 Content-Type: text/plain; charset="utf-8" The set_dev_pasid for a release domain never gets called anyhow. So, there is no point in defining a separate release_domain from the blocked_domain. Simply reuse the blocked_domain. Suggested-by: Jason Gunthorpe Signed-off-by: Nicolin Chen Reviewed-by: Jason Gunthorpe --- drivers/iommu/amd/iommu.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 2e1865daa1cee..6f4559eb5121a 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2685,14 +2685,6 @@ void amd_iommu_init_identity_domain(void) protection_domain_init(&identity_domain); } =20 -/* Same as blocked domain except it supports only ops->attach_dev() */ -static struct iommu_domain release_domain =3D { - .type =3D IOMMU_DOMAIN_BLOCKED, - .ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D blocked_domain_attach_device, - } -}; - static int amd_iommu_attach_device(struct iommu_domain *dom, struct device *dev) { @@ -3042,7 +3034,7 @@ static const struct iommu_dirty_ops amd_dirty_ops =3D= { const struct iommu_ops amd_iommu_ops =3D { .capable =3D amd_iommu_capable, .blocked_domain =3D &blocked_domain, - .release_domain =3D &release_domain, + .release_domain =3D &blocked_domain, .identity_domain =3D &identity_domain.domain, .domain_alloc_paging_flags =3D amd_iommu_domain_alloc_paging_flags, .domain_alloc_sva =3D amd_iommu_domain_alloc_sva, --=20 2.43.0 From nobody Fri Dec 19 14:03:43 2025 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012011.outbound.protection.outlook.com [52.101.53.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CA222F5315; Sun, 12 Oct 2025 23:58:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.53.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760313499; cv=fail; b=fBDNALePyGGHF8jMNa8ITMErJfnv7bQSO8BKUTzetrPxGzAf7uT77NN6rNDE3h+nlUmWHt73oGh9bXWIg5QBigXeuiNzKVN1g+t+AyCFwjVhsEMuRtSb58afbAaxLXLEpBwyXogrA7djwNbvf2U1CQ3nW02lEQTURKfN/pmhsPc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760313499; c=relaxed/simple; bh=kVR1P5jltLu9TQtu31yt7u/PXX9R1bXu1SN2+rupnJw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qlnRknK0aBCxL1H+N9nq17UALE7y3ZUbCTxEtBlT27rJX3dEb/ZQFHoAsFworp9m5LIphQMcFBti3IV4kK6pi5D9+x+QIL91ieIGBeYpECRlrWl65m5YKn8DydE0VQmuPhc7MCs5CChT0v/SE/NPVCtCvgr7dRmsuy3M3uFwpEo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=SE9GwL5o; arc=fail smtp.client-ip=52.101.53.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="SE9GwL5o" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i+c6zkI2Lp5mQU71EZx4FTx/m5i43iBTRRXxjDhEB51v/TYMwVmQ8gNfp0+Bx3Z0K4JBvu8p5hoLbN1xu1NZWWq9eeccp3WcbRP6Sa4/3Jkf8xLqzWRTShwHc0aSZLeh5NDaBzvelkqoPuaBlkkg/kIyIKCp6D8EkmwjMSV6IJsD/sDc3XwKBOO8USV1dVlDz9bIdoA/6FokxApeahIcbGAEUTCWjpcOB49TpJztmnhJnp9WwCOrYYLPe3RDWAsOY+fhBl5v7LAhkm7J2MZwmeJBH5mHjKdZZcvfP62Y7d2GVSR/cHc2LCsjr1AnDgKQrLJ5wt4g0zwIs0kJ36wFzA== 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=+ykJhQ+h2s2vD4oxxv0mUAKfdkPiwe4DMPtCtxtxrkw=; b=LKiVoRjXTSYCw9Z29imNRVIRw6Boa5f3wmjJEx50uGhc3s2X5+05oLuUt/bpEDTsHsARM7iBsuOo/ZLhTaM0CxH6qylxERxzUYXjIlr1nVo/YSq9jcwtD4Ymbk+L0jEPFHDvRfNNmQdWQ/xs1FjQvVeEB5ZanCBLD3DFUAl2ACNgDix3DyENKB3h7mon/E3LrYO87QFPVdIM9l/PVBuPp77PUpv38j+OvkQ5g2hAiM/FrFcRYbx9A37l3URXym281/+ZF5WxjV8ou18OkQ1vSYDapSg2qMywp1u4O4dMvbum7VMeTMLrcJZ4Y0KEOHYQaATBoATVCpoOPbpGdx4ESg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=8bytes.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=+ykJhQ+h2s2vD4oxxv0mUAKfdkPiwe4DMPtCtxtxrkw=; b=SE9GwL5om1okFTnob75cYTCc3u6mIUkSdmQcav93Um8OWBPvQ4tHxEJVVREUgCAIcLwncAlLqFNceKUH3WPXQx6KRYJDeYprm9resGwBuEpMRyjK5deUbXqJ5XIwOfd9zEA4H/qz/YI7/UXWf9wbPIUTameaZv6AzK7l+O055PHxI24Y+4nTKBSpBaKbgAlaT0O5taWcTt+/E6b4ikFU5L9YENJhClwXQ2y4UpuEQOCrIC2eOPGmX/WEsot9MdAnYDQGCtY2NM/n7snbh97mAIO0Tqc40gkv9SCTwdUAnt1b9fWDAmgTzfqxT4j76pOqLkBfZWMqRkc1ClBYSh47Xg== Received: from PH1PEPF000132F2.NAMP220.PROD.OUTLOOK.COM (2603:10b6:518:1::35) by MN6PR12MB8544.namprd12.prod.outlook.com (2603:10b6:208:47f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.12; Sun, 12 Oct 2025 23:58:14 +0000 Received: from SA2PEPF000015CB.namprd03.prod.outlook.com (2a01:111:f403:c931::1) by PH1PEPF000132F2.outlook.office365.com (2603:1036:903:47::3) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9203.12 via Frontend Transport; Sun, 12 Oct 2025 23:58:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF000015CB.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.7 via Frontend Transport; Sun, 12 Oct 2025 23:58:13 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Sun, 12 Oct 2025 16:58:06 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sun, 12 Oct 2025 16:58:05 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sun, 12 Oct 2025 16:58:02 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v1 5/6] iommu: Do not revert set_domain for the last gdev Date: Sun, 12 Oct 2025 16:57:41 -0700 Message-ID: <691771cd72daf8d6c813d25067c6c521d834e350.1760312540.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CB:EE_|MN6PR12MB8544:EE_ X-MS-Office365-Filtering-Correlation-Id: 50b7da0b-68a0-4b25-f1dd-08de09eb348d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?vo97KKZaWyL28eGyTdS6drmu5CXBqyoM7OIw1PwAp/IawEEFLgiS0HisJeNK?= =?us-ascii?Q?JoAdDbRq1LHPo5GugCjRCm2tv0w5w0GEIMXu0NFsPNSHuHjTT3vLvVJfw4oR?= =?us-ascii?Q?slHMfm0TUnLeZDFaF4Q2ZnZ+kUj8MtgD7pVV+DTMtS1Jsk3DqeH4a/6dqg+e?= =?us-ascii?Q?htlpIasqS+6WE1JFNE6RqIGEO3nJL//5YPeo80ayYCx9Usxej4YQWL2KEQ7I?= =?us-ascii?Q?I5/FrZx9iabqUKl5d9WUQC9obk1rW5MVEr2W3j3xE/fXMTyEH8oKOSOg7G9W?= =?us-ascii?Q?IlDAI04/UnM/p87EN3VJKSPvphN4ex3PpKI7OmOAvHASFMjqDO/APYFj+2YF?= =?us-ascii?Q?vnBhuKtc1x98r/oPINW3vhj+S/A4fhfvleJ2CBD+l/qnZxD+TR3ADdRFdk7U?= =?us-ascii?Q?b/4pMwDkDB8uHhV1P8OimrtcTaqm/QqP2VUATmU2pPZQqusCRo8fOE8xuybn?= =?us-ascii?Q?5+sCgKD5d79/xsPWUpCkUqoCJ4O/flG4/stSPF84kOFeBsQxFa207Aye6P9q?= =?us-ascii?Q?HwMQgl2oZELgIbF9fo0ONBRYK1mvC/2ECil8zytMTDDnL3nJc5BK99nFoeS1?= =?us-ascii?Q?/johPM2oivWyak2rtYMIkpZCyn5vp4KM5yez8D+QLOoYVUrNQ5w/F69OlAJX?= =?us-ascii?Q?Oa6+c9LjpEZd1SaykHIWOzSG9zISgA2XhaMS8ZncnB71jIpqhI9jFDmMn8Hg?= =?us-ascii?Q?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Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2025 23:58:13.5758 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 50b7da0b-68a0-4b25-f1dd-08de09eb348d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015CB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8544 Content-Type: text/plain; charset="utf-8" The last gdev is the device that failed the __iommu_device_set_domain(). So, it doesn't need to be reverted, given it's attached to group->domain already. This is not a problem currently, since it's a simply re-attach. However, the core will need to pass in the old domain to __iommu_device_set_domain so the old domain pointers would be inconsistent between a failed device and all its prior succeeded devices, as all the prior devices need to be reverted. Avoid the re-attach for the last gdev, by breaking before the revert. Signed-off-by: Nicolin Chen Reviewed-by: Jason Gunthorpe --- drivers/iommu/iommu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index adef1a37f9311..ce141f095f969 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2403,6 +2403,9 @@ static int __iommu_group_set_domain_internal(struct i= ommu_group *group, */ last_gdev =3D gdev; for_each_group_device(group, gdev) { + /* No need to revert the last gdev that failed to set domain */ + if (gdev =3D=3D last_gdev) + break; /* * A NULL domain can happen only for first probe, in which case * we leave group->domain as NULL and let release clean @@ -2412,8 +2415,6 @@ static int __iommu_group_set_domain_internal(struct i= ommu_group *group, WARN_ON(__iommu_device_set_domain( group, gdev->dev, group->domain, IOMMU_SET_DOMAIN_MUST_SUCCEED)); - if (gdev =3D=3D last_gdev) - break; } return ret; } --=20 2.43.0 From nobody Fri Dec 19 14:03:43 2025 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012001.outbound.protection.outlook.com [52.101.53.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3609C2EBBB8; Sun, 12 Oct 2025 23:58:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.53.1 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760313513; cv=fail; b=dlEGnH2yPyhT+QhAk1Mmu5pmJlGVvNcmo0XFz+HvkfopM7JAVkjIA5NgPgrCInwbpXtJNHIYMwK8ysRgQNWT/RU2sde8rg3239UDR9OIuK/Le9a+GX7+omRTdlQ1ft0R6F3IJQtxQ9ZIFe+6de/mfEIr61VGudeKYGu8StrxPA0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760313513; c=relaxed/simple; bh=Lp2LV1/7/L4l2a2aJcCh9dFoBDKBteREd6l9YgLZrF8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tGmtWLWxjFAWeO0GMYl0Xx5A/dj8ZEW09C2lqRPKMQ+CGAtR3bnL/WDldcfu/C4oj82A8C4XWonjZrLn5u/QQEixYL/31oo4KR1e0fQ3sJsxdY06Fm8Y2ZvhTUxln2Urb0jr15+xPJU9kj0MATSZ/okBdde2xk9D3UY4mwYRFGI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=qLkpepCu; arc=fail smtp.client-ip=52.101.53.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="qLkpepCu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yjqmXQpLfUHbIagRN1//MYvWsk3qyD3mKLx7GS1bjPgHmG23UJFTRYCL5K+Dv3rag7ELFZwovXXMe4lCRQDwC5bMDrZ6I4Y2kW+AYhZXnZNlomlBTvl4H9vyIOEvTo8W5StaLRdynsv+x2x/c8ikGzQS9tMMk59fiN68SLCjtK3vbQwi+4HqAFzq6QbOfgQIBqrPLayN4Hkstrdwt3QZf2X7pE/xlyAGYxYCI2zBRSIOMgpgQ8Ng0svp1VEBavaQVBGpyqC7iLOsUD62Pr59WWcr8bFfePBeCsdLehtJnfoZotWjpGKZB77IPKXm4ZIhtHp1x9N2sxT9rOn8MD3JFQ== 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=Q32xHwAzwHvgtM4kKLl/4rIHsU03nSI8uN2yqtpntYU=; b=bz29ledLHXIy77ubHYR+PX+gvfcNs8zV1YB0Mg4fsjmizjBPywctVtV3AbAe/IYW+geOHImfxiwEv4YmVA+XtVjIpq9HEIzQ7iDMg1gs0zDw/Z9EuAqqyhTwhUcVsWgQGUJYP+cOyq5Ej/NYhOMDhJGMQESI3M72fUc9BClNuoXJyppNd4GX8UtIB9YwdHgV6Wb6nQK9s1DFFkDABVGdIG+bzA80BM1SwVA9/8eNVAHxHY1LL6q0ZfM/IfFyKhrN0hmSBxKnqHM0SIl+N7xcP8u1DEQ2h3qejqk4jQzGix/ejo3yU+les1H+wAV3Oxen2R0FyxdqRNiKTyAfNsA+iQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=8bytes.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=Q32xHwAzwHvgtM4kKLl/4rIHsU03nSI8uN2yqtpntYU=; b=qLkpepCu1ZTFosaUSvajr486D/HxMBpVWCcxFQidhXembmwz3/rE5obRIuq8ijgDYfNWgVcU0bznNwXDN2msUdV+vlZ7rodGG+aLnosyPDbJunhffwGa2ZK7yTsMjvtrnXmeLYdcxSt4QC1VnuGnpsxdjm557qLYIwhrsAOS1O7SmFS3GouH5RD3TtZEYV6UN2+nFyy0v26acxjNEIVtO0kvgIM/eajiqdkux+O8hYPW32lZ1DmLFpdOvztx6rUxzwKTMyAlVyLYLQOGJ1jkFmSEBA7A1KiCcJdmG4uvBmH4U6PISZHinWqnYWYRkXyOGZViMgbZ28bh0QpZRRom6g== Received: from PH5P222CA0001.NAMP222.PROD.OUTLOOK.COM (2603:10b6:510:34b::12) by CH1PPF6B6BCC42C.namprd12.prod.outlook.com (2603:10b6:61f:fc00::612) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.12; Sun, 12 Oct 2025 23:58:19 +0000 Received: from SA2PEPF000015CC.namprd03.prod.outlook.com (2603:10b6:510:34b:cafe::a3) by PH5P222CA0001.outlook.office365.com (2603:10b6:510:34b::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9203.12 via Frontend Transport; Sun, 12 Oct 2025 23:58:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF000015CC.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.7 via Frontend Transport; Sun, 12 Oct 2025 23:58:19 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Sun, 12 Oct 2025 16:58:11 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sun, 12 Oct 2025 16:58:10 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sun, 12 Oct 2025 16:58:06 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v1 6/6] iommu: Pass in old domain to attach_dev callback functions Date: Sun, 12 Oct 2025 16:57:42 -0700 Message-ID: <53e12066ebcaa1bb5a3f4ed1657e088f3d8e8464.1760312540.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CC:EE_|CH1PPF6B6BCC42C:EE_ X-MS-Office365-Filtering-Correlation-Id: b5bb0c30-75cf-40ed-3250-08de09eb37f7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?iZ71YrQcqh7tUdg9lFjKDh/er+de0JMOOhNGRZoqBPw69KrR7m6hhvHVfE0K?= =?us-ascii?Q?7+m1d1io8sca5jw3PKxFPgjZ9ZvAaONXKP3roihfsJoKONtKfd7/ddOZ1vjW?= =?us-ascii?Q?jwIbRb+IHgFP+AMvWKhFsSGu7cbtRs8zFfVF9Fhxwc/R5KrtPu2ejIEDZ7Bx?= =?us-ascii?Q?NuYzirMeBBHkAB/uZB1V3+sHcoRZhHUjYI72Ckyh5pXbTDHNOcDStHbhH1Oo?= =?us-ascii?Q?pk01wCZQu87ePWf4GifrZxcQfN92p1krXlwqTbnv9bPB3S7O+HpQhL4KreSF?= =?us-ascii?Q?QE0UF9GwoSNms2bpl4H1Xx/Wn/57MhJQkt6f6SsV+dQ+kSbiaimW0KcdI/Oo?= =?us-ascii?Q?wP6DD4gzsgv8XeI7vZrIbRcFGNsAzFqEzO/3NGKSXXZJU91OkDOZWRh0OVub?= =?us-ascii?Q?z5eEmMKJTju44YCSYHCXRc6GASqMFLpV1NCFTeBbZu5E3aZYCgIkVxlynaOK?= =?us-ascii?Q?Zk7NbbGzk2qae09E6R2JEHOyw/ysqL7o0j1XCOpw52bWSea7dZ/+N9Ik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aQ5bIRQ2E/D0rM2U/8CrHEQCjtVN7nQ1X2Cl2m0t/pZ8lPlyG?= =?us-ascii?Q?p5WjMBsQu6DwGX6G2Dc5tt8yD8XuPILMibwzyU4FpF6x0fFHQvr0X2GiySyl?= =?us-ascii?Q?y5e+GFjN7urrEjjaOl/Vl7aDmus0mnSxYJVcBb09EVeHycEOkl6juqWeVrHm?= =?us-ascii?Q?THYS5BCyqRYq2UOyYaI=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2025 23:58:19.2852 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5bb0c30-75cf-40ed-3250-08de09eb37f7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015CC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH1PPF6B6BCC42C Content-Type: text/plain; charset="utf-8" The IOMMU core attaches each device to a default domain on probe(). Then, every new "attach" operation has a fundamental meaning of two-fold: - detach from its currently attached (old) domain - attach to a given new domain Modern IOMMU drivers following this pattern usually want to clean up the things related to the old domain, so they call iommu_get_domain_for_dev() to fetch the old domain. Pass in the old domain pointer from the core to drivers, aligning with the set_dev_pasid op that does so already. Ensure all low-level attach fcuntions in the core can forward the correct old domain pointer. Thus, rework those functions as well. Suggested-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- include/linux/iommu.h | 3 ++- drivers/iommu/amd/iommu.c | 11 ++++---- drivers/iommu/apple-dart.c | 9 ++++--- .../arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 5 ++-- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 24 +++++++++++------- drivers/iommu/arm/arm-smmu/arm-smmu.c | 9 ++++--- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 11 ++++---- drivers/iommu/exynos-iommu.c | 8 +++--- drivers/iommu/fsl_pamu_domain.c | 12 ++++----- drivers/iommu/intel/iommu.c | 10 +++++--- drivers/iommu/intel/nested.c | 2 +- drivers/iommu/iommu.c | 25 +++++++++++-------- drivers/iommu/iommufd/selftest.c | 2 +- drivers/iommu/ipmmu-vmsa.c | 10 ++++---- drivers/iommu/msm_iommu.c | 11 ++++---- drivers/iommu/mtk_iommu.c | 8 +++--- drivers/iommu/mtk_iommu_v1.c | 7 ++++-- drivers/iommu/omap-iommu.c | 12 ++++----- drivers/iommu/riscv/iommu.c | 9 ++++--- drivers/iommu/rockchip-iommu.c | 20 +++++++++++---- drivers/iommu/s390-iommu.c | 9 ++++--- drivers/iommu/sprd-iommu.c | 3 ++- drivers/iommu/sun50i-iommu.c | 8 +++--- drivers/iommu/tegra-smmu.c | 10 ++++---- drivers/iommu/virtio-iommu.c | 6 +++-- 25 files changed, 148 insertions(+), 96 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index c30d12e16473d..801b2bd9e8d49 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -751,7 +751,8 @@ struct iommu_ops { * @free: Release the domain after use. */ struct iommu_domain_ops { - int (*attach_dev)(struct iommu_domain *domain, struct device *dev); + int (*attach_dev)(struct iommu_domain *domain, struct device *dev, + struct iommu_domain *old); int (*set_dev_pasid)(struct iommu_domain *domain, struct device *dev, ioasid_t pasid, struct iommu_domain *old); =20 diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 6f4559eb5121a..e16ad510c8c8a 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -70,8 +70,8 @@ int amd_iommu_max_glx_val =3D -1; */ DEFINE_IDA(pdom_ids); =20 -static int amd_iommu_attach_device(struct iommu_domain *dom, - struct device *dev); +static int amd_iommu_attach_device(struct iommu_domain *dom, struct device= *dev, + struct iommu_domain *old); =20 static void set_dte_entry(struct amd_iommu *iommu, struct iommu_dev_data *dev_data); @@ -2635,7 +2635,8 @@ void amd_iommu_domain_free(struct iommu_domain *dom) } =20 static int blocked_domain_attach_device(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct iommu_dev_data *dev_data =3D dev_iommu_priv_get(dev); =20 @@ -2685,8 +2686,8 @@ void amd_iommu_init_identity_domain(void) protection_domain_init(&identity_domain); } =20 -static int amd_iommu_attach_device(struct iommu_domain *dom, - struct device *dev) +static int amd_iommu_attach_device(struct iommu_domain *dom, struct device= *dev, + struct iommu_domain *old) { struct iommu_dev_data *dev_data =3D dev_iommu_priv_get(dev); struct protection_domain *domain =3D to_pdomain(dom); diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 95a4e62b8f63c..b5848770ef482 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -672,7 +672,8 @@ static int apple_dart_domain_add_streams(struct apple_d= art_domain *domain, } =20 static int apple_dart_attach_dev_paging(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { int ret, i; struct apple_dart_stream_map *stream_map; @@ -693,7 +694,8 @@ static int apple_dart_attach_dev_paging(struct iommu_do= main *domain, } =20 static int apple_dart_attach_dev_identity(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct apple_dart_master_cfg *cfg =3D dev_iommu_priv_get(dev); struct apple_dart_stream_map *stream_map; @@ -717,7 +719,8 @@ static struct iommu_domain apple_dart_identity_domain = =3D { }; =20 static int apple_dart_attach_dev_blocked(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct apple_dart_master_cfg *cfg =3D dev_iommu_priv_get(dev); struct apple_dart_stream_map *stream_map; diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c b/drivers/= iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c index 8cd8929bbfdf8..313201a616991 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c @@ -138,14 +138,15 @@ void arm_smmu_master_clear_vmaster(struct arm_smmu_ma= ster *master) } =20 static int arm_smmu_attach_dev_nested(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old_domain) { struct arm_smmu_nested_domain *nested_domain =3D to_smmu_nested_domain(domain); struct arm_smmu_master *master =3D dev_iommu_priv_get(dev); struct arm_smmu_attach_state state =3D { .master =3D master, - .old_domain =3D iommu_get_domain_for_dev(dev), + .old_domain =3D old_domain, .ssid =3D IOMMU_NO_PASID, }; struct arm_smmu_ste ste; diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index 2125ebfc9a70e..a33fbd12a0dd9 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3002,7 +3002,8 @@ void arm_smmu_attach_commit(struct arm_smmu_attach_st= ate *state) master->ats_enabled =3D state->ats_enabled; } =20 -static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device = *dev) +static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device = *dev, + struct iommu_domain *old_domain) { int ret =3D 0; struct arm_smmu_ste target; @@ -3010,7 +3011,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *d= omain, struct device *dev) struct arm_smmu_device *smmu; struct arm_smmu_domain *smmu_domain =3D to_smmu_domain(domain); struct arm_smmu_attach_state state =3D { - .old_domain =3D iommu_get_domain_for_dev(dev), + .old_domain =3D old_domain, .ssid =3D IOMMU_NO_PASID, }; struct arm_smmu_master *master; @@ -3186,7 +3187,7 @@ static int arm_smmu_blocking_set_dev_pasid(struct iom= mu_domain *new_domain, =20 /* * When the last user of the CD table goes away downgrade the STE back - * to a non-cd_table one. + * to a non-cd_table one, by re-attaching its sid_domain. */ if (!arm_smmu_ssids_in_use(&master->cd_table)) { struct iommu_domain *sid_domain =3D @@ -3194,12 +3195,14 @@ static int arm_smmu_blocking_set_dev_pasid(struct i= ommu_domain *new_domain, =20 if (sid_domain->type =3D=3D IOMMU_DOMAIN_IDENTITY || sid_domain->type =3D=3D IOMMU_DOMAIN_BLOCKED) - sid_domain->ops->attach_dev(sid_domain, dev); + sid_domain->ops->attach_dev(sid_domain, dev, + sid_domain); } return 0; } =20 static void arm_smmu_attach_dev_ste(struct iommu_domain *domain, + struct iommu_domain *old_domain, struct device *dev, struct arm_smmu_ste *ste, unsigned int s1dss) @@ -3207,7 +3210,7 @@ static void arm_smmu_attach_dev_ste(struct iommu_doma= in *domain, struct arm_smmu_master *master =3D dev_iommu_priv_get(dev); struct arm_smmu_attach_state state =3D { .master =3D master, - .old_domain =3D iommu_get_domain_for_dev(dev), + .old_domain =3D old_domain, .ssid =3D IOMMU_NO_PASID, }; =20 @@ -3248,14 +3251,16 @@ static void arm_smmu_attach_dev_ste(struct iommu_do= main *domain, } =20 static int arm_smmu_attach_dev_identity(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old_domain) { struct arm_smmu_ste ste; struct arm_smmu_master *master =3D dev_iommu_priv_get(dev); =20 arm_smmu_master_clear_vmaster(master); arm_smmu_make_bypass_ste(master->smmu, &ste); - arm_smmu_attach_dev_ste(domain, dev, &ste, STRTAB_STE_1_S1DSS_BYPASS); + arm_smmu_attach_dev_ste(domain, old_domain, dev, &ste, + STRTAB_STE_1_S1DSS_BYPASS); return 0; } =20 @@ -3269,14 +3274,15 @@ static struct iommu_domain arm_smmu_identity_domain= =3D { }; =20 static int arm_smmu_attach_dev_blocked(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old_domain) { struct arm_smmu_ste ste; struct arm_smmu_master *master =3D dev_iommu_priv_get(dev); =20 arm_smmu_master_clear_vmaster(master); arm_smmu_make_abort_ste(&ste); - arm_smmu_attach_dev_ste(domain, dev, &ste, + arm_smmu_attach_dev_ste(domain, old_domain, dev, &ste, STRTAB_STE_1_S1DSS_TERMINATE); return 0; } diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-= smmu/arm-smmu.c index 4ced4b5bee4df..5e690cf85ec96 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -1165,7 +1165,8 @@ static void arm_smmu_master_install_s2crs(struct arm_= smmu_master_cfg *cfg, } } =20 -static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device = *dev) +static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device = *dev, + struct iommu_domain *old) { struct arm_smmu_domain *smmu_domain =3D to_smmu_domain(domain); struct iommu_fwspec *fwspec =3D dev_iommu_fwspec_get(dev); @@ -1234,7 +1235,8 @@ static int arm_smmu_attach_dev_type(struct device *de= v, } =20 static int arm_smmu_attach_dev_identity(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { return arm_smmu_attach_dev_type(dev, S2CR_TYPE_BYPASS); } @@ -1249,7 +1251,8 @@ static struct iommu_domain arm_smmu_identity_domain = =3D { }; =20 static int arm_smmu_attach_dev_blocked(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { return arm_smmu_attach_dev_type(dev, S2CR_TYPE_FAULT); } diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/ar= m-smmu/qcom_iommu.c index c5be95e560317..9222a4a48bb33 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -359,7 +359,8 @@ static void qcom_iommu_domain_free(struct iommu_domain = *domain) kfree(qcom_domain); } =20 -static int qcom_iommu_attach_dev(struct iommu_domain *domain, struct devic= e *dev) +static int qcom_iommu_attach_dev(struct iommu_domain *domain, + struct device *dev, struct iommu_domain *old) { struct qcom_iommu_dev *qcom_iommu =3D dev_iommu_priv_get(dev); struct qcom_iommu_domain *qcom_domain =3D to_qcom_iommu_domain(domain); @@ -388,18 +389,18 @@ static int qcom_iommu_attach_dev(struct iommu_domain = *domain, struct device *dev } =20 static int qcom_iommu_identity_attach(struct iommu_domain *identity_domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { - struct iommu_domain *domain =3D iommu_get_domain_for_dev(dev); struct qcom_iommu_domain *qcom_domain; struct iommu_fwspec *fwspec =3D dev_iommu_fwspec_get(dev); struct qcom_iommu_dev *qcom_iommu =3D dev_iommu_priv_get(dev); unsigned int i; =20 - if (domain =3D=3D identity_domain || !domain) + if (old =3D=3D identity_domain || !old) return 0; =20 - qcom_domain =3D to_qcom_iommu_domain(domain); + qcom_domain =3D to_qcom_iommu_domain(old); if (WARN_ON(!qcom_domain->iommu)) return -EINVAL; =20 diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 0857519ca7188..e375ced6e2b00 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -984,7 +984,8 @@ static void exynos_iommu_domain_free(struct iommu_domai= n *iommu_domain) } =20 static int exynos_iommu_identity_attach(struct iommu_domain *identity_doma= in, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct exynos_iommu_owner *owner =3D dev_iommu_priv_get(dev); struct exynos_iommu_domain *domain; @@ -1035,7 +1036,8 @@ static struct iommu_domain exynos_identity_domain =3D= { }; =20 static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct exynos_iommu_domain *domain =3D to_exynos_domain(iommu_domain); struct exynos_iommu_owner *owner =3D dev_iommu_priv_get(dev); @@ -1044,7 +1046,7 @@ static int exynos_iommu_attach_device(struct iommu_do= main *iommu_domain, unsigned long flags; int err; =20 - err =3D exynos_iommu_identity_attach(&exynos_identity_domain, dev); + err =3D exynos_iommu_identity_attach(&exynos_identity_domain, dev, old); if (err) return err; =20 diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domai= n.c index 5f08523f97cb9..9664ef9840d2c 100644 --- a/drivers/iommu/fsl_pamu_domain.c +++ b/drivers/iommu/fsl_pamu_domain.c @@ -238,7 +238,7 @@ static int update_domain_stash(struct fsl_dma_domain *d= ma_domain, u32 val) } =20 static int fsl_pamu_attach_device(struct iommu_domain *domain, - struct device *dev) + struct device *dev, struct iommu_domain *old) { struct fsl_dma_domain *dma_domain =3D to_fsl_dma_domain(domain); unsigned long flags; @@ -298,9 +298,9 @@ static int fsl_pamu_attach_device(struct iommu_domain *= domain, * switches to what looks like BLOCKING. */ static int fsl_pamu_platform_attach(struct iommu_domain *platform_domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { - struct iommu_domain *domain =3D iommu_get_domain_for_dev(dev); struct fsl_dma_domain *dma_domain; const u32 *prop; int len; @@ -311,11 +311,11 @@ static int fsl_pamu_platform_attach(struct iommu_doma= in *platform_domain, * Hack to keep things working as they always have, only leaving an * UNMANAGED domain makes it BLOCKING. */ - if (domain =3D=3D platform_domain || !domain || - domain->type !=3D IOMMU_DOMAIN_UNMANAGED) + if (old =3D=3D platform_domain || !old || + old->type !=3D IOMMU_DOMAIN_UNMANAGED) return 0; =20 - dma_domain =3D to_fsl_dma_domain(domain); + dma_domain =3D to_fsl_dma_domain(old); =20 /* * Use LIODN of the PCI controller while detaching a diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index e236c7ec221f4..f0396591cd9bb 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -3230,7 +3230,8 @@ void device_block_translation(struct device *dev) } =20 static int blocking_domain_attach_dev(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct device_domain_info *info =3D dev_iommu_priv_get(dev); =20 @@ -3537,7 +3538,8 @@ int paging_domain_compatible(struct iommu_domain *dom= ain, struct device *dev) } =20 static int intel_iommu_attach_device(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { int ret; =20 @@ -4401,7 +4403,9 @@ static int device_setup_pass_through(struct device *d= ev) context_setup_pass_through_cb, dev); } =20 -static int identity_domain_attach_dev(struct iommu_domain *domain, struct = device *dev) +static int identity_domain_attach_dev(struct iommu_domain *domain, + struct device *dev, + struct iommu_domain *old) { struct device_domain_info *info =3D dev_iommu_priv_get(dev); struct intel_iommu *iommu =3D info->iommu; diff --git a/drivers/iommu/intel/nested.c b/drivers/iommu/intel/nested.c index 1b6ad9c900a5a..760d7aa2ade84 100644 --- a/drivers/iommu/intel/nested.c +++ b/drivers/iommu/intel/nested.c @@ -19,7 +19,7 @@ #include "pasid.h" =20 static int intel_nested_attach_dev(struct iommu_domain *domain, - struct device *dev) + struct device *dev, struct iommu_domain *old) { struct device_domain_info *info =3D dev_iommu_priv_get(dev); struct dmar_domain *dmar_domain =3D to_dmar_domain(domain); diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index ce141f095f969..2ca990dfbb884 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -100,7 +100,7 @@ static int iommu_bus_notifier(struct notifier_block *nb, unsigned long action, void *data); static void iommu_release_device(struct device *dev); static int __iommu_attach_device(struct iommu_domain *domain, - struct device *dev); + struct device *dev, struct iommu_domain *old); static int __iommu_attach_group(struct iommu_domain *domain, struct iommu_group *group); static struct iommu_domain *__iommu_paging_domain_alloc_flags(struct devic= e *dev, @@ -114,6 +114,7 @@ enum { static int __iommu_device_set_domain(struct iommu_group *group, struct device *dev, struct iommu_domain *new_domain, + struct iommu_domain *old_domain, unsigned int flags); static int __iommu_group_set_domain_internal(struct iommu_group *group, struct iommu_domain *new_domain, @@ -554,7 +555,8 @@ static void iommu_deinit_device(struct device *dev) release_domain =3D=3D ops->blocked_domain) release_domain =3D ops->identity_domain; =20 - release_domain->ops->attach_dev(release_domain, dev); + release_domain->ops->attach_dev(release_domain, dev, + group->domain); } =20 if (ops->release_device) @@ -640,7 +642,8 @@ static int __iommu_probe_device(struct device *dev, str= uct list_head *group_list if (group->default_domain) iommu_create_device_direct_mappings(group->default_domain, dev); if (group->domain) { - ret =3D __iommu_device_set_domain(group, dev, group->domain, 0); + ret =3D __iommu_device_set_domain(group, dev, group->domain, NULL, + 0); if (ret) goto err_remove_gdev; } else if (!group->default_domain && !group_list) { @@ -2127,14 +2130,14 @@ static void __iommu_group_set_core_domain(struct io= mmu_group *group) } =20 static int __iommu_attach_device(struct iommu_domain *domain, - struct device *dev) + struct device *dev, struct iommu_domain *old) { int ret; =20 if (unlikely(domain->ops->attach_dev =3D=3D NULL)) return -ENODEV; =20 - ret =3D domain->ops->attach_dev(domain, dev); + ret =3D domain->ops->attach_dev(domain, dev, old); if (ret) return ret; dev->iommu->attach_deferred =3D 0; @@ -2183,7 +2186,7 @@ EXPORT_SYMBOL_GPL(iommu_attach_device); int iommu_deferred_attach(struct device *dev, struct iommu_domain *domain) { if (dev->iommu && dev->iommu->attach_deferred) - return __iommu_attach_device(domain, dev); + return __iommu_attach_device(domain, dev, NULL); =20 return 0; } @@ -2296,6 +2299,7 @@ EXPORT_SYMBOL_GPL(iommu_attach_group); static int __iommu_device_set_domain(struct iommu_group *group, struct device *dev, struct iommu_domain *new_domain, + struct iommu_domain *old_domain, unsigned int flags) { int ret; @@ -2321,7 +2325,7 @@ static int __iommu_device_set_domain(struct iommu_gro= up *group, dev->iommu->attach_deferred =3D 0; } =20 - ret =3D __iommu_attach_device(new_domain, dev); + ret =3D __iommu_attach_device(new_domain, dev, old_domain); if (ret) { /* * If we have a blocking domain then try to attach that in hopes @@ -2331,7 +2335,8 @@ static int __iommu_device_set_domain(struct iommu_gro= up *group, if ((flags & IOMMU_SET_DOMAIN_MUST_SUCCEED) && group->blocking_domain && group->blocking_domain !=3D new_domain) - __iommu_attach_device(group->blocking_domain, dev); + __iommu_attach_device(group->blocking_domain, dev, + old_domain); return ret; } return 0; @@ -2378,7 +2383,7 @@ static int __iommu_group_set_domain_internal(struct i= ommu_group *group, result =3D 0; for_each_group_device(group, gdev) { ret =3D __iommu_device_set_domain(group, gdev->dev, new_domain, - flags); + group->domain, flags); if (ret) { result =3D ret; /* @@ -2413,7 +2418,7 @@ static int __iommu_group_set_domain_internal(struct i= ommu_group *group, */ if (group->domain) WARN_ON(__iommu_device_set_domain( - group, gdev->dev, group->domain, + group, gdev->dev, group->domain, new_domain, IOMMU_SET_DOMAIN_MUST_SUCCEED)); } return ret; diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selft= est.c index de178827a078a..5661d2da2b679 100644 --- a/drivers/iommu/iommufd/selftest.c +++ b/drivers/iommu/iommufd/selftest.c @@ -216,7 +216,7 @@ static inline struct selftest_obj *to_selftest_obj(stru= ct iommufd_object *obj) } =20 static int mock_domain_nop_attach(struct iommu_domain *domain, - struct device *dev) + struct device *dev, struct iommu_domain *old) { struct mock_dev *mdev =3D to_mock_dev(dev); struct mock_viommu *new_viommu =3D NULL; diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index ffa892f657140..6667ecc331f01 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -590,7 +590,7 @@ static void ipmmu_domain_free(struct iommu_domain *io_d= omain) } =20 static int ipmmu_attach_device(struct iommu_domain *io_domain, - struct device *dev) + struct device *dev, struct iommu_domain *old) { struct iommu_fwspec *fwspec =3D dev_iommu_fwspec_get(dev); struct ipmmu_vmsa_device *mmu =3D to_ipmmu(dev); @@ -637,17 +637,17 @@ static int ipmmu_attach_device(struct iommu_domain *i= o_domain, } =20 static int ipmmu_iommu_identity_attach(struct iommu_domain *identity_domai= n, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { - struct iommu_domain *io_domain =3D iommu_get_domain_for_dev(dev); struct iommu_fwspec *fwspec =3D dev_iommu_fwspec_get(dev); struct ipmmu_vmsa_domain *domain; unsigned int i; =20 - if (io_domain =3D=3D identity_domain || !io_domain) + if (old =3D=3D identity_domain || !old) return 0; =20 - domain =3D to_vmsa_domain(io_domain); + domain =3D to_vmsa_domain(old); for (i =3D 0; i < fwspec->num_ids; ++i) ipmmu_utlb_disable(domain, fwspec->ids[i]); =20 diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c index 43a61ba021a51..819add75a6652 100644 --- a/drivers/iommu/msm_iommu.c +++ b/drivers/iommu/msm_iommu.c @@ -391,7 +391,8 @@ static struct iommu_device *msm_iommu_probe_device(stru= ct device *dev) return &iommu->iommu; } =20 -static int msm_iommu_attach_dev(struct iommu_domain *domain, struct device= *dev) +static int msm_iommu_attach_dev(struct iommu_domain *domain, struct device= *dev, + struct iommu_domain *old) { int ret =3D 0; unsigned long flags; @@ -441,19 +442,19 @@ static int msm_iommu_attach_dev(struct iommu_domain *= domain, struct device *dev) } =20 static int msm_iommu_identity_attach(struct iommu_domain *identity_domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { - struct iommu_domain *domain =3D iommu_get_domain_for_dev(dev); struct msm_priv *priv; unsigned long flags; struct msm_iommu_dev *iommu; struct msm_iommu_ctx_dev *master; int ret =3D 0; =20 - if (domain =3D=3D identity_domain || !domain) + if (old =3D=3D identity_domain || !old) return 0; =20 - priv =3D to_msm_priv(domain); + priv =3D to_msm_priv(old); free_io_pgtable_ops(priv->iop); =20 spin_lock_irqsave(&msm_iommu_lock, flags); diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 0e0285348d2b8..9747ef1644138 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -705,7 +705,7 @@ static void mtk_iommu_domain_free(struct iommu_domain *= domain) } =20 static int mtk_iommu_attach_device(struct iommu_domain *domain, - struct device *dev) + struct device *dev, struct iommu_domain *old) { struct mtk_iommu_data *data =3D dev_iommu_priv_get(dev), *frstdata; struct mtk_iommu_domain *dom =3D to_mtk_domain(domain); @@ -773,12 +773,12 @@ static int mtk_iommu_attach_device(struct iommu_domai= n *domain, } =20 static int mtk_iommu_identity_attach(struct iommu_domain *identity_domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { - struct iommu_domain *domain =3D iommu_get_domain_for_dev(dev); struct mtk_iommu_data *data =3D dev_iommu_priv_get(dev); =20 - if (domain =3D=3D identity_domain || !domain) + if (old =3D=3D identity_domain || !old) return 0; =20 mtk_iommu_config(data, dev, false, 0); diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index 10cc0b1197e80..3b45650263ac3 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -303,7 +303,9 @@ static void mtk_iommu_v1_domain_free(struct iommu_domai= n *domain) kfree(to_mtk_domain(domain)); } =20 -static int mtk_iommu_v1_attach_device(struct iommu_domain *domain, struct = device *dev) +static int mtk_iommu_v1_attach_device(struct iommu_domain *domain, + struct device *dev, + struct iommu_domain *old) { struct mtk_iommu_v1_data *data =3D dev_iommu_priv_get(dev); struct mtk_iommu_v1_domain *dom =3D to_mtk_domain(domain); @@ -329,7 +331,8 @@ static int mtk_iommu_v1_attach_device(struct iommu_doma= in *domain, struct device } =20 static int mtk_iommu_v1_identity_attach(struct iommu_domain *identity_doma= in, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct mtk_iommu_v1_data *data =3D dev_iommu_priv_get(dev); =20 diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 5c6f5943f44b1..9f0057ccea573 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1431,8 +1431,8 @@ static void omap_iommu_detach_fini(struct omap_iommu_= domain *odomain) odomain->iommus =3D NULL; } =20 -static int -omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev) +static int omap_iommu_attach_dev(struct iommu_domain *domain, + struct device *dev, struct iommu_domain *old) { struct omap_iommu_arch_data *arch_data =3D dev_iommu_priv_get(dev); struct omap_iommu_domain *omap_domain =3D to_omap_domain(domain); @@ -1536,15 +1536,15 @@ static void _omap_iommu_detach_dev(struct omap_iomm= u_domain *omap_domain, } =20 static int omap_iommu_identity_attach(struct iommu_domain *identity_domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { - struct iommu_domain *domain =3D iommu_get_domain_for_dev(dev); struct omap_iommu_domain *omap_domain; =20 - if (domain =3D=3D identity_domain || !domain) + if (old =3D=3D identity_domain || !old) return 0; =20 - omap_domain =3D to_omap_domain(domain); + omap_domain =3D to_omap_domain(old); spin_lock(&omap_domain->lock); _omap_iommu_detach_dev(omap_domain, dev); spin_unlock(&omap_domain->lock); diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c index ebb22979075df..d9429097a2b51 100644 --- a/drivers/iommu/riscv/iommu.c +++ b/drivers/iommu/riscv/iommu.c @@ -1321,7 +1321,8 @@ static bool riscv_iommu_pt_supported(struct riscv_iom= mu_device *iommu, int pgd_m } =20 static int riscv_iommu_attach_paging_domain(struct iommu_domain *iommu_dom= ain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct riscv_iommu_domain *domain =3D iommu_domain_to_riscv(iommu_domain); struct riscv_iommu_device *iommu =3D dev_to_iommu(dev); @@ -1426,7 +1427,8 @@ static struct iommu_domain *riscv_iommu_alloc_paging_= domain(struct device *dev) } =20 static int riscv_iommu_attach_blocking_domain(struct iommu_domain *iommu_d= omain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct riscv_iommu_device *iommu =3D dev_to_iommu(dev); struct riscv_iommu_info *info =3D dev_iommu_priv_get(dev); @@ -1447,7 +1449,8 @@ static struct iommu_domain riscv_iommu_blocking_domai= n =3D { }; =20 static int riscv_iommu_attach_identity_domain(struct iommu_domain *iommu_d= omain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct riscv_iommu_device *iommu =3D dev_to_iommu(dev); struct riscv_iommu_info *info =3D dev_iommu_priv_get(dev); diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 0861dd469bd86..85f3667e797c3 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -960,7 +960,8 @@ static int rk_iommu_enable(struct rk_iommu *iommu) } =20 static int rk_iommu_identity_attach(struct iommu_domain *identity_domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct rk_iommu *iommu; struct rk_iommu_domain *rk_domain; @@ -1005,7 +1006,7 @@ static struct iommu_domain rk_identity_domain =3D { }; =20 static int rk_iommu_attach_device(struct iommu_domain *domain, - struct device *dev) + struct device *dev, struct iommu_domain *old) { struct rk_iommu *iommu; struct rk_iommu_domain *rk_domain =3D to_rk_domain(domain); @@ -1026,7 +1027,7 @@ static int rk_iommu_attach_device(struct iommu_domain= *domain, if (iommu->domain =3D=3D domain) return 0; =20 - ret =3D rk_iommu_identity_attach(&rk_identity_domain, dev); + ret =3D rk_iommu_identity_attach(&rk_identity_domain, dev, old); if (ret) return ret; =20 @@ -1041,8 +1042,17 @@ static int rk_iommu_attach_device(struct iommu_domai= n *domain, return 0; =20 ret =3D rk_iommu_enable(iommu); - if (ret) - WARN_ON(rk_iommu_identity_attach(&rk_identity_domain, dev)); + if (ret) { + /* + * Note rk_iommu_identity_attach() might fail before physically + * attaching the dev to iommu->domain, in which case the actual + * old domain for this revert should be rk_identity_domain v.s. + * iommu->domain. Since rk_iommu_identity_attach() does not care + * about the old domain argument for now, this is not a problem. + */ + WARN_ON(rk_iommu_identity_attach(&rk_identity_domain, dev, + iommu->domain)); + } =20 pm_runtime_put(iommu->dev); =20 diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index aa576736d60ba..366e47978ac07 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -670,7 +670,8 @@ int zpci_iommu_register_ioat(struct zpci_dev *zdev, u8 = *status) } =20 static int blocking_domain_attach_device(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct zpci_dev *zdev =3D to_zpci_dev(dev); struct s390_domain *s390_domain; @@ -694,7 +695,8 @@ static int blocking_domain_attach_device(struct iommu_d= omain *domain, } =20 static int s390_iommu_attach_device(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct s390_domain *s390_domain =3D to_s390_domain(domain); struct zpci_dev *zdev =3D to_zpci_dev(dev); @@ -1131,7 +1133,8 @@ static int __init s390_iommu_init(void) subsys_initcall(s390_iommu_init); =20 static int s390_attach_dev_identity(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct zpci_dev *zdev =3D to_zpci_dev(dev); u8 status; diff --git a/drivers/iommu/sprd-iommu.c b/drivers/iommu/sprd-iommu.c index c7ca1d8a0b153..555d4505c747a 100644 --- a/drivers/iommu/sprd-iommu.c +++ b/drivers/iommu/sprd-iommu.c @@ -247,7 +247,8 @@ static void sprd_iommu_domain_free(struct iommu_domain = *domain) } =20 static int sprd_iommu_attach_device(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct sprd_iommu_device *sdev =3D dev_iommu_priv_get(dev); struct sprd_iommu_domain *dom =3D to_sprd_domain(domain); diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index de10b569d9a94..d3b190be18b5a 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -771,7 +771,8 @@ static void sun50i_iommu_detach_domain(struct sun50i_io= mmu *iommu, } =20 static int sun50i_iommu_identity_attach(struct iommu_domain *identity_doma= in, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct sun50i_iommu *iommu =3D dev_iommu_priv_get(dev); struct sun50i_iommu_domain *sun50i_domain; @@ -797,7 +798,8 @@ static struct iommu_domain sun50i_iommu_identity_domain= =3D { }; =20 static int sun50i_iommu_attach_device(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { struct sun50i_iommu_domain *sun50i_domain =3D to_sun50i_domain(domain); struct sun50i_iommu *iommu; @@ -813,7 +815,7 @@ static int sun50i_iommu_attach_device(struct iommu_doma= in *domain, if (iommu->domain =3D=3D domain) return 0; =20 - sun50i_iommu_identity_attach(&sun50i_iommu_identity_domain, dev); + sun50i_iommu_identity_attach(&sun50i_iommu_identity_domain, dev, old); =20 sun50i_iommu_attach_domain(iommu, sun50i_domain); =20 diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 36cdd5fbab077..336e0a3ff41fb 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -490,7 +490,7 @@ static void tegra_smmu_as_unprepare(struct tegra_smmu *= smmu, } =20 static int tegra_smmu_attach_dev(struct iommu_domain *domain, - struct device *dev) + struct device *dev, struct iommu_domain *old) { struct iommu_fwspec *fwspec =3D dev_iommu_fwspec_get(dev); struct tegra_smmu *smmu =3D dev_iommu_priv_get(dev); @@ -524,9 +524,9 @@ static int tegra_smmu_attach_dev(struct iommu_domain *d= omain, } =20 static int tegra_smmu_identity_attach(struct iommu_domain *identity_domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { - struct iommu_domain *domain =3D iommu_get_domain_for_dev(dev); struct iommu_fwspec *fwspec =3D dev_iommu_fwspec_get(dev); struct tegra_smmu_as *as; struct tegra_smmu *smmu; @@ -535,10 +535,10 @@ static int tegra_smmu_identity_attach(struct iommu_do= main *identity_domain, if (!fwspec) return -ENODEV; =20 - if (domain =3D=3D identity_domain || !domain) + if (old =3D=3D identity_domain || !old) return 0; =20 - as =3D to_smmu_as(domain); + as =3D to_smmu_as(old); smmu =3D as->smmu; for (index =3D 0; index < fwspec->num_ids; index++) { tegra_smmu_disable(smmu, fwspec->ids[index], as->id); diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index b39d6f134ab28..d314fa5cd8476 100644 --- a/drivers/iommu/virtio-iommu.c +++ b/drivers/iommu/virtio-iommu.c @@ -730,7 +730,8 @@ static struct iommu_domain *viommu_domain_alloc_identit= y(struct device *dev) return domain; } =20 -static int viommu_attach_dev(struct iommu_domain *domain, struct device *d= ev) +static int viommu_attach_dev(struct iommu_domain *domain, struct device *d= ev, + struct iommu_domain *old) { int ret =3D 0; struct virtio_iommu_req_attach req; @@ -781,7 +782,8 @@ static int viommu_attach_dev(struct iommu_domain *domai= n, struct device *dev) } =20 static int viommu_attach_identity_domain(struct iommu_domain *domain, - struct device *dev) + struct device *dev, + struct iommu_domain *old) { int ret =3D 0; struct virtio_iommu_req_attach req; --=20 2.43.0