From nobody Fri Dec 19 13:46:16 2025 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010060.outbound.protection.outlook.com [52.101.56.60]) (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 7A0AC21D596; Thu, 23 Oct 2025 02:22:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761186150; cv=fail; b=AInim7EyMZOWCEuIGx14RAJm0Gzb5ZJhncYe1+vADu7Ixt6iBxf18O4dHEztH3VuQJFcUkPDu3TeO6yZ0k5POe3IPs1hJhil7E1WRb5Xaau+gzFi/JT+MvWmzujSelHH+VOUsADYpr7UC6sGJv1980uzXPwtfiK+xPkwSAXgawM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761186150; c=relaxed/simple; bh=Oovxc2xwQBxYwcT81UaZp4r5Cby3UMpyL2z6ZKVqPCU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J/4KnQEwuY/Ddb1eZNYXQyEYt+T5QWqj98D9Cwp52MHWKZ8dACpPJlG/ZjPsrl7p6A1IEEb8xj10ny1MokHz2ozq75EqD+5S98jusKFpLJ2vnrpvs7o4GlNXCE37Ecb7rdXI0oHokKKrvN04ocr0AcUbju2TQlHXBG0cEOBZdpA= 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=jmPOFL2x; arc=fail smtp.client-ip=52.101.56.60 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="jmPOFL2x" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OfwO4eMpEGYdgaBq/wO+f8mMHIU1/PHiREhI+TnKRBEsfpMAIdVZJN1sAbHFbSbh2bcA2US8zdvrh64TD8k1zjs0JLEm5symnBKM4qNBid+PKGcD//W4FFKABjj0La005eRMLtfahPf6KyTbozOeq/ouFTJbANqGLC1e9qKuKJNLXQClcTtBqu5lKQzEOiFi+XoYEIexe5Bjfo+j4btNjPKz0pWQ73cttoQ9jUU9mvb6JG/6q8et28KQyTljG1DKJipixo2XBjx/X3YmHGcp6g+Dfl47QLTkVEvkNlSu/cYgIBcTRFThWlE6gaIywZLMXGZT+lMd3sYa3itzPJffHg== 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=F4haNnvT2YljJZP/U40dH7KiwE8U/fIFVv2WbFFlc2otn8SbdRXa+VCYA594A3SGgHCWymYWgSKDLIeY432HaMm8UXP/8NzItZCrUonnhHh5oNx9qmuAz9+KCC36P7ICxmAPjmuxKs5RjpDxHWU3XTzAsripxd+5NzfQj+yuqFRIa+kcErtNuWSYSKcJbuwq4VhIZIqLy1PAJe9nVmOJ7x8+UddJ/zSTd85NWe+c8MrteTsJgTvHlvfbvpVQE7oEhhq+iONyhx9fJq7IP2UjPlTQE7MLcJ66JAtCJMqVwUdRJ54J1po2lBCJwHRGp8sqqz5335JQEqhn0oJhfQttqQ== 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=jmPOFL2xinGmajesZ8XBc+OFmKObMYp3ZzeEbzwANX6mOPw2SSLuUC34PpLKkS2gt22LEILiCU9EfV2JPLx94cNa+FE76T97v0Z+p2njNT0q9Ogx2yRpKX+lqh7uUeo9YP8ExLUXyNNaP3OFYWmL98fBMQvd8VvaF+qm3LiXQ/QWXQ1pPmR6C7hjUMXUN1eXCQByxRR9u/LV525SySECjvbHHycDG3i4O/3MAH43TYwzEGe5Y4LfVOtHB/BsOMLQz9JDSqkd0C+vJsitQM7m7zxLXum55/CNUAtPP01QYDwsi+yALCMsCqvSEPWkiLSC/1mZx+K6UpY7hzNjMxysMw== Received: from CH0PR03CA0342.namprd03.prod.outlook.com (2603:10b6:610:11a::16) by SN7PR12MB8771.namprd12.prod.outlook.com (2603:10b6:806:32a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9253.12; Thu, 23 Oct 2025 02:22:24 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:610:11a:cafe::3d) by CH0PR03CA0342.outlook.office365.com (2603:10b6:610:11a::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9253.12 via Frontend Transport; Thu, 23 Oct 2025 02:22:20 +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 DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9253.7 via Frontend Transport; Thu, 23 Oct 2025 02:22:23 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Wed, 22 Oct 2025 19:22:11 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 22 Oct 2025 19:22:10 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Wed, 22 Oct 2025 19:22:08 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 1/6] iommu: Generic support for RMRs during device release Date: Wed, 22 Oct 2025 19:21:04 -0700 Message-ID: <80bbe9125d90b001f3ce08429704aa4168b0a00b.1761017765.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: DS2PEPF0000343A:EE_|SN7PR12MB8771:EE_ X-MS-Office365-Filtering-Correlation-Id: 108e0cb7-760e-4063-ccda-08de11db0057 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?x/UNMLeWA17a8ENKszWEqUWPMbALU0Q/+iklg2FUhBee44SobM8wldo9Mt71?= =?us-ascii?Q?8OvQKD9T8jqxqG9itNxq+9cr7ayD/9xXRWTuo1Wn49DMuKqlUwKfKLgcGwoF?= =?us-ascii?Q?RNH3Tohk7MREseMDnFchkSZTrF5zW5deCOyb3KfZps6S/EQ3TyZu++IO2iJC?= =?us-ascii?Q?iQ78vAlAAM5BKsZwF1DTkdDumHz6FO3I2VS1Ga/Czbi+akl/X7lRLdijDm7g?= =?us-ascii?Q?+f5p9hHt2NbJotH2DEBKS0hCy/DM5oRjiJ6qY/g8bcmuYbkGXEW41W3jxlIL?= =?us-ascii?Q?dJDN72Nsyejtl9t3ctz/vuYucm7HOrdfvMuW8tZpFvSFICpienHHjfewiOIe?= =?us-ascii?Q?s7nNKm2dvwYkmjWLQb1HfjuQEu9UUxn9tPSE1HjOvFbtuuVnr6F3xry9irJM?= =?us-ascii?Q?WSt/ZNeHcJIB9nD84uv0mEhNtF+MGcyJDSVoYu3Q5DxsuFj5dnd28cQYDX9A?= =?us-ascii?Q?IcHxoyE9yetyKLJs/W9fBvsvSowhajuOmIy9CdcF04pOpo2m1401AktbbeA/?= =?us-ascii?Q?Rt6WXIltPxP4i98IAzinE1c3i32BrZrLqf7KFYxMKd0ZW47kqBuRNYTCgUHG?= =?us-ascii?Q?Yt9h/f1JmejBbtqOi7Xu3/w23bTm7JSq/mEB/QRJmnfuhI1KPKPrvJuijAcz?= =?us-ascii?Q?UsavqnMDZrYgZDk5yr54PMQeyZomJcr9gAMnYqSgSe4TWvtJz5vBvFAKbDck?= =?us-ascii?Q?y+dMc6Ur/KSqDTqQiyHAeI5jk3YVIGPxAsFimdvpgBTdu6sAipz0j8XA1S9c?= =?us-ascii?Q?l/4dcyWAFOkM21IJcbTr30KJ8X9rdswElKiUDoeyRfJvyvgReYSiF3nVuycX?= =?us-ascii?Q?3/a/W/kmjl/5SgBWTZsJ0TEfzDrtzMzsrrcbzBmSnmtKUhm+2FkwOzL0b59z?= =?us-ascii?Q?7aegehLK4vbdvs7PWWtqY/28Le2MwCSqkCPcNDj7631SmAUW9lGPkW1gPDkh?= =?us-ascii?Q?yKiFI+gRexvT4nIkzEzzaEp3ZVVf9o6ag3CjYmCv9s2o0ol10hrU101JonBp?= =?us-ascii?Q?UMKGCDmD/s4JkYAXj9Yzi+/gRtnrfSCgqeZZza4kWgoHcbEmUokPjGn0lg7H?= =?us-ascii?Q?WK5QhbmHkA86+8o1xWe83HhDnE/5g6fsBa3HIpDyDjd+8guN+M3Z/BxJuzRR?= =?us-ascii?Q?Fv2g5+iqUzkjPuSwMvXV/ZL5FNwWVnuoGPB/dGXeQyWFmixFktyT8PWHgmO9?= =?us-ascii?Q?gP+zmKYJ0Sov9SW4/AXs+UcxvSRsnMSldqUguVtBq16i6iRq8q3/C4lCg3hF?= =?us-ascii?Q?eeGqWk0Z2WsHViRhBsn2wK8kinHEhxXi+W98Ym5LjEqm9IRTRpunw3EtZ2Xc?= =?us-ascii?Q?Hq+H4MrtxjZ3aNvLSoOzFacGu6cHAL/GZF6ICIn+NHwwuteimF3KauddMUQ9?= =?us-ascii?Q?12ClZn1pHXdZM23mjmJhbjZlJyNRSOwi8U0IIMSAoB4+v4HNNNp9LhLVNJRc?= =?us-ascii?Q?XLkqTKR/7SAd7q2ZNzR+O3NmvaJDZiS+hLhERcn+1l5Lp+JMs/YrUSrwxpfQ?= =?us-ascii?Q?pBvXna4Rxvisrlr8Ea5U5s2wZKin1E+DQHjAlDuag5aNU1/Llg2ZT9KO/6tY?= =?us-ascii?Q?a+GHGIzN//vW2M3rSK8=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)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2025 02:22:23.3321 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 108e0cb7-760e-4063-ccda-08de11db0057 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: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8771 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 Reviewed-by: Lu Baolu --- 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 13:46:16 2025 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012022.outbound.protection.outlook.com [40.107.209.22]) (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 BFC312264C8; Thu, 23 Oct 2025 02:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.22 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761186153; cv=fail; b=TCPXFrTLQyHX6l3e2OwbgV+A+hhpPB02FgM8kzf7ghGWJPkIu/sEIMy8pltoT25Ya2Wgh1z88ECMUcen+AFJ2OlARCUif8HgSG7kH49gOmoEj9ye/ZFMAhiIV/vDl//m5hUVTysgtxSi9SYPXBn0SRDyQduccGpkkQuYQixKaEc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761186153; c=relaxed/simple; bh=82KdmfRolmqEd0ITBZRPpa0z+C0I6ZomrBJb4IpghQk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DnF78Sm1zq2jLOYvtFyz9CKsB20kCX+8qN2u0BSZuZdtAD0kHXp/sv7vUrJb2netTXr2GNaNjVBnL9UlRMWrVHQzZ6xLaYppReBOk9pHBn5wbKDcWPd93SGHo+cbYy61v60RgqSFrneMxeclLjuK7oT+DkJ+VVjhtCGJTvLAl2U= 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=r7r1Kp63; arc=fail smtp.client-ip=40.107.209.22 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="r7r1Kp63" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sgICiOgwtBPGpFLhTTH6ONgEZAUqMntKUCgiXviEzwlL5Tab1mhUgZRLPQyS/15T4s6+y0/MdicpVlQji8Nw42mIOpkFuySoePoSrEaXu/DqYGjXm2YppHN4fcKq/fiZIL+Q/SdGxlaLLjn81yr6jYSgAfhk1N2d+E7LGxRCQZnITc9dZBTTQxbJhMjcpcwlF+A0oialde6nKmhej3+l7ynARk1XMLnCS9fY3gqAreoOBhIb98OWkkwCjzVlcngYKilwXG81Zvsim305AUQRxd8Oo0OlejSoovReN5vZ6XHoWdE7j59daxnZzsyLEM3MdSzHhYBmnRFXhipQGY9y6w== 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=fUREhz3vT+Mpc9qFBGc9hJIZZYufCmzwZ4w/akBbQc0=; b=jhL5NC5Nj2P/Dtbehjn9SgMNiOttr22gu9eaD8GTsvSjhrryZhBndhn9OMf5IR+kbY8KiCArKTIWXm2cicmylnXMnGhCVRaHzOHHeK2c8AiALKRikvtpATE5e5usLXaMQJbCNS1U7HtiT/UfT1qyelmJdBd/VFgoivaL8ozoAx+ytVKvtjLlxMR2E4RqNiR9PGdUzaJDaRZ9H+yKTa+d9BNzod/yF6DVyJlMJXNMjCWWnTV7NDHEexarifN+Hm8r53Ylqp3wG0JtT3KPqx+LkVYHEhvW/+Cj/W5Xxs72ywex4UP09VpE1VAlVu2qHlrOE9qNFs+Rkkqqxqlh4OVHCg== 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=fUREhz3vT+Mpc9qFBGc9hJIZZYufCmzwZ4w/akBbQc0=; b=r7r1Kp63cpV9Wc1VZzDYwiJ/xuNbTZ7XwRaJIN9kZmALdxXLQ9RJNM3K9rtbRChXrllJ+Jkp5CtHHgsRfK3qERfEw+KAm0FDOKV0dl2p2B7CNZcGznkCsG/AnEaxlaahMUBXllDNabp35xJVI0blGcddD+W8IX7iqkyOQrksiX9gKg1Sk9cxpKPS47QP3xk5eMJDSaPueTGDOLboLwncgHSFkCFdiI7yymDO/YUgjdqK5t4dZ+mwtcLHthR/cEoMg1ry5ySBxIQNUSYTFNZtV7i419rZZrKORBDzuvTKVsdPwhAOMUPD4U34qgcWgmNOOdWX1ZP4ZoaZlzQUWeXAug== Received: from DM6PR05CA0046.namprd05.prod.outlook.com (2603:10b6:5:335::15) by IA1PR12MB8407.namprd12.prod.outlook.com (2603:10b6:208:3d9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9253.12; Thu, 23 Oct 2025 02:22:26 +0000 Received: from DS2PEPF0000343B.namprd02.prod.outlook.com (2603:10b6:5:335:cafe::f) by DM6PR05CA0046.outlook.office365.com (2603:10b6:5:335::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9253.12 via Frontend Transport; Thu, 23 Oct 2025 02:22:21 +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 DS2PEPF0000343B.mail.protection.outlook.com (10.167.18.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9253.7 via Frontend Transport; Thu, 23 Oct 2025 02:22:26 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Wed, 22 Oct 2025 19:22:14 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 22 Oct 2025 19:22:13 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Wed, 22 Oct 2025 19:22:11 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 2/6] iommu/arm-smmu-v3: Set release_domain to arm_smmu_blocked_domain Date: Wed, 22 Oct 2025 19:21:05 -0700 Message-ID: <3ba67dcf4ebfaecaceb05767627b827793227eb0.1761017765.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: DS2PEPF0000343B:EE_|IA1PR12MB8407:EE_ X-MS-Office365-Filtering-Correlation-Id: 5fa9c909-ac2a-4836-3ed4-08de11db020b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?6v9bhqTqzL8u3ql9GWwnI/BQT3czCut3IF7F98nHQxpiR8mxjdluiY6sg5lS?= =?us-ascii?Q?3s1YkyR8rtg9egruBMGcx48kK0NCB/XS1G15m6mHxs6YT9JquZuyt/HRbnyb?= =?us-ascii?Q?vxNfZX8IkREL729vDLMgscM+M/JZS0KOCf8XfHkI+boXzX6FdsUcsvzot76D?= =?us-ascii?Q?J4MrSf0Rq7hKsq56LdOqAR7Y2dgIawyuDZQjs88o8YZWzbbSMlSBJ9lQ0axN?= =?us-ascii?Q?nHgWu5+a2Bv7E1A1aPxp3jwkV/P+Af5MkOZqphZhHQq3fYegbqnxga3VXUmg?= =?us-ascii?Q?AsUtS0oyA9UebyIm3wOv2oXkO7O0rbKJQCHpszCfQr+8DK0X0lEGrwIVfDhS?= =?us-ascii?Q?pMznG1VCNbGIFPW4C7wzg8wDJTnBUZx+et1qgzFAx9sSB1sxguMlQ/VZ25wl?= =?us-ascii?Q?GmZW7e1mLjk7sss3cZmMOmb5KE2mgc9HOLONUUAiedANryovp9H5m/Aggy5S?= =?us-ascii?Q?8Ft87ZTEAdy5wYeaB4piip2yS/pwceAgMUMzMKLsQwbDO2ZUWR3jJHfO92D9?= =?us-ascii?Q?fSg9sN5Lu/7lPmdFUBt5bAfYe/0+kp2afsksAhLwYDfQ7DcCs10jkVVgZvON?= =?us-ascii?Q?FmcwxHYFNZKyKhz5lmHMbq7nQU6jWpPK48MQ5abGKCKcGN2Tb4et4udAYkSo?= =?us-ascii?Q?VU0gkHaBX80XG42iXG/8HlNoUqXqiBsjBJg7vKwce6mGfGcWvUaTgO4wzyuq?= =?us-ascii?Q?DHgFWZ81msH01iKWoKPhGguSzIyxUGZhEdKEawRBLciRY2daNwJ+2YBwiTR/?= =?us-ascii?Q?o2lYyWFjfXH/z4FCNoj68KZdmSTS6soT2+s5Pprx5X/sw1AZO69+W18eHBvF?= =?us-ascii?Q?zUMRgVnuXqv0BMZVQwWwVgdS8CXJl0wM/BPrNU9WsdKt56S7jCGehjgWLjsG?= =?us-ascii?Q?sm0s5fvCvlk6BjewMeHanqx/IR2AIpgSW3xS8roj7zzMNY6XW1P2jsyK4kg0?= =?us-ascii?Q?aClTIsWAh1bzqH1d4z7B7thZIT4t+AqOfRrbbHHhnBk9BrG+47otWSEhlCqm?= =?us-ascii?Q?V/JRqFvRkOZK9xtBkBOiO2QSe7sB+IHr86QCwkQjvBKk/ysFtkBVOenAU+Ch?= =?us-ascii?Q?rmOb/Rcp3PHE4/syxEkGq7rxp2IWoTUmMg1fd9LrPg7gFxr7HRUx6z+dza3U?= =?us-ascii?Q?M2qlLkT3wr/f1UFtoOttF99/vE+tSI3x/JKpjZmlAVM/2U8Q7IDXQM18nsqr?= =?us-ascii?Q?EaNXrIiIpc/CqgrJLG910dN58HnzddIvF1CdGLq0JRRwix6Eq1lAgeZX2Ade?= =?us-ascii?Q?AxFNWmDNGRx5TlEUzSdmysWA8PPx5kQt/wWYCTwSr02MYAqtkEK+IE1O4SVH?= =?us-ascii?Q?f0EZdxATBiT7aEqaYxK4S7I6LClcD/GDTsi0PUhbvZ5s51K9Ze8Vyd/3I8JV?= =?us-ascii?Q?zMIbZR9S3pxt02raMuKTcU3RfcueW80fknZJtaVtyaiJn8hIDnADOXfOEwHx?= =?us-ascii?Q?iOQQm1G3X0IGIy9TWvkWybaSecL09RFdamj8ZvSAyCBgzWGyfQLZSfwwVjDs?= =?us-ascii?Q?tjnG474oivcXQ7qSHuyWRstFQR8nqj+d2bUL7efLtKA7KnkbhhaSMvqflULn?= =?us-ascii?Q?z9ZE6tdkCfOSjBVlBBg=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)(82310400026)(36860700013)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2025 02:22:26.1917 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5fa9c909-ac2a-4836-3ed4-08de11db020b 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: DS2PEPF0000343B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8407 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. Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- 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 13:46:16 2025 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012007.outbound.protection.outlook.com [40.107.209.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 2F8C92147FB; Thu, 23 Oct 2025 02:22:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.7 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761186157; cv=fail; b=KozkqM3TC2Wq2sh9aSQnFSWSmGVD/Vbaflk40ArSTZXsWkQ3kXGjnOi2BjhnwsCd5JMd04Mk1j/g+j9+kHo89JpxjDa6C+pr23urQ3okTHHO/6YdHJDSgKpcMpjJgxHxbTlD/MsyYw8hi8SqdhoJkH6N1RARplJlG5zp+4VVkbk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761186157; c=relaxed/simple; bh=KLy3Jeht/hYGl44qkDbZQkcaLWaRcjvKHRnv6c+EqLc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Oq5hV5+WrNr8dARno1ogxpBjRZEBmhrZ2NKgrb60PHkwzansKBs7lA5PgDaL5c6Z+QJttVhBethfxeNKigfzJl7eHTLS38Bqg0jauYtfoCWIUShL69E3GhsJGM6WO8mO8BrOhXdSHrfbV0+jSIg3EfN7HJtJg01UIs0gQOhlX7E= 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=O/14tXr4; arc=fail smtp.client-ip=40.107.209.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="O/14tXr4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bok+2G+mLYWvYOVkto97LNQLvH2yG5wZx6mqru4/TfpEeng+lqgKKkpPDkZXqLe/D6fUGZirXEpFmBPCqyjdQvc+flDT7LrI/mau5nsDv/w0ARO9XKBz+meZpF7oOkinghXRsu5ERtiGLul0SAgrJ1QA/T09Kv5YR7hr9So5OQ+kKV9eD18+Gik/YEDDYVUCOyyqGA5qKIGf811GZYDw7Tge0Jpx6JnXac0Et4v02AFdvR4tw74XrU6sMtJSbZUm41CxknzZ9/xG7YrbCDa/pNfMC8kupqSG4Z+h3NfZIzL1Ln/tZML5qaVcoN1TkOfH8rHowsIJWXm8DMmvkBllrw== 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=Mp+TuEQzjklMeVupU6b/RAB6IdU8vDVmQywKaJbpDnI=; b=JFxcBdjv7WLji8/Iqs9L7xkKi7fSmNgepWNOZZTgo/eH4r20xOZEOIzijfzZlEhU1SrD2iVoWoKWKw7nEY3SaHClLyoTB/lXuu0PF3IS1d+ZZvrEyRv2FkmJWIQtmFQOJ/cTa5Scl0o6JAdb06jSI4IZLEZnGCk2ODs0PtfmVDCaD6lNiJE66uwKFJfaJ0bdrlyjfpsIGGZdNl34oIB86fNhAJd6foI9nHtN6oy9HJRl/0dJUsNbRcKZnmq5OUsubt236AeIyTTP/w+dkmj3VZxpWBjocnTYbAIfA/J+qH5mTwvZZRMIbjtkz6lqz5I3Z4Liwq8NemqON4eNj3nWfQ== 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=Mp+TuEQzjklMeVupU6b/RAB6IdU8vDVmQywKaJbpDnI=; b=O/14tXr4yJ1Dos1YrxME9799bd8lCBYOShn77NBuuIZyQGZ5M/USu99CtmryTlZwOM8TDERYvhmYTgcSguUEAHLRXadmaFw9A72oZK4vtXrBIpitdMFvN7aPESr4gEajIKPlY6MoWJDQ3YI1HEmHnHjicIIEdhSJ/4yIRCtv6OEEeUaETGRgCc07tzGL3cfhkSECTsA0zQnMGLNvRGAIZcXgliaK6EAjgAaAgiaFKHf+IhlPZJdCeaOTYmnOTV8gG/cf+T1XWPTL28TbBUnvO24UCv3QZZbLUzUd2p/MyxiGhJrt0boC9h3D5kUO/GEOAV8jkBFQfb4wFGzBLoVSdg== Received: from CH2PR12CA0002.namprd12.prod.outlook.com (2603:10b6:610:57::12) by MN0PR12MB5954.namprd12.prod.outlook.com (2603:10b6:208:37d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9253.12; Thu, 23 Oct 2025 02:22:30 +0000 Received: from DS2PEPF00003440.namprd02.prod.outlook.com (2603:10b6:610:57:cafe::20) by CH2PR12CA0002.outlook.office365.com (2603:10b6:610:57::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9253.12 via Frontend Transport; Thu, 23 Oct 2025 02:22:24 +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 DS2PEPF00003440.mail.protection.outlook.com (10.167.18.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9253.7 via Frontend Transport; Thu, 23 Oct 2025 02:22:30 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Wed, 22 Oct 2025 19:22:17 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 22 Oct 2025 19:22:16 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Wed, 22 Oct 2025 19:22:14 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 3/6] iommu/exynos-iommu: Set release_domain to exynos_identity_domain Date: Wed, 22 Oct 2025 19:21:06 -0700 Message-ID: <602e44ec402ad6b1dc6c3d3894d90c069093522f.1761017765.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: DS2PEPF00003440:EE_|MN0PR12MB5954:EE_ X-MS-Office365-Filtering-Correlation-Id: 662bd2e6-395f-4621-c4b8-08de11db0479 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?76Dpg7YXch7sc/iWS9jAm3YZnkyhQ2TKmle0o+vzRFqtFXk2QnFmTIvBfo5m?= =?us-ascii?Q?25kssGmniFhgJT0VXCZcMMWUnBBmsv9rBi4z/jnQ4BkcuFCaG57tArDlkKnx?= =?us-ascii?Q?zCtg60dIZ3fAJBu0Ti573+YtUhy57IcTd15d5+e8nWtQMKdbVGa5EvZ3sHvw?= =?us-ascii?Q?5DytxG2np53EBYZ29GHh3n9GaHUP8dPA+Tu+7xocmfHHdHIWl9VkYvu4x9SG?= =?us-ascii?Q?p+zKFmD/vdoNC3zT1v1/lAwilIbgnJUWonvXrJwMaKThbrqsDAso+pBifKin?= =?us-ascii?Q?Kb1gj+Rk28jhTh3BRuHzcgGZMAbdQIgrX2idLEcdxoufjUa1c/rjbTjUqDi/?= =?us-ascii?Q?0p0kZECv1LFVst0/12/H2YXEzYs677E7zmikxhuwsScr04o4pzNoj028Xkfm?= =?us-ascii?Q?MBjEVp26752k7oJWbu0La6SWBPGrbHrwioF7BBzUguWHd/4I3GofJezH4la6?= =?us-ascii?Q?WYjQ75Ig/GvRbEeP1eD8l25VprP9LmLJfPhOGo/gZ7JZPcRaP7NcFlwA7cZF?= =?us-ascii?Q?KFZR3kSsfefW8BvzTwvzvHCnMu/chAjDzLvmysd5t97u+QX62IL8qn+HeL86?= =?us-ascii?Q?dSU/lOiDa61+D74GpDALt0HXeI/l5l5eWoY2Me0PswwcFe8MFtI6G3lIPNT3?= =?us-ascii?Q?tqlKHmwNuVYI6XqjmSNcSzd25C79knquiOqi1PaVs49r3F/VzWDUxgr8GqgI?= =?us-ascii?Q?7xr6Sp0NAtrzHAbv/+1bx31oLcTHWKRUBmQmEOyi2QQyIVKKkxoa0VrQnOaI?= =?us-ascii?Q?1wRwJtaKSxhc85GlsHOThOAKmOmyIXZGeO856UXKEKAfacZZhI+GHQorgUY5?= =?us-ascii?Q?6yZhisr/JE03e4jE45HvmMKg7lGtVfgHgzLb6RqeicjVXjkkw1ovP+hmH8se?= =?us-ascii?Q?Q1Hm/SqQsaqL7eT6xgoY1jI+X/U38qS2XvY4Qx3Ylph9zO5Y9+jDkpjnzGkJ?= =?us-ascii?Q?mS2Dynz8wmg4ORJLc4MWfgZndA2eVtZI9SeUi9DeYNBWf9Wk3oiuIWZbqYBe?= =?us-ascii?Q?UTJLcdr1dtZywbv+WeXJ4Rr60YcV4MmRPWHAyDenbJ79UrZcmKg9X/iZfyBN?= =?us-ascii?Q?oywJSmCrJiyUDlKrb92DPmpdCzzelFIV6X8u2UTaiRm1IDFI3VxPuP/8pZ5t?= =?us-ascii?Q?+eyThfNMqtBpqYRThPnb+mhs+JmKd17lZMQhpQFhA6oidsNgy8oGdrATYJ9F?= =?us-ascii?Q?x+tS6/cNJ+pnzjQNnv42dbzF81eLSczcp5xrz19s3qihmBeOAeqMSB3nOJLT?= =?us-ascii?Q?CP87jWVkZXOOMx7PB+WHHvp/adenf9OySpCEEuYTExxspwg+ALfxnTzCVXZ/?= =?us-ascii?Q?AQm6GgnUwNaH207EdT8/n6e0OAdzGg8Givj372n5h06aYePMJwVXIZMAXElW?= =?us-ascii?Q?WUuMIaCcbknrwgV/NWyoo139zxFkELHJ1V7d8hzB/texUXlf64Y6ZsWu200d?= =?us-ascii?Q?HTvRNKSFDgi2euaQ3xwjZHhnO9uBd4sBuaALL825XurykDWnjDUnOpPjzZjR?= =?us-ascii?Q?mhgm184+EZXqg39LnZC2yohDu8R/l3osyHIRk8NcnCesf1niv37KSLM2eulM?= =?us-ascii?Q?RNebi0qFuF0crWADRkE=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)(376014)(1800799024)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2025 02:22:30.2704 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 662bd2e6-395f-4621-c4b8-08de11db0479 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: DS2PEPF00003440.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5954 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. Acked-by: Marek Szyprowski Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- 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 13:46:16 2025 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013006.outbound.protection.outlook.com [40.93.201.6]) (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 B36ED2153D2; Thu, 23 Oct 2025 02:22:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.201.6 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761186159; cv=fail; b=V43CKzVF4fjwu9QMOLSmNfRjNj0JPKmFPN83wwWpy7Ib0UlDWme4M4YBpUpGAR7e7+9StvNXkNUUwzBnt/9OGXlXg5VifRKfQgC95N4PdijbAm8dWSKK+8s4V98o5ub86V62dAZPt+qDrvRvPYb36fEsB0O4awvwYHgHXArex8o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761186159; c=relaxed/simple; bh=DgsnmNuL4H3jJDrlYeKMaB65ETt6W8rN3jWKvRg875o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MbIA8F4M7T+DVo1tNq6mDNsZzyheFty7bupEUVQ8ouAMsAF2Z4K2reuQGNiJ08vO3Xz3EZL2E0aFeIYYwRIa5W/I6J3y9aIN4kAoxsrS0UqSBmPvJR7RGqFnOLk8pi7EiQRrdWfObKWO0GlVbWgLNiH5mTCHPb6/ubeHiXL42Ys= 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=fqw8/VNV; arc=fail smtp.client-ip=40.93.201.6 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="fqw8/VNV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jiwdKpr8udhPHN6QzH3U9Q/QXWE7lp4UBu0XFSAjoPBL0NQfKzy8cuvxDwtfaahl2LXafDt2v4mnlcwwKhltysPkN6O/YUsmcDshwPoTcHat8xWg1HFdXILylUqC2UP6LAK3Qt7gYV1HxV0wQln082qJ40W3LSdMWmvO/j4fFw4DBJkWCsyvhyJkT4siOzapF1DSRYNPj/SNR+0MVhQkbK4Iog7I3MNCbdj9bluavAf+Z2v6g4p3TxW862ehv1rexzj3f0wYGpwxWB3xl4RBUoaePn2vieupA3YXKUcYBW2Mtb/RO3HR+SGqRZ9uzXpkO7xCrfi7q29UNPLypMQGdw== 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=a/l1DoHWiDWO8nuNN6vhG8TwlWRXqnkw4z104DXGzyk=; b=DEhdtg2JjaTqDgsBp+pgWe5/Xc4zstegf7vlnA7m96j5pk/xVhqrijUKPY0/Kl/hkVlLTLeqv1CDmC5hCP9EAg2boUa7P0ZgTeK9XJusCzV2zNSOdKkjhcjxwCNKIpD4TssonoYCofoQS3/xlQIWBeHGJFSgA6zfAb3Y143PQyd/U9aeqyThtYVVsqpxgb6hCr5QUqNbqFJYaely0yNac28ecuYOIUP7/+K9lOE970YnEH0MzF6ewk/Hb17Lr1B8X3qD9qV3rgeZZugDC647UvuO0ZhECfm7LUkbAmIHBPhTs7o0tWZ2W9ZYHhaiyl8oATeT2zILJTl/2cBR1sSdXQ== 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=a/l1DoHWiDWO8nuNN6vhG8TwlWRXqnkw4z104DXGzyk=; b=fqw8/VNVRMI0kzPVW4wCbDDr2oRtdfVC55lJVe6SgKrJvgL8yVmxtBzNwbgkVuXHjLl4Y+XWn3fcKfcBekwHpIEv7SWBEsE61q8Ef82+gfyNcgY9Es6sc5E0fsujmqs/65EHMN0LXZngE7f/yYahKf65526xDsDOoFWmTu6BFwW60SGXPY01sL1eHhLwE0oHOTo4q89uroYSGWmwXfnyxNjNu/96+TktMdd+tliwN65C6j+repTYr1In9HVDx8deFiAL1+yVq2Ii+ODKwbzkuXPDS+RaPtxtam9jpE17R6VHvUxl2ftnWdr+GHotrnK2Hy0wikn1j0JNoapB8AlJqA== Received: from CH0PR03CA0348.namprd03.prod.outlook.com (2603:10b6:610:11a::23) by CH3PR12MB7762.namprd12.prod.outlook.com (2603:10b6:610:151::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9253.13; Thu, 23 Oct 2025 02:22:33 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:610:11a:cafe::c2) by CH0PR03CA0348.outlook.office365.com (2603:10b6:610:11a::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9228.17 via Frontend Transport; Thu, 23 Oct 2025 02:22:33 +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 DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9253.7 via Frontend Transport; Thu, 23 Oct 2025 02:22:33 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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; Wed, 22 Oct 2025 19:22:20 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 22 Oct 2025 19:22:20 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Wed, 22 Oct 2025 19:22:17 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 4/6] iommu/amd: Set release_domain to blocked_domain Date: Wed, 22 Oct 2025 19:21:07 -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: DS2PEPF0000343A:EE_|CH3PR12MB7762:EE_ X-MS-Office365-Filtering-Correlation-Id: 3628c1bd-9727-488a-2ce9-08de11db0695 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|7416014|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?hWrcS/Ecdppaajtz1bqC0jZ6hoo0+TwnZoPJyI+v23Tt58NAHE3j8tAeCIJ7?= =?us-ascii?Q?ksON/GiM8MhCthNDmcitQh/h18DCpEjU92/Kg6tUkrqBnuo9VbQjbv9Qv9Mj?= =?us-ascii?Q?pssTBaHXMHNbRz3PJIvZ/mp0frRVCRcySNdc9/Qkj5pYvCHuRLkSFARQn3Qo?= =?us-ascii?Q?iXlyJhIVxnaopkC8IQifjDTjgPwGxuE45Sk0wNdi0YIhn9f5P77Ijvp00tay?= =?us-ascii?Q?hs+CEeb0Ef+fzMda6Vs+1aRr3RHKUqipZuwh/v2D4ff1DP2Kx4pLplyD9JjO?= =?us-ascii?Q?fqIrh+oXhJuIIXFkQrjKn8w4iPW2WN2PriWN0GvTRjcUCr7k88PAdTzg4u9y?= =?us-ascii?Q?Vz0cBLLhBWJ+c7gIe4FiM+r8VGHiFj75P0ZWi7kVkBfWxSt2j5eZ0IOWGYop?= =?us-ascii?Q?QlSvQx6nycwDM3oKTT105Rsc8x0UZA2unoZShN+07DodpUKmR9bzQIKkpxLH?= =?us-ascii?Q?feEmP5wbbkndLn7kEr2LCbSlBbSI00vIzWScxn/b88nGSQ2rLfgyF6UJehY4?= =?us-ascii?Q?7jbpi0lJnJ6SBJOggqr/jaWWEkG5xu0AJ0Wmd1roXYSYag/d6k8XDTDhAka/?= =?us-ascii?Q?Xx5udicJjUxCnPY+dwzANKzq74xB+R5VvMZpKNFCXEUvos5whJL1CnyHxG2T?= =?us-ascii?Q?Xhj1ppL7yy/5UdHmvyJF9n5KMV9JV+y5IlQnO3RnfjvrHQzRdFAbc1Jref3R?= =?us-ascii?Q?EusYjIRRW9/9K7y9O9SwTmksm+FR58WQUXRFxastE9oyr37mRPGmi5+DuPE2?= =?us-ascii?Q?GfxIvevjCW91htJyNmzcM6OJyhaX5ahMYwCiyFUqQBn7bULTGrUukD0mCe5G?= =?us-ascii?Q?6mrj1waA2v74l1tHNPCWHF3aOxQAhDXrELa+aWtOsezRho2kOhmXjIxFiBJl?= =?us-ascii?Q?mYAZ0htuVKkbxjZfgJgO884ch/WNbb7ImWKraxHXWLVHB9IfYsDhglXgpICQ?= =?us-ascii?Q?Q6NJ5eq82UZNhcQxPK6x1kLBJQX7gz6hvEXzeZyPxLZv30XpK1H8SPl4Z2jp?= =?us-ascii?Q?hojMkATRKo3ZQ85i1WvzgYOiR8m8HUoONDTle53oSzTlmmglKoCp3xNFHPvP?= =?us-ascii?Q?jk7FFylzNSZKpfNUYMOQ+TIkzpswtvGBJpzBf65ULL6uYW5lqgTifGwSlUyI?= =?us-ascii?Q?OK9b8ytlFpF10Inp1n3hkLH4hXE6gfiJX9rbmSXDEOkMxgKQEit7ZgSN1XTz?= =?us-ascii?Q?AkOt3ral9ijwuiKwgiEuwOWxJqzMbWtMSuWVRgiXJsXdf+R1c9tglrY5FfI1?= =?us-ascii?Q?sVnj8a+s4YPvaa3UwYkupqp/Plz0tn6J0TKvImWuGGTvbcPyp550nFOrBMI3?= =?us-ascii?Q?+ZtokBReRGWQfAqU+yejmG/1Ywlj+x0HbxMngl2hNj1x4OFQOs53fpchVUA4?= =?us-ascii?Q?IiYd+MIr9t0lyzNecdindMNVIVcwFuW13H5mUsRMzIkbC3TBryCw/xb0ENE5?= =?us-ascii?Q?leupxRMNC/RPn/hGy/adufauA2T8g3bbEiPebhQzJzo0UpnGHiuYIifUAN/N?= =?us-ascii?Q?dB6Xb2OPXu5InP1OaVrKGAxaL/a9sybPGtNuFX5RkBP6oHXpkdnGKHrM98tn?= =?us-ascii?Q?EqWbo1ZA3lYVG31ubYM=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)(82310400026)(7416014)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2025 02:22:33.8010 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3628c1bd-9727-488a-2ce9-08de11db0695 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: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7762 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 Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- 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 13:46:16 2025 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010046.outbound.protection.outlook.com [40.93.198.46]) (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 DA4892652B0; Thu, 23 Oct 2025 02:22:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.198.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761186166; cv=fail; b=Wp4p7eA5d4iuKVwlE7BpRY8Xui54RoO008hx1e++O+6xy+wMT1VcbLd94Kvq1ws/Ws+eLHAen6uGD4dGDKWkLXrn9lGwACVspF+2vkdScQyY41TQS3qUKmitVBXeR+KTTXfSBxZmOhfJs5+FLgqYH2vNHkKKMsWm6GxoVC/36hk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761186166; c=relaxed/simple; bh=H4EKPXRl2G7sjHhTZQquv1DarkCv+9nKO1k2IdWmw8Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gFMDQFI40S6WeohMKnHTNj50HYjGZzB9rySvsI1GyqoxEEDJ2HDNHEy7pbIHneYMaxAD/Zyynsq6VfABS1U1Pbq5iu61/72ol3z6b0x3jn6gPcy+ZlzxHHVuPasg4DvDaNezi45I4+Fl9J86MV7iYViVxAW8yKn3DCnZLrmj+e8= 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=GsSxtGEL; arc=fail smtp.client-ip=40.93.198.46 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="GsSxtGEL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PPUwM1B/75hYdL9SKAKnVCGJ+qbdcrcsdDYB7A1kuEY3gwjvocfdSSqsTAkcrh38/mh/S5leYqpW+ZmI7hFfxfhIFT0R7iK8GxkvkzNZg3yD5YWiCe12DzbajH4cZsAqWab2s3Cu9gLxkBlWznsD70k6e0qszTLD9I4TtEDp61v2Uj1gCAMBl77fTcue3+aQGcV8EILGOW/qEgL6c6dn85S4+5RIlRCP9zRaCOe4cug6yvZOsQxxPjF8VLQ2Hhdbnsoks28nO5DODJsp0o7ceBzEgfpRdlaIRKz66kx+ERPf7yRm7Tl94Qp0XrsLCFVYUljPS+WX2nu7YGa+5XUThw== 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=1IAqkPpzlI39c+XOL4gOyv+nhwrtGEJ11u7XEkesv48=; b=l6018rCuJmazoRIXE6i9Hya3gCgaL2Dp8jW/DOP7O2NsauH3Gb6awZw33/ON/k3+1SGXkf4xmMvm0Xrm0tuvKOHhQeIT133mD/IHnS2+5A91T1LloVQAW3iR+dL5yxHOqn9pXrndKQtnZpyy914X8+3dCsvXhg3VEzWDQnYZwwU/g4W2WeoTk0Q8r48bsxWP9enMoAhK7vz0KZhFc+sT0viYSwEQFvrBkj2a6ambgDhgIG72XqXn8EdmvfnYNSO4wwRRGpV9VKxpZH6opNmc8yyUXy8XIA7AJrUau1k/v2xP0c3DMssTbEBPFW2MdLT6uMRIgxIf8+qIayaU3aTg6A== 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=1IAqkPpzlI39c+XOL4gOyv+nhwrtGEJ11u7XEkesv48=; b=GsSxtGELcFf80EfENUuJD8bTNapyHjUMLjZ8aPVqUGUCp+lVK8uFpJjQGYPCT0bTSvOydhYYnYgFGpKUKfufNecTGp31yE6ZYN9YEmMuT9wXK3gMVGpgkXMA9wDdxles4HN01dYH2N7YDw8vGZwRbdYXWC4+6wq4/9LSCYzhpAIjeN+ti6oHZhh55NxJfYL9NOFOd/g8vTAbLBoqI9mYRZVUa029zvVk54DGC+cwNOmkdgvZlNkCuG6r2l9nZhew1DA+Q0b6X5KzSDlz+9V5ggueqm001ERKT6kSLlqRxrpYWxTB2pZCE88YoKmMWVQmQnqLjlnDqY9OmTfsgAhwSQ== Received: from PH7PR02CA0007.namprd02.prod.outlook.com (2603:10b6:510:33d::13) by MW3PR12MB4492.namprd12.prod.outlook.com (2603:10b6:303:57::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9253.13; Thu, 23 Oct 2025 02:22:40 +0000 Received: from SA2PEPF000015CA.namprd03.prod.outlook.com (2603:10b6:510:33d:cafe::f3) by PH7PR02CA0007.outlook.office365.com (2603:10b6:510:33d::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9253.12 via Frontend Transport; Thu, 23 Oct 2025 02:22: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 SA2PEPF000015CA.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9253.7 via Frontend Transport; Thu, 23 Oct 2025 02:22:39 +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; Wed, 22 Oct 2025 19:22:23 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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; Wed, 22 Oct 2025 19:22:22 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Wed, 22 Oct 2025 19:22:20 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 5/6] iommu: Do not revert set_domain for the last gdev Date: Wed, 22 Oct 2025 19:21:08 -0700 Message-ID: <276875013de662fe50f3fdd9e9a5bfbc0f12602e.1761017765.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: SA2PEPF000015CA:EE_|MW3PR12MB4492:EE_ X-MS-Office365-Filtering-Correlation-Id: b4fc1f26-80da-4e57-258f-08de11db0a22 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xbgODF92GR+5qY+LMVM+TDSaqi+VrtHJ2pGq3cQNHSBmn7ImMg7trfJf5emG?= =?us-ascii?Q?9E5SJZfAQvYzP5pwQ1t5tTbsYXNG7/AZw1Ae4h+fvJsRGUNx0EeJ2xEWQXSV?= =?us-ascii?Q?HagHTj69Is5nB+jIBjpM5QxoXXW2GXYgRO1B+/J7JQtFODIBV5ZSxFQbTr4d?= =?us-ascii?Q?Y4sQGxTffIc6VjSkrj4/IeKa03CeF6Xjb93+6qlmU4ywiI/ZqTRQ4pdsfaiA?= =?us-ascii?Q?DajZi8V2vcDcBqdHVatc1RI1MudAkjG5x656PAgOm8b4gWIbbizMbFgsRlzR?= =?us-ascii?Q?6+M/Taltf/ZB9AxTkyp7q/2/OAWnYOtm6Ba06QNzwhYYMHcPjWE9/HV/YjiC?= =?us-ascii?Q?wGnW+63XxmXeR/b0kaV9JgqJ8D0FwRhTxyAoBQS5bzA4ydLksoE6ozVJmHKn?= =?us-ascii?Q?Zv9wwlbjRwY6MQTWpY3+U8lVbyEP54dibHiaiMgOwarvlCfM7PYxhqm98EH7?= =?us-ascii?Q?XkEtcPx4D8CNb4oDoAIMIWUBIzNHCtqoF4LcXFuVF9aMLx1y3Xe8r3yIXWSJ?= =?us-ascii?Q?i4QDkkxUkGxxZ+uFTix9IPO/1TI5CcUSTQj0PSbuhzeFlL1ISrvTpuW7ANRS?= =?us-ascii?Q?36UmzvKN0Mbdh/Fdp/RxiXhwgXlmp0GYsXE04rfcOwwMXpuLrIsWLFl3EKF3?= =?us-ascii?Q?0AgjmRWSfaHgiMoOxBvVfoRDD07iGeiPglGWMpgoQUo8zM2a8oa56bXgmly/?= =?us-ascii?Q?8DJ7P02RVnu4HZtL8ei6O0ImnlWjy4VxNWmeDhX1T6Nt49Zw2NOo1SW4ccLg?= =?us-ascii?Q?Q3DUEaDuwc3xForscAq6dhry9TqJw6wrlQt4GUyTNDQiPBwRTESNVSW6gTuE?= =?us-ascii?Q?k56v6hPY8dT3XajeaMbII5YmAL2GrRTL3xormnhHxj5jX4WtK1IjP6LI6UD+?= =?us-ascii?Q?Q5mpcF9yENiA+OZq4IXcLMQTIh6k39escrY6/OBphLsKEEqeS7JGuENE9+QV?= =?us-ascii?Q?O9Q1xlmwlp2H4hIc70tBQ0MSehOb6794x5HycmCu1Cl3nsd6d5Gst3F8Fmfm?= =?us-ascii?Q?/c4l/m1S6odCNO5DbDtyCJwWbNhK8MJ8xMgmZVeEok7vvpRfVI5ToEP6H5uZ?= =?us-ascii?Q?r98OMht6lSRSv/PagOmijDHH93m9ov2LsbqFnSJApd87RK6j1ybS9+hVt4Zc?= =?us-ascii?Q?moBSZsi9NL5ljn9ZQbPPve3SLG5wt9Bg2AKA9nyHF+I3+pZrnf2mul/BnKvM?= =?us-ascii?Q?ncoIEkmOceHEZLJELV4u8wsiB40ZsksBZmjahle8T1SjXA41vRZUivwnEA5G?= =?us-ascii?Q?T3N52EJTvBswJoaM4cl7fKqdG96OA9BfZXdTXxlPxvaKsQAObXkeWhk9w2xh?= =?us-ascii?Q?rFwzSNW7phHgHtdRdofcSTEq0jYDFoWzmt6InYATBfWOZ7DAHOw7wT3IiFDT?= =?us-ascii?Q?whM71cOVExoZaLx6C8UiUxiCp0agsnKWCRPbnHYmEzyrx5S1Xpun8Yahuan6?= =?us-ascii?Q?qvA+/WIxRDwGWsoRhxm0rSZY5Z3CpxX0kxMvzHJ4s0WUDlV70M0MopkXSq4J?= =?us-ascii?Q?/JVCmwP+Xqg1wfd5gk4TdYMZ8y118QNBejPnHvW4mnEDwzunJl8XOXajFKgt?= =?us-ascii?Q?asH8Z+A+apf5AmlxP6g=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)(7416014)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2025 02:22:39.7542 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4fc1f26-80da-4e57-258f-08de11db0a22 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: SA2PEPF000015CA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4492 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. Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen Reviewed-by: Lu Baolu --- 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 13:46:16 2025 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012013.outbound.protection.outlook.com [52.101.43.13]) (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 E5EF71A2C0B; Thu, 23 Oct 2025 02:22:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.43.13 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761186180; cv=fail; b=AoYYiM3dKnasVyRL+Lgs+iA/9UEZVe6deedRs2g67HmyU7QZYrrAYRWOgYGnzGL6PXwu52oSY42r55sxyT2gmGKyon2/fBdsyXZRI7Wu21KAc50oIyf/kN9bjkXtNbItmMmKY124AbVSLhWqz75iccHKlfl8rtOYZnjztaCBZ9g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761186180; c=relaxed/simple; bh=LLK1y8OTqWlkTXJWyHbryvDgYNio5ECRGwNouJ+SYy8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=a0J0uBYTH5xEMIfplHdXCdb+/+0vNK39F4YgU7r5X+5sQYE657GrpK+Tsj4FZ7yMuPY3dWSfdX093aNpbKufOH/mAvDg74tZSkYixbSmUTman7waUVIBUsDovxxz++v5GhDe6sUy/vG6joZq9stWW2S5hfdh9ah+V2MpPH+87CM= 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=U6LPO+nq; arc=fail smtp.client-ip=52.101.43.13 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="U6LPO+nq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ez/Mjc8X58VSOJwk42d+ybbgxJhzgKsiz2o24p1geWhTioHsYeDgUoyxf6fdK3nebE66EuTAVO1oRbTXM+aCmQdWzIuNBM3CWAXw6tzzllZr0nPE36MsuATslJRny3GaQCvrbpf2jRZuFeXiFEk4HaCUFnmU1pUft+LbeAivDH0Dl7Z6oPaowMdSJn28Ugru4zSGoU1heUsjFAGBeiixuZszFcd+duzLnKZI4cdsdlhkZf1AXZB8TodSR/2xasuQJnlnKcol7caKA8I5RkALLeWJdAorMLMZOFlunRYPEf7nw5WwGLuZRiEYFfDJjczXkVeTwDPlYvEoSBkr9g+7LA== 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=2vm1yNDcrFygnkl/L7/7sBm66JmWilDRnRfI3FVcxBo=; b=L+nB1lKCnDix1MGHKDTLhjqZpd8VXahhSTW5V9yhWHKkqh7VCAwrdlmAWvfQ8MDoXzQdLN6JQ5spIb/EUw37whk143L2740mZYUqp1P0wmMM7VftQrW4oc5OQ0Uf/oSzhQPDL1ouRvytQMY7MJ+oikeplHQzAxznR/HObsmnotMBn6qSxlYPqFBz+WQSJ1hfqKh5bzQsDsmulPCR3SNMmWNXC2KdaaO8CbeuWAQNRNWO9Cjmlgmon2rqq8eN3GMUlMsOBELns8TmCgdUCK6S46hSTyVvQcKVD4zu5NL1Br3/f7NEOF/49qCZLARYrsYXBGSxrAIw3oEQKexX6C/5qQ== 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=2vm1yNDcrFygnkl/L7/7sBm66JmWilDRnRfI3FVcxBo=; b=U6LPO+nqOKXpaUNKmMwBYSpYLw382q+CKu9EKGxiq/g2aXSCpkDjgO0U0pOCUwKpgjvaV6NAJZlw8yTfMp7gJYQ5GJd72UpGqkpjzhNZeL2Ui1oHPBe7CuyKYSHCbtycs1OtyL2a7OsNYwDW96T4pioKX0SLcdl1ZwUMNE0HI99vyWrz4LmAWePVReDtcTLafEfg/FfYwBbcg0ewYQdlCbfjNWvryCdwTrh931NoLPcVtzc5f1He4+juZy9l17RMVcoO/6Ny3tv7u0cBKmNdwLuftLUgh4QyLBm7tdN4BtZMddM6CW21bnUQeBbBT6eLQG3HMv7wb1SnqvYP7ulpzg== Received: from PH7PR03CA0007.namprd03.prod.outlook.com (2603:10b6:510:339::9) by DS2PR12MB9616.namprd12.prod.outlook.com (2603:10b6:8:275::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9253.12; Thu, 23 Oct 2025 02:22:45 +0000 Received: from SA2PEPF000015C6.namprd03.prod.outlook.com (2603:10b6:510:339:cafe::a) by PH7PR03CA0007.outlook.office365.com (2603:10b6:510:339::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9228.17 via Frontend Transport; Thu, 23 Oct 2025 02:22:44 +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.9253.7 via Frontend Transport; Thu, 23 Oct 2025 02:22:44 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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; Wed, 22 Oct 2025 19:22:26 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 22 Oct 2025 19:22:26 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Wed, 22 Oct 2025 19:22:23 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 6/6] iommu: Pass in old domain to attach_dev callback functions Date: Wed, 22 Oct 2025 19:21:09 -0700 Message-ID: <7f760e795097e3052da82abf410c6ee963e4c62b.1761017765.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_|DS2PR12MB9616:EE_ X-MS-Office365-Filtering-Correlation-Id: 28cfbfa5-43f3-477b-6e45-08de11db0d0f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?5Zho1wbvYfRCGgXdrv6Pq+V4+MiRJxSq7HGKQZ98vZ3nJrRPc7m5cNAQDfQ1?= =?us-ascii?Q?NBPmD5ls4HSdZd7gANhvt9dWXXHn0yEPwNJab651bVoGH+vPZK5JLEUfu6Rp?= =?us-ascii?Q?Lnfo2hv3EQSLXqAuxUj9bd9ztSw89vIoRWKjV8gD7MZbXpAe7eHw+mIk9+t8?= =?us-ascii?Q?i4G5svZQFL+WDbumlK7675G2fG1uccz/PpJ29FwD/6uXSt2MIXVAuJWnhRNM?= =?us-ascii?Q?mW2Ae5CzEJvtmuzmq0rFas7nULFDtptA+hpcr5snev6IgpF6fkpdBj4krK4h?= =?us-ascii?Q?PsSRTPROIxNLFkKZgyxjjFdBHLKC2vxtxWeUkCC+m94p5XCc7SJ5wiiPLQpG?= =?us-ascii?Q?N7dUf09PVtzZGmHG/yBqK9quGQJFrPfr312ZeVSd+i7JAQCJ9+FvcTf8oY+I?= =?us-ascii?Q?lvZyh35+knBrCUKdeF1qltqyyTlvYM2DC3bo67mztfiXn+COZLN5jnjWGU2f?= =?us-ascii?Q?rWkwGg9VzOOpAl4xklL9iqontYCaoN0lSKCmDRFIFcgcEt/jxl06Lt1NuAHB?= =?us-ascii?Q?6NrnEwGOQXE5CP8UAWVV3u9P4ZEDoESDjEJcpyKW1g+VzLtbvIFpShB232fQ?= =?us-ascii?Q?VzJldGvt6yzDZp5SN3/pBhb3rqnLkXflmdkHfkmXPiZxfPH2bm5qiSlWg5/D?= =?us-ascii?Q?BHCo1yLfhWR995mpRaNdZkdLTitOl8suIRS4ors4E3+B3dW4BPWVUct0IFZa?= =?us-ascii?Q?0KwI/2fiBNdYkkQFBXb8wwn1s7xxO8WKC1jmkWExTt5vTTgoTpF9qqifEE+F?= =?us-ascii?Q?w+fWw6ozKekENU3JAOcikSy2BVFWkWWY6hXzKBSc5RjLo+c4lkQ7ErEiA9qX?= =?us-ascii?Q?kHKMuIn8fWvTh/9qhPKMdWodWfNZ7td0hObabzHUwXZLRA+qZTtNYvsqwtvr?= =?us-ascii?Q?NgDZk7No4t85bUawSozcMCADlj4tRGyirmwiQ7whfS6iDk6WDZQ1jAXqOt4B?= =?us-ascii?Q?ypDtU6Ogtb5bat4VxNo/G0SbhpaQ4ehQpOXWcnD0QVAbYCq3iztrQnWr8J9Z?= =?us-ascii?Q?EPYOA1zBEbEtAiGdpSysPPwKi7YcRy0JoWJcWee9Gyd35B74HHW/+2iBULNa?= =?us-ascii?Q?/mF15Sclsz0ZJxilRjPKHQFtmkm0DJkde1miNkvyYm5KAq5shSK4is9roTxl?= =?us-ascii?Q?KNKhnBnYEJdW9UtlpDTEECXHuDQR6wD5TAY47NDek94lbxEApVEhEd1ghV71?= =?us-ascii?Q?8pxfQq8ZCW4NFtiGVRILgwc08GqvX3U+lF746GpRidnabHomnxc+DPbdK7j/?= =?us-ascii?Q?UX5YZl1ZSRa8ip0I9I3KnWeaL1z7++gngDIXU/oSX3fK7F7cfdEZtlFEDT3t?= =?us-ascii?Q?/vdnlHZupS4NbidtRELXlhrB17K4IE1WcBJmVOtyM8mgpHxtzOz2VkMQu/4X?= =?us-ascii?Q?6Q6EO8lL3e0B8f31YeCZ+3j0wbhJBXk3yjn0mGJppatCgQZ558hODLZ4ii/9?= =?us-ascii?Q?Vo5AHelyFbKQ65S3inSQEGYq49v71sDq3oEvIq1y9ucTJk+PfEy8+Po0dYLV?= =?us-ascii?Q?bH4pexJjARBJqxiQVC0ieMYHNL1BlxevQgatbELqjmCfQAuIrg9wPgDBoWYI?= =?us-ascii?Q?muyo2060TkVwxsN/WQQ=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)(7416014)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2025 02:22:44.6665 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28cfbfa5-43f3-477b-6e45-08de11db0d0f 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: DS2PR12MB9616 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 Reviewed-by: Lu Baolu --- include/linux/iommu.h | 3 ++- arch/powerpc/kernel/iommu.c | 5 ++-- 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 | 13 ++++++---- drivers/iommu/sprd-iommu.c | 3 ++- drivers/iommu/sun50i-iommu.c | 8 +++--- drivers/iommu/tegra-smmu.c | 10 ++++---- drivers/iommu/virtio-iommu.c | 6 +++-- 26 files changed, 153 insertions(+), 100 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/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index 244eb4857e7f4..b7dcf07b24994 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch/powerpc/kernel/iommu.c @@ -1156,7 +1156,8 @@ EXPORT_SYMBOL_GPL(iommu_add_device); */ static int spapr_tce_platform_iommu_attach_dev(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 iommu_table_group *table_group; @@ -1189,7 +1190,7 @@ static struct iommu_domain spapr_tce_platform_domain = =3D { =20 static int spapr_tce_blocked_iommu_attach_dev(struct iommu_domain *platform_domain, - struct device *dev) + struct device *dev, struct iommu_domain *old) { struct iommu_group *grp =3D iommu_group_get(dev); struct iommu_table_group *table_group; 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..fe679850af286 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); @@ -709,7 +711,7 @@ static int s390_iommu_attach_device(struct iommu_domain= *domain, domain->geometry.aperture_end < zdev->start_dma)) return -EINVAL; =20 - blocking_domain_attach_device(&blocking_domain, dev); + blocking_domain_attach_device(&blocking_domain, dev, old); =20 /* If we fail now DMA remains blocked via blocking domain */ cc =3D s390_iommu_domain_reg_ioat(zdev, domain, &status); @@ -1131,13 +1133,14 @@ 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; int cc; =20 - blocking_domain_attach_device(&blocking_domain, dev); + blocking_domain_attach_device(&blocking_domain, dev, old); =20 /* If we fail now DMA remains blocked via blocking domain */ cc =3D s390_iommu_domain_reg_ioat(zdev, domain, &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