From nobody Tue Jun 16 11:17:51 2026 Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012066.outbound.protection.outlook.com [52.101.48.66]) (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 48F932D5937 for ; Sat, 18 Apr 2026 23:41:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.48.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776555713; cv=fail; b=GSlgcAHIvZyBJaRkNut13bjthPJ//wv4ImJk65kHwDKwBa70I9uzULE00U7VrQdJNhyTcw22RcZP9JWN4YYAdD16IFjTx/lFYxKPhJTkag2WzD+Rdn6XU6tmIOR1d0GC9LTKV/Xpuv+zD+IrxN4B8v1YZT/lETDu3guncdD05cs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776555713; c=relaxed/simple; bh=AwdB2ylh41+rfwi5Yz1wDWO5IXfZ/Jh86gXRPdcJlG4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s2Kk72s8VDJCkI0fwGWoNA0hN87IUm6GHMUdHjZd9Ik05KD+B1QHf9bOoAPnZJkSm9B+m4Rd4/ILDMf2D6QTtTUYnnQkr840Q3YEKeSXGnfiuKNlSUrmtR7TkE2DjMdz3ln4IwFhSqSV7NcEQZaQ7irrNnVeM/AF0zzQjklFq50= 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=AEy8YgaZ; arc=fail smtp.client-ip=52.101.48.66 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="AEy8YgaZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EaCjuszFKUK+r30XK/xX3RU7aEtxN9cOfkfcjcIx6FE9B7RlvdigWR4Eao0D5rR8Trlrg81BcTGZjVLwOVWrxt1G+VfDcbbZ8McUnZKgHpvC3qn/ieaNdY7dxkk5Hyk8t5X3Rt1xDKSy+qWVneNkLDNwe9xzOdzgwNa91sUTG1DvkO+vcr91MY6jx5mxsFw5nD1WbJz02sKfrqn4Kvo1K3YAozD3xa/CZoFtv3jCcgOiIPirlhNJNxebTtNwd3SjqrH9CoCR7kYxA6JVg6wDylvglSfkW3/dOi2J92lIpqCBTjO9EJICHtA2QsUEQOeO+x06Gj6xZyny9h36EEfddw== 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=y12mwetR3+q08LZG7TBwgev9sGFf0doVoIzcX572bTM=; b=j9l2rs9kL4q5NU1T/24crVoqo4g/SO/taLSgRhPoZDsbhdtIPeEOTwTgAmbdttwVgq9QX7BWsISAsqJluECLOeN01RoxFtMppOpg7bjFcy5TxfBCEgpARjQV19bXZEpu3MAOqL7Ax6kFjdV51tjfdnUsVyy8DWHW71v3HXl5xbe0irsx8Y6xlLqE6vxCJ7FWFkfIUW+BTJfmnS5kUMbolnuIM5HzlDsZ4ilUGf64Pb8yZzOqlKzg9i6SCR0hdUGog2o8Pl4IYXv6dpVR1r96TPPjuZFWpenaLXP5a9nrn9t4NtD+okCu0w51Up11pdMUEKXwNHC+MqdLbDMayD7mdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=y12mwetR3+q08LZG7TBwgev9sGFf0doVoIzcX572bTM=; b=AEy8YgaZzUUAfrlXZKIM9GQZeVmeBeHNAsX5JNBLYU1wVtzFDMhx2qqC8JY7O0653xWlcsdVLqrU1LVyIXfEmILLSM7ymVJ8POjEdZyL3NBfDTbM4D/QYoIR84Xnx14BbAvNT9cgYvN/zVXrL59kSoK0AT6oofvI4OXTYKUw0udli4/HkBenNB54QkUXUQJpuhLL7F7ZpHxH18BcP1NoBgHgN67bvg0QyYW44VqXnQX1woKT/ZdU/XYlmTAbOaUAJ1wjJTKWdquIdPnQrrm4d9LP5EvUreMsPUPNnFS94rSSGzeHCLMLYW+M6YkBNYGGfUsQeOfWnri4a8KPiOLLCw== Received: from CY8P220CA0048.NAMP220.PROD.OUTLOOK.COM (2603:10b6:930:47::25) by MN0PR12MB5882.namprd12.prod.outlook.com (2603:10b6:208:37a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9818.20; Sat, 18 Apr 2026 23:41:48 +0000 Received: from CY4PEPF0000E9D4.namprd03.prod.outlook.com (2603:10b6:930:47:cafe::d4) by CY8P220CA0048.outlook.office365.com (2603:10b6:930:47::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9769.55 via Frontend Transport; Sat, 18 Apr 2026 23:41:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CY4PEPF0000E9D4.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9791.48 via Frontend Transport; Sat, 18 Apr 2026 23:41:48 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sat, 18 Apr 2026 16:41:47 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sat, 18 Apr 2026 16:41:46 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sat, 18 Apr 2026 16:41:46 -0700 From: Nicolin Chen To: , , CC: , , , , , Subject: [PATCH rc v7 1/6] iommu: Fix kdocs of pci_dev_reset_iommu_done() Date: Sat, 18 Apr 2026 16:41:32 -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: CY4PEPF0000E9D4:EE_|MN0PR12MB5882:EE_ X-MS-Office365-Filtering-Correlation-Id: 82cedccf-7aa4-4408-50da-08de9da40f00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|1800799024|376014|18002099003|56012099003|22082099003; X-Microsoft-Antispam-Message-Info: IHFDtaxAaaUY7zUOBp8BU5ie2oIxxd7wyP8BY1bPdKe9Cq4clfHqznSNUEnh5UglKel3LiGFKH6lhDv4vjHG5y4cONNTd/s6ZRJv1RfCjQOOnmuXY35pgXJQWF1qWrDWu+DOzJ+HiDdb0ZZeBl20SJz3lEakjL9Kvikwtc6m467jJVPPriBxgtsXwd2zlZE4AoM72PD0dDsNIlE8pUAPllGl/xvAk6p8FVTem9OMq0y7wq3MxFCo/CmO5NmHeiWrNHcKxBvIaCYiu1V/IkZpVH6SrnDOOjMIPqScwn1BCAcjSHhFzTrfg30LcB5k/Vh9x+5S+RBJwX6bttYcIei1TLhuaj2DTm51tShDKekal4n5Zml8vvjpCpmsZu8AVET0YL8rJDg9GLi+l1Dw4sPPcyK4LuGbS4ldZog/ZuguR3e69vm/qKpLWzOsY6Oqn/QAf6GU/dMs2vd8tt9Bsrm0iCgiZ2eYp1Ny6Y86dt/KMzxALMfaggR+jaPCWUY4sgtxlVSbx10fG4ep8DhHZ/Hwp7Csdj/T5Ex8XWECFFypSQqDO6wecffNOLpotUhoH2tcPH0CAE80FOQ9RVoQ9OgNHHOawDQBHlaS+Ir10kHx9X6u3b4+FYNn6DFPv+ZMJ5MkkDrz3OZ9DDweNAJv0UXmqjzaq2j6LshGvl4CvHEJyFwfnuEvY86UtMADhMCMbf4byiPdOJo8tzta3EB0OSOulqlAZQw4+MekSdX6z5OvbtltUHxr45YTodJP0PJmncjbZRdNoOucJ3nPhBYMstqYxw== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230040)(36860700016)(82310400026)(1800799024)(376014)(18002099003)(56012099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sDQfngd/UPkwRwcWO3q57xOoxQ2vHH7xtQx8HPhj6rjEGTtapBKexHcQg+zIxbAvyimiEAdAUB4AFNKrvP1RunL2WS/2hjTfWWedvBkWYgsf+otR/76T2WU3XNpMd7sPcYDWalO9V+uATknGqfOEYEQFc3VF+kIjS2hJkn1VDI+YzvsSwTQ0y5Q+lYxhbsxBIK5y2y2q4Zl+zNbLPLJV26NJPgJeLayWbhlKMyu6vnnK5wQ1KSxqfBGlAZSulQuwqtHzn40evWgD3B5WSZO2mtPtjKuZlC9obPWIWnorc5Uw9gVvX7NFKuI0LPTPFQJWtNCnHZVJVfrWcV6mxqqF2P63d7ybrKc2Ety3Hqj1oFcaHcdb+ZUewIdqTXGkGFnJUD5nGMUWuagmuWUjml5Dgdx3JxgfMFi0jHZHnqRPoKVbM7reug75kew2FpcDuYVI X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2026 23:41:48.3716 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82cedccf-7aa4-4408-50da-08de9da40f00 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5882 Content-Type: text/plain; charset="utf-8" Remove the duplicated word. No functional change. Fixes: c279e83953d9 ("iommu: Introduce pci_dev_reset_iommu_prepare/done()") Reviewed-by: Shuai Xue Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Reviewed-by: Lu Baolu --- drivers/iommu/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 35db517809540..b950e7be1a3ed 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -3997,9 +3997,9 @@ EXPORT_SYMBOL_GPL(pci_dev_reset_iommu_prepare); * @pdev: PCI device that has finished a reset routine * * After a PCIe device finishes a reset routine, it wants to restore its I= OMMU - * IOMMU activity, including new translation as well as cache invalidation= , by - * re-attaching all RID/PASID of the device's back to the domains retained= in - * the core-level structure. + * activity, including new translation and cache invalidation, by re-attac= hing + * all RID/PASID of the device back to the domains retained in the core-le= vel + * structure. * * Caller must pair it with a successful pci_dev_reset_iommu_prepare(). * --=20 2.43.0 From nobody Tue Jun 16 11:17:51 2026 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010049.outbound.protection.outlook.com [40.93.198.49]) (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 9CD253A4509 for ; Sat, 18 Apr 2026 23:41:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.198.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776555721; cv=fail; b=bXkNpqkh+oQ1A3SF73GrOtWPrLcXtrfCIj/G/EnVYa61dqlMdY2Ci4Ln1sM5CLowAWSXrwCXi62dNrfxUlsjImv2BvmyZpEGxwD/0I+UecFEKT8mt0r/XCovmlBAEsFlGhdfX7OABsDi6VuSqjD0WuB2CFB/5yNg1Dm16RrX7fA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776555721; c=relaxed/simple; bh=QPx0nPf8nL/aoup1/h5nV9v6V+ufUNTXd/QTm7Dc8hE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hE5b2Coka2GRIX4ie8luflP2CA6fAL/k+YBtMaj0ZN8rQTyKGAqkdoj8vyo8wy6iZORHbwwY9Vj/CgOa5FAQGlq7R3xVcuKwi0Qp3871hgiuwhMBptlyuCCNDO7/Vduk1a2p0mzPS5498JgR/7pX9/ybqT+2uWVIdB9Cu9DD87Q= 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=GRipB9zO; arc=fail smtp.client-ip=40.93.198.49 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="GRipB9zO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=c/96Ql+HMENbcJI/bxhxVC1/XNhehLUS0I2mwp8k56oBr7Acp4STXGi2M1mGAHZonpXfw+M3Q4GMqCDOcTlv27QW8Yh2u38GlI5fa2KuqXK/rywsb4plYCCquo7oITiHY1BT4xUCB0Fh46u3t2t+0mKAWtDAAPWZBhL2bJP9I24Jibl+cK9ftTCLIribg0BRqijOrAyrEAEbyvKRG0paeTFnAIN3isqON7x/ovF+Cy1L40XOW9FzDLxrVxY+DtQYC3gub2WFeW+++zmVnaOjUMv5D2VX092cWO1VPZh4d07uoRFzf/s9VS1RrHUDPz7aVjnzD+zj/TTFTrFEQqE+Hw== 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=/dfTMu4K5T4pxipueaarI91WfscDbe+AdXqarepfdD4=; b=cnPIPZULttUCvVtkiILg2b+/+uakJnO+jdFMDCbw7k98tnYq5GQ71BCpDZZMhEsV6ZH8tqh6QombowXLUlQkLXEeIlzRuMB9Tr0vbiiepfKz9+c0jhwNk3EohBzGvsShe+mJG2Mv7fDRsrWOwXhPLhZEWM6OieHNhBAH5rYvUBlHrw1IPik/4kzRWnNrbju+k3vN/e6lEgBiUZ81l1jsEPh+hi10yuIUL3jFu2G4aG2bH5yQAnvfcuv/nzFhLnpl/NdHZvtKRRXZrRtwizb98yz5LtvcIS9quzLoO6z/Z6Zm4O1m1EsAWzBrrUFgkhDv+AU/Jeg0phnQeX7DYJ1C4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=/dfTMu4K5T4pxipueaarI91WfscDbe+AdXqarepfdD4=; b=GRipB9zO3tCBfnbG6geHCBdQjq0FuAFmeVk/MhnIJXuqr/0Twhxh/X/aWQ9kHjAgdtztDwuIwx2HuDdQthAVPDNINozJGtf/DR+4iLrMjGVFvMuFH/nxsrK2+qshYYLxjYsWJGFLQeU50f9YM7TxKl1qMIyefJNvzUCg59h2xJDfNcWGzCNraCVqF9XThCjTgn1rDv/fzKWzWGCJzhH3BV952hEUfXQLNyOfuhYpfG9peNFx81djmnjcpASe/5cTn5wV3+VWjuGEIAxzniwh+1mn4hoJojTdcpUtOkKGOpfd63QKwf+4f7jxWKCFp7+e1GgK6fhGAm+fHryOWT9zCg== Received: from BYAPR03CA0004.namprd03.prod.outlook.com (2603:10b6:a02:a8::17) by SA1PR12MB7365.namprd12.prod.outlook.com (2603:10b6:806:2ba::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9818.25; Sat, 18 Apr 2026 23:41:53 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:a02:a8:cafe::c5) by BYAPR03CA0004.outlook.office365.com (2603:10b6:a02:a8::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9769.55 via Frontend Transport; Sat, 18 Apr 2026 23:41:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9791.48 via Frontend Transport; Sat, 18 Apr 2026 23:41:53 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sat, 18 Apr 2026 16:41:48 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sat, 18 Apr 2026 16:41:47 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sat, 18 Apr 2026 16:41:47 -0700 From: Nicolin Chen To: , , CC: , , , , , Subject: [PATCH rc v7 2/6] iommu: Replace per-group resetting_domain with per-gdev blocked flag Date: Sat, 18 Apr 2026 16:41:33 -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: MWH0EPF000A6734:EE_|SA1PR12MB7365:EE_ X-MS-Office365-Filtering-Correlation-Id: b0700a68-95ba-4adf-e540-08de9da411f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|376014|1800799024|13003099007|56012099003|18096099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: CcMa7aQDVLoSGOR68codT4RN8qqD43pHBQ2FY6brChTM4Fs7xd/D83VIeT21rHFeEkoAFVD8baHZpiaL4g/nxItXbzKV/JLM3fabv0DRCxOvXvNNNug80rozc6HUvJNtfmk0azNDCoaL7EWWBcqqDADv1fLYymbartz7Xi/fyr9n2Xcs8zPM7EUIDj2BUL+iH5IMbyqKGMoI2I0H5XUxl08tK30Lnxzp8QSiFDiu9mNp8JlfXAKamyc0CSzQBF/7FmS4V4kdw2zAPJHiuv2OfjfZhFPmXqzl7HYo3vEoig6bpxJwbBDwsmsMjIWffvFL+YBBPU/G1sDvmVk2vMfh1fgXBny0mARrKajhnKFf+tE2uo7LPSBHzZtKQmkJ0VeEabAzU/fXLJqxqbxMVJjyXozCPwpHN4w4uUHVhjbtkvE1COYjMoo0txywaDS8zheevIfym9kxc9ISwBj3bpB72/FRZlm8rzz3A7i6yAV2ethZQa9sImewcA0DrgWv/36XmvRn/ymA5jjYVWF4MgbgQH6zej+G1BSplKB/EGKY7qfuBXYg1KIXE9PVcRMoz/akg/8YXP88UhhlSVZefogiwmvlrk/I9Qg1dkgsemUjOwNpMELKfqNvOWcjW4m2gnKfiAvHN8Ui+5abKynJr7UOeyE48s8YO7O46yJkxLF+TPkzw/FxbaCq4H/p/nQn+iymrhX8OhcUX8ESnD28JFQd1tMXbt9WBUWPv+0glYDrtVGHsQzrReIBQPYW4/8yg2UElIQj0wiNnBjuDnLnd4J/bQ== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(36860700016)(376014)(1800799024)(13003099007)(56012099003)(18096099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: arP9wwnn5dN9lOvkTu5E8cw6/k4Q+WJEMOAqlyKNsp8EE8rarMje3KBP2HHnAU7OLQyI1bJuev2k9I1yqdw+LS6ZP4HvDOHlEVDh55ewmqY9MfPzDCb3IselPotxdhYvvUgDKqJy1pnMzCP7P2YFpF5EDSIcWUzBkwxFctdEt4m+qTQAe364unbDs1X001YTbJsgMhq4DLeDLTa00AfltsbJ9oNx1t/kjsaQMGQ82XkQSQTZvpa6x4okMTMPPg48Vv+5qfDdPIBzSLg37e+xWIyNxVlU3pMAez56UwISKRtF/Ud0/XlZOMDsuGd0axCgV7LSnufnfs7uZ0sA+UMT94EwEF2tGYOxrCJAHvIYpQ2MXtdkGQ8o1F5E5LbX+ea1rSeQ2Lw47QfiIUu7ggiR+cdKsYPbBAUGNYeLzPFlI1il5LmBQoqAjXKkvBlH4zPR X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2026 23:41:53.3455 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0700a68-95ba-4adf-e540-08de9da411f2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7365 Content-Type: text/plain; charset="utf-8" The core tracks device resetting states with a per-group resetting_domain, while a reset is actually per group-device. Such a mismatch might lead to confusion and even difficulty to untangle per-gdev handling requirement. Shuai found that cxl_reset_bus_function() calls pci_reset_bus_function() internally while both are calling pci_dev_reset_iommu_prepare/done(). And the solution requires the core to track at the group_device level as well. Introduce a 'blocked' flag to struct group_device, to allow a multi-device group to isolate concurrent device resets independently. As the reset routine is per gdev, it cannot clear group->resetting_domain without iterating over the device list to ensure no other device is being reset. Simplify it by replacing the resetting_domain with a 'recovery_cnt' in the struct iommu_group. No functional change. But this is essential to apply following bug fixes. Fixes: c279e83953d9 ("iommu: Introduce pci_dev_reset_iommu_prepare/done()") Cc: stable@vger.kernel.org Reported-by: Shuai Xue Closes: https://lore.kernel.org/all/absKsk7qQOwzhpzv@Asurada-Nvidia/ Reviewed-by: Shuai Xue Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Reviewed-by: Lu Baolu --- drivers/iommu/iommu.c | 104 ++++++++++++++++++++++++++++++++---------- 1 file changed, 79 insertions(+), 25 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index b950e7be1a3ed..d5d9102b9d750 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -61,14 +61,14 @@ struct iommu_group { int id; struct iommu_domain *default_domain; struct iommu_domain *blocking_domain; - /* - * During a group device reset, @resetting_domain points to the physical - * domain, while @domain points to the attached domain before the reset. - */ - struct iommu_domain *resetting_domain; struct iommu_domain *domain; struct list_head entry; unsigned int owner_cnt; + /* + * Number of devices in the group undergoing or awaiting recovery. + * If non-zero, concurrent domain attachments are rejected. + */ + unsigned int recovery_cnt; void *owner; }; =20 @@ -76,12 +76,32 @@ struct group_device { struct list_head list; struct device *dev; char *name; + /* + * Device is blocked for a pending recovery while its group->domain is + * retained. This can happen when: + * - Device is undergoing a reset + */ + bool blocked; }; =20 /* Iterate over each struct group_device in a struct iommu_group */ #define for_each_group_device(group, pos) \ list_for_each_entry(pos, &(group)->devices, list) =20 +static struct group_device *__dev_to_gdev(struct device *dev) +{ + struct iommu_group *group =3D dev->iommu_group; + struct group_device *gdev; + + lockdep_assert_held(&group->mutex); + + for_each_group_device(group, gdev) { + if (gdev->dev =3D=3D dev) + return gdev; + } + return NULL; +} + struct iommu_group_attribute { struct attribute attr; ssize_t (*show)(struct iommu_group *group, char *buf); @@ -2191,6 +2211,8 @@ EXPORT_SYMBOL_GPL(iommu_attach_device); =20 int iommu_deferred_attach(struct device *dev, struct iommu_domain *domain) { + struct group_device *gdev; + /* * This is called on the dma mapping fast path so avoid locking. This is * racy, but we have an expectation that the driver will setup its DMAs @@ -2201,14 +2223,18 @@ int iommu_deferred_attach(struct device *dev, struc= t iommu_domain *domain) =20 guard(mutex)(&dev->iommu_group->mutex); =20 + gdev =3D __dev_to_gdev(dev); + if (WARN_ON(!gdev)) + return -ENODEV; + /* - * This is a concurrent attach during a device reset. Reject it until + * This is a concurrent attach during device recovery. Reject it until * pci_dev_reset_iommu_done() attaches the device to group->domain. * * Note that this might fail the iommu_dma_map(). But there's nothing * more we can do here. */ - if (dev->iommu_group->resetting_domain) + if (gdev->blocked) return -EBUSY; return __iommu_attach_device(domain, dev, NULL); } @@ -2265,19 +2291,24 @@ EXPORT_SYMBOL_GPL(iommu_get_domain_for_dev); struct iommu_domain *iommu_driver_get_domain_for_dev(struct device *dev) { struct iommu_group *group =3D dev->iommu_group; + struct group_device *gdev; =20 lockdep_assert_held(&group->mutex); =20 + gdev =3D __dev_to_gdev(dev); + if (WARN_ON(!gdev)) + return NULL; + /* * Driver handles the low-level __iommu_attach_device(), including the * one invoked by pci_dev_reset_iommu_done() re-attaching the device to * the cached group->domain. In this case, the driver must get the old - * domain from group->resetting_domain rather than group->domain. This + * domain from group->blocking_domain rather than group->domain. This * prevents it from re-attaching the device from group->domain (old) to * group->domain (new). */ - if (group->resetting_domain) - return group->resetting_domain; + if (gdev->blocked) + return group->blocking_domain; =20 return group->domain; } @@ -2436,10 +2467,10 @@ static int __iommu_group_set_domain_internal(struct= iommu_group *group, return -EINVAL; =20 /* - * This is a concurrent attach during a device reset. Reject it until + * This is a concurrent attach during device recovery. Reject it until * pci_dev_reset_iommu_done() attaches the device to group->domain. */ - if (group->resetting_domain) + if (group->recovery_cnt) return -EBUSY; =20 /* @@ -3567,10 +3598,10 @@ int iommu_attach_device_pasid(struct iommu_domain *= domain, mutex_lock(&group->mutex); =20 /* - * This is a concurrent attach during a device reset. Reject it until + * This is a concurrent attach during device recovery. Reject it until * pci_dev_reset_iommu_done() attaches the device to group->domain. */ - if (group->resetting_domain) { + if (group->recovery_cnt) { ret =3D -EBUSY; goto out_unlock; } @@ -3660,10 +3691,10 @@ int iommu_replace_device_pasid(struct iommu_domain = *domain, mutex_lock(&group->mutex); =20 /* - * This is a concurrent attach during a device reset. Reject it until + * This is a concurrent attach during device recovery. Reject it until * pci_dev_reset_iommu_done() attaches the device to group->domain. */ - if (group->resetting_domain) { + if (group->recovery_cnt) { ret =3D -EBUSY; goto out_unlock; } @@ -3934,12 +3965,12 @@ EXPORT_SYMBOL_NS_GPL(iommu_replace_group_handle, "I= OMMUFD_INTERNAL"); * routine wants to block any IOMMU activity: translation and ATS invalida= tion. * * This function attaches the device's RID/PASID(s) the group->blocking_do= main, - * setting the group->resetting_domain. This allows the IOMMU driver pausi= ng any + * incrementing the group->recovery_cnt, to allow the IOMMU driver pausing= any * IOMMU activity while leaving the group->domain pointer intact. Later wh= en the * reset is finished, pci_dev_reset_iommu_done() can restore everything. * * Caller must use pci_dev_reset_iommu_prepare() with pci_dev_reset_iommu_= done() - * before/after the core-level reset routine, to unset the resetting_domai= n. + * before/after the core-level reset routine, to decrement the recovery_cn= t. * * Return: 0 on success or negative error code if the preparation failed. * @@ -3952,6 +3983,7 @@ EXPORT_SYMBOL_NS_GPL(iommu_replace_group_handle, "IOM= MUFD_INTERNAL"); int pci_dev_reset_iommu_prepare(struct pci_dev *pdev) { struct iommu_group *group =3D pdev->dev.iommu_group; + struct group_device *gdev; unsigned long pasid; void *entry; int ret; @@ -3961,8 +3993,12 @@ int pci_dev_reset_iommu_prepare(struct pci_dev *pdev) =20 guard(mutex)(&group->mutex); =20 - /* Re-entry is not allowed */ - if (WARN_ON(group->resetting_domain)) + gdev =3D __dev_to_gdev(&pdev->dev); + if (WARN_ON(!gdev)) + return -ENODEV; + + /* Re-entry is not allowed (will be fixed in a following patch) */ + if (WARN_ON(gdev->blocked)) return -EBUSY; =20 ret =3D __iommu_group_alloc_blocking_domain(group); @@ -3977,6 +4013,13 @@ int pci_dev_reset_iommu_prepare(struct pci_dev *pdev) return ret; } =20 + /* + * Update gdev->blocked upon the domain change, as it is used to return + * the correct domain in iommu_driver_get_domain_for_dev() that might be + * called in a set_dev_pasid callback function. + */ + gdev->blocked =3D true; + /* * Stage PASID domains at blocking_domain while retaining pasid_array. * @@ -3987,7 +4030,7 @@ int pci_dev_reset_iommu_prepare(struct pci_dev *pdev) iommu_remove_dev_pasid(&pdev->dev, pasid, pasid_array_entry_to_domain(entry)); =20 - group->resetting_domain =3D group->blocking_domain; + group->recovery_cnt++; return ret; } EXPORT_SYMBOL_GPL(pci_dev_reset_iommu_prepare); @@ -4009,6 +4052,7 @@ EXPORT_SYMBOL_GPL(pci_dev_reset_iommu_prepare); void pci_dev_reset_iommu_done(struct pci_dev *pdev) { struct iommu_group *group =3D pdev->dev.iommu_group; + struct group_device *gdev; unsigned long pasid; void *entry; =20 @@ -4017,11 +4061,13 @@ void pci_dev_reset_iommu_done(struct pci_dev *pdev) =20 guard(mutex)(&group->mutex); =20 - /* pci_dev_reset_iommu_prepare() was bypassed for the device */ - if (!group->resetting_domain) + gdev =3D __dev_to_gdev(&pdev->dev); + if (WARN_ON(!gdev)) + return; + + if (!gdev->blocked) return; =20 - /* pci_dev_reset_iommu_prepare() was not successfully called */ if (WARN_ON(!group->blocking_domain)) return; =20 @@ -4031,6 +4077,13 @@ void pci_dev_reset_iommu_done(struct pci_dev *pdev) group->blocking_domain)); } =20 + /* + * Update gdev->blocked upon the domain change, as it is used to return + * the correct domain in iommu_driver_get_domain_for_dev() that might be + * called in a set_dev_pasid callback function. + */ + gdev->blocked =3D false; + /* * Re-attach PASID domains back to the domains retained in pasid_array. * @@ -4042,7 +4095,8 @@ void pci_dev_reset_iommu_done(struct pci_dev *pdev) pasid_array_entry_to_domain(entry), group, pasid, group->blocking_domain)); =20 - group->resetting_domain =3D NULL; + if (!WARN_ON(group->recovery_cnt =3D=3D 0)) + group->recovery_cnt--; } EXPORT_SYMBOL_GPL(pci_dev_reset_iommu_done); =20 --=20 2.43.0 From nobody Tue Jun 16 11:17:51 2026 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013069.outbound.protection.outlook.com [40.107.201.69]) (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 AF35E3A1685 for ; Sat, 18 Apr 2026 23:42:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776555723; cv=fail; b=eAhMw7f5t0dpGm5fHjUd8Vwev77GQyRtG1yFNhd5iGnSuqStyyp7SotXZPMDtSKU+p/5mBuylYrvsITJAigWLah1RpP84J2OZb1HzWE3sDmyroZbeKbTW+EGXO6+8zWYfj3LKZ+zVccqMx1RZGwi/XrBWQguDyyCduIeYC+CYIc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776555723; c=relaxed/simple; bh=s/sEuPI5iul2pB0P0Fv4cqUoU/31AMDnsIJlHETHE7Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e+WNcln4kY/7GNqXFIHGhHqt8TBneBL7hCeXdYtVgZY0BydswLXSpNYFH5TCcQk4RF4zskJPMbEBJ7XajvISFuUJwd0B/ZzEwIFvZ5DQw6+vCrAFSAZUw6jAdfjHwoeOlKrlGN9mDpw8fN4htIgFzwb2gUJ9e7Qy05W/VgiNCwk= 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=qEGRc6i2; arc=fail smtp.client-ip=40.107.201.69 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="qEGRc6i2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ShrfuL6yD0zt9UYrFYvCeuDccfBv3boq/eCaEcmrwUDYUvlFWMYmIGyixImmzv4hupiLo1gvmo8yCtM1os7RBI2EShDFJX+sQUl/33XPQZsIoiYG71GJapD6LmYCCXKQ9722MFbrBO7EilagbkAk4HxBRt5Zbh+C4ZmIXs//B5xOedkWP/p3kC9LM18iDaVXgjHLf7+SPm8Cw7LOsFL57fuNsv0URbvm7kpWrPmh2EwIQLFgAaO+a+BgXPuNQMEf5Neh3uJoeoLGhklBW2oc9Jrf1/mZsDhYBADkuLY9ObQwfRu8WPiwsDg3JgZBvK7Y3reqlfFYA2BW6XwAlHAP6w== 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=5bxPqLlMuj1Si0oG0TJZeNAeQOJMNRDxdokGfgl5mps=; b=ujMcJezH/WuNGXTlLh3WKjPBG4ttSD2vQoY4kzOTitPfsWUs84UUeNRO7fN8KPWQlYEHkj0FOvqk3Qtr2aMpjS3o0FoCeJiCYJx6vcSXFwDjoQ4y3hlJuQQ0xGOW7olZsg4n8s/pr5fzHSFmg1Jn+yqvvkPAt/2IL+Y0WdqZpOqtZJcQ4zWzp3z2kgQUp01apNy2B5QiUfK9W8j81Xt40owFssg+rNeoVwl3D6k5kWlX5HGBxr0bzYjEdSrPazkhTtNjPOjvHtT7ChfxNXhfE3Ae9Cjcnuk1DJtvMZnYN3dPGIOUmp4akLPPvYSkUjBDFq1pislG/zFtnqzLDofamg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=5bxPqLlMuj1Si0oG0TJZeNAeQOJMNRDxdokGfgl5mps=; b=qEGRc6i22DwG6mrzWhMAV3NalgnAcTn9wbrMvmNcIcWi/rXgsUCAT26v3t8Sj/TLmTxuuaNTVPPgApH0lVwAWuIRN1mfjB7fJ3asD+gaY2AvoKAuEelqGhVn3dJo/GaayyhGpYNATCGqYvvNC5xgNmKUffV9pjEh/r9tbtAic+o03lwFj6Ie3TzyhEEfCXu1cIoHuatb1GpWEIlvTGs8o09ssXojjCZi13AnX6xnucPSZdjfzGojIn9++/3FJSpQGegJ4ihOTcKH9lRpPavcXbILw2T10nNz7kWm9EKvwR/UMTSSqY8oOC0Qll7GmZu37fqU7cNYncgRQaPbEVDhPA== Received: from BYAPR03CA0012.namprd03.prod.outlook.com (2603:10b6:a02:a8::25) by LV3PR12MB9410.namprd12.prod.outlook.com (2603:10b6:408:212::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.12; Sat, 18 Apr 2026 23:41:56 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:a02:a8:cafe::56) by BYAPR03CA0012.outlook.office365.com (2603:10b6:a02:a8::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9769.55 via Frontend Transport; Sat, 18 Apr 2026 23:41:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9791.48 via Frontend Transport; Sat, 18 Apr 2026 23:41:56 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sat, 18 Apr 2026 16:41:49 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sat, 18 Apr 2026 16:41:48 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sat, 18 Apr 2026 16:41:48 -0700 From: Nicolin Chen To: , , CC: , , , , , Subject: [PATCH rc v7 3/6] iommu: Fix pasid attach in pci_dev_reset_iommu_prepare/done() Date: Sat, 18 Apr 2026 16:41:34 -0700 Message-ID: <3f1b73fa5162e55ffbe497508aeea1fc7cee6e2c.1776551790.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: MWH0EPF000A6734:EE_|LV3PR12MB9410:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c54046f-1860-4bc7-1124-08de9da413a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|376014|1800799024|13003099007|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: rCtzkPR+XLFqwbw688KPU8WH/3ut2nGh2bAb/ZWFFMQMKaKC++7epCPwaf5s7ErbvkNNhpYHjGqRqmafqqbkP8iqpjYCEYrS40krct0vFD/QzmyEdQEsEa70d22dcGHCZupRBz0Q0ijnc5GaqNQ6LtjLPS/iNB6mIsHZ/t6e4UPOEbOvhi5ls/BecklxBBOMZGvTz62ddFASju8oxsiFKKb8QnVD71XRzh/9NENXX835guMG0hD7UAbueMV8B7h8R78RlI2TNyxlRtfSJgcBnuR7WE+hTa/aQ+9NSIdFK/hOFw41AbDhjco2efIq2vLO9f0Eq5dgtceV1bb8Yjg4ZLtxL/FpZN/G5L38gsAXsw4m8RTe2Q6WV04i6fR4fs2Fkuy4gEyR2Vj5cb5Ogh6ZRhGTWTUXrdxn30004NjQP7sBR0TrZNJvYPSl561i8Nq/1g1w/b3jC2cb6fZGUtlSpoOLXtTAeMG2EvP/J4L0lajNKpD4nIWStqI6o9bTkQrigncJXiS/Xzvwhm2XUf+OoGOdVYLGL8jvvf8ue4PU7anjbBqNDO4npEvrwx2wbyYvi/w6GtbJD0fwgQ657lsPInBQwS63STpG3/P0KRnO1NnGClqWJ+qluKPrXXrStskR5yTKTXK7/Dsp/0DjTL4xE573HE6qKwfQC2zS0PCITqHUPwKUBjwy46O5Ypac5UJYGXyUbFENoaKeC76Me92G/CLDOuhkovgYOs845nAdyT39ATjGwGX3su18tBoJ1CFWFwAxhDROPZ/tK7lXzfsVTA== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230040)(36860700016)(82310400026)(376014)(1800799024)(13003099007)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: faHvzf4w44D8c9WEeQvZCzwe7RV3Ohat7EVwz5MKdopBf9YcZ7XMt7Ta+S+RCyrIIt4tCf4jDAh8ZVqT7ywPtCgyOiKPIZq6efHxTrkgvn19d2FVw8O3NgzXTZInzp6xk8mm+K0ZE4OwB6qn26r5TW2KH3fzd+X+id68077AoL+kSyPNo203fuAoQdIohm+0+nogvFcaAoq5gTFE2w5hPuOb015LdgktR/RdXWiDqz+Xp6Yh9sn0t189c2x1En2BTm2qNZ0V28J6BT1tjZyYxLC5MQ1zw56UaQgy0QM/9+Pa+JwgxbYnIURbtSQZINpNwaqMbcZxIV1ejKjuf1z6PXvpgA59HjeE6h0IIThAAPfLBvZa2BGe2oSUexVckCbV58Bl1O/LDBrGKfzjsDqgtfFyF7J5hX+lLt1tb69AVEn4ZrCxHkViZTvl+j19PviJ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2026 23:41:56.1924 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c54046f-1860-4bc7-1124-08de9da413a5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9410 Content-Type: text/plain; charset="utf-8" Now the helpers handle per-gdev resets. So use the per-device API properly to attach/detach PASIDs. Also add max_pasids check as other callers. Fixes: c279e83953d9 ("iommu: Introduce pci_dev_reset_iommu_prepare/done()") Cc: stable@vger.kernel.org Reported-by: Shuai Xue Closes: https://lore.kernel.org/all/ad858513-09fc-455e-bbc5-fe38a225cc78@li= nux.alibaba.com/ Reviewed-by: Shuai Xue Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommu.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index d5d9102b9d750..e9ffa562b614f 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -4026,9 +4026,14 @@ int pci_dev_reset_iommu_prepare(struct pci_dev *pdev) * The pasid_array is mostly fenced by group->mutex, except one reader * in iommu_attach_handle_get(), so it's safe to read without xa_lock. */ - xa_for_each_start(&group->pasid_array, pasid, entry, 1) - iommu_remove_dev_pasid(&pdev->dev, pasid, - pasid_array_entry_to_domain(entry)); + if (pdev->dev.iommu->max_pasids > 0) { + xa_for_each_start(&group->pasid_array, pasid, entry, 1) { + struct iommu_domain *pasid_dom =3D + pasid_array_entry_to_domain(entry); + + iommu_remove_dev_pasid(&pdev->dev, pasid, pasid_dom); + } + } =20 group->recovery_cnt++; return ret; @@ -4090,10 +4095,16 @@ void pci_dev_reset_iommu_done(struct pci_dev *pdev) * The pasid_array is mostly fenced by group->mutex, except one reader * in iommu_attach_handle_get(), so it's safe to read without xa_lock. */ - xa_for_each_start(&group->pasid_array, pasid, entry, 1) - WARN_ON(__iommu_set_group_pasid( - pasid_array_entry_to_domain(entry), group, pasid, - group->blocking_domain)); + if (pdev->dev.iommu->max_pasids > 0) { + xa_for_each_start(&group->pasid_array, pasid, entry, 1) { + struct iommu_domain *pasid_dom =3D + pasid_array_entry_to_domain(entry); + + WARN_ON(pasid_dom->ops->set_dev_pasid( + pasid_dom, &pdev->dev, pasid, + group->blocking_domain)); + } + } =20 if (!WARN_ON(group->recovery_cnt =3D=3D 0)) group->recovery_cnt--; --=20 2.43.0 From nobody Tue Jun 16 11:17:51 2026 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010027.outbound.protection.outlook.com [52.101.61.27]) (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 D2C913A4F26 for ; Sat, 18 Apr 2026 23:42:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.61.27 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776555726; cv=fail; b=MmXhFXMbhNLpN+f/eV5GQMkI08Rwqbn74MTKZWQ3hIUMTNyFtshim7KE9iiX69iImhW7S4eGNgOmFAZTHAM8xw9bFXr7cpsoAIr0C7OtjddoTimPGoBTxEkIzAG0JAzhOksCADpEX2CBYgXO0upAvCVXLTC/Rj6lQXkzyRHS97s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776555726; c=relaxed/simple; bh=8sY+pj+T4XgLL3gm8gl1OzHPLl1DZQYuuDz66CU9W3Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=o80zHtvzGh/ejbijDxGqtDatP7nEZb7KMScy5boUaQdG7KHqYdgVoDT9Q0a4rPVLmdpbpkG5AajBuQEmSk374fX7MBNN8SkOwjXzII8Nka3wZLz0hMyImi2EdntFXgPveQm5frwlkPkdmo1FwMP9JKzkx+Z9jm7nmVzv9obi9Kk= 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=Ol8zNVBa; arc=fail smtp.client-ip=52.101.61.27 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="Ol8zNVBa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hgMmpXwyYmkNBRKZOz4KSe1mOVVb/RW/MB3xjIVCV+um2YcrEf8ZgJFHg+rfhDVgpFoP5UviFMiQOd7Ck5kDjk219HYHyS0aOJvj53iMIySOJHZhJhARq+0yOBsFXGrHgYt7cWNaK+yf7Sn7kGhVHtAYvFDHFR6TgC0Ryg4j9bh53fa9hXKMp/xTA+Wr0ni60s3JJZsDNw3Eps+5SC7L4cS7OaVGt2ntpLLF8BHdKgik+nPWxpZzgp4pv0yNn2WFM9lUbSqjNrRUih2q79CvO1EHcfAsplr+Pi0txrmycs2QUmq8BH/eBA4W5jsyow+z2m7bjJkCy57jESrmJThWhQ== 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=HA2YYHodJWY/zbHe5c8QA02jtvg8NJ/awoZOgxpKY/s=; b=prv69xdGHj4joZ3CDcBnJnDUBoKrc3YIW3S15dw6T2Wo+LWFx12HmWx43P79mVEtD2ewjbejYkfWqhCpHh/g1Hs7hiaesVFYHx89TqNAS3W/KcTbZK1wWFeu8n1vL5d5YnU0dV4y9B9qvmor9/P2pGg1/ixYtCVstKcvuyY5rhgPqHmuLMZZRW5ThZyq5eY5HQXHkzWE1BzxBvlRZ4blT+V2qWTxwffNBCjrg7R6XgT6YIZZ3qYRpkbj7SbtGkU8LtN8Jg7AZNe9aNmLbv72gq9/M7Ad0SOSp3tAyJbezW2jvcBZ+bKY6F5Jk2rSvIZBr5kLNBFB4ff1ZH+vi5YJIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=HA2YYHodJWY/zbHe5c8QA02jtvg8NJ/awoZOgxpKY/s=; b=Ol8zNVBaGEniF2PUC7FwR8Nl8EbHj1j/1yUQ019m5ohaXmySS+t5aAz3TO7AQYITphHpprouiH3rZgnYc4VsT78cRDeQvjBxUHrGwMdzqc+3GFSJ4UHUSnJnd5Nl82RmDktwvFU4+GKNWs54fKKvCyRAKK87s9563MmQ37aGfEf9JVrGjRgvLGyT0By7iJ7pHhTyaDadLlpHF6apKFLDc/3+Yf5GxM7Gn6xB0UUgjGRMGx9UDiyVXoPO5IRuaTijM2MYSLq26xTV/99+4Ll/hq52FYMGF/L2MMkD6EKLYl8McMOzjNTmq2GWWSC+GfLXRsic8XHKEJCCyhhVTAt4tA== Received: from BYAPR03CA0010.namprd03.prod.outlook.com (2603:10b6:a02:a8::23) by DM3PR12MB9414.namprd12.prod.outlook.com (2603:10b6:0:47::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9818.25; Sat, 18 Apr 2026 23:41:58 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:a02:a8:cafe::3e) by BYAPR03CA0010.outlook.office365.com (2603:10b6:a02:a8::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9769.55 via Frontend Transport; Sat, 18 Apr 2026 23:41:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9791.48 via Frontend Transport; Sat, 18 Apr 2026 23:41:57 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sat, 18 Apr 2026 16:41:49 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sat, 18 Apr 2026 16:41:49 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sat, 18 Apr 2026 16:41:48 -0700 From: Nicolin Chen To: , , CC: , , , , , Subject: [PATCH rc v7 4/6] iommu: Fix nested pci_dev_reset_iommu_prepare/done() Date: Sat, 18 Apr 2026 16:41:35 -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: MWH0EPF000A6734:EE_|DM3PR12MB9414:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ba8d2ac-0260-4c52-134f-08de9da4148f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|376014|82310400026|13003099007|18002099003|56012099003|22082099003; X-Microsoft-Antispam-Message-Info: W1UCXfRlFIdVNJVILb76tDZq5zYtkQVdrBdeIaoLBWTdB3IV25wm1jyo3Qjw/SO6S70WsKoHHv4y7/EyEv1oIKPll977mCJo9XS372+1lNQmuCDby3I0Vz1USxbJBiI48AWmbgOGBewp4Rsud9RdFPtLuMNdH6WwjGhZu/ilF81jjuTQpZ/7dk0O/v86stl1WtKjBDhA7X7u0OGVDcyMFd9Wz5/6dDl91ogYRxS/JNGEhfzEq53Th2KBS9epUkd+KhPI6GatskF+9ExkfVYeofK0tMLpMSIV7nTHKyzO53yXzsRfm1CcIE7hjytsJeqrSJWgte+fmT3LlIoQm3y2MOdrFBbumrLlr2uEiPFJK+KL6dnHRRcZ+x9/3l4iPv4bHrypKpyeBLdTpu87wrk7NScZsdKZtec+1BWj0AuBogB0GMTOFh8ePfv8YbEui+kEo0kmClqxm4cHK6qbCZi8xPkB+oRZZ+S6HuA0hdKZ92I0xew4C8WmxYfsPda2iVlAqQuYosuNq68CDD6ZhqPhPr1x+rrc5B059d97WxWfinEYf9XrB8HD6jGan2cQpk8OarbqBq2Gpqu+RQrMaKCfkhMGQbeuPqB/FKRTYrdPcDL4lLf6xxXf0JX6vBXJnbSCv/Jo7CmVJfWTufcxH6Y0/DLYwJGsbJWb/mYNuZgI9lreu9MYPPYUoWPRSI98egjtJivMW1KEsNDHI2UvYZWPeDUAprbBVtkOlyouvfqdLLC294HZp8uIUK/JwZQN4OpcOOR4X1nLQjezxRVRWe6UyQ== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(376014)(82310400026)(13003099007)(18002099003)(56012099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kRPCptcK9x/Y7bzs4HLwvn2RB49QDl8EkwSbyuEtzV8vm4PLPqOZGRgkSm5DZ/RDUrtI4MhG0+J6QQMwtuPOw6orGPniNi59fRRp6t+RFt0dS01E6pQr4tRRVQwQMVxOgwasQdkdMURmrLqz5KG8NRuHb5L0BOsUeVXhCg2bJzretKGeskLBTMJ2zkwdMKd7Vxx51p9eq0sUu4PSUXH7LwDG1QfsDMMgBVSfNFkJud7jPYW6ko7LQ9YelwW2KG9chWt5z6lm64Le1fkYVSXKRB8CrjA8q1nSTEeqoiyrQe0/6hmrMM1fDiwa6O6ogYm1eDTWEHnrMz0GeBFOegN9sObr0Cfgt8Qqej8uHqax7oQuVDb74tWnwz8NIpvR0Ro5N1CGMlmCIju/KegNs7cDia43W4Yg/DjGnppu8YgT4u9SjZizDwYDtqOlkc+k9jXR X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2026 23:41:57.7344 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ba8d2ac-0260-4c52-134f-08de9da4148f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9414 Content-Type: text/plain; charset="utf-8" Shuai found that cxl_reset_bus_function() calls pci_reset_bus_function() internally while both are calling pci_dev_reset_iommu_prepare/done(). As pci_dev_reset_iommu_prepare() doesn't support re-entry, the inner call will trigger a WARN_ON and return -EBUSY, resulting in failing the entire device reset. On the other hand, removing the outer calls in the PCI callers is unsafe. As pointed out by Kevin, device-specific quirks like reset_hinic_vf_dev() execute custom firmware waits after their inner pcie_flr() completes. If the IOMMU protection relies solely on the inner reset, the IOMMU will be unblocked prematurely while the device is still resetting. Instead, fix this by making pci_dev_reset_iommu_prepare/done() reentrant. Introduce gdev->reset_depth to handle the re-entries on the same device. Fixes: c279e83953d9 ("iommu: Introduce pci_dev_reset_iommu_prepare/done()") Cc: stable@vger.kernel.org Reported-by: Shuai Xue Closes: https://lore.kernel.org/all/absKsk7qQOwzhpzv@Asurada-Nvidia/ Suggested-by: Kevin Tian Reviewed-by: Shuai Xue Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Reviewed-by: Lu Baolu --- drivers/iommu/iommu.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index e9ffa562b614f..ff181db687bbf 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -82,6 +82,7 @@ struct group_device { * - Device is undergoing a reset */ bool blocked; + unsigned int reset_depth; }; =20 /* Iterate over each struct group_device in a struct iommu_group */ @@ -3997,20 +3998,19 @@ int pci_dev_reset_iommu_prepare(struct pci_dev *pde= v) if (WARN_ON(!gdev)) return -ENODEV; =20 - /* Re-entry is not allowed (will be fixed in a following patch) */ - if (WARN_ON(gdev->blocked)) - return -EBUSY; + if (gdev->reset_depth++) + return 0; =20 ret =3D __iommu_group_alloc_blocking_domain(group); if (ret) - return ret; + goto err_depth; =20 /* Stage RID domain at blocking_domain while retaining group->domain */ if (group->domain !=3D group->blocking_domain) { ret =3D __iommu_attach_device(group->blocking_domain, &pdev->dev, group->domain); if (ret) - return ret; + goto err_depth; } =20 /* @@ -4037,6 +4037,10 @@ int pci_dev_reset_iommu_prepare(struct pci_dev *pdev) =20 group->recovery_cnt++; return ret; + +err_depth: + gdev->reset_depth--; + return ret; } EXPORT_SYMBOL_GPL(pci_dev_reset_iommu_prepare); =20 @@ -4070,7 +4074,10 @@ void pci_dev_reset_iommu_done(struct pci_dev *pdev) if (WARN_ON(!gdev)) return; =20 - if (!gdev->blocked) + /* Unbalanced done() calls would underflow the counter */ + if (WARN_ON(gdev->reset_depth =3D=3D 0)) + return; + if (--gdev->reset_depth) return; =20 if (WARN_ON(!group->blocking_domain)) --=20 2.43.0 From nobody Tue Jun 16 11:17:51 2026 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013003.outbound.protection.outlook.com [40.107.201.3]) (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 1558C3A4F2D for ; Sat, 18 Apr 2026 23:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.3 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776555725; cv=fail; b=WeaA+mCIcm+Bf2qqu6sR6gXWFBqHTVI0CfZdFzqUhAsJi0GKq0ZfrxwLeQNHSLWgdtuN+WmgbBC7sieM1FGrgK+lpzBvCH4BFxxtoxJsWEO6cHsFXKHHrwnBXB0xhME5jhKpKvzCpXmmSc1kH/Erjr4jKNu9CjWfyIhxI2aqJZY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776555725; c=relaxed/simple; bh=WzPmDHZFFVuYhuokevURezp8rcFhQldC4+SwdO/C1U0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KJ2xNJHfL6KvDysdFJTr0DKLV0cs6jx+waYy9Tl2OChNT3I4kUEj4kCiL9NZUu/L0/ffpf+kLdnR5+NFAB8TNFyKJeUOM1+V8rMRxBfQFbDwG7LgQwqLEKvvXI4lJxSfugM/XQ2nApnVrec7FhoFd46KH5CDmGwolzgeiTWisjE= 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=gw2VLucG; arc=fail smtp.client-ip=40.107.201.3 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="gw2VLucG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dTtQMiUcKIYulVY1ZETnCmRulXXPQDscNGX2epw/i/tkelQk+m2uoCfOA7it6rqobm0sE3pQVd9W0t9O2qJhRmW0YvzSgICCESItFHyf9AKkTBKU2/K7OwacgyyL5XAFjRqe6q19oi2NQzfbeYcA18x9wvEeEFplzoRwKBkEmsmbIFiYg/ouDbqguwrEve78OHSOhAHTWgRkJ18Z1VO8Ao1RuzgcYNzoXDOFat/G9MaVRoVisdysHgBvNuz3PSTCcUn4CHpJglzSJZnDWUhOlw5M7HPFVzEyWc2zPo4F8SQXetiomb/35FkgprQAMTpXVNMTLnIIECCDkvdt93ms3g== 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=MnYh7bC9mxd0vdWtRig6aYpDXIDqz9uVhMRaYC4Ze4o=; b=ZCXIMewcEN5XVC/TGCd4C3iOABeQTZK/lCkJsje2aVPKGUOWOQg5S4R6H1HPmmPlVwkd2HQE7lPDJc3rSF/1amnmawwPlD4bUasF10TFX8xlenHPpWwt6qiMoFpVaQVvYI/cJN5GOLw0XdEQ3glz9iN6+p0ZKXCV5d08HNAMtSszLpBF9ZmSRas0HyljSDGPEC3+lWB+sAbYzsGlcATOVgbpVPFLl+tgIVtBwfIuynRT38vQ4NminumfMinW0PkmYq3jDMUCGuaR9jKHgb5Cm3C7HQ1H5mJ+o/KwKaPkCQuK0vkcTfMZrYVypKjjiXQHCNBCQhN7QaukNmL5scqkmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=MnYh7bC9mxd0vdWtRig6aYpDXIDqz9uVhMRaYC4Ze4o=; b=gw2VLucGQ/XRiKYTiquhCpPxZkFMpylVhSHATrdy4Mj2b7vRaxMyF6vaY6YAfnjpjzYVOIqsPGEZZ3MdUnujsRU9oifupSBkSYBOjjILnDiuYp+aPmrH0iMw//iMYSeX7L8OvbxW23usznyr/zt5SVHO1LdSjqXiL8w+RgWv9IZphHWu/AKgB9Zgb2dp1fqcDwvt7WD1jCePGCaNDYj4vxJs/xpk1kO4as6XPrVsc4CQfb/IpOaNDGYp3QCy5k3PzvGyiDswKfCfw2xS5R5xAcCIHqr5SiSWEl2SwFx0K/Mxyq5L/CAxVXr4WKIivUJIN35MfJJaziVByaGO449pGw== Received: from BYAPR03CA0009.namprd03.prod.outlook.com (2603:10b6:a02:a8::22) by CY1PR12MB9582.namprd12.prod.outlook.com (2603:10b6:930:fe::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9818.21; Sat, 18 Apr 2026 23:41:59 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:a02:a8:cafe::9f) by BYAPR03CA0009.outlook.office365.com (2603:10b6:a02:a8::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9769.55 via Frontend Transport; Sat, 18 Apr 2026 23:41:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9791.48 via Frontend Transport; Sat, 18 Apr 2026 23:41:59 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sat, 18 Apr 2026 16:41:50 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sat, 18 Apr 2026 16:41:50 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sat, 18 Apr 2026 16:41:49 -0700 From: Nicolin Chen To: , , CC: , , , , , Subject: [PATCH rc v7 5/6] iommu: Fix ATS invalidation timeouts during __iommu_remove_group_pasid() Date: Sat, 18 Apr 2026 16:41:36 -0700 Message-ID: <8914b746d0e19b05a26c1fc5d14f170336faa3d2.1776551790.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: MWH0EPF000A6734:EE_|CY1PR12MB9582:EE_ X-MS-Office365-Filtering-Correlation-Id: 42b383f7-f580-4845-d0f9-08de9da41575 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|376014|82310400026|13003099007|56012099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: sbWxJQqnxluPQYssBwRUfk1Kl2bSlB83mE+9Dc16wI6G6uIktQxaDJbI4Gn97F7xyxmRaD8pUTicJ2JtXm6WwcHYkg8Vj++MJeTDLQFqG47ZreHfCMW07R6LXeHhaGXWMz5pHw9glxw/ATglkBeGs97blAOhWY8NxwmgUsAYjEjcq24CGltplxsjCZ2mPuPubZVdDSS3PYIHBCiLzXkcRy5Q8RmIFzUGTzS+aF9zUw4mwMfrMoQ+9mm/vt/vo1cM0CqUC/Q1/jp1ouWfLQAT/O5QEMFhQfXAEOSiC1SwtmxISGujBOkiCphK5H8bxPkVlTsZAv+oUav7Te+EmOqndYPEvVFuMrZMQFWCSVBv/4Ei1yEb6/dSll5JZ2SkAuUp7Xo8OndmDbjGB/KKmFkpPKy0K+6faPaw2UMMj2iRkB9oAUjT5PjqEWWPFDJ2uajpfqznbDZh3fSj8zF7dlonfd7myLU9WAz2X1D3s+PVjKDor5uQj/wWUcqoUbZYQBsNdFE91aeGFkYd8yyykNRcAOMTbD8Jx4VtA5MXUaOgTLIc3ZJSfOLIUfvblBdX0AqnvpFip5rmg4E2HLzVweh4Nr5dvnWxBEZUISgaIJzkjYypd7vWH5eijlGONNw39eTePwe0Wt8vW0tGdsj7SLgIqzXrP3b5FbRUe3uz0mMh0bjLP8pjW4egdPagEoQL2OpYxapnyow/HIMX009Pav9obKYAR33U1LQu5WnJPH03hMCbexbr5h5fxXtl6Zp9s+Rg6dqaagPZvp/K1K1sVPbPeA== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230040)(36860700016)(1800799024)(376014)(82310400026)(13003099007)(56012099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lvExC6AiNFQiunPIP6lOLXC5bupw2N7fz88Ft3g33+R66JxbsLYLa2GFg8/4oqbQUfY0UUTPEZjZneKKeX9PWVWePe3BllQdVIULXpnlyUnnxLJF3o8XFku4x+Ys8nc+bqWBYVnJfTqSHFAagqjfIEUlTVg5JDBpldZY8xxVI3Irv0U3TR1Ku11n6nKsZPp0oVNFeJVwDdU6x7Yp/u85Sb77ghPz4XxAuev+7UScgdoM+iFNh28NhCibvtL396EWziLUXbDf9+eOpTVOtgSYLaoT6ZdyErifN2AMagx7+xm6c8i8ALgnKdjov3SzewA5AoTuSxTmfJAfMUkNLVBdjXB7XkZ/2rAgD6V8ZzseYShO6z2x1yTnBNVme50n/c0iJr0wc+zJB6IwBgT3jY4z5xjiF6C/IzRx5eulSG1lr0SVTHuYblkDepYP4JF4SWd6 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2026 23:41:59.2428 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42b383f7-f580-4845-d0f9-08de9da41575 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB9582 Content-Type: text/plain; charset="utf-8" If a device is blocked, its PASID domains are already detached. Repeating iommu_remove_dev_pasid() is unnecessary and might trigger ATS invalidation timeouts. Skip the iommu_remove_dev_pasid() call upon the blocked flag. Fixes: c279e83953d9 ("iommu: Introduce pci_dev_reset_iommu_prepare/done()") Cc: stable@vger.kernel.org Reported-by: Kevin Tian Closes: https://lore.kernel.org/all/BN9PR11MB5276D60096EBF15C5753C4BB8C202@= BN9PR11MB5276.namprd11.prod.outlook.com/ Signed-off-by: Nicolin Chen Reviewed-by: Kevin Tian --- drivers/iommu/iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index ff181db687bbf..30ba18e613faa 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -3554,7 +3554,8 @@ static void __iommu_remove_group_pasid(struct iommu_g= roup *group, struct group_device *device; =20 for_each_group_device(group, device) { - if (device->dev->iommu->max_pasids > 0) + /* Device might be already detached for a device recovery */ + if (!device->blocked && device->dev->iommu->max_pasids > 0) iommu_remove_dev_pasid(device->dev, pasid, domain); } } --=20 2.43.0 From nobody Tue Jun 16 11:17:51 2026 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013044.outbound.protection.outlook.com [40.93.201.44]) (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 D8A593A4524 for ; Sat, 18 Apr 2026 23:42:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.201.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776555731; cv=fail; b=QeYh9MF32sUlpdcrbmPsJGk3UctzZc0g4eK27CnK+d8L9X1A+ewMeYEJYH+vUoZm+jyRHeC5Nb+ACxd7wkvE6iFnY+pGQ8WYxnQgPzXt1yHbyhid4tcFH5Ze6KaLGwnkfZ8cXyQpAQdkMVBDAJJjIfN2/+YbGAL/252yEVWXi3A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776555731; c=relaxed/simple; bh=P0LaOp/tp8CrtLRWKNyexG5H3sdZ8Y/IMpYdzeWIH7k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e5MiTUYZ4JPn/wC/kcZ4PiTkxCrYtzh4XDPlSUDCJ81lsMnLjEs8vUYsIJyGXnc99Dcl93/kj0qQtEu3+Sn3VpMV5mwTrV0AdF1KZJrkney/Pc+1sdUSRWUoN6yGtNiYfle52osIJIseaXMIt6S/FJca3/YXCYYTa3dIrjMS5wo= 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=LJ6GtvQj; arc=fail smtp.client-ip=40.93.201.44 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="LJ6GtvQj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tXZ5GR+CHNGc4B4Ag+Getk+VvzyHGXRwX4eWw1OAVcvz6ljhpcZrxAKGu+d8mLToSeurmLmSXo7p1DjcBXjEZQJj3O/24ulnOpjGButxYwk+9HgKSaZFIt5HCQQz7uT7Bk9sUErMCPWMCHRYswmFoOBOBq4UmHZ2AWsqR24dQsf26qPiBZH2pEqqney9fqJDqXR+vtwEzS0qCzYMmJxA9yXrUkSAaoiLlnYS/duQwnpgVhd3eJq6zHWhAndv0sQYqZ7dPkkhZCqSBt725qCaJ5yQ8aRNnbaFvZ0C3A18g9pYKTmzyc5ow2ON0UOzNpMjn4Ksxk4i+7C4bU+2MbRR8g== 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=+W1iG2lxZl6ENO7Tb7ExK1tMkGtliyPSGUa9jNceLvc=; b=gZCrIESxzA5NpdlP2OEU9g0AnxUl3vHX3GoIoyKlam3eTq7n3+bcQcadd0AkU/0BEAuYXoRontS18Zw03wIFkYOn9HsYW3sDZ6HSLa0x0MFCckFOyvMDtSSwpFT+Vtxotd7lKSMMtFm30RVPmUDDTwk+KNcViZtxEZlT7kcGOh9H30lslIAjrbwI9VZmUj54t8kjakjEizj9smRp95YtAlLTsb9TBMVCOzKpBFWY85LZgkBdtscnf5htbIJTfum2cs0cI1os4L/YZJ/pOekzY6mRuvoDLkwAyX96Gi6gII4N2LUaAUwwxEkcZLg+t58gwo5JzrCnr2SW6XJ+Pz+ivw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=+W1iG2lxZl6ENO7Tb7ExK1tMkGtliyPSGUa9jNceLvc=; b=LJ6GtvQjS5cWsouvD7WjSoj2JqvCV7p3mpF8j2bAPkaT8NAoTnZ5n0EP8r0lCGXT9fuTBKbbGZHEOhlaGgX5ZVl0a1ex62BgQnf6Y+b9wnH3EKaeQwYCxVSmwftf00SZlb7dql+wShJZnrfww8KroLTYVBP4Osmepz1m2kCTdJXoU8MRUxZN889Q3wvUpG0m1lBLqtBPJrrx6w2ubvH0RsgDYSlGPdNqIMQY2oZd/Xd9v3BJ9BmwdOcB94UXOZhiD/F6y2pPPjYk9bx0JPvzG39hMoyEPjlxdeD56I8mJvla9gnNECGIl+II/58OfOgG3wH1/e1Y7A4fdCS4ud+BQA== Received: from BYAPR03CA0003.namprd03.prod.outlook.com (2603:10b6:a02:a8::16) by LV5PR12MB9754.namprd12.prod.outlook.com (2603:10b6:408:305::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.12; Sat, 18 Apr 2026 23:42:05 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:a02:a8:cafe::60) by BYAPR03CA0003.outlook.office365.com (2603:10b6:a02:a8::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9769.55 via Frontend Transport; Sat, 18 Apr 2026 23:42:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9791.48 via Frontend Transport; Sat, 18 Apr 2026 23:42:05 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sat, 18 Apr 2026 16:41:51 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sat, 18 Apr 2026 16:41:51 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sat, 18 Apr 2026 16:41:50 -0700 From: Nicolin Chen To: , , CC: , , , , , Subject: [PATCH rc v7 6/6] iommu: Fix UAF in pci_dev_reset_iommu_done() due to concurrent detach Date: Sat, 18 Apr 2026 16:41:37 -0700 Message-ID: <96a8ab981d365bdedc5dc705df10414ccf578c9d.1776551790.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: MWH0EPF000A6734:EE_|LV5PR12MB9754:EE_ X-MS-Office365-Filtering-Correlation-Id: 710a05e3-0d8f-40a7-7412-08de9da418ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700016|1800799024|13003099007|56012099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: O0CTWstkOmvdlgd8gLD80oT/MaMWuThy1JnnlUYdCXYpAdxAG3w8Hj4Q68Rejfbd92+b13c4GWLP9I2L8pV/AYmMBfptzPF5uhDm3NcILK1aARrLEu6qr3nRCwQnNq4c1Nm30ErYs31BPy5BBN5BEu7b0Wm3zVnRegm3eGJmtoQCiIdIpgfidDQgS0UP6Tw6jki8BvvnRukj3UKw8NGbXT/NY1ZArLSI+v7zMTi+7+FZRUKo44Ljhz4ZCXYnRuXjnttfw2lZYJZCIjVb2Ze+wPeb3HYPAz6YtxJL8CtXIOhy45OlsEMvIWJtqS2WltNtkxFi2w4owYqxYifQdQyl4BbW2v7FQVZ8Wk2TcHEyr2bstJ529RlVBLeqJu9prlqkEi2sHUffKWPv2zYKpil79HnuxHdP1ULWr9iugtNujU8UUo67X/tHCgQBdUn/V2PzGTFOOG7+YmcG3qwhs7FeFeH48xGjxjvbDWJ0Q+M+ZY86UoLX37GLC77FsQW1O4GYxAN+eNgqgP0zUDBEubQcz6gWf2J6a6ucGlJmXv2+ri7GiFV1tARNM1LKY1ysHJGvxOBaX7JkEEfhlAY3mbQwO3TPtT4e9aHPLfNB4lqVbwl2e9B3wGD1AgBl3/KYH7Mozib5I5Dmva3gp3wYP08JQW1SR2GHknLZBePOv/0pO29R8IWhdqxENcfEKFhG7jlcEvJ8XLtq+UlrXieCmiMWyJWMnegQjI/OzH5hwTLQRl/xecS6eHazwdE4fdnFTWeuT5NOk4xljxU3cuioymtV3g== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(376014)(36860700016)(1800799024)(13003099007)(56012099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yVtBaWoZW+cv529/Bex9jO0aZGfbz6mcPROQxJtMN5eORUX/jxHepLaK6qql8hPxgejlQYF0t93T/b1Gm6h1W9oYSs1cStHhigkXRnvU8Xs5XNSp51C1qsqy/lLB2cLRVzJ+KFfubp9cxUHKL0nU0Ch1j+K8mkR9/3ee+Vfq5nNL+uoKlL6Cnb7rXGnbKBTX1YOLE0Xvr39L9KkS6GX6PhFPlmSc4Rgx1PkKcwGcMTSkakGeWI/7gII3K3iiVsTObT/t0TG8voVh1er+15vtm+THy7dMnExVT/pnY2Kjl4hXj07GYoIzbbhlmE51mn5VD/DgrCrlBQXs8B8U46HArS4OsNifYARPRtdQWLwZKKQwtpYrVtHjv74dgWrL2M3mQlV3uIz8IjiOOHyZPMRHiRxnK5rmAG9nUnNdmTJdS+ZQhh5Rv3tCksF9yyGFuet5 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2026 23:42:05.0553 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 710a05e3-0d8f-40a7-7412-08de9da418ec X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV5PR12MB9754 Content-Type: text/plain; charset="utf-8" In __iommu_group_set_domain_internal(), concurrent domain attachments are rejected when any device in the group is recovering. This is necessary to fence concurrent attachments to a multi-device group where devices might share the same RID due to PCI DMA alias quirks. However, IOMMU_SET_DOMAIN_MUST_SUCCEED callers (detach/teardown paths such as __iommu_group_set_core_domain and __iommu_release_dma_ownership) should not be rejected, as the domain would be free-ed anyway in this nofail path while group->domain is still pointing to it. So pci_dev_reset_iommu_done() could trigger a UAF when re-attaching group->domain. Honor the IOMMU_SET_DOMAIN_MUST_SUCCEED flag, allowing the callers through the group->recovery_cnt fence, so as to update the group->domain pointer. Instead add gdev->blocked checks in the device iteration loop to avoid any concurrent per-device detachment. Fixes: c279e83953d9 ("iommu: Introduce pci_dev_reset_iommu_prepare/done()") Cc: stable@vger.kernel.org Reported-by: Kevin Tian Closes: https://lore.kernel.org/all/BN9PR11MB5276D60096EBF15C5753C4BB8C202@= BN9PR11MB5276.namprd11.prod.outlook.com/ Signed-off-by: Nicolin Chen Reviewed-by: Kevin Tian Reviewed-by: Lu Baolu --- drivers/iommu/iommu.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 30ba18e613faa..fa7b04a77e469 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2470,8 +2470,11 @@ static int __iommu_group_set_domain_internal(struct = iommu_group *group, /* * This is a concurrent attach during device recovery. Reject it until * pci_dev_reset_iommu_done() attaches the device to group->domain. + * + * Note: still allow MUST_SUCCEED callers (detach/teardown) through to + * avoid UAF on domain release paths. */ - if (group->recovery_cnt) + if (group->recovery_cnt && !(flags & IOMMU_SET_DOMAIN_MUST_SUCCEED)) return -EBUSY; =20 /* @@ -2482,6 +2485,13 @@ static int __iommu_group_set_domain_internal(struct = iommu_group *group, */ result =3D 0; for_each_group_device(group, gdev) { + /* + * Device under recovery is attached to group->blocking_domain. + * Don't change that. pci_dev_reset_iommu_done() will re-attach + * its domain to the updated group->domain, after the recovery. + */ + if (gdev->blocked) + continue; ret =3D __iommu_device_set_domain(group, gdev->dev, new_domain, group->domain, flags); if (ret) { @@ -2511,6 +2521,8 @@ static int __iommu_group_set_domain_internal(struct i= ommu_group *group, /* No need to revert the last gdev that failed to set domain */ if (gdev =3D=3D last_gdev) break; + if (gdev->blocked) + continue; /* * A NULL domain can happen only for first probe, in which case * we leave group->domain as NULL and let release clean --=20 2.43.0