From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011007.outbound.protection.outlook.com [52.101.52.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 E4F2D357D13 for ; Sat, 29 Aug 2026 01:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.7 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787966576; cv=fail; b=XS95E114LMU48z0yGA8Pfu+uJ3hHFQK+ViQXoqOLWEQa9VtRELe9Byo+Fccw1NDIJnSQlszUuSD5ovw//0KFGMCr9x98lsh/xCmTvG21N6p+dyAQXyyK81Jhb8js+kBJSFv8YtGLLc2RQ3E2yVq54oPwl40lpAlOCOD0OCHTX+w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787966576; c=relaxed/simple; bh=WkY53zfBN72vENaBP3QCBQHjLgA8ZVx/UUIpI017P6U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=arm/M0PXYWOSxONN2hO1K5HStq7gMwMMiGiFwPfnoDXvA3b+EraCPVpAkDByp9nofVzjm6TwpCyHt02f0v66adMABQn6EmJUXqkPUsKyqiQThYr0vIFJvF/CV8YJ4EM+yYEYmVCfJ7gcACPrmnkpBxZsN7vmMxgtRkLFWc63JC4= 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=frT9EQfc; arc=fail smtp.client-ip=52.101.52.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="frT9EQfc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CXYNMR+QlXnZ5Se1L7l1M5YtagqkSOej0VZI1KGeCrhV3UXtiyypIVToxwKxSLg5AOpkVU9Nv3/ZG96z+hK02uncTJ2tyrasmAq1LOPNgsS1idbKYnc93L9xvbHXoKscuCaMimXVxNdsFee1IVSRi+1vws99f4ME7zDd+ieQJStp3cGIcuIKSU1niS+w4jN6XAxdiOS9inbp9vEO+zzVk6RSmqVnuiPnd/REd4vahZMGRV85OtmlDDCunPwSG5tdoP3n3zuz/MWngVbrxSddT91c3wZxg2qNNxaLc/w5YnNtJ2cfOEkSh85HzppNDkhZd6Zyve5rmpK1LVA0uwHnqA== 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=8GBQaYsl+PMy2uTAaFVICPzfYTzKtoK/yBqaPJKCyow=; b=JxcrzhLzKOQ/euBYwuxP4pjDMBaLbqcgdrOrvE17bG6apk0wn2IWEEo+uMz0rf3DwJeME4JETPM+fx9+DdOcLUtu3FeRiFwMRi+xrGbXYI9om9/B9U5FeDUlMZJ7c0y6ZyDSlMIQzSScDniueizOvWhkcchWUU+A9O1nJDol7QuRlw9tMpP7DXFWCb+S5u2TQGC0EqLmfPDscqnF+3bHCaBlMv7ZqiNqBiOosK5178T+z+4gTHtpt0FLXDNohqb92q3/tAhtrQ8s5KN2wgAv6ez3bMpYUCsmz/nLgVwGZBLFRwSQtJ54p5GXUlbiw4siL1EyM+5UCNy4VNIfdRAptw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8GBQaYsl+PMy2uTAaFVICPzfYTzKtoK/yBqaPJKCyow=; b=frT9EQfcoXwWcadFl062vyFxA0vtnjLqeVHRtC5WTBlNl6+E5qjMLZF39nuEtrgJuSLVO8L806IUIuYNRcoc/oLueGqK5/VnqZPty2nxxgxu8tfcMnfMgKQVXbHdiwXIRp0IQMUF4jKDQlwyI0Qd69Cue7HdHSKbM/O4F8ygEtt+SEySXLJ1/5t0f4IwtwISewhVwqHtEV3FDG7cSCh7lY7A+Feb+MSr07M4OAO7rDsCyg6w0Li+CGB9E0fvaxhcVo909rFbq2WQiXb8b5h0paFetY7SdtsYuuLjZr4V4+LQayS6u19v0G9yQ5k9xVEykYVw1nxwNQdY6LxpBuql9w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by MN0PR12MB6125.namprd12.prod.outlook.com (2603:10b6:208:3c7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:22:49 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:22:49 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard Subject: [PATCH v2 01/15] rust: pci: declare IrqType and IrqTypes with impl_flags Date: Fri, 28 Aug 2026 18:22:29 -0700 Message-ID: <20260829012243.496697-2-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ2P220CA0009.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:5da::8) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|MN0PR12MB6125:EE_ X-MS-Office365-Filtering-Correlation-Id: 0fdd7ac2-ab0c-4f89-8dcd-08df056c09e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|366016|1800799024|3023799007|10067099003|56012099006|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: XlHLgdRzh2Ne0wm/X4jKYRxN+ctenmgHMnUENhxPiGcbck5BbJMz1/3NKEP8WbVOH4kPi60e8l2qr46Y/7enJ5VKti9LPEj12GnN0y3I0x6ZLK98BI0Ewl9zTyK/VFazLa74m6dxQVOZ5UtkYn6vnTBd+oIRJIppBIobiWZpPDcP8FpR56GNqtPxbSd5fkezNu42o3u/o+91u7Y1ITDIIjg05FBNUrbvziIXYkLw6F1RHZwb/kogf1l+hok04olXrOpCPzZDrY8vcQsqMi52N+cxueIo4In8waaR3IXxh5ZHWZFlva+ScmDVJvzwN1ZgU3ziw5tqJE6/fRSPVeMhlcm7/uJ8LmbJA1LxBu+tiKJVSvgCe/vSMmRdD83DHKrOxPNq8cFq/IIPbYaBXfjlvMukFVAp/w0YKfAZYlCD0iSUBetCDTXVi39J+VFB0X9s5FTuznkNMF5UH78xt34vFuO1phC0UvIl8u3Kzmhzd9jsTfmvMN3nCy3pwmbkkaXt269/R4w7VaoKP0nrnaOrhphQdbDZaU0MtVe9Q29Ho8MwVnVSoO1XhhA3CBS1qAvZVPep6dQvVue0XD4nzBqQurEutxbWu61HZhvZzbFHC+dUtC4lINBSZ0y9iQ9oKGgU0ALBmy64HPJh7inMv47bAO3/+0kkhYJrGKdTGHJTR5k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(366016)(1800799024)(3023799007)(10067099003)(56012099006)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?9gWwUvvGzp1waGwkGrKH32LLjW6xIlaWZQ2Ihgsrt1ZdyN1VoWSxky9/Jc1z?= =?us-ascii?Q?U8SnsWqxJVi1DLtjPyuQumT3GQB77fDAg2tQhJcyhzyNgB98oDZ2AEq4PMWq?= =?us-ascii?Q?whq25v5i2z2bcQ8dsNa6M/3LE54EAi9wY7GpfwA4iMltwnzsr/CHz+uyPFyg?= =?us-ascii?Q?+LkREZV5cgXuVE2i/ddj4b2TXe5iAmMdCDZCpOmsv3O4sJ/mx4dswbPwFPvE?= =?us-ascii?Q?X4t8iIRzPe4Uu3jScrhWa4rSqC5GuiRfAiwC58LTKVkaSankuzGpedIwg2vr?= =?us-ascii?Q?VdNoEtVn35SHPmAEAZjUGAzfLMekgir9wbLwgjEHUS0EY3DRhzVFMuhZm02H?= =?us-ascii?Q?+KzR05xzT9a8snO0tO3av05jhNokxN9Cr3QkVIXpacI8Zg6TXwuObgnjsxx+?= =?us-ascii?Q?BWIWRbsNaRF8WfIuVxcgUwxyw+tIOI83A4YSmImqYYR3McdCBwNiV/YcR8bo?= =?us-ascii?Q?dw++BTBbb3WjPAu8aEVYUkUDEcjDjzBwuXktOa4sfdXUIhmGChAUPOGPGNSo?= =?us-ascii?Q?BVq8/HozS/q/9dKJYfm0LlxykSvhPyoRUIa0pIKjvmJNYVBbxq5G+Un/sNpm?= =?us-ascii?Q?6g/V7o8NbQ/5ZTU9Nl/S2isLZPQOGo2M+3pVZ4rCMZH3pHFdsP5zV8rXAKN0?= =?us-ascii?Q?SisrZj9t0tF8aNvkx96RtED/8cuP/skqoNSIaBIDG5PjHqXVzcUMmEr9OOWl?= =?us-ascii?Q?Pv2KgTI7RFhz66Lf91YG9ij7Z66R4Dw8sMm9I1FKf1lMKF1SrcATKRhm1KmY?= =?us-ascii?Q?/E305CbGJsimMvPxjWaWtzg7J3AayxNyTi66ML98+vh8euhU5UFXG2R1Y5bW?= =?us-ascii?Q?F8ji6seJLhPWkURHv7eEKa7H9B9MlVLZGyzbmfTnP2G/ewRwZZKmbxg7ION/?= =?us-ascii?Q?X4Jsoi36RJEu3331dsoyYKLp1ybSc31f/nRBh2QdGltANqQkxC8jNotEh470?= =?us-ascii?Q?oDxP+MLb6DC8zhQJAicA95mvTeqgjIKI0tUo+QM/OzyS505Y38KueK6R8Pd4?= =?us-ascii?Q?THRjnm7B8eVOKDOZCgzGZL/rVIDjs7BcebiTlACNhH0X1XixUhjUV3Yx41qG?= =?us-ascii?Q?QGolMASpfkGJDvKQOK1ZXXfR0cIS6EsANTq5GTZR51Dw2DktQUekhiZ71YGe?= =?us-ascii?Q?b2iZGQxD76W5OmojLoq++Z2rBj40PSUuqIAg5XxqPE8cTYkZNg5hlNtAbjTH?= =?us-ascii?Q?1uHLIEV0kQd3my4wrXyCiBORcIExta+4ZdoemKe9jmsPwh05hpOG19XGPBzk?= =?us-ascii?Q?siXAoi+nXzC/9zHN+AUjvbLGEgujOXAXF7l8DCfNN89usdqRGBk3rpTk2QB+?= =?us-ascii?Q?/k+i4+/5Ajk2bAJwfiSqscwlbtosja67jvTRtjit5yrTQOtPe/6+YoqgSkyh?= =?us-ascii?Q?160w4RvQUnOpbpY0doi4S10tnTME8HDKYVS3mQAOWUzqXUMVCuYJf6wSoWAy?= =?us-ascii?Q?8pX/A5rUxWSv/YodNCXEkuuf/CX/7jZ3NLSdGxWObSLtj1uT6zhySNY/xEY8?= =?us-ascii?Q?10PQxp1xj1dr6L0/aN3s9ucpK3a42Lg76hunMKLl+iw1U3ANbZrDdGDhjBRZ?= =?us-ascii?Q?tFsRDoAs+U8Hxi9pTrosFVbLsKC+iFebAq1cduENWo7FDa6O8k6es8kqTmeW?= =?us-ascii?Q?G0Q39YooGgQZombnvSNUMnTZ8LzseLtYJtH7SEjqrzTok8//RsCAag5I3L3r?= =?us-ascii?Q?IRyzMIuWBkfaONWlcRPOfx3BnmgkVHheF2Ou9ldD6UE2AQ5+/UABv2S7FTRp?= =?us-ascii?Q?GL3mIx7TYg=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0fdd7ac2-ab0c-4f89-8dcd-08df056c09e5 X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:22:49.2122 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7+Ohs9Ib9j3FJJXDre4jcVr/Z6OjucCs7i4Ue6o8Co+wFRgObxB7sTWyNCjtoBSK7o0mapn6ck1vppRGWy6IbA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6125 Content-Type: text/plain; charset="utf-8" The kernel provides impl_flags! for declaring a bitmask type alongside the enum of its individual flags, generating the bit operators and the containment queries. IrqTypes open-coded that pattern with a with() builder, so a caller naming two interrupt types chained two calls onto IrqTypes::default(). Declare both types through impl_flags!, so the same set reads as IrqType::Msi | IrqType::MsiX. Suggested-by: Gary Guo Signed-off-by: John Hubbard Reviewed-by: Alexandre Courbot --- rust/kernel/pci/irq.rs | 68 +++++++++++++----------------------------- 1 file changed, 21 insertions(+), 47 deletions(-) diff --git a/rust/kernel/pci/irq.rs b/rust/kernel/pci/irq.rs index 6741046ec1c0..f074aad7f1d8 100644 --- a/rust/kernel/pci/irq.rs +++ b/rust/kernel/pci/irq.rs @@ -13,27 +13,26 @@ }; use core::num::NonZero; =20 -/// IRQ type flags for PCI interrupt allocation. -#[derive(Debug, Clone, Copy)] -pub enum IrqType { - /// INTx interrupts. - Intx, - /// Message Signaled Interrupts (MSI). - Msi, - /// Extended Message Signaled Interrupts (MSI-X). - MsiX, -} - -impl IrqType { - /// Convert to the corresponding kernel flags. - const fn as_raw(self) -> u32 { - match self { - IrqType::Intx =3D> bindings::PCI_IRQ_INTX, - IrqType::Msi =3D> bindings::PCI_IRQ_MSI, - IrqType::MsiX =3D> bindings::PCI_IRQ_MSIX, - } +crate::impl_flags!( + /// Set of IRQ types that can be used for PCI interrupt allocation. + #[derive(Debug, Clone, Copy, Default)] + pub struct IrqTypes(u32); + + /// IRQ type flags for PCI interrupt allocation. + #[derive(Debug, Clone, Copy)] + pub enum IrqType { + /// INTx interrupts. + Intx =3D bindings::PCI_IRQ_INTX, + + /// Message Signaled Interrupts (MSI). + Msi =3D bindings::PCI_IRQ_MSI, + + /// Extended Message Signaled Interrupts (MSI-X). + MsiX =3D bindings::PCI_IRQ_MSIX, } +); =20 +impl IrqType { /// Construct from raw value. #[inline] const fn from_raw(raw: u32) -> Self { @@ -45,33 +44,10 @@ const fn from_raw(raw: u32) -> Self { } } =20 -/// Set of IRQ types that can be used for PCI interrupt allocation. -#[derive(Debug, Clone, Copy, Default)] -pub struct IrqTypes(u32); - impl IrqTypes { /// Create a set containing all IRQ types (MSI-X, MSI, and INTx). pub const fn all() -> Self { - Self(bindings::PCI_IRQ_ALL_TYPES) - } - - /// Build a set of IRQ types. - /// - /// # Examples - /// - /// ```ignore - /// // Create a set with only MSI and MSI-X (no INTx interrupts). - /// let msi_only =3D IrqTypes::default() - /// .with(IrqType::Msi) - /// .with(IrqType::MsiX); - /// ``` - pub const fn with(self, irq_type: IrqType) -> Self { - Self(self.0 | irq_type.as_raw()) - } - - /// Get the raw flags value. - const fn as_raw(self) -> u32 { - self.0 + Self(Self::all_bits()) } } =20 @@ -203,9 +179,7 @@ impl Device { /// let vectors =3D dev.alloc_irq_vectors(1, 32, pci::IrqTypes::all())= ?; /// /// // Allocate MSI or MSI-X only (no INTx interrupts). - /// let msi_only =3D pci::IrqTypes::default() - /// .with(pci::IrqType::Msi) - /// .with(pci::IrqType::MsiX); + /// let msi_only =3D pci::IrqType::Msi | pci::IrqType::MsiX; /// let vectors =3D dev.alloc_irq_vectors(4, 16, msi_only)?; /// # Ok(()) /// # } @@ -222,7 +196,7 @@ pub fn alloc_irq_vectors( // - `pci_alloc_irq_vectors` internally validates all other parame= ters // and returns error codes. let ret =3D unsafe { - bindings::pci_alloc_irq_vectors(self.as_raw(), min_vecs, max_v= ecs, irq_types.as_raw()) + bindings::pci_alloc_irq_vectors(self.as_raw(), min_vecs, max_v= ecs, u32::from(irq_types)) }; to_result(ret)?; =20 --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011007.outbound.protection.outlook.com [52.101.52.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 C7FAE306774 for ; Sat, 29 Aug 2026 01:22:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.7 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787966578; cv=fail; b=hbzmEaP+uQ3xmyZWIquhijB+Ymh7TP61/g+a4paT0BNqeShsVJs4PqwRzjVAgkwjCtfhuseV8NgollRnuuMzaybwfHAxgDJfRHa3NUhYEZ4GCeYwn3mHpXQB7+o7jKAdyE767XcrxOFtLAANDtKyrUdeeJbcWCEpA3S73K7n0Ns= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787966578; c=relaxed/simple; bh=X4OMXCHxJqpZJdD+DqBw3o2Kyif4UbKS7XrH2N91AhE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=e2A2qpI5HYeMpeC6BWXTXYOwYK6LiavtvtVphgp22zNvWfN03+JGmSH0vuyqIeCDXjfvGuIfGdZbPELQ4ijbDClZrvq9XCLG437mVlj59/Rq9ZcQgpN8XIYqEOW69v83B1uVTJf1mQ6cCtMt0T2FLNDtYxR+08AyFaKfdltc1Dg= 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=IgybHqmf; arc=fail smtp.client-ip=52.101.52.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="IgybHqmf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=npzAo0slRzGegpvsmnCwxTi8re57nqQAce8HUe+3JGjE7Rx7GW2I8J7P65e1RRyOt/AqkCKvc3YVffwfTloBcRf0EA+Xv7ZB8YC1sEy+cYap19viGQWqPQoLC621eYFm3x49zxm8U9cVo/u7V/3znRB4gUG+6620Rc7Em7/DKlwW+Qk2M44JtpyhzkaOviVavrtmIKRK3yIkEsrnRwAD2ouY5/kjdo/QH0Mtu8AnWMmUUifa5MPdyrdX31uo6hvIX+2G8KZ+lkcRv5GodKDU6mf2gkRAaE2/Yp4w4gTPFUKmHWSEhCZd52YhS5RFMz+KdFIigo9NKVO1OH1bz+lQ6g== 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=F0kKN+BAVEio0TjUBgNwFMrJDacKTl5nPet8gASb7Kw=; b=dxmFRY+CWjIS1CqQPoR8Zvxq9dw7tzbLpA3CjypNb9+W0Am8Mb/KLCXLuSSUUgAaiznT1f2jHqB5LIUhSLaSsO88BCmWjBM3LXJM9R3etVJxXDIB0ZyyedEKkUC+9fp/rxZwmqUEegvfpucqOLP+qaecV4r5jDDa4Yj10CN14xfG0QJr1JZcQUUT3mbrIVhqqnyX7sFIY/6sr2z+ZFNSDhoPMWPsPewGAd6pAiOi0KcSc/6VGjSefSSDuLaJw3Ht3UxOHdhXL7V6Vpa/EwJ/3OrxTxHIiTTGJCatw7totJ+X8GqvROyyscR+z0lAw9P/sY+HePDeZ03Kohf9PIA5wQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F0kKN+BAVEio0TjUBgNwFMrJDacKTl5nPet8gASb7Kw=; b=IgybHqmfvEn7yOXotxrTc+VKqyf0QRPMWEt3QGZnuIULWjKOfK49sI0rA4aBT98HXGQJP1A/fq1yX5HYYATCWn45JjwSI2T5gcd77J1O5Tzmhn9umwHQmeMiJuJa6/ibwk+Hoc9I1xVFTXeCU/xVb1vfp94Y62B9UIWRdJ+q3eal7OfnjQJajALiAykmDsqDBVdG0SlZZqvHmPnr6fq/nyjFg/SV/fAoceq5M6oDIptrU36aE+ovKhXztHXuGxHIYaL60sjj5SgC0TJMjhvJ4uuEiJSHknOGBgnOiP7q/yTRhkT8ncYfdcnPqnOkR8J8G8NZKxxl9embWZXWAqsDuA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by MN0PR12MB6125.namprd12.prod.outlook.com (2603:10b6:208:3c7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:22:50 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:22:50 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , Joel Fernandes , John Hubbard Subject: [PATCH v2 02/15] rust: sync: completion: add wait_for_completion_timeout() Date: Fri, 28 Aug 2026 18:22:30 -0700 Message-ID: <20260829012243.496697-3-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ2P220CA0006.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:5da::19) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|MN0PR12MB6125:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b7a5c98-e38c-4560-7c49-08df056c0a94 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|366016|1800799024|6133799003|10067099003|56012099006|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: IABZlgNqNbUyW2ZIcNHpOiez8nTPd8mIp05Ce9ItxYEPlklvGPPEMNxit3VHT1sRJmBM+N0BGIbVzzelSCKhRDtu6Sjm/CZoNWSHS/M4Tm2fKeu/FeC4HjexSuWb5wJfJgxl9cllhbwQ3in30b766injLoaYqJJF0um574KcZvByt6LYuuJ24X0Kds6PoX8dJbLk1E17NiKg8EdU18PN508Dg38h24uyeCxUay4FfoqhSB8RMG8RjoA/jBwghlleyKJQuo0k7TNMutKFD86dMFB21Cx8JiQXk81s2+/JoXqE1wsO05OaX6YEOgpaQQryMyHAc3V+s5HdhyF44WgNndEcewOsEfaaKyizAKi64z2HdwOiZ9rg7vAgZYPYGLZgHzqEuaKJlE5BlMcMgbwStOnuZhWDoEnPsqPmyTQdMKRgpW+EyThYo4W/JrYr8+GVWv3PZj4ZIHKLwqSSnMfpWcljnCGds5wiby1L1gWMNHCe2NWkTjMaoxIQosYR3zKFzazFLr6aJL8SNLGQmN8Ew5bLtuPeuat7AplvkRrvKXpD289ga0mFKvqgApl223/nU3hf8NTEBWT80+Nun3opgecw2qv/DZSldJRIAmLWku1Z3iQ6wkxftiproUyAsha4LypMBYTrprLrucSYfit87C60qoSGpP4AG9iYAtsbjVY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(366016)(1800799024)(6133799003)(10067099003)(56012099006)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?hfJTeUWvFC0HEvLBfLF5GlpsDniTi/647/X2tsmDC/OICXkuorjdvV0+4Hrg?= =?us-ascii?Q?eok+1wY2+XmQUpFV9/IikuMgoRHtcVbxZuR5aA+jMEfiStaQ8+vqovZ0svj7?= =?us-ascii?Q?ixGu6oIZBMVS0/VjmDVVOY86K0NlyYq2y3pq4qzQId/TnH7UObvbnlrxdJUB?= =?us-ascii?Q?dOa4FoGieq/GlTpAk1g7A8Qp9mnOAljL2VFWpzOHQQ0Pl0MEuJbsyn/JgQZv?= =?us-ascii?Q?43J5yqJe/y4nFGAmyqFWVqG76srXOBrDHKPBpZP++StRzlApURMRbFwUyME0?= =?us-ascii?Q?t4Fjs+vxa3PV1+NXrBpYH3fceQ7vNg7EHbiU6hCr6hS1gxuLyKNQYgHfA2CF?= =?us-ascii?Q?N2TF5IEwklvmjyHiMVhBoajfSUYtj9xtoumIfv9WYxpVdbLO9LaA0IrMxf2x?= =?us-ascii?Q?uf0/0YD7no8j5TxH266RIttCs86prwxI9geDGNnvbnwamh/KgZuOdIK5Ylzj?= =?us-ascii?Q?yhZMKi/jgNNdATD9LGrlmL64LjGrm2ONNrysaCuMpqukPujmBECjOPQW1FYg?= =?us-ascii?Q?XHIjrCvb3zd3/ptsvqInZYD2E4YYpWyzzOTR/b2NyK8X5c8EQRmted41cbF8?= =?us-ascii?Q?7d/SLMJCPyiZmKdao1jLsY+fxhGGWr1R2E0cELx2aRRbavL+/mcLdlwta6Mn?= =?us-ascii?Q?1amejfGPJ7thIOEAPBm9a8RfvaxIv2DWKSy/mdHJKLoNuRM6MLvPwOQiqGMz?= =?us-ascii?Q?RYakepUw2GvL06nIIZ+UhwntQ+TuT3B9S4FiFLvQqm3T4TH+cY1gdUyddz2y?= =?us-ascii?Q?zJvPaa4Ma4Hko5z964BwRXaH9ODtiTrxl3hXm0BuSVqQCgq5AFJKOvEXlH1U?= =?us-ascii?Q?siopeld4wvvS2WMqXhHO25awIPDIqT/8WbR/8J8zgX70fGSfZEs/9xjp6hqo?= =?us-ascii?Q?wpY5SwB1e+4y0zBcnNhTK+2l90bck1fFW8KjJFgdL90z8ZrsKF1CM38yzPcv?= =?us-ascii?Q?vvwRWS5BCsIHNZivluNTSn3bO/n7ZgxIaZcfKVEX8bLU6hRvh8D8PAoLDtQ3?= =?us-ascii?Q?RZuhnoonYXjyEt3le1fvLaVsuyjiWmXHCTqSq7ID52oLPhywahF+PElpE4IA?= =?us-ascii?Q?+tU97R/xxmtacfAYAeCf0fZzwLS09vMVygSXIoKtsOenViNLZtElAIKWZTSR?= =?us-ascii?Q?RuNMpXPsdbgrkHLfqRDR+VfT+FgyPg9meBnCSpYWtl2N5TWUlNtLho3cF23b?= =?us-ascii?Q?SQm0CIlodi/Qn1+iBuBx8iO70nyW1gFbLVpWRBR4bH1Tvx///S4PiNTS0z0k?= =?us-ascii?Q?75ZjGBdm5IvDi0ER8SzBU5MwWVQOxaQFBeClSIegmRRLlbjKgj/kVe3s2+Tf?= =?us-ascii?Q?1pPTjj+h4zKIHtOh5ylZ5X4AKjmM6c/Ky1iMHGuc68R7fg2Y2fv389ZXgAdm?= =?us-ascii?Q?jEiLGj+znM9KWA2ZM3OLqr6hFpVqOyjs7v/u1K6o6AtLjSNGBRSm18e7gp/A?= =?us-ascii?Q?ol+6UDRB7ne8CRZvyQ6IOw1QlhJtiTWzBLT1cbFJ0/rk4hx8ghh2Gck96l9D?= =?us-ascii?Q?MiwmcVVkIvGXMuYaWj1zA67IpkHDrWRYxwvbw3R6S57xD2EAZFzdM84MVcyq?= =?us-ascii?Q?zLUJrkIJOzPTHEkrRBcj9iAoeoCmvbNA/okf5U/2LX6fBZ0S1cGL4tv/rurS?= =?us-ascii?Q?59cmrog5i0ST+2oOLxWJM+oTM14EYFGfpXdu6B2yMXGrsN0Ru4fDmm0/o47j?= =?us-ascii?Q?rsRgmII1YG3cjwSC2hvFb5ax7vwfcY6hxxcq6DEt8NNH/OJ8QYvxRzszEHaH?= =?us-ascii?Q?9zbW8Re3Yg=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b7a5c98-e38c-4560-7c49-08df056c0a94 X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:22:50.3797 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: V2mUNs1Wfs5IOi/r20dBmqp3/qvJlm+EsM/L7diYwJVlKSZhNlMjsxShPUIuif6oQhvwFJxw4RU1MxoFPK7Nng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6125 Content-Type: text/plain; charset="utf-8" From: Joel Fernandes A driver that runs an interrupt self-test during probe waits for the handler to fire. wait_for_completion() has no timeout, so a broken interrupt path stalls probe indefinitely. Add a timeout variant of wait_for_completion(). Signed-off-by: Joel Fernandes [jhubbard: return the remaining jiffies] Signed-off-by: John Hubbard Reviewed-by: Alexandre Courbot --- rust/kernel/sync/completion.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/rust/kernel/sync/completion.rs b/rust/kernel/sync/completion.rs index 35ff049ff078..7e8b3c1c880e 100644 --- a/rust/kernel/sync/completion.rs +++ b/rust/kernel/sync/completion.rs @@ -6,7 +6,12 @@ //! //! C header: [`include/linux/completion.h`](srctree/include/linux/complet= ion.h) =20 -use crate::{bindings, prelude::*, types::Opaque}; +use crate::{ + bindings, + prelude::*, + time::Jiffies, + types::Opaque, // +}; =20 /// Synchronization primitive to signal when a certain task has been compl= eted. /// @@ -111,4 +116,20 @@ pub fn wait_for_completion(&self) { // SAFETY: `self.as_raw()` is a pointer to a valid `struct complet= ion`. unsafe { bindings::wait_for_completion(self.as_raw()) }; } + + /// Wait for completion of a task, with a timeout. + /// + /// This method waits for the completion of a task, or until `timeout`= elapses. It is not + /// interruptible. Returns the number of jiffies left when the task co= mpleted, or [`None`] if + /// `timeout` elapsed first. + /// + /// See also [`Completion::complete_all`]. + #[inline] + pub fn wait_for_completion_timeout(&self, timeout: Jiffies) -> Option<= Jiffies> { + // SAFETY: `self.as_raw()` is a pointer to a valid `struct complet= ion`. + match unsafe { bindings::wait_for_completion_timeout(self.as_raw()= , timeout) } { + 0 =3D> None, + remaining =3D> Some(remaining), + } + } } --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011007.outbound.protection.outlook.com [52.101.52.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 8D09C3A1A3F for ; Sat, 29 Aug 2026 01:22:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.7 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787966580; cv=fail; b=e9bnk/hriIbwdeufozn2f4Nsvm3khZTe93KQKIne+LT9+4KszRzyk9UonkmJHFuFiqG3eh9sX6Y1w/i/vkCnqEVf1LyLPcclRwmGiHdlZb5aMsCh5YiTXhy/P3+2K9FnA+InepQoFQeg7I78eTSTStNq3nfek6ULEbM4WNRKwMU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787966580; c=relaxed/simple; bh=WxYrFRx6cuSzIvQoDB9aMRoEf/00SQtDg7LPAXmOSuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=sV+9frD3EIQsmfC2ew3kMIiNY0HxrtvBECgXV0//oS0klPHLjz3u2MbGe9i1gLYR+L0tUHX62mInqANxAnYGXqC+PAD8ubl+1H/azND3DjHq7CUDmvlJcqSHGLteuFBrUrbo3nCENPXRBkiWJcQtpZPK9ZZMCnubr5oKePptksY= 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=gI3dnDGg; arc=fail smtp.client-ip=52.101.52.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="gI3dnDGg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=H/th6RIyhqsbb/Eym7qcFH4rwSyrfvojhQe2QfKxhcaZnFbEr72uatr6HTyXuosIevznBf4sz/NTUoUx58zcdTTl5G2D7yhUIVKWjhyzqQce9uxBUt9u0qSkR9QeH9uD8+Nnpzn26Ro00GrHgIVIV5yB7298LJCynxscA0da8GsLo0ibhFpApyrJ1YdG6ayFf7zptb7bzHzhJ3UwB53s53oniaknBv6tlP8Ms6Ehe330XbNJx3CCw1V5I75+CTmIuxIV5Bf20iXltc3UWPtXvGrYgvrlIQcylbizxXCtXDCurdoonKVyhM8vgSZdTMZQe88RoqRZNKjRICJDYbIETg== 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=ibdM4QPTlPbdV9RkNobEMbK0JZY5Dd0tofb4iLFIs7M=; b=sk1poa5NQBewzzgxvfAFSrBOV0R2T8GmtaIBPF1R1Bz69YuHJAvAOyF9MBhsaVoYN8m+2WbaKroKNz5fHHb5qySjf6hD98BRhcJ/ndxcagCHWWnwx18LX8bpEvDwpifujg9DJemF8LLYxwwO2FJrY+FnYpUTQEQXUrSQvBwJPMzzCw6e5FFTT6V/2PZ8tY6Aha/21f4hxRAHMawCO/jy0RRN3J9nAWpU4EzPqFYxTXSaIx5LgHrNHQmItuOMGAfdZF0Ash5cGDX69XOEQ/DP21bhvLmwE0NYbV++vkteKxIFRsWsjAjiE0Ic+us205jDXGOiMYIuDx9BwVhTKUN4lw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ibdM4QPTlPbdV9RkNobEMbK0JZY5Dd0tofb4iLFIs7M=; b=gI3dnDGgvu+kJr5FH+QFqFuPlgDmhLRVuCs1CZHmU4wrLSMi+Uws8ykbRFCg9aCt5JW/o0z+8dPFa7UqLCCTk7VSYvhZSO/PmMVcoo5m0F68jJ4zqViyEiyauY41dn57aBShJk4tPZf6SOZ9dz0w789BK3So1uyhYr/ZQEkfuqAWSuMIsY6B3x8Kp1UDS8KAsEoPvMcKbweN7M6s+kMnSDm8uP+mE7OLPs5halcd20BS41Zt5o+9dPw9bWTPA/iShtqAOD+QS3ILSWuOilAd7GnA1iEEWDl0IHEK170w1CEJL1alysmah7SrK6iG3dh0b7w4Q8yJBgFqucHBf2nXLA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by MN0PR12MB6125.namprd12.prod.outlook.com (2603:10b6:208:3c7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:22:51 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:22:51 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard , Will Pierce Subject: [PATCH v2 03/15] gpu: nova-core: add the GIN CPU interrupt tree and MSI EOI registers Date: Fri, 28 Aug 2026 18:22:31 -0700 Message-ID: <20260829012243.496697-4-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR05CA0009.namprd05.prod.outlook.com (2603:10b6:a03:33b::14) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|MN0PR12MB6125:EE_ X-MS-Office365-Filtering-Correlation-Id: 0bfccb28-795a-44c5-2c3c-08df056c0b64 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|366016|1800799024|6133799003|10067099003|56012099006|5023799004|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: QtdkzJXqlBn33tVPe1zpOWFLkeG23HNdXB3iYxeBlqIdVE2hIHnYS3Sn0cnLVEFu7KMnVk+Q0KkuDFdmp97MW8yvzB3/OprUR3iSOxQIPaXyckePZX6Cc8ujCbB3Dc93DU0Cto8H8LwK5jBw56FH4l1LWiyjBedJJVqtqlTdql+uS81XjxxMRWv7kpxvTH5VkOQ1Oecu/tMZdxPza444MEl67bfcGmnmgIwkFNFgHN5aH8do5PCxc7a1v2uBz3jz4FwxdZxX2hdc4879HT66j3AmAf5Pi4mLeV8XHic4FmoZG5GL/RNEzLkQ79WGP4Qkr0jopGKpq2HL1F/zW/CRXaAsbs4HvV/tQPkSrBRXeVnxlqZP82pLWYIDO006ojKSJFBpWl8ciIT4CAGEoJz1atL9oq6QB2AjKB5VOmeWteOWoL/G3rhP7oLAzW/b90K4ZVR+xWrNH03l1uMsg6uWDcQMbw9awoPX7hDxzNGm3y+Qz7cCcPsGFFTi4/pImgupF/ww/jIa8Mlwhs8r0vdBheh/CPKTmso7iAG7l5k13zQ8WjA0kdxORJzg3mkG0lj/EMUH8LcdW+pvfYmprfB9wWkAU7BMw0vKCzLNps5AN//AfcW0tjAeNHrf628O8IaBr32WXSanFbiSM8OmoMESqsqZXZmCouTWnA+h+XMFK+k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(366016)(1800799024)(6133799003)(10067099003)(56012099006)(5023799004)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?WLueG0iA/wijZej2p9Ri49c4hi9N/4+g4nOK3E87qwoTSbpCcycn/7HH3PF8?= =?us-ascii?Q?PMi+ySTPqCYV6RHGuLrrm/8vRl/zFaojEK+Uvxu7hPmCZgRfIVXBM1rvpfS9?= =?us-ascii?Q?oCNW05gj3zA+RtJ9MSS2S0TxTv7zcZkRBftaSl9QjY+XKxdp+vLSHIpczTcr?= =?us-ascii?Q?RLkF6RInlgSXZVCbJOkKfYhA3BenzAy/zpepUrzYZHxwOLGd8P7+o9KESxfq?= =?us-ascii?Q?Uhdef5/oWotG/qopvxSuqqr19vcI+IYH/vlUVpikkpE9G/r9AptLQD5q4XnD?= =?us-ascii?Q?X0rb24d6ROK03ohVMT7yPOa+6NAX/5IiJngCDhuIipfJXMKTPoaEeBQdPeZF?= =?us-ascii?Q?SwbqyD4OZVKofrQaXK9WNgXQaUlMFY0k9AzQOcmzz/Rd+LJ5Mrvk0HDGGSa6?= =?us-ascii?Q?NWsGO+PEn2VxsVATTCBa1oRBmeNIS5k1uc6aZ7dIwgNPkrj/ax2J4668nZi6?= =?us-ascii?Q?A6FrtNJKMwZg+OyHNooviRNSPNZyHWR/FFW5QFEspu9W7x+Tn3vMBWxr0qTP?= =?us-ascii?Q?ES+w+RohnUd+fhNkFhc1lzbXAqRE7eOKiNpDrVh+X7cku8cOplGx5hLXXbQ8?= =?us-ascii?Q?oYcbO14rq3S/dU57oFETkus3l19PWaiUqpPKOsoR8pdMOtkoPBtdvXX808qZ?= =?us-ascii?Q?gftPXY36xEzqJgNSoD23fKrsaopxrSWLS39aTOPH+9cuKfwSfVH0yIG1my3d?= =?us-ascii?Q?mDqImsl7kTrYYf0zPxMLoAeRcfAHdT6B6rlZgy92o4adZrsBMQWeT4wQ+DIY?= =?us-ascii?Q?9pU60TQAe4Iw8r4y/JqE5jE0ivUAFZZjKt6LQ/PWiswkYUU7/8Bxuj6nLb/9?= =?us-ascii?Q?Oymy9eFbZ0MPnwku9P2GqUb2ASR2ZnTUj2zNhfrlQj1bUKfQfngPPgabeOAu?= =?us-ascii?Q?jEvPMmSHZCLeXftIW5HBFapOhtlj2/+Gfr9tQZnn/AjpgVkAyADOEVBida+o?= =?us-ascii?Q?pw8OxKjxdgO/WQy0+lsYyKuRTRxyPq+dg/Y4TFiZwlUPpS8/F21GGJt6v1Ry?= =?us-ascii?Q?bQAlsdrDcKtiHTKKR0zfLmIuxbTb98q06/Anbmg1nlnaR12bHiPgN+2UsZeh?= =?us-ascii?Q?KAfgD3nbCOuKUBhHXNCNAsiU9o6RP6zeSaAwZAtE92bL/6GRsnLr0fF+AJr3?= =?us-ascii?Q?EM7ixGnHcMdQpiJi273mupLvXrREs0ZqrvqpHUV0f1xPOdtYFzgFGCX4kQ9R?= =?us-ascii?Q?i/rebtJAKz4dZHWGsqFMgD8Ttj/Uhq8qF7d04rdkfOtKLO00Jkz8ieOihL31?= =?us-ascii?Q?bcTfIOlB8RDOs+71NRQwnWmCJsiFmc7XnpPybb+8j4tUrOu5PVIFUZOggD9+?= =?us-ascii?Q?U/l/t9ki58OoEzog4JOAeujG6+lil68S4iminy4RZTG1DzUQTfKgkS0O4f8x?= =?us-ascii?Q?f04O3CaR4vGBapgDJ/OwHu5qUbIfpFDywtG8hsv3dAy57xxNH85gQ4EouRlb?= =?us-ascii?Q?+Ogq9mE83hLg7Bc9xAxOXOTta/sICMHv5IGK6WQA0HVoLxxdzaPoJZXyZmS4?= =?us-ascii?Q?ceFiIOJOOZGZ4chkFaROFuDE4M/Ahmfel45xb+ZakpS7DI9vzs7T/VOg9ozb?= =?us-ascii?Q?52LCLXcFGLqFR6+40fp0fkbNyMPlAF/2s5KkKdtNI3rGOz4WRC3x3dh/P72s?= =?us-ascii?Q?8ToE9vCEF203S3lXuUb1YJ/ymuJOZunFTkEH7HIq0sGJIvR1YC7MJB30svwY?= =?us-ascii?Q?7FyKL84aMO+r8a5gP+HS0sJ7b+Lfrdun9POPtYMVrp28b9ljA8Fr7Tw1iJpk?= =?us-ascii?Q?SuUePasPJw=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0bfccb28-795a-44c5-2c3c-08df056c0b64 X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:22:51.7107 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: i7HsknvdexhNqjhjQ0md2xZdMrOg825h4cuf4GQpogOSWw69CLd+p2+uzbf8gRnK0Cvc13yUDiFi9580Y12AMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6125 Content-Type: text/plain; charset="utf-8" GIN is the GPU's interrupt controller. It records interrupt sources in a two-level tree and signals the CPU over PCI when an enabled vector becomes pending. Add the CPU tree registers needed to receive GSP interrupts and to run the software-triggered interrupt self-test. A pre-Hopper GPU that signals over MSI requires delivery to be rearmed after each interrupt, by a write to the MSI end-of-interrupt register. Add that register. Assisted-by: Cursor:claude-opus-5 Reviewed-by: Will Pierce Signed-off-by: John Hubbard --- drivers/gpu/nova-core/irq.rs | 11 +++++ drivers/gpu/nova-core/irq/regs.rs | 71 ++++++++++++++++++++++++++++++ drivers/gpu/nova-core/nova_core.rs | 1 + 3 files changed, 83 insertions(+) create mode 100644 drivers/gpu/nova-core/irq.rs create mode 100644 drivers/gpu/nova-core/irq/regs.rs diff --git a/drivers/gpu/nova-core/irq.rs b/drivers/gpu/nova-core/irq.rs new file mode 100644 index 000000000000..6656a1a23d59 --- /dev/null +++ b/drivers/gpu/nova-core/irq.rs @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIA= TES. All rights reserved. + +//! GPU interrupt support. +//! +//! GIN, the GPU Interrupt and Notification unit, is the GPU's interrupt c= ontroller: a two-level +//! tree of pending and enable registers, one tree per PCIe function. +//! +//! See `Documentation/gpu/nova/core/interrupts.rst`. + +mod regs; diff --git a/drivers/gpu/nova-core/irq/regs.rs b/drivers/gpu/nova-core/irq/= regs.rs new file mode 100644 index 000000000000..a01a78d197bd --- /dev/null +++ b/drivers/gpu/nova-core/irq/regs.rs @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0 +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIA= TES. All rights reserved. + +use kernel::io::register; + +// GIN, the GPU's interrupt controller: the CPU interrupt tree. +// +// These registers are the two-level CPU interrupt tree at the +// `NV_VIRTUAL_FUNCTION_PRIV` aperture (base `0x00b8_0000`), which any fun= ction +// uses to reach its own tree. The leaf arrays have 16 entries, the widest= tree +// on any supported part. Pre-Hopper parts implement the first eight, and = the +// interrupt HAL supplies the count for a given architecture. See +// `Documentation/gpu/nova/core/interrupts.rst`. + +register! { + /// Latched state of the 32 vectors that belong to one leaf, one bit p= er vector. + /// + /// A read yields the vectors currently latched in leaf `i`. Vector `v= ` occupies bit `v % 32` + /// of leaf `v / 32`. Each bit is write-1-to-clear, and a write of `0`= does not affect the + /// value. Each bit must be cleared before its vector is serviced. + pub(super) NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_LEAF(u32)[16] @ 0x00b8100= 0 {} + + /// Enables individual vectors within one leaf. + /// + /// Each `1` written enables the matching vector for delivery to the C= PU. Zero bits leave + /// their vector as it was. + pub(super) NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_LEAF_EN_SET(u32)[16] @ 0x= 00b81200 {} + + /// Disables individual vectors within one leaf. + /// + /// Each `1` written disables the matching vector. The enable governs = delivery alone: a + /// disabled vector still latches in `LEAF`. + pub(super) NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_LEAF_EN_CLEAR(u32)[16] @ = 0x00b81400 {} + + /// Enables whole subtrees at the top of the tree. + /// + /// Bit `N` covers subtree `N`, which spans leaves `2N` and `2N + 1`. = Each `1` written enables + /// that subtree for delivery to the CPU, and zero bits leave their su= btree as it was. + /// + /// Hardware defines a single-element array here, and its one element = covers subtrees 0 through + /// 31, every subtree of the widest supported tree. nova-core declares= it as a scalar. + pub(super) NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_TOP_EN_SET(u32) @ 0x00b81= 608 {} + + /// Disables whole subtrees at the top of the tree. + /// + /// Bit `N` covers subtree `N`. Each `1` written disables that subtree= , and zero bits leave + /// their subtree as it was. + /// + /// Hardware defines a single-element array here, and its one element = covers subtrees 0 through + /// 31, every subtree of the widest supported tree. nova-core declares= it as a scalar. + pub(super) NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_TOP_EN_CLEAR(u32) @ 0x00b= 81610 {} + + /// Latches a vector from software. + /// + /// The vector named in the `vector` field latches in its `LEAF` regis= ter exactly as a hardware + /// source would latch it, and then reaches the CPU under the same ena= ble conditions. The + /// register is write-only. Every supported part implements it. + pub(super) NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_LEAF_TRIGGER(u32) @ 0x00b= 81640 { + /// Vector to latch. + 11:0 vector; + } +} + +// PCI configuration-space mirror, pre-Hopper only. + +register! { + /// MSI end-of-interrupt register. + /// + /// A `u32` write rearms MSI delivery on pre-Hopper GPUs. The value is= ignored. + pub(super) NV_XVE_CYA_2(u32) @ 0x0008_8704 {} +} diff --git a/drivers/gpu/nova-core/nova_core.rs b/drivers/gpu/nova-core/nov= a_core.rs index 35a8b1214b0e..68b5abfe494d 100644 --- a/drivers/gpu/nova-core/nova_core.rs +++ b/drivers/gpu/nova-core/nova_core.rs @@ -17,6 +17,7 @@ mod fsp; mod gpu; mod gsp; +mod irq; mod mctp; #[macro_use] mod num; --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011007.outbound.protection.outlook.com [52.101.52.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 68D823A8758 for ; Sat, 29 Aug 2026 01:23:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.7 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787966585; cv=fail; b=KDywUOIx/KvIHXoe5fgEfohVylBMa2/stTBWJdcOL6syCiodgPGyzRFQROTc2cK9fl8DDEUUtW46sUBkA4squq86kemKo85zh8hGhAzgPAY4NQQ9gGXmW+sRV7IXpLKf+ryrIGfTvsFy9TthJdAeCoMZtcKjD4hE7OWgBAbfIhk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787966585; c=relaxed/simple; bh=Y9pYXxJkCbYlEc042YAi7AgL6rDsJigXtGMdc+z0ZXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=qaaoDgBRpfejzQQndYV5X/9Ulp5tHCYjflWVDlZJsUqVaVRl007NMInLqOnbJj/4AodERPXzgDyxxUusfbOGgZD3HLPogiwHCtmjmTbzBfhieg1+neuVHUpssNxr9bC8lbBoRX/rKH9ZfH3enggprkBdhQYnhu2bPhYHFCs5pPs= 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=h/b3i0lZ; arc=fail smtp.client-ip=52.101.52.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="h/b3i0lZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IBtoBaRhG/C1/UACt4G5sYIlmvOmVQRg+o8bm2Cm55/Kk2OUqymeOmX9zFk3Hp6cDPUURul+lP8nyG99wUPv4S4sOzQS8MZHfLXz44tiZb7s8+MThKM3Ohfbyt19T04oktuTNaiDVnY9V7G3XXfRagyh8RpUby57K/WvAbxB2fz8BUx/R1XbANF83l8WmX++g6Z3ywz1Y27G6WnfyDUZbH/ahigI61ywPCDcwO01VJRW2j5JOwwDirkNNat/CxNKTL8cgFclLjDzYYfHsDVxX7yo3NLm2jRSqd2h+GmTlyThpbssuURluXqO1DxttabKf5zXdx+W2E+jqdWaJctnRg== 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=Mo984nfQGR/pb/88cAxFJxt4MakBkDZR+7JRFkqMggE=; b=otJ7ZAim54ZnKzaTK3PeLZDNjtJBj8Gf1T8WCVlWuTWtJnuCXZN4r+gBjiefdRuFfcw2P9eG/h0pmZ2g4rrokUdGOiLJsdVlpExfeUm/PHP8oxLsdaCiTabzVs2Im4KD5gSKztAftypv9aSP+GzFpdKBzXGYsMIjR7tjr4Qf+768CARXVRoCELI+0E7sEi+ms3TiK4Z7OIzmpP7WZQxAKvNi+v5e/7TB1j/qA1cjaI7FKigj8GnlgXrVUw/1x5jNUqry6bkFCrOXpzSOHbGz/HXjGOyxE9ju9TAVKgQqO1MklEV3n7G6X/dL5n2/krfYYWd4VMbemZunozfHdzOHcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Mo984nfQGR/pb/88cAxFJxt4MakBkDZR+7JRFkqMggE=; b=h/b3i0lZ9ojiTyaR7Hx8Aqj5EermbN6L3btC3UR8nWZ/CI7PeoAETpoRtkkQt5qkNCJs8A22FgiYrXD5vd5g2vpmcXKAglK+qzZO4U8ptc6IIMqs3hvLmBOojGNInN8iBSEKAGdpUF8ppJXdRLxkqZCxZaFYCBg3HoXxYq1lZXLSoFPuQxtM1Ok60VjBP4spWCrRTf3ZPDueW0HULbde6r+lllgGWNgdof9kzcdkdkxh76epmB7jXy0W3Em3N7flVBzU250HaArOzEkaD5zPSLo2cyxAu/xO9ZDtIDvFGeRKjInZuQLBhwkc/doql6G23BgdnrUS8CaVVifvT3Kb2w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by MN0PR12MB6125.namprd12.prod.outlook.com (2603:10b6:208:3c7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:22:53 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:22:53 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard Subject: [PATCH v2 04/15] gpu: nova-core: add the GIN vector and subtree newtypes Date: Fri, 28 Aug 2026 18:22:32 -0700 Message-ID: <20260829012243.496697-5-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ2P220CA0010.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:5da::7) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|MN0PR12MB6125:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fb54699-f3f3-4823-92ec-08df056c0c1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|366016|1800799024|6133799003|10067099003|56012099006|5023799004|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: R7vQZPeyVaLC5l6ypguq3CwwDjBCcA8GXoO8xrgJuabLxwOckzRPQKh/HWRhqpAeMvlTy8//+AsIzkMJGHECLxc97uJpPLdYUuo7SbZYDAFlrD6cdUuLlmo8CXjeymdGLGmK0v4hHrOD+1TztX40SbNaVI5sodXPZx3SAJI86jO5JE9wfAwZd2eixaNYl6Cuf9jNuxoSWheZU2wqlQZY0qMaewUhG/gbGzT2Fn0KEXK5fdjb8OY5FJ8IgNv81yp8ncCQnDgZCloV1JDNIBZEoiMG4HSmt7BHasng018ZCWQ2u+vKTMTA3XO5ubWOQUnqXO+G1Ceij9sC2skvurDgTSXV+ZB7pgOoBQvZVgIJtCjbcOg3AGKxsYUy78DkeYQFvYmFDAqVjt7phM8D35RExTjcJHgor70LbK8DCnhqaZAmvyuCvUsclh6hHXOGd86aB4MIa+vHqoNgxA0hDlvrjHzJ+7zzjFR6OoskaIa7NIwq/+z1qkFcP7Lq8UbVC3506x7rXyRqQjoRuKAfphSeMX/2npbuHiBe76eOYaagZ8lZG/CgdCLuy63y3ro/3Yut/+/KIimOAWFb1V5egvMjXCn3WskvHOhh5phNEZ+5dH0IffiCh3Tm34iTn8t9ZZ0ZWlye2Vb0nRKYjE2fllFsh3Tja9Rlc+9tVNppjjvBi4Y= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(366016)(1800799024)(6133799003)(10067099003)(56012099006)(5023799004)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?M0A2mLt4nFpJWmFWoeL2Zava5AKorF4wAxFQaCU1udNYc2gQMOx6fSup8AFS?= =?us-ascii?Q?ztrj5DIGGvC6I1B64Nq4Vde+L6u2omFdEYl2BA60It34tIq0/MjYHN4NZXUm?= =?us-ascii?Q?rtN9PulH9Xdii5XSzI+D0ijIiDihBSTZDtUTwIeCpEp0dOqG5/iHA3ZeQs81?= =?us-ascii?Q?GaJcr4ZSray63zqtsXbm7lGc6N4CJGbYPI3uqwb4yZRZkgpasEHGOGmg3rA1?= =?us-ascii?Q?xvEiS2RmdIqtzqHGX12W9plG8T1TJUSzF2OzE+Sc9yB4DRhaSLrXA2a1H1zW?= =?us-ascii?Q?IUG98FsiwDROU8oZ6oZRvdpJV2IJTFtfX8Oj+ZPX1fhYahPnCUj/ZyTdrv0W?= =?us-ascii?Q?IyFslPrpKaiJlxvOq+PSjHTuj/QQp36DGMFqI4D7KT35OzuItW7o7K93UnwJ?= =?us-ascii?Q?lmIi4BcBEEIwmcCvqLLynQGtuEINMO5AzihbReu2HEXtTJcFgGidId7yWrUm?= =?us-ascii?Q?we0n2cpgIobZvH4lI38Dfhw0RP1MOFnOfEe/BUypY+/GqOHczSZ57sU1Ef4D?= =?us-ascii?Q?tTmM4AnFE43WOb6fSNeYgnjfmeg55m+bZk9OcMcs1ch/v4l2jNOGjctle/LX?= =?us-ascii?Q?aKp6+FlLPYkksLySUjS1NoqpPXD57HGEG0YwwmLFgCDta9V1IwKaSRl0R44f?= =?us-ascii?Q?1YCB/CCDngWMSWcfS59ZU5L6gqPyjCe7zmgd/7iaGz7xACNckJu7Uay/4Cqp?= =?us-ascii?Q?jV0NU/0tT5KR3Hau/4zpUmyQQ4D8IEW/Ohcb2dIJDh/MNUeosvIiowj5pat4?= =?us-ascii?Q?UDWubzB3cKKyzbMitBqcoV9EA0/pjFT11V5mihK+H+LSiJF08lFboX2nA5SJ?= =?us-ascii?Q?m34vTn4roK5UTnZV9KuafWMrPYmWhtml/VX60PQB0B+ureFNpe/tlVL7eOfj?= =?us-ascii?Q?V9HZN0QcxdJVCXoTfYYskprZA7ykQZdnZykRG7GXbBRws1x1q54PT3kaip2F?= =?us-ascii?Q?Z1cvuFFi4IWpggUZJipGrpd8didkaXaC9T3Kdv/vN9w9tBoorN6fWkoCfg6z?= =?us-ascii?Q?X2LZ4UEixtYjXG14t7L7Z4t0NHxWRTWP+rOlQ9w2StJbKDUQxIOY7/bjpnE6?= =?us-ascii?Q?P9W4LXaVZIQQlnlxcuYbAM8TJxbZ7AJBGGg5OXlC9aeuWoZVlBepHiNkKU38?= =?us-ascii?Q?A9jBGH0869ps/ThYkLxyz0igtajVJBNOQx0ha/GG4obKPPT0AE+U+uKa4BQR?= =?us-ascii?Q?bgG8l2uj5+OjiPE9yHM4asjzRmHsBsKPh40VagUAfUhoYwe23vXyfEM++OV0?= =?us-ascii?Q?sw49Bg6ZOxp6M5RpgF7VKJ+t0c61Ktk65hCIsSZIAFTwx01CUMhePUAru9wE?= =?us-ascii?Q?l5WKuTTpf3dygSC7DvcvVukVtSIB9PhJJ7TNKWizWzf5T9Z3OrCD4hTfqt3g?= =?us-ascii?Q?mSWrF9jY1lq/XWOGxLUE/1QKCz1epv0WfljMeHZi2UmQOi60rv2Qbw2j6Hk6?= =?us-ascii?Q?FqYkhUPvPJCeBGQ15mNuU2trJHAgG1a/jl0w0MU0qejFCGJY8VPZSLGvIGlq?= =?us-ascii?Q?SRWg107Y/w6NPXY3iscXd/5AHJwOXsyjQaNDd3kEnQIAz+pMQCHbDIV4wXk4?= =?us-ascii?Q?+9CwvhxNKoKWMMVZZPp3iW5YGYwbRGusa0eIRRnhTCp04elsodCKfiAp8Omq?= =?us-ascii?Q?3kcEvpLUOsLQdRRNwQZyY34ePZbB5xDbPCv8SviKUbhXGIwE+v2+cOmupoIC?= =?us-ascii?Q?WmlYw5Q32fl79yitQYJ3QTuUC29ZiYQ9SKpJ/LhKAtBauucE82kl3rUHFjm4?= =?us-ascii?Q?oWJf8LPgNQ=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1fb54699-f3f3-4823-92ec-08df056c0c1c X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:22:52.9398 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jA6vQ2tSPi0Rat8xZk70Hh2vbQY40DwJdUHfnBI+q1ItHqgCmAp42iZbzFVk8zP3fuCmayoTXijW96tpdH9mGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6125 Content-Type: text/plain; charset="utf-8" A GIN vector's number fixes its position in the interrupt tree: it latches in leaf vector / 32 at bit vector % 32, in subtree vector / 64. A tree implements either 8 or 16 leaves, which sets both its subtree count and its highest usable vector. Each of those is a bare bit pattern, so a leaf mask and a TOP bit are interchangeable to the compiler. Add a type for each: a vector, a leaf index, a set of vectors within one leaf, one subtree, a set of subtrees, and a leaf count. A vector converts to its own leaf, bit and subtree. A leaf count yields the subtree set it implements. Suggested-by: Danilo Krummrich Signed-off-by: John Hubbard --- drivers/gpu/nova-core/irq.rs | 1 + drivers/gpu/nova-core/irq/interrupt_tree.rs | 209 ++++++++++++++++++++ drivers/gpu/nova-core/nova_core.rs | 1 + 3 files changed, 211 insertions(+) create mode 100644 drivers/gpu/nova-core/irq/interrupt_tree.rs diff --git a/drivers/gpu/nova-core/irq.rs b/drivers/gpu/nova-core/irq.rs index 6656a1a23d59..3066ceeb850c 100644 --- a/drivers/gpu/nova-core/irq.rs +++ b/drivers/gpu/nova-core/irq.rs @@ -8,4 +8,5 @@ //! //! See `Documentation/gpu/nova/core/interrupts.rst`. =20 +mod interrupt_tree; mod regs; diff --git a/drivers/gpu/nova-core/irq/interrupt_tree.rs b/drivers/gpu/nova= -core/irq/interrupt_tree.rs new file mode 100644 index 000000000000..da24f3d35893 --- /dev/null +++ b/drivers/gpu/nova-core/irq/interrupt_tree.rs @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: GPL-2.0 +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIA= TES. All rights reserved. + +//! Vector addressing in the GIN CPU interrupt tree. +//! +//! A vector's number fixes where it latches: leaf `vector / 32` at bit `v= ector % 32`, and that +//! leaf belongs to subtree `vector / 64`. The types here keep those three= views apart, so a leaf +//! index, a set of vectors within one leaf, and a `TOP` bit cannot stand = in for one another. + +use kernel::{ + num::Bounded, + prelude::*, // +}; + +/// Index of a leaf register, bounded to the `0..16` range covered by the = leaf register arrays. +pub(super) type LeafIndex =3D Bounded; + +/// Number of vectors one leaf register carries, one per bit. +const VECTORS_PER_LEAF: u32 =3D 32; + +/// Number of leaves one subtree covers. +const LEAVES_PER_SUBTREE: u32 =3D 2; + +/// Mask that bounds a leaf index to the leaf register arrays. +const LEAF_INDEX_MASK: usize =3D LeafCount::Sixteen.into_raw() - 1; + +/// Number of leaves a tree implements. +/// +/// Every supported part implements one of these two counts, and the inter= rupt HAL names the one +/// its architecture uses. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[repr(usize)] +pub(super) enum LeafCount { + /// Turing through Ada. + Eight =3D 8, + + /// Hopper and later. + Sixteen =3D 16, +} + +impl LeafCount { + /// Returns the number of leaves. + pub(super) const fn into_raw(self) -> usize { + self as usize + } + + /// Returns the number of subtrees, each of which covers two leaves. + pub(super) const fn subtree_count(self) -> u32 { + self as u32 / LEAVES_PER_SUBTREE + } + + /// Returns the set of every subtree a tree of this size implements. + pub(super) const fn subtree_set(self) -> SubtreeSet { + SubtreeSet((1u32 << self.subtree_count()) - 1) + } + + /// Returns the number of vectors a tree of this size carries. + pub(super) const fn vector_count(self) -> u32 { + self as u32 * VECTORS_PER_LEAF + } +} + +/// Set of vectors within one leaf, one bit per vector. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(super) struct LeafMask(u32); + +impl LeafMask { + /// Returns the mask with every vector of the leaf set. + pub(super) const fn all() -> Self { + Self(u32::MAX) + } + + /// Returns the mask holding the vectors set in `raw`. + pub(super) const fn from_raw(raw: u32) -> Self { + Self(raw) + } + + /// Returns the mask as the value the leaf registers take. + pub(super) const fn into_raw(self) -> u32 { + self.0 + } + + /// Returns whether no vector is set. + pub(super) const fn is_empty(self) -> bool { + self.0 =3D=3D 0 + } + + /// Returns whether every vector set in `other` is also set here. + pub(super) const fn contains(self, other: Self) -> bool { + self.0 & other.0 =3D=3D other.0 + } +} + +/// One subtree, named by its `TOP` bit. +/// +/// # Invariants +/// +/// Exactly one bit is set. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(super) struct Subtree(u32); + +impl Subtree { + /// Returns this subtree's index within the tree. + /// + /// Under MSI-X this is also the index of the allocated entry the subt= ree raises. + pub(super) const fn index(self) -> u32 { + self.0.trailing_zeros() + } + + /// Returns the subtree as the value the `TOP` enable registers take. + pub(super) const fn into_raw(self) -> u32 { + self.0 + } +} + +/// Set of subtrees, one bit per subtree, in the layout the `TOP` enable r= egisters take. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(super) struct SubtreeSet(u32); + +impl SubtreeSet { + /// Returns whether `subtree` belongs to this set. + pub(super) const fn contains(self, subtree: Subtree) -> bool { + self.0 & subtree.into_raw() !=3D 0 + } + + /// Returns whether the set holds no subtree. + pub(super) const fn is_empty(self) -> bool { + self.0 =3D=3D 0 + } + + /// Returns the subtrees present in both sets. + pub(super) const fn intersection(self, other: Self) -> Self { + Self(self.0 & other.0) + } + + /// Returns the number of subtrees counted from subtree `0` through th= e highest one in this + /// set, which is `0` for an empty set. + pub(super) const fn span(self) -> u32 { + u32::BITS - self.0.leading_zeros() + } + + /// Returns the set as the value the `TOP` enable registers take. + pub(super) const fn into_raw(self) -> u32 { + self.0 + } +} + +impl From for SubtreeSet { + fn from(subtree: Subtree) -> Self { + Self(subtree.into_raw()) + } +} + +/// A GIN interrupt vector. +/// +/// # Invariants +/// +/// The vector lies within the widest tree any supported part implements. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(super) struct GinVector(u32); + +impl GinVector { + /// Returns the vector numbered `VECTOR`. + /// + /// Fails at build time if `VECTOR` lies outside the widest tree any s= upported part + /// implements. + pub(super) const fn new() -> Self { + build_assert!(VECTOR < LeafCount::Sixteen.vector_count()); + + // INVARIANT: `VECTOR` is within the widest supported tree. + Self(VECTOR) + } + + /// Returns the vector number. + pub(super) const fn into_raw(self) -> u32 { + self.0 + } + + /// Returns the leaf that carries this vector. + pub(super) fn leaf_index(self) -> LeafIndex { + // By the type invariant the quotient is already below 16, so the = mask changes nothing. It + // is what proves the bound to `from_expr`. + LeafIndex::from_expr(crate::num::u32_as_usize(self.0 / VECTORS_PER= _LEAF) & LEAF_INDEX_MASK) + } + + /// Returns this vector's bit within its leaf. + pub(super) const fn leaf_mask(self) -> LeafMask { + LeafMask(1 << (self.0 % VECTORS_PER_LEAF)) + } + + /// Returns the subtree that carries this vector. + pub(super) const fn subtree(self) -> Subtree { + // INVARIANT: a shift of `1` leaves exactly one bit set. + Subtree(1 << (self.0 / (VECTORS_PER_LEAF * LEAVES_PER_SUBTREE))) + } + + /// Checks that this vector lies within a tree of `leaves` leaves. + /// + /// # Errors + /// + /// `EINVAL` if the vector lies beyond the last leaf such a tree imple= ments. + pub(super) const fn validate(self, leaves: LeafCount) -> Result { + if self.0 >=3D leaves.vector_count() { + return Err(EINVAL); + } + + Ok(()) + } +} diff --git a/drivers/gpu/nova-core/nova_core.rs b/drivers/gpu/nova-core/nov= a_core.rs index 68b5abfe494d..dfd11dfe562c 100644 --- a/drivers/gpu/nova-core/nova_core.rs +++ b/drivers/gpu/nova-core/nova_core.rs @@ -17,6 +17,7 @@ mod fsp; mod gpu; mod gsp; +#[expect(dead_code)] mod irq; mod mctp; #[macro_use] --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011007.outbound.protection.outlook.com [52.101.52.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 2C2D537C93E for ; Sat, 29 Aug 2026 01:23:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.7 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787966586; cv=fail; b=QzKYIpdlBiVZxmiMcl5+fxj0Z2ZofXZ5aM0YYMhhdd8SJG9gHH+KIbMeO+JCp9FYfmp9tbF8cakt9HS0RhH5ZQmQ/4MJqRACadmVM90w7XoT92Jn/AaDHoz0CXjhHJ+uyw94qiQdVheR1QtsGj5XcVPsaJAhyRCwjBp6xzHOdYU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787966586; c=relaxed/simple; bh=0jNIMZV7DddEdyE+9AoYVOLLDp4/aKaA6ojxdI/vWC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Q6DDk8J83vdq3e12TBSZ3DtFGczSWKJ9yXcAOoYzV73jsAYz0RSADlQdtuNHHk65OkMu/lKNSF5bpDz8HmrcKkks6l6gd3nflyxquXKFaYEbgXZOG4RHD4W6LFNt0IqZhaHA5EhLEDSvmlSThi7QroQZsWFAvmBsWdCVEaRfoUM= 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=o7TFt3YA; arc=fail smtp.client-ip=52.101.52.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="o7TFt3YA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IZphpruZn7V+Xh6opaFOxVpWosFiJ49HrxL9LAObCjEWy7MRhb5KoilWBq7MmQY6V5o7U3g0jfMggA8M7H3mY9nDetFl4dPZUE4AcUqWOemEGnYrfaoA+KbGBnzX/SnYYfnqOyrlcEceEWPYRytgbgDgdYOgGRCue8JkwwlIutFXc0j91P6uVjTiHRLNne0ZVC/J58pzhlzC1y7+1wBAbjpNl5Cd4l2n31am3dcbz1C9bdLzjoNGRbAwBZLvcQu48+8fQOTaBEk6DHjON61q87mZvngHu7ZC2TM7UCSy1QQymGXmMeG+PauhsCi6hIrKvMmtK0HU3+I0SSrs6EQwgQ== 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=BhtvfWHqPYHrbizIucNd/EyShjvqWs0YJjFg8BRlFcM=; b=yau2b8zkJ+KiTaSA9qDd3pUmxZAgG1qHx3q/V1JMeR0NI+2X6ZPgUYO5P2mddqXH5Qy4ePiYFYmYAnofmALIK7ukx4p+jAfgWAWB0IJHJhRoV3dtZDI7Hb7g74us91r4XATAppejsuhWd0eq1OLMJaYbeNhj2ScYVB0W31GgLSD56QYphXKZpR/PoS/7xoBWt6O5GbC2DRSdPyxKLRKXhjK+H9uI1jdsEanGoP7D9AwHD2Oft/wMoVokTqPLEz9I7fZ31HNox/mbzWSF9qkwniANSbO2pUxIH5gkozyBiKmiGTXgn7ZjqFTkOgOzzANxXCcOue4LXbhVBGhFwJqlQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BhtvfWHqPYHrbizIucNd/EyShjvqWs0YJjFg8BRlFcM=; b=o7TFt3YAPyXqJ9SqAmrgfqlQ4/rJWJlPEgDkerLrH3VsXGdvzFv6kaa4VBnLSCkdyqS0v5q6vAwU5MBiDHPI1TxH52mwRU8hV7gaALVPvFbQpCNc/cdOoa5HPLCxtdZiQ9oPbWsGAy8HicdH6pb/ZM1fCPePffucVv3y60vAz33PPjZib4tziZezGb+utXaPIYikQ4Oel/TsPDbByg7N8ksoBiLVC43A8+OvaeLWHKjJEBJmvkyt/oAr84Q23AbfUCy6RhPhK/1HSdB85e3o2bn4DSF3FhTHfCdJy0e4boz8iiQVOTP4WFvQ2Yh532/4E1DeaTSk8s1WD/Y2Z9Qffw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by MN0PR12MB6125.namprd12.prod.outlook.com (2603:10b6:208:3c7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:22:54 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:22:54 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard , Will Pierce Subject: [PATCH v2 05/15] gpu: nova-core: add the per-architecture GIN CPU interrupt HAL Date: Fri, 28 Aug 2026 18:22:33 -0700 Message-ID: <20260829012243.496697-6-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR05CA0097.namprd05.prod.outlook.com (2603:10b6:a03:334::12) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|MN0PR12MB6125:EE_ X-MS-Office365-Filtering-Correlation-Id: 0cb4cb09-6473-4d12-f2c0-08df056c0cf2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|366016|1800799024|6133799003|3023799007|10067099003|56012099006|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: +aQlEqvFDcY1A0YGH74wSTRr4A9/vfK2P+kVBhBV62H8hN+cgY4udtONoudWgU8ngeagYYIU0kCy8s+h381/fkGrrl4S6R1p/9HsU7xxRNP1ZVnjWYWVA8P6MUv1jV1oIBRHH9hLvTtOA8Tb6htcDXQ0Tjsoxkqyjn57qLkz/pgqBAWKRQhLi91sku5/szDUkDQ4J3a8XE/sW2te2SiXtJNkuk/mYm27sPbQll19Z/znq+Le4Z9XFZLRH/cnCX7Y/TqiJDolNvxoJtkZoVmiCwaPjtU9TmKWQBTLxxnEFNN65VSJ2pel7qpCXuqw4RdTP54h2CwyCJSx1MrtzdKi2BcT6x9+BTQrKW+4Iy+Ysy15U8T/r2qxC3fz4MxQFSSfeVua5+Z+7DG4Pp9yMXXhC8MJt6W+y8LQVFz4gRnoMrrE/INgoMnSHIUJgu5C2hJ5qE3sCWLaG2R7L0TasILL7Dj30vPMXwwIN7jnjsMfo7j/twIFOr0IqOO26k/TADBigYwFHzZ6g7RpworrOF2+I0eOm1g9qi07IQmFz5LwI9ubMZ1tzDqXPxbUty12yl5RFg2iwftleV9lp4n/jIyRqAElQg/gVOws4mLdbI3ApBxXbsgic3OaPoD2K8gi81Sv8dO4iBRDCCJyHEP9wSSWcp4qflCGkXwwp7eWG5OBZVY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(366016)(1800799024)(6133799003)(3023799007)(10067099003)(56012099006)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?9ONqkxFdOgPoy+2lC3FReXoaC6I4TfO9uw861nNDa+WV3Xbl8r19hObWRSEa?= =?us-ascii?Q?Dhx9EJVIEYPplum9pwLSQUYfbxve9ZhD/Ibtfz8R9txXcry9RLv8xuN5BUO1?= =?us-ascii?Q?/xT6PSLmxvOe+hrLd4VrhIl71FzO/wwZ39K++yoXM+ds8hELmKySqILCtED7?= =?us-ascii?Q?lZVuNKD0M2/Ul2G4+PAQnzuUVfLID1vVY1WP7vx6yIVSHOt0eutJycywKvp8?= =?us-ascii?Q?v/T5vQiMAE6P2mpfOl39XuNrUWmHWN7kW60dcGJJJ4LH7Rvp3xJtVa3tc14j?= =?us-ascii?Q?uhkFx5FSrm1TTzZ6nKNbhcXWBgloLdL+xI96PTJovM4EK2s96N6lc25ZH2J3?= =?us-ascii?Q?VXoI4Ni0FTjWs/LpYiQP2K80H65QkOcNLvxWwWvnLf60pTRIOtx20nW60jDF?= =?us-ascii?Q?+trh7CZoLcnfnmo6EaDAtP+bYI/vPEHZOwQW9p/WvZy/K1peE26+HAqmSsgy?= =?us-ascii?Q?mduOjgUelt9lJ8sq43TFO5EZk9jwghmrGwiGTkxtcBvklP+p0DccI8DA/HzM?= =?us-ascii?Q?AuU+Ha9A4kmmGhKFyeXW+Bn5g9Yr0U4VZilkBw8PkMaEuSmqIG+sifbuLaMD?= =?us-ascii?Q?Bt4sdKWt9QHblQ+DDtpo8pLnEd6Xhqi65WC+0B22c+Wi272ighpvjAqCrscO?= =?us-ascii?Q?bAeuRhU3uijgZVXvOFrRwZjCu31r8snZRkeTcGiE0HQH0PHRyq6yU9jiTdiZ?= =?us-ascii?Q?5lzcf4ZxB5zT4qYWN/kxES4XDdjLC2U2I8rra3u7/kPPMH6gfW/d44snQ6j4?= =?us-ascii?Q?cYsLT1V5cauyxw+/pDOacyyFsNQMaWrLhwsZzXT1j41/k7yqisd4Hc7+VQet?= =?us-ascii?Q?6bXtj7H2VrlhMcOkIpNL1kl06cJy4tyPjnZnnXOwY9Oi5WyRggKZvgolSGKt?= =?us-ascii?Q?Rfou5JFCmN6HUOsb76C77xrOS5QEldLN2dkjCdXOGp8V1o3Ewx/YEko9F5LT?= =?us-ascii?Q?Lv/VoZsbOUrgr79miw0kL9Pa8lYp6K5fwSxILeDV4n4i5R5zL3FbqeiR4Inf?= =?us-ascii?Q?ufJMTVcqHTj28fHKu33BNu2Au+Q9AuWN3ioSmfuonNVA0Rh8cEL8XZ4aA7Tt?= =?us-ascii?Q?J49WRY0iCUPdsnok7EMNJK3zK9kUELuSNCQGx3j6NfxMwozVFLcaUgC/f3Cd?= =?us-ascii?Q?wr4u0pwuHz6IYjtPfCv5gEXIZyXdoqG54+WLcE9taHTQctcxx75E9bCDjD+r?= =?us-ascii?Q?2b3v5DB1ckVO8LkUCFidF95e1F7RsVgNLPC9gacKgsUK+zmncTpQjDSxnPLj?= =?us-ascii?Q?WDahCyDNSB5gsjxS6trmwKt/s26ZK4nxfRwgCEUx/pwH99VNmIyPRSFe/5ft?= =?us-ascii?Q?kh4EYa5yuoVgilv6HX3ZL9rnPQF8+mZ0jZ41ECLsPc8cxDHNKTSjOhj+PFTa?= =?us-ascii?Q?IvWM0VPSH+1DmRIE2LCgZ+RNZu1UT+Kr5wFxR87RSOWKY9/Y+smMIOWQYINk?= =?us-ascii?Q?bOr5FoHOGufin1z9NJx2ReM5ELa3JTCqqic8H87iVW62Li7LX3nO/Mr/kYf1?= =?us-ascii?Q?rV2irq5E5ShehtV5EGua+142TprKuxylLgWjPI1VblAai5ImY4sBYvHGCOXA?= =?us-ascii?Q?7CdeohE6Q4IRpf/zUeVtNOpRQz1+87npIK0hWxtCc1lGBK/Ig9GsdBKvFPxp?= =?us-ascii?Q?48VS/K+IH84MtlQrth30Aq0KCU3Oh67O6gHbopIRxKRo4x9CO7X40kRV35F4?= =?us-ascii?Q?KdVCHA/GZeWxME5FT8kzEe7Qq32yfQNTb0Oi4WB31CctYI47mTGMwtuWton7?= =?us-ascii?Q?6KdEu+/ysA=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0cb4cb09-6473-4d12-f2c0-08df056c0cf2 X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:22:54.3240 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2+0IlvAWm7lsWRQUDwCPSli+bMj/sZR/4TO26mcabZWiB3iZm0qKMD+LyzsR3eZ7CzcT3T3HJjkznrvTDSWXiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6125 Content-Type: text/plain; charset="utf-8" GIN, the GPU Interrupt and Notification unit, is the GPU's interrupt controller. Each PCIe function has its own tree, whose leaf count depends on the GPU family. Message-signaled delivery stops after each edge until the CPU rearms it, and the rearm write differs by family and interrupt type: * Pre-Hopper MSI writes an EOI through the BAR0 PCI configuration space mirror. * MSI for Hopper and later cycles the TOP enable bits of every serviced subtree. * MSI-X on any family cycles the bits of the handler's own subtree. Provide the leaf count and the rearm method through a per-architecture interrupt HAL. Assisted-by: Cursor:claude-opus-5 Reviewed-by: Will Pierce Signed-off-by: John Hubbard --- drivers/gpu/nova-core/irq.rs | 1 + drivers/gpu/nova-core/irq/hal.rs | 111 +++++++++++++++++++++++++ drivers/gpu/nova-core/irq/hal/gh100.rs | 31 +++++++ drivers/gpu/nova-core/irq/hal/tu102.rs | 30 +++++++ 4 files changed, 173 insertions(+) create mode 100644 drivers/gpu/nova-core/irq/hal.rs create mode 100644 drivers/gpu/nova-core/irq/hal/gh100.rs create mode 100644 drivers/gpu/nova-core/irq/hal/tu102.rs diff --git a/drivers/gpu/nova-core/irq.rs b/drivers/gpu/nova-core/irq.rs index 3066ceeb850c..02ecfc47f4d0 100644 --- a/drivers/gpu/nova-core/irq.rs +++ b/drivers/gpu/nova-core/irq.rs @@ -8,5 +8,6 @@ //! //! See `Documentation/gpu/nova/core/interrupts.rst`. =20 +mod hal; mod interrupt_tree; mod regs; diff --git a/drivers/gpu/nova-core/irq/hal.rs b/drivers/gpu/nova-core/irq/h= al.rs new file mode 100644 index 000000000000..ee354859b965 --- /dev/null +++ b/drivers/gpu/nova-core/irq/hal.rs @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: GPL-2.0 +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIA= TES. All rights reserved. + +//! Per-architecture properties of the GIN CPU interrupt tree. + +mod gh100; +mod tu102; + +use kernel::{ + io::Io, + pci::IrqType, // +}; + +use crate::{ + driver::Bar0, + gpu::{ + Architecture, + Chipset, // + }, // +}; + +use super::{ + interrupt_tree::{ + LeafCount, + Subtree, + SubtreeSet, // + }, + regs, // +}; + +/// Register write that restores PCI interrupt delivery to the CPU. +/// +/// A message-signaled interrupt is delivered once per edge, and the PCI s= ide delivers no further +/// interrupt until the CPU rearms it. A handler that returns without this= write receives no more +/// interrupts. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(super) enum PciIrqRearmMethod { + /// The MSI end-of-interrupt register in the BAR0 PCI configuration-sp= ace mirror, used by + /// MSI on pre-Hopper GPUs. + ConfigMirrorEoi, + + /// A clear then a set of the `TOP` enable bits of every serviced subt= ree, which produces the + /// edge that delivers the next interrupt. + /// + /// MSI has a single message that every subtree raises, so the rearm c= overs the whole serviced + /// set. + TopEnableCycleServiced, + + /// The same enable cycle, restricted to the one subtree the handler s= erves. + /// + /// MSI-X gives each subtree its own table entry and its own handler. + TopEnableCycleSubtree, +} + +impl PciIrqRearmMethod { + /// Performs this method's register write. + /// + /// `serviced` holds every subtree the driver services, and `subtree` = is the one subtree the + /// calling handler serves. Each method uses whichever of the two its = interrupt type delivers + /// on, so both are required. + pub(super) fn rearm(self, bar: Bar0<'_>, serviced: SubtreeSet, subtree= : Subtree) { + let subtrees =3D match self { + // The written value is ignored, so any write rearms delivery. + Self::ConfigMirrorEoi =3D> { + bar.write(regs::NV_XVE_CYA_2, 0u32.into()); + return; + } + Self::TopEnableCycleServiced =3D> serviced, + Self::TopEnableCycleSubtree =3D> SubtreeSet::from(subtree), + }; + + bar.write( + regs::NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_TOP_EN_CLEAR, + subtrees.into_raw().into(), + ); + bar.write( + regs::NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_TOP_EN_SET, + subtrees.into_raw().into(), + ); + } +} + +/// Per-architecture properties of the GIN CPU interrupt tree. +/// +/// The tree size and the method that rearms PCI interrupt delivery differ= by family. The tree +/// walk, the vector encoding, and the read-and-clear sequence do not, and= are in generic code. +/// +/// See `Documentation/gpu/nova/core/interrupts.rst`. +pub(super) trait CpuInterruptHal { + /// Returns the number of leaves the CPU tree implements. + /// + /// [`LeafCount::subtree_set`] gives the subtrees behind them, and + /// [`LeafCount::vector_count`] the vectors they carry. + fn leaf_count(&self) -> LeafCount; + + /// Returns the method that rearms PCI interrupt delivery for `irq_typ= e`. + /// + /// `None` means that `irq_type` needs no rearm write. That is the cas= e for `INTx`, which is + /// level-triggered, and which nova-core does not allocate. + fn pci_irq_rearm_method(&self, irq_type: IrqType) -> Option; +} + +/// Returns the [`CpuInterruptHal`] for `chipset`. +pub(super) fn cpu_interrupt_hal(chipset: Chipset) -> &'static dyn CpuInter= ruptHal { + match chipset.arch() { + Architecture::Turing | Architecture::Ampere | Architecture::Ada = =3D> tu102::TU102_HAL, + Architecture::Hopper | Architecture::BlackwellGB10x | Architecture= ::BlackwellGB20x =3D> { + gh100::GH100_HAL + } + } +} diff --git a/drivers/gpu/nova-core/irq/hal/gh100.rs b/drivers/gpu/nova-core= /irq/hal/gh100.rs new file mode 100644 index 000000000000..32b9b4a01adb --- /dev/null +++ b/drivers/gpu/nova-core/irq/hal/gh100.rs @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIA= TES. All rights reserved. + +use kernel::pci::IrqType; + +use super::{ + CpuInterruptHal, + LeafCount, + PciIrqRearmMethod, // +}; + +/// GIN parameters for Hopper and Blackwell, which implement a 16-leaf CPU= tree. Only 12 leaves +/// carry sources. +struct Gh100; + +impl CpuInterruptHal for Gh100 { + fn leaf_count(&self) -> LeafCount { + LeafCount::Sixteen + } + + fn pci_irq_rearm_method(&self, irq_type: IrqType) -> Option { + match irq_type { + IrqType::Intx =3D> None, + IrqType::Msi =3D> Some(PciIrqRearmMethod::TopEnableCycleServic= ed), + IrqType::MsiX =3D> Some(PciIrqRearmMethod::TopEnableCycleSubtr= ee), + } + } +} + +const GH100: Gh100 =3D Gh100; +pub(super) const GH100_HAL: &dyn CpuInterruptHal =3D &GH100; diff --git a/drivers/gpu/nova-core/irq/hal/tu102.rs b/drivers/gpu/nova-core= /irq/hal/tu102.rs new file mode 100644 index 000000000000..e22eb37906a8 --- /dev/null +++ b/drivers/gpu/nova-core/irq/hal/tu102.rs @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIA= TES. All rights reserved. + +use kernel::pci::IrqType; + +use super::{ + CpuInterruptHal, + LeafCount, + PciIrqRearmMethod, // +}; + +/// GIN parameters for Turing, Ampere, and Ada, which implement an 8-leaf = CPU tree. +struct Tu102; + +impl CpuInterruptHal for Tu102 { + fn leaf_count(&self) -> LeafCount { + LeafCount::Eight + } + + fn pci_irq_rearm_method(&self, irq_type: IrqType) -> Option { + match irq_type { + IrqType::Intx =3D> None, + IrqType::Msi =3D> Some(PciIrqRearmMethod::ConfigMirrorEoi), + IrqType::MsiX =3D> Some(PciIrqRearmMethod::TopEnableCycleSubtr= ee), + } + } +} + +const TU102: Tu102 =3D Tu102; +pub(super) const TU102_HAL: &dyn CpuInterruptHal =3D &TU102; --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011041.outbound.protection.outlook.com [52.101.52.41]) (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 6779E1A9FBA for ; Sat, 29 Aug 2026 01:33:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967218; cv=fail; b=BNZpQHRj8k1koUWOlmjr4jcEA5PNxctuLrrrawfpYWLSjUNiR89nVUPqaQRazjDp/aIaQ7MQUS7iaygwXyNTUIoHUAYTlI2SV92+MXvpgJ8ruPu1rTnrOdnPigvcP/Lph9pe5pY6OcmB0/I1mHFu05/+X/dUzcQ3mN0iFkmGeII= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967218; c=relaxed/simple; bh=w4sWyG+SxM6Q8F7vsIlgkiJHqvOFsKgcpBM7whEoVVY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=CrPPmTClR8YNyoV/l+iSHjAbGR+UBUxODsSNWsKvDWq4OPx93eRC8evB0opGWzSs0f1ikVFJpKYWX9GzU0qUInPXjJ5199SLTDtRonVMQYXz8wWeRGFz+bO5kN/hjhP4LA4m2FAfvcsz8W0oV5oYTwFrDi5lYjfPhKpXoypZl2U= 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=cpv60VHv; arc=fail smtp.client-ip=52.101.52.41 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="cpv60VHv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CD3BjaaWsEXHVXCeogcY6H2JBAuaup/1jnoyz+y3JuGCZLC9oapNEvftbphMps4bc0QcY0x84VkFr7lyuR/uHi6LaEN1bkXMHWVaEgo6S+piWWzNdOi/k87O33kVXzhMlSOam+Q4+gLLvlNiw2OS+vJHe6+QRmuQx3cIMW7Da8wDjM/5OK40tpgWPxQxM3NhU9NjqzoWbYSvS3778OHH3ZM+zc/4e92mCCxTM3hfgZ/3Qif4mAPrHvYs/cHfIxLPpHUGkLehfwHUX95FIuROGnmFpCqa5Dc/PLa9WE6uTu8zAbjCujDb03bLT4GtUQBk+3vx4ynH+y/1X37J4InaEQ== 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=YOWkoMNv4jn5aRBD1G6M6IRId8wNLOa3O3Y/4Vsd3wY=; b=o8WUAN6fRJqCyejKwzscJ6PpM06eP5ZHdSUFt+3bKSCscoqu+mEzncGRJeWQDznAYyr3WK7BhWqDGk29NCFU/RprtDgJvxyCZbnFaeMeEgzAWuBrDzqRnJTqBEADzMNRYZx7ocjJ6DXDWFuUwGuft9FU45f0zs1IPxQy0SQ5N6KG7poweSUehkpe/5snNCJorpHs7LsMcYgsRDO8ANumkVGnv9WoUezuEVL6jkqq9dY7F8/ThobM2BPmPsGpRP3UQCOaW20y2f/cVmCASfiaRGeHUNQBzYZW6MN2OcDdWQyQbUCIohUKzgb+KhMa+O3FfdI1ATNJesuW8Qd4I2xYJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YOWkoMNv4jn5aRBD1G6M6IRId8wNLOa3O3Y/4Vsd3wY=; b=cpv60VHvhKnu7pUusTapZa5DhTQVKTzMBPCwbm+rhedOPgo50qjKKRLiyDwWHHxJZWoUJiKM3xJOb4ePNzedrKe6kaO252SyXUIVkHEAeOB3nCdpiJCd9ieZGZQlLNw0Mk0IAnmn7f8dmCKwDgbrfG14GnbTjoijC3nCMZhnUfm/1d+ok224+licVVKMBlWYI9V6v4QNCKGmZnWiiNuWkLvsEtW+UJip6MWWGhguHc3dBVyDRGh2CquzeFZcSHo07v4Uvlx+AvjEp2qVqqwIVq4F+uQm34VYiLO+Mxzen1YVlvcSUpW5mgv2vI48SiPv4fnsaOsQW5ZTIWm+42+Umg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by SAVPR12MB999121.namprd12.prod.outlook.com (2603:10b6:806:4e7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:33:32 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:33:32 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , Joel Fernandes , John Hubbard , Will Pierce Subject: [PATCH v2 06/15] gpu: nova-core: add the GIN interrupt tree and allocate its vectors Date: Fri, 28 Aug 2026 18:33:25 -0700 Message-ID: <20260829013324.499542-11-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0389.namprd03.prod.outlook.com (2603:10b6:a03:3a1::34) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|SAVPR12MB999121:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d898e21-5b37-4462-1f03-08df056d88f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|1800799024|366016|6133799003|10067099003|56012099006|5023799004|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 9IQIHpiFDD2dJY8xQU50mbEmjsamzBZ5x49OUDbuShCN0q+RBFs2pgwWRUa0/zJxk7pOTztSp3jlSYo4yTclkEy/sXgxOKdsfW1ZQbAK1Jfls5UlTodiLNF8xb30tlfVx2YmYK3mgfYP/45K4XkncOeMaAeThq6yen8+MLigLsRBoeAWumcsF5ub19JBIwUz/Mrl2MunDu/Cag/zQ45jHj6bH7DJcPpbsJOzg6i3msKbcuDYbN9s5q5MyQvpUuKcNC0S/cDEaoJ+1YxN3So6Ak+XGetbqHqjq+YlgDwkVrXMDUHVZT3OBU/QEXtueUux0R585+k94sv0aRpU/tamTGchFhJe02DBKGslgFxGA0OgGxD8RrgbaL+5cIgfoyQIB6TJt6eUtGyx09FQTOFVCeR5yoqRXYDSxzt92y/+qFCB21MlpJ/tfliafu2MB1whkv00xTI029+8DWxXXdMzmGHE0lKWempQjO830WeNQPRWwBiLZOXCDsUxgSan1nJy1ExX1fU5hdaVpg6a29ShaM/hcMA33JdLB3iipeL3QMQFPKfDedeo59/ljqJzhRnyRcG3nITBuJLOPsQQBwZIPP2Yfky0U5RxqmPLjNu2gETL/vBqMTdBWN0ZhTQDlc0kREdFp33T6Eok/W80gkjh42wWHq56HLUfYQ8W0o5CSb8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(1800799024)(366016)(6133799003)(10067099003)(56012099006)(5023799004)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?VSQ0pc5RmVUptZGnPEdtGj0i3fPXbCJWQZalULgTm6ZxMJkmddluJyHdhMkQ?= =?us-ascii?Q?efsFSCq2WO9Whf57V2hIVYYQSgl57HJx+xqkv+b41vWwF97piopDzsGe45bL?= =?us-ascii?Q?Jk827s4i29LXQuUR1RKSFYRx8A1sNXtt6MaQ4dXM+kQAb1u8mLxfxNiPQFkT?= =?us-ascii?Q?eLO3rVmlaVXETi+v7hK5xZiMPrNq1iQS3Ub/n5dAG/ezuVTVVCVxyRDMzWof?= =?us-ascii?Q?ZgV7g+TL0yo3Kh/blsQ/KrmiqgRBMosYgUQbd+9L9/XJAz8vuogn3U/K+LM7?= =?us-ascii?Q?BPaZleolFDrL17XX3Ti9R6eMsSbjjh600IsjspnTe6jbTPMOgE+NTHCsvN5l?= =?us-ascii?Q?owzzxBFMhJ5G8OSqhUcm1e7MqrzLtX8ala/y67215Qi3KQQTn1SDS9fVkiUc?= =?us-ascii?Q?ZL0UecDQMqDWu+53nKOgxKhfllYXM5MXVZw89j0zZzv1RCDvTkjowXWSAf9P?= =?us-ascii?Q?EqFXU/j2qUNufqv246cFx2ZYsFchw0ZFtyXvzqvXPxR6sCYdQbMocCXZVzjT?= =?us-ascii?Q?IJ+xt1+OIZKVcEleUbq5+VKT3jIbe24f6SjZzfWhEmtjLCfuQqvNsRW3sxpg?= =?us-ascii?Q?wUk8/1Ks0/JK2xOz4kKgvcNRUEb9xIPGPdFVGQjlROwCeQYCIvla4itleaZ7?= =?us-ascii?Q?JbZTLky22LODlnFfN+g4jK3ShQALm32NK1FgAmVCkUq6/ppC/dOr3txiPlV2?= =?us-ascii?Q?YaYblDv2B4VKuv89D5Kek677Cfa7Up9wGd9nDhhqZYOkqpFKnlQehcoWdbql?= =?us-ascii?Q?Zi+tSzZHfrhNYMqpMyO7yENMhDag94x6Wilh4gI+H91k3kXwgyG3jyvbiO5P?= =?us-ascii?Q?HvMb0n0nII1g0tJR86HB8qtX613qJD6Grfwic+2bzIyNfKQOmL4sC7HU34CP?= =?us-ascii?Q?yH3E4lF9+4mfQEDwRdrRt4b3saU3zzREvmcNMAOw34YoI5MTou4q/rZqEZ5S?= =?us-ascii?Q?YLl9a75OIFiP1sVIAkxh2Slw+rM47fhgATH+ps2hMxqUMjXFtOgU/qhuyG8q?= =?us-ascii?Q?gi370BpgLHQlf1tEsr2A+UYSqjRK5Cmnp+kuwAPLgs+j6NEKp3oqdTqkgBQg?= =?us-ascii?Q?kF4jYlIim487GsTGO6hXMCs3QDAo/o7za0LEXXY+xPD3TZRpBxjYjZJOhiZu?= =?us-ascii?Q?wwbNWvRYORMOYzap70Vg8ioQLZnQUDdZHiFl76lZXd4NvNffi8EojCMW9d/g?= =?us-ascii?Q?RnJFBzjYCR8/sgBrHR10+3ahvGCziRU5IkXoh691kwW9th/MLb8NSgDd7A5W?= =?us-ascii?Q?punLYh54J2B2W/4Az+8TSKFw/D8X0TRmFS2vPVHfffbbqoyL9Zy9QKTsDRQO?= =?us-ascii?Q?dyoGKHTddWmhum2GAjkzI12cMn6wfG2NCVucJ7wZG9YlLbMMzD+1ExgqC7s9?= =?us-ascii?Q?u5c814XvnQEU9MvluIrMSlpc6TuPV5OlyZ7hzN4rZfsRuBj6cBQaRbItmIgD?= =?us-ascii?Q?RStM3lrFnl2s4CaW4BzcpmEfvBJRd06nU0Xpr3az64n5acKEOxTS+NAiYGHu?= =?us-ascii?Q?TaaEJMUMdeUpH74mtgxyoO+YfPV/L4zYvvQvpuVfGWlNdj2TNTAaGMVGafUv?= =?us-ascii?Q?DnEoHpyMFMImSTgIpFDyyZzVZ1x4fy1GRRMKtcuMhZcqoxM3wAaND+eTltzR?= =?us-ascii?Q?auecbO3YDVMatCM0O3Ki5vHdQ1qao41YAjiF6S/mhAb2Ry7iaJ7cOPLCPCEW?= =?us-ascii?Q?6M+CySYF9wasTUE8H12LGMwJIY7TOU0vfnCgXAYfs4K6X6lWqa/z7RALkrC5?= =?us-ascii?Q?jS8ZvGHRHA=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d898e21-5b37-4462-1f03-08df056d88f0 X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:33:31.8719 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: c1ZYUUt3O2mcKiF4onyTGricGequxZWhH96N64LQj58eDNnEEd02MZUUFO0f7ILhZry42toYsqlzKIpy7ankBA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SAVPR12MB999121 Content-Type: text/plain; charset="utf-8" From: Joel Fernandes Servicing a GIN leaf has a required order: read its pending bits, then clear them. Clearing a leaf before reading it discards every vector latched in it, and nothing reports the loss. The driver must also allocate a PCI vector for every subtree it enables at TOP, and register a handler on that vector. MSI-X gives each subtree its own table entry. Linux masks every entry the driver did not allocate. An enabled subtree with no entry of its own raises interrupts that never arrive, and its leaf and TOP bits stay pending and enabled. MSI instead has one message that the whole tree raises, so a single entry serves every subtree. Add an API for one PCIe function's CPU interrupt tree, in which reading a leaf yields the handle that clears it. Size the vector allocation to the serviced subtrees, requesting MSI-X entries up to the highest serviced subtree and falling back to a single MSI rather than a shared INTx line. Reviewed-by: Will Pierce Signed-off-by: Joel Fernandes [jhubbard: name the module interrupt_tree with a Tree type that owns the BAR mapping, use the canonical NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_* register names, express vectors, leaves and subtrees as newtypes, let the read of a leaf produce the handle that clears it, add the enable guards, take the leaf count and the rearm method from the interrupt HAL, and read every implemented leaf in drain() rather than descending from the TOP registers, which cannot see a vector that latched while disabled] Signed-off-by: John Hubbard --- drivers/gpu/nova-core/irq.rs | 89 ++++++ drivers/gpu/nova-core/irq/interrupt_tree.rs | 284 +++++++++++++++++++- 2 files changed, 369 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nova-core/irq.rs b/drivers/gpu/nova-core/irq.rs index 02ecfc47f4d0..c6bf1dbacabe 100644 --- a/drivers/gpu/nova-core/irq.rs +++ b/drivers/gpu/nova-core/irq.rs @@ -11,3 +11,92 @@ mod hal; mod interrupt_tree; mod regs; + +use kernel::{ + device::Bound, + irq, + pci::{ + self, + IrqType, // + }, + prelude::*, // +}; + +use interrupt_tree::{ + Subtree, + SubtreeSet, // +}; + +/// The PCI interrupt vector that delivers each serviced subtree. +/// +/// MSI-X raises a separate table entry per subtree, so subtree `N` arrive= s on entry `N`. MSI has a +/// single message that every subtree raises, so all of them arrive on the= one allocated entry. +pub(crate) struct SubtreeVectors<'a> { + vectors: pci::IrqVectorRegistration<'a>, + /// Every subtree nova-core services. + serviced: SubtreeSet, +} + +impl SubtreeVectors<'_> { + /// Returns the interrupt type the PCI core selected for these vectors. + pub(crate) fn irq_type(&self) -> IrqType { + self.vectors.irq_type() + } + + /// Returns an [`irq::IrqRequest`] for the vector that delivers `subtr= ee`. + /// + /// # Errors + /// + /// `EINVAL` if `subtree` is not one nova-core services. + pub(crate) fn request_for(&self, subtree: Subtree) -> Result> { + if !self.serviced.contains(subtree) { + return Err(EINVAL); + } + + self.vectors + .index(entry_index(self.irq_type(), subtree)) + .map(Into::into) + } +} + +/// Returns the index of the allocated entry that `subtree` raises. +/// +/// MSI-X gives subtree `N` its own table entry `N`. MSI raises its one me= ssage from every subtree, +/// and nova-core allocates a single entry for it. nova-core never allocat= es INTx. +fn entry_index(irq_type: IrqType, subtree: Subtree) -> usize { + match irq_type { + IrqType::MsiX =3D> crate::num::u32_as_usize(subtree.index()), + IrqType::Msi | IrqType::Intx =3D> 0, + } +} + +/// Allocates the interrupt vectors that the subtrees in `serviced` requir= e. +/// +/// Every subtree nova-core enables at `TOP` must have an allocated vector= with a registered +/// handler, or the interrupts it raises are lost. Linux masks every MSI-X= entry a driver did not +/// allocate, so the MSI-X request covers every entry up to the highest se= rviced subtree. A part +/// whose MSI-X table is smaller than that falls back to a single MSI, whi= ch serves the whole tree. +/// nova-core does not fall back to a shared INTx line. +/// +/// # Errors +/// +/// `EINVAL` if `serviced` is empty. The error from the MSI request if nei= ther type can be +/// allocated. +pub(crate) fn alloc_vectors( + pdev: &pci::Device, + serviced: SubtreeSet, +) -> Result> { + if serviced.is_empty() { + return Err(EINVAL); + } + + // One entry per subtree up to and including the highest serviced one. + let entries =3D serviced.span(); + + let vectors =3D match pdev.alloc_irq_vectors(entries, entries, IrqType= ::MsiX.into()) { + Ok(vectors) =3D> vectors, + Err(_) =3D> pdev.alloc_irq_vectors(1, 1, IrqType::Msi.into())?, + }; + + Ok(SubtreeVectors { vectors, serviced }) +} diff --git a/drivers/gpu/nova-core/irq/interrupt_tree.rs b/drivers/gpu/nova= -core/irq/interrupt_tree.rs index da24f3d35893..523b26d55137 100644 --- a/drivers/gpu/nova-core/irq/interrupt_tree.rs +++ b/drivers/gpu/nova-core/irq/interrupt_tree.rs @@ -1,17 +1,49 @@ // SPDX-License-Identifier: GPL-2.0 // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIA= TES. All rights reserved. =20 -//! Vector addressing in the GIN CPU interrupt tree. +//! The GIN CPU interrupt tree for one PCIe function. //! //! A vector's number fixes where it latches: leaf `vector / 32` at bit `v= ector % 32`, and that //! leaf belongs to subtree `vector / 64`. The types here keep those three= views apart, so a leaf //! index, a set of vectors within one leaf, and a `TOP` bit cannot stand = in for one another. +//! +//! Servicing a leaf has a required order: read its pending bits, then cle= ar them. Clearing a leaf +//! before reading it discards every vector latched in it, and nothing rep= orts the loss. Only +//! [`Tree::read_pending`] produces a [`LeafPending`], and only a [`LeafPe= nding`] can clear, so the +//! wrong order does not compile. +//! +//! Serializing access to the tree is the caller's responsibility. =20 use kernel::{ + io::{ + register::Array, + Io, // + }, num::Bounded, + pci::IrqType, prelude::*, // }; =20 +use crate::{ + driver::Bar0, + gpu::Chipset, // +}; + +use super::{ + hal::{ + cpu_interrupt_hal, + PciIrqRearmMethod, // + }, + regs::{ + NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_LEAF as CPU_INTR_LEAF, + NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_LEAF_EN_CLEAR as CPU_INTR_LEAF_E= N_CLEAR, + NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_LEAF_EN_SET as CPU_INTR_LEAF_EN_= SET, + NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_LEAF_TRIGGER as CPU_INTR_LEAF_TR= IGGER, + NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_TOP_EN_CLEAR as CPU_INTR_TOP_EN_= CLEAR, + NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_TOP_EN_SET as CPU_INTR_TOP_EN_SE= T, // + }, // +}; + /// Index of a leaf register, bounded to the `0..16` range covered by the = leaf register arrays. pub(super) type LeafIndex =3D Bounded; =20 @@ -97,7 +129,7 @@ pub(super) const fn contains(self, other: Self) -> bool { /// /// Exactly one bit is set. #[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub(super) struct Subtree(u32); +pub(crate) struct Subtree(u32); =20 impl Subtree { /// Returns this subtree's index within the tree. @@ -115,7 +147,7 @@ pub(super) const fn into_raw(self) -> u32 { =20 /// Set of subtrees, one bit per subtree, in the layout the `TOP` enable r= egisters take. #[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub(super) struct SubtreeSet(u32); +pub(crate) struct SubtreeSet(u32); =20 impl SubtreeSet { /// Returns whether `subtree` belongs to this set. @@ -199,7 +231,7 @@ pub(super) const fn subtree(self) -> Subtree { /// # Errors /// /// `EINVAL` if the vector lies beyond the last leaf such a tree imple= ments. - pub(super) const fn validate(self, leaves: LeafCount) -> Result { + pub(super) fn validate(self, leaves: LeafCount) -> Result { if self.0 >=3D leaves.vector_count() { return Err(EINVAL); } @@ -207,3 +239,247 @@ pub(super) const fn validate(self, leaves: LeafCount)= -> Result { Ok(()) } } + +/// Returns the leaves that subtree `index` covers. +/// +/// An index beyond the leaf register arrays yields nothing rather than pa= nicking. +fn subtree_leaves(index: u32) -> impl Iterator { + let first =3D index * LEAVES_PER_SUBTREE; + + (first..first + LEAVES_PER_SUBTREE) + .filter_map(|leaf| LeafIndex::try_new(crate::num::u32_as_usize(lea= f))) +} + +/// The GIN CPU interrupt tree for a single PCIe function. +pub(super) struct Tree<'a> { + /// Borrowed BAR0, through which every tree register is reached. + bar: Bar0<'a>, + /// Number of leaves this tree implements. + leaves: LeafCount, + /// The subtrees this tree enables and services. + serviced: SubtreeSet, + /// Method that rearms PCI interrupt delivery, or `None` if the interr= upt type needs no rearm + /// write. + rearm: Option, +} + +impl<'a> Tree<'a> { + /// Creates a `Tree` for `chipset` covering `serviced`, with the rearm= method that `irq_type` + /// requires. + /// + /// Each serviced subtree must have an allocated PCI vector and a regi= stered handler, which + /// [`super::alloc_vectors`] sizes the allocation for. Subtrees the ar= chitecture does not + /// implement are dropped. + pub(super) fn new( + bar: Bar0<'a>, + chipset: Chipset, + irq_type: IrqType, + serviced: SubtreeSet, + ) -> Self { + let hal =3D cpu_interrupt_hal(chipset); + let leaves =3D hal.leaf_count(); + + Self { + bar, + leaves, + serviced: serviced.intersection(leaves.subtree_set()), + rearm: hal.pci_irq_rearm_method(irq_type), + } + } + + /// Returns the subtrees this tree services. + pub(super) fn serviced(&self) -> SubtreeSet { + self.serviced + } + + /// Rearms PCI interrupt delivery to the CPU after servicing `subtree`= , the one subtree the + /// calling handler serves. + /// + /// A handler must call this before it returns, or it receives no furt= her interrupts. + pub(super) fn rearm_pci_irq(&self, subtree: Subtree) { + if let Some(method) =3D self.rearm { + method.rearm(self.bar, self.serviced, subtree); + } + } + + /// Enables this tree's serviced subtrees (`TOP_EN_SET`). + pub(super) fn enable_top(&self) { + self.bar + .write(CPU_INTR_TOP_EN_SET, self.serviced.into_raw().into()); + } + + /// Disables this tree's serviced subtrees (`TOP_EN_CLEAR`). + pub(super) fn disable_top(&self) { + self.bar + .write(CPU_INTR_TOP_EN_CLEAR, self.serviced.into_raw().into()); + } + + /// Enables this tree's serviced subtrees until the returned guard dro= ps. + pub(super) fn enable_top_guarded(&self) -> TopEnableGuard<'_> { + self.enable_top(); + + TopEnableGuard { tree: self } + } + + /// Enables the vectors set in `vectors` for `leaf` (`LEAF_EN_SET`). + /// + /// This is the per-vector counterpart of [`Self::enable_top`], which = enables whole subtrees. + pub(super) fn enable_leaf(&self, leaf: LeafIndex, vectors: LeafMask) { + if let Some(loc) =3D CPU_INTR_LEAF_EN_SET::try_at(leaf.get()) { + self.bar.write(loc, vectors.into_raw().into()); + } + } + + /// Disables the vectors set in `vectors` for `leaf` (`LEAF_EN_CLEAR`). + pub(super) fn disable_leaf(&self, leaf: LeafIndex, vectors: LeafMask) { + if let Some(loc) =3D CPU_INTR_LEAF_EN_CLEAR::try_at(leaf.get()) { + self.bar.write(loc, vectors.into_raw().into()); + } + } + + /// Enables `vectors` for `leaf` until the returned guard drops. + pub(super) fn enable_leaf_guarded( + &self, + leaf: LeafIndex, + vectors: LeafMask, + ) -> LeafEnableGuard<'_> { + self.enable_leaf(leaf, vectors); + + LeafEnableGuard { + tree: self, + leaf, + vectors, + } + } + + /// Reads the vectors pending in `leaf`. + pub(super) fn read_pending(&self, leaf: LeafIndex) -> LeafPending<'_> { + let pending =3D CPU_INTR_LEAF::try_at(leaf.get()) + .map(|loc| self.bar.read(loc).into_raw()) + .unwrap_or(0); + + LeafPending { + tree: self, + leaf, + pending: LeafMask::from_raw(pending), + } + } + + /// Injects a software interrupt for `vector` via the trigger register. + /// + /// # Errors + /// + /// `EINVAL` if `vector` lies outside this tree. `EOVERFLOW` if `vecto= r` does not fit in the + /// trigger register's vector field. + // Only the interrupt self-test injects a software interrupt. + #[cfg_attr(not(CONFIG_NOVA_CORE_IRQ_SELFTEST), expect(dead_code))] + pub(super) fn trigger(&self, vector: GinVector) -> Result { + vector.validate(self.leaves)?; + self.bar + .write_reg(CPU_INTR_LEAF_TRIGGER::zeroed().try_with_vector(vec= tor.into_raw())?); + + Ok(()) + } + + /// Disables every vector in every implemented leaf (`LEAF_EN_CLEAR`). + /// + /// Boot, or a driver that ran before this one, can leave leaf enables= set for vectors + /// nova-core does not service, and such a vector delivers to nova-cor= e's handler once its + /// subtree is enabled. + /// + /// This clears enables outside the subtrees nova-core services, so it= is a probe-time + /// operation only. + pub(super) fn disable_all_leaves(&self) { + for index in 0..self.leaves.into_raw() { + if let Some(leaf) =3D LeafIndex::try_new(index) { + self.disable_leaf(leaf, LeafMask::all()); + } + } + } + + /// Clears every pending bit in every implemented leaf. + /// + /// Disables this tree's serviced subtrees at `TOP` across the walk, t= hen enables them, + /// whatever their state on entry. The leaves cleared reach subtrees t= he driver does not + /// service, and the `TOP_EN` writes do not. + /// + /// Call `drain()` only during probe. It must not run concurrently wit= h an interrupt handler. + pub(super) fn drain(&self) { + self.disable_top(); + + // `TOP` summarizes enabled leaf bits, so a vector that latched wh= ile it was disabled does + // not appear there. + for index in 0..self.leaves.subtree_count() { + for leaf in subtree_leaves(index) { + let pending =3D self.read_pending(leaf); + if !pending.vectors().is_empty() { + pending.clear(); + } + } + } + + self.enable_top(); + } +} + +/// The vectors read pending from one leaf. +/// +/// Holding one is the proof that the leaf was read, which is what [`Self:= :clear`] and +/// [`Self::clear_vectors`] require. +pub(super) struct LeafPending<'a> { + tree: &'a Tree<'a>, + leaf: LeafIndex, + pending: LeafMask, +} + +impl LeafPending<'_> { + /// Returns the vectors that were pending. + pub(super) fn vectors(&self) -> LeafMask { + self.pending + } + + /// Clears every vector that was pending, by writing its bits back (wr= ite-1-to-clear). + pub(super) fn clear(&self) { + self.clear_vectors(self.pending); + } + + /// Clears the vectors set in `vectors` (write-1-to-clear), leaving ev= ery other pending bit + /// set. + /// + /// A handler that services one vector uses this rather than [`Self::c= lear`], which clears + /// every vector the leaf had pending. + pub(super) fn clear_vectors(&self, vectors: LeafMask) { + if !vectors.is_empty() { + if let Some(loc) =3D CPU_INTR_LEAF::try_at(self.leaf.get()) { + self.tree.bar.write(loc, vectors.into_raw().into()); + } + } + } +} + +/// Keeps a leaf's vectors enabled for as long as it is held. +/// +/// Dropping it disables the same vectors, so an error path cannot leave a= source enabled with no +/// handler behind it. +pub(super) struct LeafEnableGuard<'a> { + tree: &'a Tree<'a>, + leaf: LeafIndex, + vectors: LeafMask, +} + +impl Drop for LeafEnableGuard<'_> { + fn drop(&mut self) { + self.tree.disable_leaf(self.leaf, self.vectors); + } +} + +/// Keeps a tree's serviced subtrees enabled at `TOP` for as long as it is= held. +pub(super) struct TopEnableGuard<'a> { + tree: &'a Tree<'a>, +} + +impl Drop for TopEnableGuard<'_> { + fn drop(&mut self) { + self.tree.disable_top(); + } +} --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011041.outbound.protection.outlook.com [52.101.52.41]) (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 99A80361675 for ; Sat, 29 Aug 2026 01:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967220; cv=fail; b=fThg4CgZZVPJ65hBuMgMsh7A9iA+FfmYHRBOCNmnFLLqQRj5ISKfZS3zjLD+8Uuupq8+4uGUPENH9o76rEjhkeymB3VSHvzCQ2o/OjGWvioikxqhaKG3HPBR23EParw4Rc34qGby3dEIlWqSXnEw6kttMlU7EWVuKpBXR5o3ZFE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967220; c=relaxed/simple; bh=6gISvyzzNA4sv8+NgNu6bThYJ/MZ7woHadWEQuvTc/U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=kNPUGvnTo4BLiGrgImXXBqKtJQkHRfuyqkW+ZrXsLFMqwAvy15YI8S0lSuBvsmaaLXIVyIAEiTgyj6tS/zjyBI/oG+Ejo+kIiPvCFIufGRDLg6XLAI8gwsRrxcXAasSbodNtXBhR4Yep/wqnFPEIh1q/nY97fsoxiBgj8n+wHLs= 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/oPnmZx; arc=fail smtp.client-ip=52.101.52.41 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/oPnmZx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=D8T0RdrQ8ZYRqK9/otZaScTN+1HNHrGV4T1GeqWniATEWswVPnXdYTRrjV+IrITRmwngp8Uk0uUUq3LM8sqMeTSYxmRkIgu0WfunqFaCZyXujGzCAQxehBA5R5xznFrI9oLZu6ZNxYhgEO76J/FKEB6RNEdsq8Wj9l5Wi/TdijBwl9NYHsZ8Y8gQdD4zZMqQMk4L3oqPd+/dvn+npUduJiyJuaXDhP7YuWKDJHOpehnYo8XiZrUh4bxsSEI4cVcMCa+DHHbbtVvKpCERAVysOOwDf8RcMJJg86e5G/l3MURKpaFBRcTB8VSImTLB8nc9DkgXzLtNlOWugCjaOU+t4A== 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=S+lPD43wj5wqJVjpS9k8Exj0sQND8iH5lC4XgzESCz8=; b=ACwtRc1syDI/flojgXpLyeI68eCE22ntyUO9r2rkqneEF9JmDBwsUH01MTMnR5RAurCn3bStP0kxcunvZuvt1gqZeICOXIRvHmQKz6rzpT5Qw7U86y5CCftB6xrHIY2WDRdcUxCx6MeuL0O5d7cOSduACkxDog2j8KpXE9oMgQZOxXW4vuHnMUjdp9yvf21Y51FltbHb+qc9RszkJLkEepu8uFdtMX4mP8niMBvU9uUkGOP3VCKDWAUZZ3ewyby0iJuYlz+cLL4ziC8j085NJa4HyJd17V72Sii4IrrqKIUVSyuWHY1R6Y1yp65shBQJ2yWz+Q9eAG04WxrZhXCNYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S+lPD43wj5wqJVjpS9k8Exj0sQND8iH5lC4XgzESCz8=; b=o/oPnmZxBrrh+qGwfzB/Ake+Qw2nbPZ+u/yBF0QcS/S/Dk67M8SD9TpmLt6ibTSLhVMUgI0jNglp8cYfyyAAgpXLboxCjs94qtk2rybXOV8GCJxPriPZ1doSuNbOzltI8TmgSZnx1hvrQwYcdBGwDP0GCs5KplvVp6epzmsW6knpL172qFeVfvT0iC3lPv4sFeCU0PvAdk+khK4tFB35zioUpDcxxNAw5cD5KoqGy+J3Xo/F4LBC9TreO2aInYlQCI/qHwL2xmTiCxj6PWwPHtvzVRMg0FbXzBQWmcu/kyYl98S4DivhLTqKHpSalc7BASQ0lvxZXz+eDyxDqZYsOw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by SAVPR12MB999121.namprd12.prod.outlook.com (2603:10b6:806:4e7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:33:33 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:33:33 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard , Will Pierce , Joel Fernandes Subject: [PATCH v2 07/15] gpu: nova-core: add an interrupt delivery self-test Date: Fri, 28 Aug 2026 18:33:26 -0700 Message-ID: <20260829013324.499542-12-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR05CA0052.namprd05.prod.outlook.com (2603:10b6:a03:33f::27) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|SAVPR12MB999121:EE_ X-MS-Office365-Filtering-Correlation-Id: f8cfca3f-de19-4228-f810-08df056d89af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|1800799024|366016|6133799003|10067099003|56012099006|5023799004|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: Rf/XzPd2XCj0qDrU35e9h7/989ARty81llmaRIR3UyBT2dseWKy087+Ih2w8zCc+fksnwlUXufFAkmytpLhYH9wmAjwty84mQrBWhUBg0NWImHS9DpxW10M7VuE/fxVCgNYvZ4AZAVQSwheYuvMGRV/xh16hys0szlIP1bYfdtX0HLIVsJjLRRofDfxP1khieDPiXpS7up5PQphI971XiOlhn8o3vKfTkXtaylxXAHHTgw5XoDCf3qvTBzpa0ADxWMzdSR/8SutOLEFhVZJSPRjAcFATXQh6RrWxoD3bWADR85XmIf21BlAzwUZiSQAE87VH7YJEOA5wQTbDlnwrwSXPRCJfAUfDwlvX8RfjznWqtnE6AgoVxgOc+nq9Dv52ZkB+ySAv/83v5riG7yTxQ53uAaA1wTfCKCMCyfAkvwQbmJKRQY4BGuMIL+1iFdnhUwkqUH8EFYT5MRx6Qt4ErI14Qaqt/geio0u+GJ+GYFhpcwhuh31s9y53DO367j27B/UaNQNIAnM02vR0UeDcFlOyYWTsTg58qiQQEPKQ/p8Rb+2eD1c28UTamkH3//ADCGyNZaLd0OMaQBrzYGgYswvRvecmLGsYpHt61DKO1tuo9CuIqnePN9poFl4t5rvY6scdSjfygmiQjp0ZqMTitJStyZU2R+p7jFLktFM6FZQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(1800799024)(366016)(6133799003)(10067099003)(56012099006)(5023799004)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?qHwccqFGNlhwiHZe9/lKLOEQ45Yt7ErUU9F3IOlOzhXxDRAWTRCOOwpcfu3U?= =?us-ascii?Q?mnNRu6YpZ23CpQUaCc00K1ZfcP4OsXvog122y7GZ29SE+2fVBtXz4nMIhMha?= =?us-ascii?Q?sCi8EoVi296FENTOuJkVmRpHGrY9Z+eJ6NEu1c1VlB3uN7B6ZZvViah5DcxP?= =?us-ascii?Q?KyW4BtglE1iyAQz/ZrKKou7KZdS5hVJj3Hfr+ucdSGErCnUDsi93usJTuSjn?= =?us-ascii?Q?6FogX6wOJhhoG7SScgGOqMM06ubQNtOKKF7NNs6YLghm30u7UkJ+rrOahD86?= =?us-ascii?Q?3N7d3ubhacgdpxaoffz5u9UMwgYv7N1wdm2n7K7AsBvhDl8hB1Eaai5rRZIM?= =?us-ascii?Q?bOck4eVCsgjHtZHJHYdCH5OJidkDp4PghvcVLe51F8uRXCdQqd4Zfkzv7Sbf?= =?us-ascii?Q?tGecw2WnGz4wevEMaV6zGX6sG0F7TugcbTuu6wcW54lqFm1ZogzzW2PU7H2l?= =?us-ascii?Q?AqB5+QAX5KCYJusHx9K3WtTybJinGOeMpk/6rvoFTaFIohPjadu1MxYuhvlY?= =?us-ascii?Q?e3WXsLJ5bGYoDdZmakZ+aKbiMSP0xA2TUCINF3QBu1LbmMuA7ckGGqwT9VRM?= =?us-ascii?Q?8qzsaFGnAUdXS35HEUBTSBLrTpy4j+iNvQBhoLjhIWhnmnaoVDs2STvdrDkf?= =?us-ascii?Q?Ft0idb+o7kZ7K1aHYbsOzMHKPBBJJT+4BptXrZsHkasSvxr9lUvhfvDj/utM?= =?us-ascii?Q?JjzzH6t445xiAR9vrUdsBN5OixOE3bkYUTJFzGDEl2KaGWE2tv+5SgPNROeM?= =?us-ascii?Q?Ngf71noCk6A5VdmRFt0sTHtutg8mHUU8k+46bjIxWO4OiNXmPDcB1CeIsIZj?= =?us-ascii?Q?F+Zd4G/otFnPAUgMCsVRIYgniiOjm7AHyluVNR/PIQ7JbL+U3mczxTnhrTMA?= =?us-ascii?Q?a4Zv1IYIRNJ9JK4sKzYyYFAF0FKvLimaVeHk0us5t3+pMD9Ftrlo8oTUDura?= =?us-ascii?Q?3p1vDCy+AzRgTF85WCYbqwqB9vLoIfS/XyGVHF1qM2+bbO3j/RqyhMvI2Fur?= =?us-ascii?Q?l8gDFSkEAwV66fH02pq0WwOj3Vnd26s2dL7EXpr3SXuN7SMt4VeyfZwVlRKi?= =?us-ascii?Q?T8aIJE170Q+ucylNAR1U7jqQms3dl/o/Sxy9PjIt7AUqt/c5s9wVIqZw7isQ?= =?us-ascii?Q?b1l03yiNFN4s08xcyvP7D5mVRMboscFhvrErqzH0HIdqFB6uYiRZ7mg2Mhk0?= =?us-ascii?Q?jh0tKam7VKwCHiuqQH6wd9HHlAlhXvSnOrDRJf0M1tx4MIyKXzgi/A5yxcOm?= =?us-ascii?Q?JzBFIKkX4GyI5z2CRkEJKdtokJd/nNKiKxeDAZai+aBXIvCm973IducF72xW?= =?us-ascii?Q?EJy/7gLck+4d1ulvxB2sATmeM7iGVYEgEy+hefx8HESci5C/Wk/oFBdGs7j1?= =?us-ascii?Q?JHQ2+4hn5yBl2m2OT0E7r6rLyE8iGR0zVFmc8M4HARfXZDu5+CM2spIfvg0K?= =?us-ascii?Q?sNINKqxnV8WLqaYEw/TxI3PLm+EVWNMYwGDSk0VqJ8RsNI6RSQCHtFOl8WGk?= =?us-ascii?Q?F+9IlGIkC7zaLXD3dLw5K/PrfO8jcC2blKq/HV8PFLfxM1Q7AcxiyaUsP8Jo?= =?us-ascii?Q?izfnt0wx5ax8aO9ZWbfNZSHj1te979nmgqc0mAD5C20QOuW29pyCnWUFJjAo?= =?us-ascii?Q?mu6RSby9gEaJKDisDsIQHDklpyEHR+1ls5J98JNujigmYNz4ZpVlB7K2yn4I?= =?us-ascii?Q?+bFqY6g6HBnpUTPAnjHN10yqNimRjD+/OD40ApZdUdcgomL83CNghwBh0w2s?= =?us-ascii?Q?XOTgjXvI4Q=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f8cfca3f-de19-4228-f810-08df056d89af X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:33:33.0745 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: u+8MR/sOqdRkXehHExJ43ZlP6xe+F+I044h9HXtb0N6Enlncy46qqhjKHbFn0DmtXiqjG2i/lmVkTjPuQleddA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SAVPR12MB999121 Content-Type: text/plain; charset="utf-8" A GPU interrupt can be lost in the MSI or MSI-X allocation, in the GIN tree's enable bits, or in the rearm. Every one of those failures looks the same to the driver: no interrupt arrives, and nothing in the symptom says which one broke. Add an optional probe-time self-test that injects the CPU doorbell through the GIN software trigger. One injection would pass even with a broken rearm, because the first message-signaled interrupt arrives whether the driver rearms or not. The test injects twice, and waits for the first handler to rearm before it injects again. Run it before GSP boot on a quiesced tree, and fail probe unless exactly two deliveries arrive, each delivery finds only the doorbell pending, and the leaf ends clear. Under MSI-X the injected subtree has its own table entry, so the delivery exercises that entry too. Assisted-by: Cursor:claude-opus-5 Reviewed-by: Will Pierce Co-developed-by: Joel Fernandes Signed-off-by: Joel Fernandes Signed-off-by: John Hubbard --- drivers/gpu/nova-core/Kconfig | 15 + drivers/gpu/nova-core/gpu.rs | 8 + drivers/gpu/nova-core/irq.rs | 2 + drivers/gpu/nova-core/irq/doorbell_test.rs | 294 ++++++++++++++++++++ drivers/gpu/nova-core/irq/interrupt_tree.rs | 73 +++-- drivers/gpu/nova-core/nova_core.rs | 2 +- 6 files changed, 367 insertions(+), 27 deletions(-) create mode 100644 drivers/gpu/nova-core/irq/doorbell_test.rs diff --git a/drivers/gpu/nova-core/Kconfig b/drivers/gpu/nova-core/Kconfig index f918f69e0599..7198fae6b6f4 100644 --- a/drivers/gpu/nova-core/Kconfig +++ b/drivers/gpu/nova-core/Kconfig @@ -15,3 +15,18 @@ config NOVA_CORE This driver is work in progress and may not be functional. =20 If M is selected, the module will be called nova-core. + +config NOVA_CORE_IRQ_SELFTEST + bool "Nova Core interrupt delivery self-test" + depends on NOVA_CORE + help + Run an interrupt delivery self-test during nova-core probe. It + injects a known vector through the GPU interrupt controller's + software trigger and confirms the interrupt reaches the driver's + handler, validating the PCI interrupt path from the GPU to the CPU + with no dependency on GSP firmware. The result is printed to dmesg. + + If the test fails, the PCI probe fails and the driver does not load. + + This is intended for driver bring-up and for debugging PCI, MSI, or + passthrough setups. If unsure, say N. diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs index 9e4232645a7e..589b4b210a22 100644 --- a/drivers/gpu/nova-core/gpu.rs +++ b/drivers/gpu/nova-core/gpu.rs @@ -347,6 +347,14 @@ pub(crate) fn new( .inspect_err(|_| dev_err!(dev, "GFW boot did not compl= ete\n"))?; }, =20 + // Validate the MSI interrupt path before booting GSP, when th= e self-test is + // enabled. This runs on a quiesced interrupt tree with no GSP= state present, so it + // never observes or clears GSP or PRIV_RING interrupts. + _: { + #[cfg(CONFIG_NOVA_CORE_IRQ_SELFTEST)] + crate::irq::doorbell_test::run_selftest(pdev, bar, spec.ch= ipset)?; + }, + // Initialize this early because `gsp_resources` depends on it. sysmem_flush: SysmemFlush::register(dev, bar, spec.chipset)?, =20 diff --git a/drivers/gpu/nova-core/irq.rs b/drivers/gpu/nova-core/irq.rs index c6bf1dbacabe..37dea5abf833 100644 --- a/drivers/gpu/nova-core/irq.rs +++ b/drivers/gpu/nova-core/irq.rs @@ -8,6 +8,8 @@ //! //! See `Documentation/gpu/nova/core/interrupts.rst`. =20 +#[cfg(CONFIG_NOVA_CORE_IRQ_SELFTEST)] +pub(crate) mod doorbell_test; mod hal; mod interrupt_tree; mod regs; diff --git a/drivers/gpu/nova-core/irq/doorbell_test.rs b/drivers/gpu/nova-= core/irq/doorbell_test.rs new file mode 100644 index 000000000000..3fd8b26e135e --- /dev/null +++ b/drivers/gpu/nova-core/irq/doorbell_test.rs @@ -0,0 +1,294 @@ +// SPDX-License-Identifier: GPL-2.0 +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIA= TES. All rights reserved. + +//! Interrupt delivery self-test, driven through the CPU doorbell vector. +//! +//! Exercises the whole PCI interrupt path (GPU to PCIe to CPU to handler)= with no GSP dependency: +//! it injects a known vector through the GIN software trigger and confirm= s the handler runs. Two +//! interrupts are triggered one at a time, which also covers the rearm th= at every delivery after +//! the first depends on. Gated behind `CONFIG_NOVA_CORE_IRQ_SELFTEST` and= run before GSP boot, so +//! it never observes or clears GSP interrupt state. +//! +//! See `Documentation/gpu/nova/core/interrupts.rst`. + +use core::pin::Pin; + +use kernel::{ + device::Bound, + irq, + pci, + prelude::*, + sync::{ + atomic::{ + Atomic, + Relaxed, // + }, + Completion, // + }, + time, // +}; + +use super::interrupt_tree::{ + GinVector, + LeafEnableGuard, + LeafMask, + Subtree, + TopEnableGuard, + Tree, // +}; +use crate::{ + driver::Bar0, + gpu::Chipset, // +}; + +/// Fixed vector for the CPU doorbell. +/// +/// The resource manager pins the CPU doorbell to this vector on every sup= ported chip, so nova-core +/// uses the constant directly instead of discovering it at runtime. +const DOORBELL_VECTOR: GinVector =3D GinVector::new::<129>(); + +/// Subtree carrying the doorbell vector, and the only subtree this test s= ervices. +/// +/// Derived from the vector so that changing `DOORBELL_VECTOR` moves the a= llocation, the subtree it +/// enables, and the handler together. +const DOORBELL_SUBTREE: Subtree =3D DOORBELL_VECTOR.subtree(); + +/// Time allowed for each of the two deliveries to arrive. +const DELIVERY_TIMEOUT_MS: time::Msecs =3D 1000; + +/// Interrupt handler installed by the self-test. +/// +/// Services the doorbell the way a notification source is serviced: it cl= ears its own leaf bit and +/// rearms PCI interrupt delivery, leaving the rest of the tree untouched.= It records the leaf's +/// pending bits seen on each of the first two deliveries and signals the = matching completion. +#[pin_data] +struct DoorbellTestHandler<'a> { + /// The interrupt tree, which carries the borrowed BAR0 that register = access needs. + tree: Tree<'a>, + /// Signalled by the first delivery. + #[pin] + first: Completion, + /// Signalled by the second delivery. + #[pin] + second: Completion, + /// Count of deliveries this handler has serviced. + irq_count: Atomic, + /// Doorbell leaf's pending bits observed on the first delivery. + first_pending: Atomic, + /// Doorbell leaf's pending bits observed on the second delivery. + second_pending: Atomic, +} + +impl irq::Handler for DoorbellTestHandler<'_> { + fn handle(&self) -> irq::IrqReturn { + // Clear only this handler's own bit and leave `TOP_EN` alone. A f= ull walk disables and + // enables the tree, which produces a delivery edge by itself and = would hide a missing PCI + // interrupt rearm. + let leaf =3D self.tree.read_pending(DOORBELL_VECTOR.leaf_index()); + let pending =3D leaf.vectors(); + if !pending.contains(DOORBELL_VECTOR.leaf_mask()) { + self.tree.rearm_pci_irq(DOORBELL_SUBTREE); + return irq::IrqReturn::None; + } + leaf.clear_vectors(DOORBELL_VECTOR.leaf_mask()); + + let count =3D self.irq_count.fetch_add(1, Relaxed); + + // Rearm before signalling, so delivery is possible again by the t= ime the waiting thread + // triggers the next vector. + self.tree.rearm_pci_irq(DOORBELL_SUBTREE); + + match count { + 0 =3D> { + self.first_pending.store(pending.into_raw(), Relaxed); + self.first.complete_all(); + } + 1 =3D> { + self.second_pending.store(pending.into_raw(), Relaxed); + self.second.complete_all(); + } + _ =3D> (), + } + + irq::IrqReturn::Handled + } +} + +/// Everything the running self-test owns, torn down in declaration order. +/// +/// That order is what every exit path, including an early error, needs: d= isabling the leaf stops +/// new deliveries, dropping the registration runs `free_irq()`, which wai= ts for a handler still in +/// flight, and only then are the tree's subtrees disabled, so a late hand= ler cannot rearm them. +struct SelftestResources<'a, 'r> { + _leaf_guard: LeafEnableGuard<'a>, + reg: Pin>>>, + _top_guard: TopEnableGuard<'a>, +} + +impl<'a> SelftestResources<'a, '_> { + /// Returns the registered handler. + fn handler(&self) -> &DoorbellTestHandler<'a> { + self.reg.handler() + } + + /// Disables the doorbell source and waits for a handler already runni= ng on another CPU. + /// + /// On return no further delivery can reach the handler, so its counte= rs and the doorbell + /// leaf hold their final values. + fn quiesce_source(&self) { + self.handler() + .tree + .disable_leaf(DOORBELL_VECTOR.leaf_index(), DOORBELL_VECTOR.le= af_mask()); + self.reg.synchronize(); + } +} + +/// Runs the interrupt delivery self-test. +/// +/// Quiesces the interrupt tree, registers a temporary handler, and inject= s the doorbell vector +/// through the GIN software trigger twice, one delivery at a time. This v= alidates the PCI +/// interrupt path from GIN to the ISR without GSP firmware, including the= rearm without which only +/// the first interrupt would arrive. The handler, its IRQ registration, a= nd all tree state are +/// torn down before this returns. +/// +/// # Errors +/// +/// `EIO` if the doorbell is already pending before the test, if the deliv= ery count is not two, if +/// the doorbell bit is still set once the source is stopped, or if either= delivery found a pending +/// bit other than the doorbell. `ETIMEDOUT` if either delivery does not a= rrive within the timeout. +pub(crate) fn run_selftest<'a>( + pdev: &'a pci::Device, + bar: Bar0<'a>, + chipset: Chipset, +) -> Result { + // The allocated interrupt type decides how the handler rearms deliver= y, so the vectors are + // allocated before the tree is built. + let vectors =3D super::alloc_vectors(pdev, DOORBELL_SUBTREE.into())?; + let request =3D vectors.request_for(DOORBELL_SUBTREE)?; + let irq_type =3D vectors.irq_type(); + let tree =3D Tree::new(bar, chipset, irq_type, DOORBELL_SUBTREE.into()= ); + let doorbell =3D DOORBELL_VECTOR.leaf_index(); + let doorbell_mask =3D DOORBELL_VECTOR.leaf_mask(); + + // Under MSI-X the subtree index is also the table entry the delivery = arrives on, so a pass + // shows that the per-subtree routing works. Under MSI every subtree s= hares one entry. + dev_info!( + pdev.as_ref(), + "interrupt self-test: starting on vector {}, subtree {}, with {:?}= \n", + DOORBELL_VECTOR.into_raw(), + DOORBELL_SUBTREE.index(), + irq_type, + ); + + // No delivery may reach the CPU before a handler is registered. `drai= n` enables the top level + // as the last step of its cycle, so disable it again afterward. + tree.disable_leaf(doorbell, doorbell_mask); + tree.drain(); + tree.disable_top(); + + // A delivery can be credited to the trigger below only if the vector = starts out clear, so + // refuse to run otherwise. + let pre_pending =3D tree.read_pending(doorbell).vectors(); + if pre_pending.contains(doorbell_mask) { + dev_warn!( + pdev.as_ref(), + "interrupt self-test: failed, vector {} already pending (leaf[= {}] pending {:#x})\n", + DOORBELL_VECTOR.into_raw(), + doorbell.get(), + pre_pending.into_raw(), + ); + return Err(EIO); + } + + let handler_init =3D try_pin_init!(DoorbellTestHandler { + tree, + first <- Completion::new(), + second <- Completion::new(), + irq_count: Atomic::new(0), + first_pending: Atomic::new(0), + second_pending: Atomic::new(0), + }? Error); + + // Register the handler before allowing any source to fire. + let reg =3D KBox::pin_init( + // SAFETY: the registration is owned by `resources` below and drop= ped before this function + // returns, so its `Drop` (which calls `free_irq()`) always runs a= nd the registration is + // never leaked or `mem::forget`-ed. + unsafe { + irq::Registration::new( + request, + irq::Flags::TRIGGER_NONE, + c"nova-core", + handler_init, + ) + }, + GFP_KERNEL, + )?; + + // From here every exit must tear down the source, the registration, a= nd the tree. The fields + // are initialized in the order the hardware requires, which is the re= verse of the declaration + // order that tears them down: the handler is registered above before = either source is + // enabled, the leaf next, and the top level last. + let resources =3D SelftestResources { + reg, + _leaf_guard: tree.enable_leaf_guarded(doorbell, doorbell_mask), + _top_guard: tree.enable_top_guarded(), + }; + let handler =3D resources.handler(); + + handler.tree.trigger(DOORBELL_VECTOR)?; + let mut completed =3D handler + .first + .wait_for_completion_timeout(time::msecs_to_jiffies(DELIVERY_TIMEO= UT_MS)) + .is_some(); + + // Trigger the second interrupt only once the first handler has cleare= d its leaf bit and + // rearmed, so the two cannot coalesce into one delivery and a handler= that never rearms + // cannot pass. + if completed { + handler.tree.trigger(DOORBELL_VECTOR)?; + completed =3D handler + .second + .wait_for_completion_timeout(time::msecs_to_jiffies(DELIVERY_T= IMEOUT_MS)) + .is_some(); + } + + // Stop the source and wait out any handler still running, so the valu= es read below are the + // final ones. + resources.quiesce_source(); + + let count =3D handler.irq_count.load(Relaxed); + let first_pending =3D LeafMask::from_raw(handler.first_pending.load(Re= laxed)); + let second_pending =3D LeafMask::from_raw(handler.second_pending.load(= Relaxed)); + let residual =3D tree.read_pending(doorbell).vectors(); + + // The self-test runs before GSP boot on a leaf that `drain` has just = cleared, and nothing + // triggers the vector after the second delivery, so each delivery mus= t find the doorbell bit + // and nothing else, and the leaf must end clear. + if completed + && count =3D=3D 2 + && first_pending =3D=3D doorbell_mask + && second_pending =3D=3D doorbell_mask + && !residual.contains(doorbell_mask) + { + dev_info!( + pdev.as_ref(), + "interrupt self-test: passed, subtree {}, {} deliveries\n", + DOORBELL_SUBTREE.index(), + count, + ); + Ok(()) + } else { + dev_warn!( + pdev.as_ref(), + "interrupt self-test: failed, {} of 2 deliveries, leaf[{}] pen= ding {:#x} and {:#x}, \ + {:#x} left set\n", + count, + doorbell.get(), + first_pending.into_raw(), + second_pending.into_raw(), + residual.into_raw(), + ); + Err(if completed { EIO } else { ETIMEDOUT }) + } +} diff --git a/drivers/gpu/nova-core/irq/interrupt_tree.rs b/drivers/gpu/nova= -core/irq/interrupt_tree.rs index 523b26d55137..1d26ca408dc3 100644 --- a/drivers/gpu/nova-core/irq/interrupt_tree.rs +++ b/drivers/gpu/nova-core/irq/interrupt_tree.rs @@ -240,6 +240,30 @@ pub(super) fn validate(self, leaves: LeafCount) -> Res= ult { } } =20 +/// Clears the enables of the vectors set in `vectors` for `leaf` (`LEAF_E= N_CLEAR`). +/// +/// Shared by [`Tree::disable_leaf`] and by [`LeafEnableGuard`]'s [`Drop`]= , which has no tree to +/// reach through. +fn clear_leaf_enables(bar: Bar0<'_>, leaf: LeafIndex, vectors: LeafMask) { + if let Some(loc) =3D CPU_INTR_LEAF_EN_CLEAR::try_at(leaf.get()) { + bar.write(loc, vectors.into_raw().into()); + } +} + +/// Clears the `TOP` enables of every subtree in `serviced` (`TOP_EN_CLEAR= `). +fn clear_top_enables(bar: Bar0<'_>, serviced: SubtreeSet) { + bar.write(CPU_INTR_TOP_EN_CLEAR, serviced.into_raw().into()); +} + +/// Clears the pending vectors set in `vectors` for `leaf` (write-1-to-cle= ar). +fn clear_leaf_pending(bar: Bar0<'_>, leaf: LeafIndex, vectors: LeafMask) { + if !vectors.is_empty() { + if let Some(loc) =3D CPU_INTR_LEAF::try_at(leaf.get()) { + bar.write(loc, vectors.into_raw().into()); + } + } +} + /// Returns the leaves that subtree `index` covers. /// /// An index beyond the leaf register arrays yields nothing rather than pa= nicking. @@ -251,6 +275,10 @@ fn subtree_leaves(index: u32) -> impl Iterator { } =20 /// The GIN CPU interrupt tree for a single PCIe function. +/// +/// Copying one is copying a borrowed BAR pointer and three small values, = which an interrupt +/// handler needs so that it owns a tree of its own. +#[derive(Clone, Copy)] pub(super) struct Tree<'a> { /// Borrowed BAR0, through which every tree register is reached. bar: Bar0<'a>, @@ -287,11 +315,6 @@ pub(super) fn new( } } =20 - /// Returns the subtrees this tree services. - pub(super) fn serviced(&self) -> SubtreeSet { - self.serviced - } - /// Rearms PCI interrupt delivery to the CPU after servicing `subtree`= , the one subtree the /// calling handler serves. /// @@ -310,15 +333,17 @@ pub(super) fn enable_top(&self) { =20 /// Disables this tree's serviced subtrees (`TOP_EN_CLEAR`). pub(super) fn disable_top(&self) { - self.bar - .write(CPU_INTR_TOP_EN_CLEAR, self.serviced.into_raw().into()); + clear_top_enables(self.bar, self.serviced); } =20 /// Enables this tree's serviced subtrees until the returned guard dro= ps. - pub(super) fn enable_top_guarded(&self) -> TopEnableGuard<'_> { + pub(super) fn enable_top_guarded(&self) -> TopEnableGuard<'a> { self.enable_top(); =20 - TopEnableGuard { tree: self } + TopEnableGuard { + bar: self.bar, + serviced: self.serviced, + } } =20 /// Enables the vectors set in `vectors` for `leaf` (`LEAF_EN_SET`). @@ -332,9 +357,7 @@ pub(super) fn enable_leaf(&self, leaf: LeafIndex, vecto= rs: LeafMask) { =20 /// Disables the vectors set in `vectors` for `leaf` (`LEAF_EN_CLEAR`). pub(super) fn disable_leaf(&self, leaf: LeafIndex, vectors: LeafMask) { - if let Some(loc) =3D CPU_INTR_LEAF_EN_CLEAR::try_at(leaf.get()) { - self.bar.write(loc, vectors.into_raw().into()); - } + clear_leaf_enables(self.bar, leaf, vectors); } =20 /// Enables `vectors` for `leaf` until the returned guard drops. @@ -342,24 +365,24 @@ pub(super) fn enable_leaf_guarded( &self, leaf: LeafIndex, vectors: LeafMask, - ) -> LeafEnableGuard<'_> { + ) -> LeafEnableGuard<'a> { self.enable_leaf(leaf, vectors); =20 LeafEnableGuard { - tree: self, + bar: self.bar, leaf, vectors, } } =20 /// Reads the vectors pending in `leaf`. - pub(super) fn read_pending(&self, leaf: LeafIndex) -> LeafPending<'_> { + pub(super) fn read_pending(&self, leaf: LeafIndex) -> LeafPending<'a> { let pending =3D CPU_INTR_LEAF::try_at(leaf.get()) .map(|loc| self.bar.read(loc).into_raw()) .unwrap_or(0); =20 LeafPending { - tree: self, + bar: self.bar, leaf, pending: LeafMask::from_raw(pending), } @@ -389,6 +412,7 @@ pub(super) fn trigger(&self, vector: GinVector) -> Resu= lt { /// /// This clears enables outside the subtrees nova-core services, so it= is a probe-time /// operation only. + #[expect(dead_code)] pub(super) fn disable_all_leaves(&self) { for index in 0..self.leaves.into_raw() { if let Some(leaf) =3D LeafIndex::try_new(index) { @@ -427,7 +451,7 @@ pub(super) fn drain(&self) { /// Holding one is the proof that the leaf was read, which is what [`Self:= :clear`] and /// [`Self::clear_vectors`] require. pub(super) struct LeafPending<'a> { - tree: &'a Tree<'a>, + bar: Bar0<'a>, leaf: LeafIndex, pending: LeafMask, } @@ -449,11 +473,7 @@ pub(super) fn clear(&self) { /// A handler that services one vector uses this rather than [`Self::c= lear`], which clears /// every vector the leaf had pending. pub(super) fn clear_vectors(&self, vectors: LeafMask) { - if !vectors.is_empty() { - if let Some(loc) =3D CPU_INTR_LEAF::try_at(self.leaf.get()) { - self.tree.bar.write(loc, vectors.into_raw().into()); - } - } + clear_leaf_pending(self.bar, self.leaf, vectors); } } =20 @@ -462,24 +482,25 @@ pub(super) fn clear_vectors(&self, vectors: LeafMask)= { /// Dropping it disables the same vectors, so an error path cannot leave a= source enabled with no /// handler behind it. pub(super) struct LeafEnableGuard<'a> { - tree: &'a Tree<'a>, + bar: Bar0<'a>, leaf: LeafIndex, vectors: LeafMask, } =20 impl Drop for LeafEnableGuard<'_> { fn drop(&mut self) { - self.tree.disable_leaf(self.leaf, self.vectors); + clear_leaf_enables(self.bar, self.leaf, self.vectors); } } =20 /// Keeps a tree's serviced subtrees enabled at `TOP` for as long as it is= held. pub(super) struct TopEnableGuard<'a> { - tree: &'a Tree<'a>, + bar: Bar0<'a>, + serviced: SubtreeSet, } =20 impl Drop for TopEnableGuard<'_> { fn drop(&mut self) { - self.tree.disable_top(); + clear_top_enables(self.bar, self.serviced); } } diff --git a/drivers/gpu/nova-core/nova_core.rs b/drivers/gpu/nova-core/nov= a_core.rs index dfd11dfe562c..65ce547bd44e 100644 --- a/drivers/gpu/nova-core/nova_core.rs +++ b/drivers/gpu/nova-core/nova_core.rs @@ -17,7 +17,7 @@ mod fsp; mod gpu; mod gsp; -#[expect(dead_code)] +#[cfg_attr(not(CONFIG_NOVA_CORE_IRQ_SELFTEST), expect(dead_code))] mod irq; mod mctp; #[macro_use] --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011041.outbound.protection.outlook.com [52.101.52.41]) (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 F347535E950 for ; Sat, 29 Aug 2026 01:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967222; cv=fail; b=KsaFW4m6yya+y/ft6VKYDMgaqPdx1ZhUQsjZsd2FEKLRGT0fyp9e8UfoCwMhVCtY7U3HECcSZ8XDhcq+jand5S5vZ1+X5wT78UgxxFBtMbrHIVqrjW+2BIvYCjJUNyTvlauyslSLpDbK25qsQk+NzoxnlVWDnqhLiZovyv/8wVE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967222; c=relaxed/simple; bh=b9HzY3kJVVTLGqS0zdMEDaHaL2S8Rmd+KC/3NRetZTc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Hjwg9C6kaxo0PZJsZ8Z9iphkMM4GOdZWCsy18jUAke3sENnuoAboRMp1f/G2cYadUVrqjKRka2bZaWtzUelj1+M1K3MbIFBYq7Vu3yTyq1xm2QBNZRJpXB41BkXNgFAw50j7RSn8ddFF0KzqQHmQGu4FWURX9kAMl4EYFO/zX0c= 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=NlFkgonH; arc=fail smtp.client-ip=52.101.52.41 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="NlFkgonH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I3DCK1CAps5yM6V9AH/s2B0vrAqzGdM/6JwG4aFoV9dqB9uIy+glT8KrvP80TUW9jYJwhBDNSU+EA3du+sjOmBYlB9aB6bks2LMCsfZKJGnTVR1kILfM8ErdrxZD6ygCTPCBh1XQk4ZgQy6VvF7j3vHW49T0KidnTxw7IXSZGz0zdc8sjvm1394XS403dn/dJOYBIZmSE5bR1KJqzDN1tFph8AQsU6Jk7NqK+Tq64vEaSPNp8+MWWF6gfc5Mhf5ygufEMHnED861A3JVPXQu20GyryfhlG1VrtkxjYn5IgWfg1M6KnUaR6DtcHTwyfV8kZSR1Lsl1t/vKbLzIk08+Q== 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=Mlk5ak3/7QCGT1Ud2zxMof2+83i8+FVYy8dkXQSeS1U=; b=ARSaB3OpM1h/OOUAk3lo5FzTHBKcSE+Zq0Wtxobhv6wjkJYWxewrNKRAPS+yKMbhaNoz3NaXulrQtKZaxZOf5wgiYPBVR8RKOrxK79S8rElfHacCpWETQ9R40TdWBEV+caYhnQspJAqI5zed/Oj60MxpNne27sKN1e2yGXpgoLTPAFG5XuJVIdFiUo0Nfca67MTPelNDrE8/xvZlfLGszxzNFeuAstbNVZcmd65vdbOnwvN+nj5ii56V7+E8MTElewCMxNu2hih0bwYb8R8pZiIHFM6eqHd2al1iRASNWLHLwoI5KmKJYKiASB2/lkN3RtVBoeEc5zhJoujjdn9cDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Mlk5ak3/7QCGT1Ud2zxMof2+83i8+FVYy8dkXQSeS1U=; b=NlFkgonHvnfM7XCX9QAxNnYAJA6CO78QKEPGYmvD83buMz6lHylusfA3T1ux11wOBH9xhOPPLmZhoFvn8sc3EYns0F1pvS8CmYhnE/Z3I8gbUz2Kif+g/JcJz14ixnn+EJwviqK/b2PrBrqW6QLhROP7x16HBeDAOPp/Wt+XElVa9BYZ8FP78f6erGk1jACeuNihJAwyNKI94MNg2PExQ4MpiQe5lRCY5mwoPuWTJPJlCHQqtSZpa4EWHjGbE94zc7lrJc5brSTiFgzjEkXWbMCyc5Sob0CnwkJT8N2iqzZjX39xBVyf9Wr5R3bo1t45Ui+sKpvapXB6NISP/bK+RQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by SAVPR12MB999121.namprd12.prod.outlook.com (2603:10b6:806:4e7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:33:34 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:33:34 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard Subject: [PATCH v2 08/15] gpu: nova-core: dispatch GSP events instead of discarding them Date: Fri, 28 Aug 2026 18:33:27 -0700 Message-ID: <20260829013324.499542-13-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BY3PR05CA0035.namprd05.prod.outlook.com (2603:10b6:a03:39b::10) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|SAVPR12MB999121:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bf021d5-d667-4ab7-3299-08df056d8a44 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|1800799024|366016|6133799003|10067099003|56012099006|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: cBbkoOdpyQpjJnbP+LAJwA6/a5W94LknclF6l35X6joc8rXgErB/MHe0yzettL34G3LLEVolOpXIvnWCrDe0i2VwaiW+vg+xnV9gPjrOFeS2a57iZXtMzKqWJc1uUpih55joBUBO3ej/iEZRlq0cGHia7jKTG0mJLCG8FCSjlIn3ws2KPQ1nDCj7Qf17xg2OKco/cjhbtNo3uZLzzTIVYYMcVTjgp1673NfRHW79nLfz11eobHTyjyWkC0SDYLgFaXSlgLug48y9Ai6tq76Y7y6c4LiC9A4soSuoBvOlv1kXOHPOb8EPhsXNGdkso/l0TEF1lga86Q20D/utP4j40DfYQWWGc88rxpC5BRokPyXHxZkm02Y57xOV7ZkkgWE4gp2utK/HBX80cKhouO15/DolJStFfRtnYgqWqgiei3mLEefYwiaUC1UA+XpoQ2dHnIa2OxKoIlxmsR8CxQ/kbWmQgyzUTnVka7x9BwaRefMvg54j3PYGceByDIMpJFG6kbgh6AmFbvDxRURWrMcWmJ2xsj9qw/+SIptnE7JqAsH/T35SH2c/QpZMTTMExft0VSs57C26QiEJUf5lMhAhfiU/3CWx0O+t6sN9VBWGF2xTuffcpB/Ktp9GU6DKfi5QK3QnLjn89M0yc1YQJVf1VDrF4GJ19jBTYhAZjX1I9aM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(1800799024)(366016)(6133799003)(10067099003)(56012099006)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?TyOOLztPHGwdhBD2T7obDDOUQ+bPCE2fIDoR1LUr0UAN0iuoTwpvg1+YuS4a?= =?us-ascii?Q?DCyunWIgmwRzk38ftU+c+jtHfux/QCDAAkkYtz3HuE1YypESmpJVbGdDtS91?= =?us-ascii?Q?VjbhmQUYxmO1VvwRGoGpSzDkaY3ylE/jZIGc/WC3xhGdTlhjcawT5RNcnba3?= =?us-ascii?Q?wz8vQtXMX7ECFzZCeL7SZ77cSo0HOMeOPwjYYYdjCnZP1x4AM5bLiyxN3m42?= =?us-ascii?Q?83kxHY0erSim62cHm9YQTRH8e1lluMgYiQdWW1ObA3zuUCHgIZdsRpdQcj3/?= =?us-ascii?Q?ERpS+96ZI7y4VVJg6Bgv+NQ9jZ+Obbid7lhXIJqe5YVUEO0DQZGOqawxMgAD?= =?us-ascii?Q?5YWj/vhOL0gSomPGtxqJ3uK2f1xwrVLaxGEHPhQizGiZWicwKBhLaG1AZgem?= =?us-ascii?Q?SUagmCCl2JBVrlkdHH2gIc5E62N/OKdEZSyBN29BCWU6iC7dbAMLLLZqpRvd?= =?us-ascii?Q?cDoxIMQPRz3aNQwWJi/7fdmNhmqVkXsrAnhgkC5K1aPe+4hae8PzoAoBgsJN?= =?us-ascii?Q?HINVRTg/XP77a4f4wEJ4w/eBhysnb50og88ranRLxcBauB/+/pdhbDQ5XpSQ?= =?us-ascii?Q?ajKZJIZsepbOMw4yLL5rue9tpR55sudB2vn8+AA/2NUd6RYlZOvv5klPcOKm?= =?us-ascii?Q?EmQjLNomminc6dLMwWPiJSABKMLutkLbwa9yIMwXY9Uuj5GaRATJ3A9sXg5D?= =?us-ascii?Q?Z/pvSIa3JbTL8d0DP/0RsHyu6GCFqI8tm7m4CgXbpLFXW/w1SC3VHKx4rHoQ?= =?us-ascii?Q?jX7FLz9FtR2BrWSmc3rR9G9srUSzKJV8OLrlZoZvkqV08ZXQlBgjIft5WnkE?= =?us-ascii?Q?UH601h38eiVlVXRzHjCczg6xO1pK/UvX2ZPEcJpQpL1I0EVzK9w47hBL6Q2e?= =?us-ascii?Q?mmJh63iEGTW/vD47ldupfBUmxMoFxmi0IW8sjpYoxKT+XFMzNNCC0GHwXvhq?= =?us-ascii?Q?gdnWE03xgBBWYUUAnKRCjR+lQGHeh+6etUWYH90NrHzkFTobUrll94DcIAOp?= =?us-ascii?Q?m2m39HVflWPWI9TSeFheNwOmA9n4sJHhBk/KeHsjPtVoLFrfH5nZd9DkwT7S?= =?us-ascii?Q?C+N8W+jRn1ERe5G3FUt8sqSECqVPG65XMRW8vyEVrYXDvHg0hTpnCbLfbgXs?= =?us-ascii?Q?lEp8naQWU2DUk2xn6ZBEXKbY3omn9FQod7/M/EnbbKZ7IYR7mL3Jxz57nkBW?= =?us-ascii?Q?nTTgXMI/oQCsJ41J8atNVUkdGs4d50FaZst5et5wmKEPdjms33F8QdyTqPhH?= =?us-ascii?Q?eJuCM/krbgHgUvyBRKa/2owlaC511wi9dUGFNUORmf3AoWB0Km6JN6N9xDR9?= =?us-ascii?Q?tc+e5HuGKiYQwtDQJtuVxmiyqlR8BH/z4hrV4j8PNHsDqkid2huW/BkPiZdi?= =?us-ascii?Q?a7O8LL/KwZC3LPaQ9eqHmQGLWZ9F6Omrx1MIDeBDVQkp23ew/HfNv9qZ4dGb?= =?us-ascii?Q?AWmkeBXxkrlxtUvQYVMi7auUVmB3ZcoIlwi98SfyJB2lqwo0+TX/lb5jf/Cj?= =?us-ascii?Q?4xVA6qKlBfpBtFfAnCWnY7ruODvLo3VuB/IumYV+OupCsMqG5U9qeWqTV4bt?= =?us-ascii?Q?NmSSVHZ+40kbKMcg4CpThRmrOHP0uABxxFMTsK2itAfUS7QgScg7Zalw6HWA?= =?us-ascii?Q?5zabshVt8Mm6AAmaFitpG7eJ5S+PUinh52OBRW4zXrM97RUzIC3EnonT5EA0?= =?us-ascii?Q?t94sNhyVmulO/2agmlmrchLTdPM9tygijXKYMg/AqKIb4pAfHy8eOQwQ8gFc?= =?us-ascii?Q?l/Le6epyRQ=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7bf021d5-d667-4ab7-3299-08df056d8a44 X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:33:34.0997 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LZaoAG4DBXTqpibgAX9je3iSL2NFIAxxaFTFLX490lhWk5YH/LnsPUELMi31FB1WCwI0DFRnFHAWMZwlhvd1Ow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SAVPR12MB999121 Content-Type: text/plain; charset="utf-8" The GSP posts unsolicited messages onto the same queue that carries command replies: logs, OS error and robust-channel records, and lifecycle notices. Anything that was not the reply a caller awaited was discarded, and an unrecognized function code aborted the in-flight command, so the GSP's error reports never reached the log. Route every non-reply message to a dispatcher, which logs the error records and leaves the in-flight command waiting for its reply. The dispatch runs on the existing command and wait loops, so events are handled during normal operation before any interrupt exists. Event payloads, such as XID numbers and log contents, are not decoded. Assisted-by: Cursor:claude-opus-5 Signed-off-by: John Hubbard --- drivers/gpu/nova-core/gsp/cmdq.rs | 64 ++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/= cmdq.rs index f0f28b6ded7a..0df52df1da89 100644 --- a/drivers/gpu/nova-core/gsp/cmdq.rs +++ b/drivers/gpu/nova-core/gsp/cmdq.rs @@ -547,11 +547,11 @@ fn notify_gsp(bar: Bar0<'_>) { =20 /// Sends `command` to the GSP and waits for the reply. /// - /// Messages with non-matching function codes are silently consumed un= til the expected reply - /// arrives. + /// A message read while waiting that is not the reply goes to + /// [`CmdqInner::dispatch_event`]. /// - /// The queue is locked for the entire send+receive cycle to ensure th= at no other command can - /// be interleaved. + /// The queue is locked for the entire send+receive cycle, so no other= command can be + /// interleaved. /// /// # Errors /// @@ -805,8 +805,10 @@ fn wait_for_msg(&self, timeout: Delta) -> Result> { =20 /// Receive a message from the GSP. /// - /// The expected message type is specified using the `M` generic param= eter. If the pending - /// message has a different function code, `ERANGE` is returned and th= e message is consumed. + /// The expected message type is specified using the `M` generic param= eter. A message whose + /// function code matches is decoded and returned. Any other message, = whether its function code + /// is a different one or is unrecognized, goes to [`Self::dispatch_ev= ent`] and `ERANGE` is + /// returned. /// /// The read pointer is always advanced past the message, regardless o= f whether it matched. /// @@ -815,8 +817,7 @@ fn wait_for_msg(&self, timeout: Delta) -> Result> { /// - `ETIMEDOUT` if `timeout` has elapsed before any message becomes = available. /// - `EIO` if there was some inconsistency (e.g. message shorter than= advertised) on the /// message queue. - /// - `EINVAL` if the function code of the message was not recognized. - /// - `ERANGE` if the message had a recognized but non-matching functi= on code. + /// - `ERANGE` if the message was not the awaited reply. /// /// Error codes returned by [`MessageFromGsp::read`] are propagated as= -is. fn receive_msg(&mut self, timeout: Delta) -> Result= @@ -825,11 +826,13 @@ fn receive_msg(&mut self, timeout:= Delta) -> Result Error: From, { let message =3D self.wait_for_msg(timeout)?; - let function =3D message.header.function().map_err(|_| EINVAL)?; + let function =3D message.header.function(); + let seq =3D message.header.sequence(); + let matched =3D matches!(function, Ok(f) if f =3D=3D M::FUNCTION); =20 - // Extract the message. Store the result as we want to advance the= read pointer even in - // case of failure. - let result =3D if function =3D=3D M::FUNCTION { + // Bind the result rather than returning early. The read pointer m= ust advance past this + // message on every path. + let result =3D if matched { let (cmd, contents_1) =3D M::Message::from_bytes_prefix(messag= e.contents.0).ok_or(EIO)?; let mut sbuffer =3D SBufferIter::new_reader([contents_1, messa= ge.contents.1]); =20 @@ -840,7 +843,7 @@ fn receive_msg(&mut self, timeout: D= elta) -> Result dev_warn!( &self.dev, "GSP message {:?} has unprocessed data\n", - function + M::FUNCTION ); } }) @@ -853,6 +856,41 @@ fn receive_msg(&mut self, timeout: = Delta) -> Result message.header.length().div_ceil(GSP_PAGE_SIZE), )?); =20 + if !matched { + self.dispatch_event(function, seq); + } + result } + + /// Routes a GSP message that is not the reply a caller is waiting for. + /// + /// GSP-reported errors are logged at error level and unrecognized fun= ction codes at warning + /// level. Every other known function code is consumed without a log l= ine, because the RPC + /// receive trace in [`Self::wait_for_msg`] already records its arriva= l. + fn dispatch_event(&self, function: Result, seq: u32)= { + match function { + Ok(MsgFunction::OsErrorLog) =3D> { + dev_err!(&self.dev, "GSP reported an OS error (seq {})\n",= seq); + } + Ok(MsgFunction::RcTriggered) =3D> { + dev_err!( + &self.dev, + "GSP triggered robust-channel recovery (seq {})\n", + seq + ); + } + // GSP logs, libos prints, NoCat assertion records, and the ot= her known event codes. + // None of them requires action. + Ok(_) =3D> {} + Err(raw) =3D> { + dev_warn!( + &self.dev, + "unknown GSP message function {:#x} (seq {})\n", + raw, + seq + ); + } + } + } } --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011041.outbound.protection.outlook.com [52.101.52.41]) (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 A8FF0387346 for ; Sat, 29 Aug 2026 01:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967224; cv=fail; b=ECat+ateoniPcHnYDeN70lOPrZ9MtWPTisV2RLC0RNjC57gJf+S4eDn+0EI8+xDbpn7H+1cFmldZyBOEEoc0O1f83dK+H+fRE2zE8zVAz/p8k7/L8l+gYfNB+3LN8zSO9qxWfI1E8y96uPWIApYuP0EoBOHg8pb7m+nAZjT0psc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967224; c=relaxed/simple; bh=pht1DVQLuulETVRWMNi0PSOyv8J5sl57fBGUg9r7jM4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Ltny2GajwkCaDljynLH880yRcyHnUx6RiOhxfSY7qEKLoYRMJeygnJWdvS6BYu3ION7KtGnhlArjb1G2wBmEOTKUz05Y1TiGGf8RROGCpQXGozqMeaFok589D3I/rgNVl6C0Ibcy5QRGPdlNgp0vw9BbcWuUyXYL2pfWFDqnJp0= 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=X9wN1c/s; arc=fail smtp.client-ip=52.101.52.41 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="X9wN1c/s" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AaUjCnXkBnQZ9dVKCWyKis1lzZvYD+g0J2aTR0A/YpYEi/FoTpEwoXICj3cTOGTC1qnEeO5mPeBFZoQj4yEfoJv9vg/c6y20FTwz4vMPIrc4VmWT8Ed6Vec95Iy2o/YrTcTsLrCwTfE0fneFvzSsCtB9pQrQneb4s0G42bUtFNrv4XXri4CteR9FXCJB7zoUZCFv57CFwNCGsssm85CakEXeuG/zy/skfmTrWduP1yJJJfSrzhf/n9KcsHv3uYriimLVLD8BPMbdQh8cEGRMYqqUEMGlyCygt0uKjYbaEQMV+kHFJ1DGFyMA5IXlNG7cllBBooNGWgzQzgqsQ0zBFA== 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=wHz3y5DKMJJ+2f2yTsIvFfnrNYxw/0un4RdJnBO8EFo=; b=J8a0YcqE4nYDpXe6ptba+T13nF5Y+wuIJchuXrxAsAFbWMIl1UrrnrECnC1ITf1z9qdKxpHXvM8izicI9VGLfya+3qaLcd/mtkg00jcTf9z09sFaM/aVptWSZQyK6xp7ckbjxNrS8lWDrhTUt0AicV38148F7hdLnr20pYlxiGnBUBbLm0mQaPQwRwCMl0UUq8DNXvUAOtunMbvhr/+Nsuf1SUppNfRa1MOeSpZKtie62x+g3JDR5k2aNZVqAIqWOnYrONB05IHru5gj/HwvSHp3kRfNKTK0s9UrxA+R1+v3X4sI005EJTRg5BI+J4x4Ujmqo1sn0sJthqi5DQqJdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wHz3y5DKMJJ+2f2yTsIvFfnrNYxw/0un4RdJnBO8EFo=; b=X9wN1c/s2JXVt9JTnGU/MJqbp+J+07y87SCreyWK6Rd2xICYhGZmx0TscqZ2f593gbEUdT9WEB9/2wt3LNTPWaFICrQKCWNdMZxnuS7jFLouK2M5Z+eW2LDO7Spa5ng3Ucj34rw42X4Cp8XiPyYATfsWkJJDALhtp3kwSx25rnz400Y6ALEcevYD5CvCzoH4+C5XbEqCPxnZIkjJBgNEXIwLS/Z7AtobydnQFVDlQgtFrv+vaGa1RKg3m079x4x+8yvfFSZtMekwAoct3RuQcGRR4xOjcpLJydKhtkAuSomVZAeJybpPiblBVCXOyJSR/FBoL3XjvRvNNet+oEOovQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by SAVPR12MB999121.namprd12.prod.outlook.com (2603:10b6:806:4e7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:33:35 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:33:35 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard Subject: [PATCH v2 09/15] gpu: nova-core: match GSP RPC replies by sequence, not just function Date: Fri, 28 Aug 2026 18:33:28 -0700 Message-ID: <20260829013324.499542-14-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR05CA0052.namprd05.prod.outlook.com (2603:10b6:a03:33f::27) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|SAVPR12MB999121:EE_ X-MS-Office365-Filtering-Correlation-Id: 849bb472-4796-4a45-e489-08df056d8ae4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|1800799024|366016|6133799003|3023799007|10067099003|56012099006|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: mr6+sITwwCM6253UEUZHFmyHAF4c2r8QESEsStprb3jPAu++INIf2Ch7v8+nXnSele7/viH7tfGdcj10z4toaBaQ82rfQTlHyuVpaFMcwr70OVrdg6FZCoHlXVT0/weZs1mzqB7HbcAneeIr/faVXLq3apVuxotZZEFDcV7bpJmdhh/neh/qFYw8oDh5c/jB+AusGdQexkYvEpDBpCNoBigXNMgnDQJUSNsu6xQUcCo78CwUtdZX9M8ZMYxuUjjfD/vhuo38jTqcZP8urL6s01Mnb8XrXJQfFNGUv+LwT5FzL8ObTBVmNajc3zjmbFotWoKK54Sks+814KYLysVDw/Pdpn+7aHGoDjKQcbsPw+q/cQYt4goyScW3FwKPERuNZcna4WruzhJ2dz9HwfD9HN30PcOFEFrSETvFbmwi4FUKzUV893FzjOTgRoOcwEOMYuvRvlHA77zberVJ0DzizxuOkbEkaVDhK9ASff94YVoayCNtT5DjJKV/TbhYLdvipC/NGwY9F/oH/rxjJ6je48uzOR+gIJxhSzyFOBNKQq/bl749Km6pUdaJflNmqrIHs/pRT7ZitwzkMIc0hDm1G9UFdxPotGvsEUa6q4nWCLLK24NThMe/EDfTBZnbIeyHuGPU+lu9Jf3cTKkZLHvbAz4MXxdcWEanMEt5Z1v3iOY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(1800799024)(366016)(6133799003)(3023799007)(10067099003)(56012099006)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?iofPit6VGPmrxl0GNVkion0qNI3vytcc8zEYGcCeM1Q6T6JS2BncCXrbmJKQ?= =?us-ascii?Q?956Aa835IYJiaBHh+HfLoMqkr43VC6rTy86e/owPlwmdCP4zDLYUgM5Zs4Xj?= =?us-ascii?Q?RIhpb8KxyKSZPAxUPIPk9I0sF3F9TU/IS5g5ObcJuRwTh1E3lDZjpg5OdkKs?= =?us-ascii?Q?SZVQgSLU5ghZdb1zNdYHzhn4A3YmHj+lTmey5w1TyJTYaK8on4sdg9DBQVto?= =?us-ascii?Q?oaONAveplAYxIbK7mlCsJ/kEo2QyxInl9h39lCFZVv9QzpA9MdE5TBC02eja?= =?us-ascii?Q?gHtJMxbfH99HTIEL7EF2ihSTJoOC3kplggwKvIvPCnxF7UEM4HVL7Ef4wDcO?= =?us-ascii?Q?cxTDT0dnsNOEUQ9RqLMPE7oGLvoj/oKxQQXtEbZmARDmNNROi00mFyomOIAe?= =?us-ascii?Q?PAv2ESlP2FYwLWtij61WsqnLLnX2/QqHnMBzv/HExkQz8JXCix13lLXBOkNf?= =?us-ascii?Q?gJPpYJYNdFjEHIbRy2nOBQCURipDqr5OxECKIRXv6Y75WpHfz+hAyGqdKSz3?= =?us-ascii?Q?fH6THS4O9A8eR4BBjjjtB5ANKiXKQT7yAHnhb5jt/BhNVTQV3pzx4DjuMu0B?= =?us-ascii?Q?9ZjIHDCT87txPTayGeNMGj2KunGYP0Tn7qJinn/Zt7Q99V6q/+dVZAHntMcF?= =?us-ascii?Q?VOLIHK2jUwpCRVVHM8TyNK6akFKnPYHfsfmXo7hjRqCGK20eflCQBXIUZhmX?= =?us-ascii?Q?pJA9reONHZIohI5RepcQyU+AoVoYboejfpKJnepLoxoe79EIj+DNB07UQT/2?= =?us-ascii?Q?v+Rj7bNjllW5HeScbbdQT1w/wx5RfvJe864dJyTCXvg9dYBQ9qsERtp0fcs6?= =?us-ascii?Q?N/ANKXu/IxOdH0m8biVmbHbWRhSgHb5JFuFjX28HkLqPppQnNX9bUm3tGrTU?= =?us-ascii?Q?4L3aNtz8ODC4eGoLp+sem/gxRdqN155VVvYXQjNQkyQ/ao+0/6Z8TKIV69dD?= =?us-ascii?Q?pjFs1faWx9Qs+tvdsugqrmp+tRa9lwiJfN9vmuIe58fOLlDQp1zRxnsx4HAp?= =?us-ascii?Q?R67/cxXKclU5wKMNa8mWT/VHgTTZX3JcKw2SwuaerTDYq2UHHt3gaWz/qJ1e?= =?us-ascii?Q?O58FMndDYC2u045mbDAqlLTM/x5LKKWBajs78RLxBS1SxYNGH61/zeWWKvmN?= =?us-ascii?Q?9Ho65vw4JYDWINHUZ1kmOOZ75LEv7eaJRrHZKKPxggFKVk+ae5quGt3lLIL4?= =?us-ascii?Q?DFYkHTb8qUwdLSpKOHhvXXlkRHyVyuIUoLtGnOvx36O6gopcmkb/M70TUXTj?= =?us-ascii?Q?JnbzCmbSUFeHCMRGZxKBc4cxqwyk93ZVSnPEE14qj+fli2IOSoXWLmcwJ42V?= =?us-ascii?Q?agZZVIx61A68IpanEX9my2ftTeEaNrynqFGC9uVkRk2PtwYRPstakumIMGcl?= =?us-ascii?Q?JDP/3YP6iVLhCcxqMf9nn4IhlEyMXZPWhz8Me9I+fp5Lm1UmGkAb4IP7zAXM?= =?us-ascii?Q?spmaj2OhboPr6m6lnY4JmLVmGNQfIAkF4xxR7hcLLxMxv/rlYXtgFWNttrWX?= =?us-ascii?Q?KSMEym78TpAxX9/C3dnKO41qXwAyEyKUBq8irf8OVihEdFmyt7K1TKhSSNaX?= =?us-ascii?Q?F7/0iL0b7vcx3CZvUi3DByLPLdPPCvSQftJt6Orvrq/Vur8vRkZ/S8x+/ilw?= =?us-ascii?Q?slXWYdo/iYEgUGRLW/2/h1FBsXWA51dg98eEwtDmuR+5Hg0esnFhiFDQ9Er1?= =?us-ascii?Q?XGff6v0s74XMFmNt7W+QDz9SExc/tKSw3kBIuc7nFa2uQT70U8Rjx54HuBML?= =?us-ascii?Q?g9T+vgD+3A=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 849bb472-4796-4a45-e489-08df056d8ae4 X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:33:35.0921 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wDNNOpqYwcb8kilKMWNhdFw1FCUwHvwDnxp1z6rcgbVgPX2Fvr8+ZFzT8QZiHsDQIW5ZoyzYu3y+3u4KH29whw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SAVPR12MB999121 Content-Type: text/plain; charset="utf-8" The GSP replies to a command by echoing that command's function code and its RPC sequence number. nova-core matched replies on the function alone and never set the sequence, so a reply for a command that had already timed out could satisfy a later command using the same function. Give the RPC sequence its own counter, separate from the per-element transport sequence, set it on every command, and require both the function and the sequence to match before accepting a reply. A message with the expected function but a stale sequence is logged and dropped, not mistaken for the reply or dispatched as an event. A caller awaiting an unsolicited event still matches on the function alone. Assisted-by: Cursor:claude-opus-5 Signed-off-by: John Hubbard --- drivers/gpu/nova-core/gsp/cmdq.rs | 89 ++++++++++++++++++++----------- drivers/gpu/nova-core/gsp/fw.rs | 13 +++-- 2 files changed, 67 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/= cmdq.rs index 0df52df1da89..3224079abf7e 100644 --- a/drivers/gpu/nova-core/gsp/cmdq.rs +++ b/drivers/gpu/nova-core/gsp/cmdq.rs @@ -521,7 +521,8 @@ pub(crate) fn new(dev: &device::Device) = -> impl PinInit(&self, bar: Bar0<'_>, c= ommand: M) -> Result::InitError>, { let mut inner =3D self.inner.lock(); - inner.send_command(bar, command)?; + let expected_seq =3D inner.send_command(bar, command)?; =20 loop { - match inner.receive_msg::(Self::RECEIVE_TIMEOUT) { + match inner.receive_msg::(Self::RECEIVE_TIMEOUT, Som= e(expected_seq)) { Ok(reply) =3D> break Ok(reply), Err(ERANGE) =3D> continue, Err(e) =3D> break Err(e), @@ -594,18 +595,19 @@ pub(crate) fn send_command_no_wait(&self, bar: Bar= 0<'_>, command: M) -> Resul M: CommandToGsp, Error: From, { - self.inner.lock().send_command(bar, command) + self.inner.lock().send_command(bar, command).map(|_| ()) } =20 /// Receive a message from the GSP. /// - /// See [`CmdqInner::receive_msg`] for details. + /// Matches on the function code alone, for a caller awaiting an unsol= icited GSP event rather + /// than a reply to a command. See [`CmdqInner::receive_msg`]. pub(crate) fn receive_msg(&self, timeout: Delta) ->= Result where // This allows all error types, including `Infallible`, to be used= for `M::InitError`. Error: From, { - self.inner.lock().receive_msg(timeout) + self.inner.lock().receive_msg(timeout, None) } } =20 @@ -613,8 +615,13 @@ pub(crate) fn receive_msg(&self, ti= meout: Delta) -> Result struct CmdqInner { /// Device this command queue belongs to. dev: ARef, - /// Current command sequence number. - seq: u32, + /// Next transport sequence number for a queue element (the `seqNum` f= ield). Advances once per + /// queue element, including each continuation record. + elem_seq: u32, + /// Next RPC sequence number. The GSP echoes it in a command's reply, = which lets + /// [`CmdqInner::receive_msg`] match that reply to the awaiting comman= d. Advances once per + /// logical command. + rpc_seq: u32, /// Memory area shared with the GSP for communicating commands and mes= sages. gsp_mem: DmaGspMem, } @@ -633,7 +640,7 @@ impl CmdqInner { /// written to by its [`CommandToGsp::init_variable_payload`] method. /// /// Error codes returned by the command initializers are propagated as= -is. - fn send_single_command(&mut self, bar: Bar0<'_>, command: M) -> Res= ult + fn send_single_command(&mut self, bar: Bar0<'_>, command: M, rpc_se= q: u32) -> Result where M: CommandToGsp, // This allows all error types, including `Infallible`, to be used= for `M::InitError`. @@ -650,7 +657,7 @@ fn send_single_command(&mut self, bar: Bar0<'_>, com= mand: M) -> Result let (cmd, payload_1) =3D M::Command::from_bytes_mut_prefix(dst.con= tents.0).ok_or(EIO)?; =20 // Fill the header and command in-place. - let msg_element =3D GspMsgElement::init(self.seq, size_in_bytes, M= ::FUNCTION); + let msg_element =3D GspMsgElement::init(self.elem_seq, rpc_seq, si= ze_in_bytes, M::FUNCTION); // SAFETY: `msg_header` and `cmd` are valid references, and not to= uched if the initializer // fails. unsafe { @@ -678,23 +685,25 @@ fn send_single_command(&mut self, bar: Bar0<'_>, c= ommand: M) -> Result dev_dbg!( &self.dev, "GSP RPC: send: seq# {}, function=3D{:?}, length=3D0x{:x}\n", - self.seq, + rpc_seq, M::FUNCTION, dst.header.length(), ); =20 // All set - update the write pointer and inform the GSP of the ne= w command. let elem_count =3D dst.header.element_count(); - self.seq +=3D 1; + self.elem_seq =3D self.elem_seq.wrapping_add(1); self.gsp_mem.advance_cpu_write_ptr(elem_count); Cmdq::notify_gsp(bar); =20 Ok(()) } =20 - /// Sends `command` to the GSP. + /// Sends `command` to the GSP and returns the RPC sequence number ass= igned to it. /// - /// The command may be split into multiple messages if it is large. + /// The command may be split into multiple messages if it is large. Th= e GSP echoes the + /// sequence number in the reply, so a caller passes it to [`Self::rec= eive_msg`] to match the + /// reply to this command. /// /// # Errors /// @@ -703,24 +712,26 @@ fn send_single_command(&mut self, bar: Bar0<'_>, c= ommand: M) -> Result /// written to by its [`CommandToGsp::init_variable_payload`] method. /// /// Error codes returned by the command initializers are propagated as= -is. - fn send_command(&mut self, bar: Bar0<'_>, command: M) -> Result + fn send_command(&mut self, bar: Bar0<'_>, command: M) -> Result where M: CommandToGsp, Error: From, { + let rpc_seq =3D self.rpc_seq; + self.rpc_seq =3D self.rpc_seq.wrapping_add(1); + match SplitState::new(command)? { - SplitState::Single(command) =3D> self.send_single_command(bar,= command), + SplitState::Single(command) =3D> self.send_single_command(bar,= command, rpc_seq)?, SplitState::Split(command, mut continuations) =3D> { - self.send_single_command(bar, command)?; + self.send_single_command(bar, command, rpc_seq)?; =20 while let Some(continuation) =3D continuations.next() { - // Turbofish needed because the compiler cannot infer = M here. - self.send_single_command::>(bar= , continuation)?; + self.send_single_command::>(bar= , continuation, rpc_seq)?; } - - Ok(()) } } + + Ok(rpc_seq) } =20 /// Wait for a message to become available on the message queue. @@ -805,10 +816,14 @@ fn wait_for_msg(&self, timeout: Delta) -> Result> { =20 /// Receive a message from the GSP. /// - /// The expected message type is specified using the `M` generic param= eter. A message whose - /// function code matches is decoded and returned. Any other message, = whether its function code - /// is a different one or is unrecognized, goes to [`Self::dispatch_ev= ent`] and `ERANGE` is - /// returned. + /// The expected message type is given by the `M` generic parameter. W= ith `expected_seq` set, + /// the message must also carry that RPC sequence number to count as t= he awaited reply. With + /// `None`, the function code alone decides the match. + /// + /// A matching message is decoded and returned. A message carrying the= expected function code + /// with a different sequence is a stale reply to a command that alrea= dy timed out, and is + /// logged and dropped. Any other message goes to [`Self::dispatch_eve= nt`]. Both non-matching + /// cases return `ERANGE`. /// /// The read pointer is always advanced past the message, regardless o= f whether it matched. /// @@ -820,7 +835,11 @@ fn wait_for_msg(&self, timeout: Delta) -> Result> { /// - `ERANGE` if the message was not the awaited reply. /// /// Error codes returned by [`MessageFromGsp::read`] are propagated as= -is. - fn receive_msg(&mut self, timeout: Delta) -> Result= + fn receive_msg( + &mut self, + timeout: Delta, + expected_seq: Option, + ) -> Result where // This allows all error types, including `Infallible`, to be used= for `M::InitError`. Error: From, @@ -828,10 +847,10 @@ fn receive_msg(&mut self, timeout:= Delta) -> Result let message =3D self.wait_for_msg(timeout)?; let function =3D message.header.function(); let seq =3D message.header.sequence(); - let matched =3D matches!(function, Ok(f) if f =3D=3D M::FUNCTION); + let func_matches =3D matches!(function, Ok(f) if f =3D=3D M::FUNCT= ION); + let matched =3D func_matches && expected_seq.is_none_or(|expected|= seq =3D=3D expected); =20 - // Bind the result rather than returning early. The read pointer m= ust advance past this - // message on every path. + // Every path must advance the read pointer past this message. let result =3D if matched { let (cmd, contents_1) =3D M::Message::from_bytes_prefix(messag= e.contents.0).ok_or(EIO)?; let mut sbuffer =3D SBufferIter::new_reader([contents_1, messa= ge.contents.1]); @@ -857,7 +876,17 @@ fn receive_msg(&mut self, timeout: = Delta) -> Result )?); =20 if !matched { - self.dispatch_event(function, seq); + if func_matches { + dev_warn!( + &self.dev, + "GSP RPC: dropping stale {:?} reply (seq {}, awaiting = {:?})\n", + M::FUNCTION, + seq, + expected_seq, + ); + } else { + self.dispatch_event(function, seq); + } } =20 result diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw= .rs index 05f54fee6186..0b01c81ec092 100644 --- a/drivers/gpu/nova-core/gsp/fw.rs +++ b/drivers/gpu/nova-core/gsp/fw.rs @@ -782,13 +782,14 @@ fn new() -> Self { } =20 impl bindings::rpc_message_header_v { - fn init(cmd_size: usize, function: MsgFunction) -> impl Init { + fn init(sequence: u32, cmd_size: usize, function: MsgFunction) -> impl= Init { type RpcMessageHeader =3D bindings::rpc_message_header_v; =20 try_init!(RpcMessageHeader { header_version: MsgHeaderVersion::new().into(), signature: bindings::NV_VGPU_MSG_SIGNATURE_VALID, function: function.into(), + sequence, length: size_of::() .checked_add(cmd_size) .ok_or(EOVERFLOW) @@ -813,25 +814,27 @@ impl GspMsgElement { /// /// # Arguments /// - /// * `sequence` - Sequence number of the message. + /// * `elem_seq` - Transport sequence number of the queue element (`se= qNum`). + /// * `rpc_seq` - RPC sequence number, echoed by the GSP in the reply. /// * `cmd_size` - Size of the command (not including the message elem= ent), in bytes. /// * `function` - Function of the message. pub(crate) fn init( - sequence: u32, + elem_seq: u32, + rpc_seq: u32, cmd_size: usize, function: MsgFunction, ) -> impl Init { type RpcMessageHeader =3D bindings::rpc_message_header_v; type InnerGspMsgElement =3D bindings::GSP_MSG_QUEUE_ELEMENT; let init_inner =3D try_init!(InnerGspMsgElement { - seqNum: sequence, + seqNum: elem_seq, elemCount: size_of::() .checked_add(cmd_size) .ok_or(EOVERFLOW)? .div_ceil(GSP_PAGE_SIZE) .try_into() .map_err(|_| EOVERFLOW)?, - rpc <- RpcMessageHeader::init(cmd_size, function), + rpc <- RpcMessageHeader::init(rpc_seq, cmd_size, function), ..Zeroable::init_zeroed() }); =20 --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011041.outbound.protection.outlook.com [52.101.52.41]) (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 D42743A5429 for ; Sat, 29 Aug 2026 01:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967226; cv=fail; b=MyC+Xeujnr4bPgQlmds0iFsEKXe/pLEYYiiEJrQggyqj/7QLeOvJE6uZx/Q3aaUOO5PxWa2gAVwyeBbErVaBEHqXnFkqler8mVCABH1/p8clvuFJn9gl1AS85G0R+5tRpTe4I+iySjAPmIwdEbGpKlCGJvWAB0FvqaLdeSA9i2o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967226; c=relaxed/simple; bh=cb1BJP5hFXYyjNUy0wLD91cq88LIXOpAhchYphk88Mc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=t1bw8naUH8Ufkssl1Ge1UcbbiUTdF/A+5lzfMZpNON5xj6a80ZgHWX9WH1aUp2/4oS+9KKSmwF0asbDlrO925Eid2dPOhqDzt4YzZ8LXWpsGxsnR9IBDUsPPRGJvUJwtt+uA+SJCmjUtbXBVzKByQTkDZsXO+ooxg5B2P6UaZJc= 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=Hx1A7eC2; arc=fail smtp.client-ip=52.101.52.41 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="Hx1A7eC2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oPMgTu+rxzr+PdTQNdNpKw0ilDNiDX/Tz2evmlZhe1Xop5CUrGIRPahgSAHWRZoOkoMoAAyV2Ql/fQiRKXBcrQPAN/+7BuUUcdTU0FNn6DHLevWslLwM4W/mxrIamhilSnA6WJdf7Be4BRoaQCSfEEgpVENclHH84bXKnclkZmt/TNDztzI3MHKc93PGVF9i+BluqdQNnBTCyJvXLSgONYbdqL3XQ9UTzzRt85DBHpP0wqlt/Wa4Pq1lEAso14pUTDNWxvrmIW6U47sMMZDlxohQNEY+sIWmYaUkAHVk8hk8ngXX7zjPMmETH+Tik7uhud2lR/nyqDsngBVyW/xH2w== 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=sOClEYn0U6XqlU0chrPSSjOr5hlhCqX8US9UPEIyJH8=; b=rXtW3AqiZYSxudpmbm3W8/eh32WFellEbLPmPavhyseqAjNN9yfz46QlQRovnodm0tgC8sYwIZHaCggPQQxKDE0GRpmGd+OhlDGBi/E59pkRV+34HjCvNDBJyLZqKlEo1keChH5mBlD194UGA2C224h6yoGwaPep87Fxo9oBWda7m10KBGD54ATzjgHSTxnhTPeiSVJeK1hNmSzs8yzErH+7yV+8oyZfA4PNr0eIGhFHKq5d+K437qfwl0zm28+kSxsHtf3Y06C0zOUux/5wcZZV/ulGpvgjrcq+WKx1RniG/+vhQsDBQ3AvCa0ivLiVATXx+tcioOzmthovN728og== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sOClEYn0U6XqlU0chrPSSjOr5hlhCqX8US9UPEIyJH8=; b=Hx1A7eC2pi8Nu8aUkB+xLw4uOuiGf82U1xwBNep6AdBB8eIEpSArn2wcvpJEJ3vfGZxmyPdMVBVvKA/q2FAFKmHTQDyy5adBPgpcdgwjYXd324E9w1w5SEUzJ6K8Qm8EL5S/zzZ1SI7oLqSbUG++t4tI6H6Xm1rW9knj08PlmQS9GekJqw8EGlDhMb2kq4+TWUq7ZRxBQfIegjew5pUbWOii/qlJcOobDQrC5l5RlUSNhDPlM1CYFecLZD2f6Jku8gYrCZ+ZKdqhKVNnaE9mf9Xyz48WKp7Na6wsjKJ678NigJirTIcWFv8lluXc+gwn4lpY1sbMYeKAmbPU6knBnw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by SAVPR12MB999121.namprd12.prod.outlook.com (2603:10b6:806:4e7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:33:36 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:33:36 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard Subject: [PATCH v2 10/15] gpu: nova-core: recover the GSP receive path from corrupt framing Date: Fri, 28 Aug 2026 18:33:29 -0700 Message-ID: <20260829013324.499542-15-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR05CA0060.namprd05.prod.outlook.com (2603:10b6:a03:33f::35) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|SAVPR12MB999121:EE_ X-MS-Office365-Filtering-Correlation-Id: a460b8c4-096e-4459-9981-08df056d8b85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|1800799024|366016|3023799007|10067099003|56012099006|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: ZaaycB+6v2Mo2wwIJiDN8IZhvODOqfV0e2m9/TH8J8RM1I5PZIAjk5KLJdxMnQQbozsazdR1hl7azNl2WY5jl57gF2iRZy3oowCxldPRkdWsr5Gi0RoIQ0A/rufSQNdmnEnFjVPJSmaqhtjSNjieuZj0m1tNh2WlcCxZoxO1mpwy6p9PMIB/FASViDn3p16LfXSqcKPXDUy7dhL9liFaHCgGLEOV6U/rqHe0FGjUVAKnYqzImvhemzi0SCNWFeq0vKt4RM4GmlZ15CqgU+8BXMzeCTWhd1X9awh3xnU5YHjZjxYdIqLDItxwzi1uylozfp2KDINFFLlva5KxcDBAaopKugL7+hvVhIUXuXbsIQANRScvSEG167dSa/rlX5eEf2oGUT8neLOKc4gqOu1IXykDRwLKeo9/XueM/lF2cNO2w4ieCNkOO79csYfbibPWVfYyo/HPSxd1f/1qJvYxkjzjpz4ygMyo24lBVPkc20J479sgABITLZP3aY574z5JSrcHWB1UGs4WMXkb4Kuiu+GpwYbjpQ+Fffapwp2sjhOuElQu4/osj350fccdX2A/QbOVCfnFgPHBT8a/SSkjs/pFRMLtJ2clSACmHqDAIJxPZSRTWMZprlmORDeBzQkMvVjnk+n1iSVlFySRVvqlOBRWLY+eUO0Kml9oooPnTpk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(1800799024)(366016)(3023799007)(10067099003)(56012099006)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?dMwhSrC7HO5h4OPceqR0iyHnajEuikHsz6gCQ5bsmHnrtCvsHUZsLjwGkWhG?= =?us-ascii?Q?GudRTIk0yDFSynjk4U7ubOT/bEF/zN0v55G4CgKwp54nvlVAJIiPLc+9EVl1?= =?us-ascii?Q?PycGz3Hosg5UuzzOKadexftLKU6w2QCC1UhtEQap0DOXvQlsF/a3+qrCRGGH?= =?us-ascii?Q?ArbFxVFFzJPajh8lfXjbHJZRF4eUyPPBEyg5UAD+oPjJ5wZqhlsp9tORLfhd?= =?us-ascii?Q?N4dcS4aMxMObHWlaEzNqlrYYtktVEowMpXDVofs65DMwFYz7Vo7x2XgemGlw?= =?us-ascii?Q?iNZMzucSlZjGKMuWxl5ATgwRfL4jK62DL3PAReaCCWwA4qYb7yGCaNYxVWQW?= =?us-ascii?Q?xuDLOExdjsDaVc2nZBKq+/MtU7AWqB66KLgu9FZRlxBmGn63SlrMSDRFUjAk?= =?us-ascii?Q?+Gxh8LPFjPsfqA/TTvZ+S+Jftp3O4Bv4Vp0ZCiROKyaewkBXWkDTNKyOHIhu?= =?us-ascii?Q?CD6utpoYQtD9dx0NBRDW+Nix6+QljcFN5rinyYAQvmEX74kbYMsVkXnzTE6s?= =?us-ascii?Q?ZCT1xuvuwLRRMO2vIdb+Civ1BLsojnbsZvRGFSAIaTPYNKISnVp1qdBw8Hd1?= =?us-ascii?Q?JCYLOy7k5dJQkVX0lVIxys0afND4WdMUT8XxgwwZHmeeT++GZW91BXS10pmQ?= =?us-ascii?Q?0pSoOnqz0iVFjBGvZmQsxF7EUOHKIcCcGHUaZbUgtHwBN3zpAcj6im9cD4bM?= =?us-ascii?Q?XYkpknl+5aR48J0u98AD/zQH1pFzzyna4ui6IYjfWI+nzulhOy9cLHJ1bTTl?= =?us-ascii?Q?s3vN4qkGAO/Zw1ctpSoXIPp5nqla4k4PhXD9Py+vbEttfsDlO5Q5Tw251V7a?= =?us-ascii?Q?E9Yme0sSYt6cf9d7jvKAOipXn5dJtyO9YSRPOsFxrA7oktPkZHwjmzDWgqU1?= =?us-ascii?Q?P14gYKgKq3qjRSkL3YP+ebD80gkcV146qDEk3bkcUuLznGZVZhG1jWoYOvjV?= =?us-ascii?Q?ghGL9dUZWFDGO3SWoaWvPhvrtEDCmYZfd6RfGRUZw2BNpUY345FWCYBTEwKR?= =?us-ascii?Q?zWAdzY3r1y5a+K3EPJxcgppr4Imd9RZIirDgc2Spud8lYuKSv25UtX3WvdIm?= =?us-ascii?Q?tKPRZmLjFHWVjDvW02jJBODEuWa8HU3NrdH+bR1pE2lWXVUSxbNsTH9kBDp4?= =?us-ascii?Q?S/dZFzZuGwWuSSUw/LJR+NR3GHQLiCgkjrTbf3rn47HZE87vGBdsdZi9RnJk?= =?us-ascii?Q?0DhKSDQdZYWbCmO9modbEvFXGmvemhfT39/3V3boD4esfT/QcSZzC92eI47e?= =?us-ascii?Q?LRiP7Y5p88bUdFdc+EJlwoZx//758EMAWT91020I9k9yjCv+ZHaeC29zdRm0?= =?us-ascii?Q?zXO39DIT7aNgx47/GmDb8Yx+V4HW2E/TTixohUVichujEz/99unTuyZCG7xC?= =?us-ascii?Q?fh2JvLhmL3h8FXlctG/kOJypPQHE5ESyQlIl+LCykTS9LQtVAGHcqZa9jSjp?= =?us-ascii?Q?07RxKGHX1DNdlbBH/7scxWVC+MowZ1yKK5KhCsBoZhTnzJQ52wZrhGYRU1rV?= =?us-ascii?Q?ba48sgu9QvD5xxfLg4fL/wSW5XwLdE6VGHJ50ar7sxL0/4A4r51E7/tWj3DF?= =?us-ascii?Q?DPWeUGd8c5Ns4jNiWhqIRD4nh2QVpFiw8fpEinQKsQy5nCIegd693jeokLny?= =?us-ascii?Q?Vo12z7B8/hpJAecQ90P50UYvvjLKbW+aV1O24jy6jPt9UswLTN87MrzNJSTT?= =?us-ascii?Q?BxPr6Vqk0joFv+oLdsR1c2QUbRwpzsUrYk5NRGEhF8alUlkKoXruhrZPsztN?= =?us-ascii?Q?3o5jZ1/kow=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a460b8c4-096e-4459-9981-08df056d8b85 X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:33:36.1313 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xVmGOLG3apST3hYhl6wV0hWVWV0OkgBNSHdvy9JHxYdse8uMQ+qCkIG6iCH5WwCvI1w4IXGDSrsuuRapToZprg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SAVPR12MB999121 Content-Type: text/plain; charset="utf-8" A GSP message carries its length inside the checksummed region, so once the framing or the checksum fails, the length cannot be trusted to skip the message. Two paths left a bad message at the queue head. A framing or checksum failure returned without advancing the read pointer, so every later receive re-parsed the same message. A validly framed message whose typed payload failed to decode returned early and did the same. Poison the queue on a framing or checksum failure, and fail every later receive, so the bad head is parsed once and recovery requires a reset. Advance the read pointer past a validly framed message whether or not its payload decodes. Assisted-by: Cursor:claude-opus-5 Signed-off-by: John Hubbard --- drivers/gpu/nova-core/gsp/cmdq.rs | 63 ++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/= cmdq.rs index 3224079abf7e..fc4c229b8b9a 100644 --- a/drivers/gpu/nova-core/gsp/cmdq.rs +++ b/drivers/gpu/nova-core/gsp/cmdq.rs @@ -3,6 +3,7 @@ mod continuation; =20 use core::{ + cell::Cell, mem, sync::atomic::{ fence, @@ -523,6 +524,7 @@ pub(crate) fn new(dev: &device::Device) = -> impl PinInit, /// Memory area shared with the GSP for communicating commands and mes= sages. gsp_mem: DmaGspMem, } @@ -748,11 +756,13 @@ fn send_command(&mut self, bar: Bar0<'_>, command:= M) -> Result /// # Errors /// /// - `ETIMEDOUT` if `timeout` has elapsed before any message becomes = available. - /// - `EIO` if there was some inconsistency (e.g. message shorter than= advertised) on the - /// message queue. - /// - /// Error codes returned by the message constructor are propagated as-= is. + /// - `EIO` if the framing or the checksum is invalid, or the queue wa= s already poisoned by an + /// earlier such failure. Either failure poisons the queue, so recov= ery requires a reset. fn wait_for_msg(&self, timeout: Delta) -> Result> { + if self.poisoned.get() { + return Err(EIO); + } + // Wait for a message to arrive from the GSP. let (slice_1, slice_2) =3D read_poll_timeout( || Ok(self.gsp_mem.driver_read_area()), @@ -763,7 +773,10 @@ fn wait_for_msg(&self, timeout: Delta) -> Result> { .map(|(slice_1, slice_2)| (slice_1.as_flattened(), slice_2.as_flat= tened()))?; =20 // Extract the `GspMsgElement`. - let (header, slice_1) =3D GspMsgElement::from_bytes_prefix(slice_1= ).ok_or(EIO)?; + let Some((header, slice_1)) =3D GspMsgElement::from_bytes_prefix(s= lice_1) else { + self.poisoned.set(true); + return Err(EIO); + }; =20 dev_dbg!( &self.dev, @@ -777,6 +790,7 @@ fn wait_for_msg(&self, timeout: Delta) -> Result> { =20 // Check that the driver read area is large enough for the message. if slice_1.len() + slice_2.len() < payload_length { + self.poisoned.set(true); return Err(EIO); } =20 @@ -805,6 +819,7 @@ fn wait_for_msg(&self, timeout: Delta) -> Result> { "GSP RPC: receive: Call {} - bad checksum\n", header.sequence() ); + self.poisoned.set(true); return Err(EIO); } =20 @@ -830,8 +845,8 @@ fn wait_for_msg(&self, timeout: Delta) -> Result> { /// # Errors /// /// - `ETIMEDOUT` if `timeout` has elapsed before any message becomes = available. - /// - `EIO` if there was some inconsistency (e.g. message shorter than= advertised) on the - /// message queue. + /// - `EIO` if the queue is poisoned or the message fails framing or c= hecksum validation (see + /// [`Self::wait_for_msg`]), or if the matched message is too short = for `M::Message`. /// - `ERANGE` if the message was not the awaited reply. /// /// Error codes returned by [`MessageFromGsp::read`] are propagated as= -is. @@ -850,22 +865,26 @@ fn receive_msg( let func_matches =3D matches!(function, Ok(f) if f =3D=3D M::FUNCT= ION); let matched =3D func_matches && expected_seq.is_none_or(|expected|= seq =3D=3D expected); =20 - // Every path must advance the read pointer past this message. + // Every path must advance the read pointer past this message, inc= luding a failed decode. let result =3D if matched { - let (cmd, contents_1) =3D M::Message::from_bytes_prefix(messag= e.contents.0).ok_or(EIO)?; - let mut sbuffer =3D SBufferIter::new_reader([contents_1, messa= ge.contents.1]); - - M::read(cmd, &mut sbuffer) - .map_err(|e| e.into()) - .inspect(|_| { - if !sbuffer.is_empty() { - dev_warn!( - &self.dev, - "GSP message {:?} has unprocessed data\n", - M::FUNCTION - ); - } - }) + match M::Message::from_bytes_prefix(message.contents.0) { + Some((cmd, contents_1)) =3D> { + let mut sbuffer =3D SBufferIter::new_reader([contents_= 1, message.contents.1]); + + M::read(cmd, &mut sbuffer) + .map_err(|e| e.into()) + .inspect(|_| { + if !sbuffer.is_empty() { + dev_warn!( + &self.dev, + "GSP message {:?} has unprocessed data= \n", + M::FUNCTION + ); + } + }) + } + None =3D> Err(EIO), + } } else { Err(ERANGE) }; --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011041.outbound.protection.outlook.com [52.101.52.41]) (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 DEA0B3A9D8A for ; Sat, 29 Aug 2026 01:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967229; cv=fail; b=XTKS2qos3V7xOCDu72yX6WycNULEieWHfiGe6DbfDlM9txMN7VujSfb2taEniCO/o9/xm1mQE8ZrW0/NZaPZWpfyWmadtrZM567PNPWlAe6+HV5/MlFsIdpcpYJCZA/9l/mk8960HuV9+SVfJQNQ67ivX3Nn6WM+UpQpVlnwHrs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967229; c=relaxed/simple; bh=3CeLMBPZmxuRg51AqB4jsGXZfAyw9ThhLPbdWhV6nyA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=tNNWlwC5UPdr0rJjpGFeAuaOAsYvR84V8R2/J6QdtaBdBDVdX2VP24DRTxtHW/Es04c5Six7OkKgR+BIzKQLxBuueWEOWXsaokrLdrLPnspoXAiznpzTbEIOTVA220Pcwrb0tZ1lza703+6vIFW0e3cwtgdWmbDH0tkS1hpyFG8= 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=j9oiLiul; arc=fail smtp.client-ip=52.101.52.41 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="j9oiLiul" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=drpHNtb9OcgHXoD6rprSwWHCVX9FSO/laaDm1SPSr6UreeDhaxM46gPd9keioEaR3dB14wbZFlPPlVXSAYNMWjXwI4yxIlYGujFiUNX0BAU8xONhtvegvffg3I4ldTXSI0XfDwJiwQHcwzkYH0s4Kw4Owb/MPsrfxmgVc71hZMX3Fvx4T8Bu98Vm1Zng+XGhvnFNuyl09jpedxOozPyORZWOG0o4O7IjbG8hw7nP7FX42MBidR9A4c+L/a8I7yCx3Cv2/TlyJR04XUbj6JH4H9l7U4h/O/gQkFrWs9WhoJ9OImLREftcnIXZmFNPEOvdVoANrgfZztGr2L4Nz2LPew== 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=w8aoowABUSYK/7YfMaZ7uWcOpXQNcL1ywTtScIJ6bSk=; b=lJl0c/iAVo3rv6ttJaQcB8/PE91/BPFdvMrlJ8NiI72Bf9aoDpKi9tbKY+jEI+4A/HDLUI8i+904CZpK/aW6jebvi6plLHYnP8eOEoJ0yvy5LqHeRsuzTsjL4OSXEAWoPC2ThkCsVgGOY5cpJze3obTKSTHkZfHh3DOpWupnpafjyVvsE9GD4K+grmcC0eO27FhE+JmaQTst7jJp0oHUy93zncHEKogqXHGLMxqASQOMmDo4PgoYI/6+aoV5W3/yhrAs+IEJnUsxEu1XZPjjwvo56cIeC4vRMT0HBffzyuWeCRMpc1TSbCWd/B7087bJGr+RN4xjM8Novsxa7j6ovg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w8aoowABUSYK/7YfMaZ7uWcOpXQNcL1ywTtScIJ6bSk=; b=j9oiLiulYTCGhBmAJ7gm73nFQ+EuhaI4zmwm/gbfAFxT/cvsgI8xUL1m7zm9rm11fP6C4dpmvpKDxLEtO1R/UJu68o4Ma5NV7OT7JqAOfQoa3tkgMXXvL55kNW1BtSpYz85yTw+NCxIRmSQWlOnGxXasri4NfkvDIjiM0ag4GeDKlHuQjkY2BdBqLsGddETMnh8c7GqhvFE661lEv3iGKMB1wJGS2njSjb5T4A7rzSh1XHu0aApiaBnw6zMyEVHvAavNzGN1Qk2r5zgtWz6yOy82hrMWaIP6MHbnEURzLsfasWTHCKqMrdQVV5KqmIx4Mw2ol3RWgMNDbItvRQz/xg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by SAVPR12MB999121.namprd12.prod.outlook.com (2603:10b6:806:4e7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:33:37 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:33:37 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard Subject: [PATCH v2 11/15] gpu: nova-core: bound a GSP wait by a single deadline Date: Fri, 28 Aug 2026 18:33:30 -0700 Message-ID: <20260829013324.499542-16-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BY3PR04CA0001.namprd04.prod.outlook.com (2603:10b6:a03:217::6) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|SAVPR12MB999121:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c071fff-6cf3-4290-6d2e-08df056d8c2c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|1800799024|366016|6133799003|3023799007|10067099003|56012099006|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: at/8cIq5eOS2HayMZ8JPYFLaFn+BosJWVaI9Pvi3p+7fHIudFrpPsOMII6srohL+yTf4d6gWg8QsL6jNBiY5eOEoOx4v/ZdxaBSedUgVwqQQgXtMO/XaeP3PZc3mtKUP+olHOgneueB9yN9Zv1UxRI5zpCc2fOIRCLdEOz/Y70SWAWVEhieh/hTTkFIYSJuvKctk07rN5Q9qNX2z54JjWjTo+oxP4PCCf714URdz6hGU9F8QdHKaffKA+QpAO/cMH9X+7zY+BHjI7c9mWZlrKkA+LaRjquduSCeKXya3Fpx2mDGQQRzmWgJY49+ybOz+GYnGCSbtraB5tfg5Ss5NcJ9RetWZFJA/zkC1GgS7lsl/0XE7MPRTvrg/BBuF0hGIPOdEc1qTMFab3tRi8wPGARtZHywG3wbwrSxEEnHwNsENKYeljs3wZMMatuaZuw0HgA4jM/7kbcWsWdY4vxhR6d8TP2z5tL6GIAhGQICUOngMfag8jJe985MX8jMYeNHyIIcVkwfX2TvA9fakA9xFRFpCYTO7awm10/itE2hWfIgFeQukQ0SsewaIQJ1QxXz2v9pqbhVaY02W5zCjNYKOVrYRsqgZ4xV0j3N3ioRQCkcxSV8KvyqZUegumDCsdIJVfgkQ6fD/SyK3qp0IzckSvU2AAGgoRLLTHRPeu1QUB+I= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(1800799024)(366016)(6133799003)(3023799007)(10067099003)(56012099006)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?a6oJ9jHaGoxVI6oUXoEyVylAwtvncaXO73Sl/SRLEQ+ECGAMY5zy2B+lgo2s?= =?us-ascii?Q?Ur2NsHjLbMy2898QPPqV7fvlELWJJHX72iKCzzey61c4Gbv1wZccB/ac2WVj?= =?us-ascii?Q?O40CTd9xpmVckvEx4X3OsRaX4uLxoIbHuWSMu2BolpCnoa0oMrpfjFHSUK/Y?= =?us-ascii?Q?R7di6c5Z+LG6wAl3magWgMt6kJ0hx9WtO1ZCf81UWd6awMv2d/NNxotaA9nc?= =?us-ascii?Q?yQbvgz82yfEqkNvZeWcME3+bQeNOpeI12BTkCoXx+LybWKZaHHaLflmeZtqR?= =?us-ascii?Q?Kdqb0huu7TBgBK8cfxaoywj0epmXasy5ke0PZ16U48JmVdpaCqaR2ix2Xljp?= =?us-ascii?Q?PoC6eWOwxw9XXZH+MPVTJtVRYt4RZlqEZDOb8k7KDYDYDBzauHzTKg0BH8Qw?= =?us-ascii?Q?5wuIaqeHxh8uDvGBqv++9jjAPphG+wEiUPjpOVwpW9/knpa5c51IY+dPCAII?= =?us-ascii?Q?GJhrBBYz3QM+kfHEXNPhKI3LZFSReNPbUBIfRakn7EAk3FOaVu07pHgpvwI7?= =?us-ascii?Q?BFdRAN2ij0RxhqwIxY2khyxF6fJbEgpumJxV/dz85V/uh1Y3kY2edv/2O64d?= =?us-ascii?Q?z3bjDeMMMN6fdm8XsqSLzX+e0xXblsSRYlK6N3erxOIx+iuXi0DB5OlZFSej?= =?us-ascii?Q?u5wgk5BKFdCWQPess3dxsp7qp4V0S7Koilx7yUKwYITGNdrA/ONOJTmlXq6t?= =?us-ascii?Q?yknb1X0aEahnoABAXa/ddzqWfdn4S0jDXqpP0GmTsuLirwhOIINm3oiTUWPA?= =?us-ascii?Q?s3mMXDJE1BW9e9qq010Qa3z6dq3v3EAm93BNANWW0j7n15Y36Gp774RPysV+?= =?us-ascii?Q?uQFkLS6SvRT70393AfL2qfNjActjiZnWSJvI0Mqs+BJWLE3f2SPqwveI3PG8?= =?us-ascii?Q?0lR8y2IZUQ1+lVirQuDmCogJ/ep1N6HFQHg/3QgRYWGrMK9zLaxBOyrcAtnQ?= =?us-ascii?Q?Yz+2ZO/bhselZg1NIkWXDkD8unXORjcP4Yv7WNowzqpJ2bbcFQI0Py7KBjbU?= =?us-ascii?Q?nL2rkOxbgu86sddNS/PW9gepAoRRAFZFMBBc8JIo5QBYMRw4XZ3vMMJF25YH?= =?us-ascii?Q?VX3X7mtXpdwJDAvhPZjIS1e1WhgSn6tdEdUG8PR3sORcO1FABoPmkSCkDIdL?= =?us-ascii?Q?+HqUOl/ELC6NaG/nLxpMfco2IKGlLlnDu4OJCMIamzg7tXvRy9h3u3lnfI3i?= =?us-ascii?Q?pjmrBtR9jPvws6bzqxrkvlaviltgw6gASPidzt94LPqggudY4kB8QfiorSr8?= =?us-ascii?Q?0fq4EnPuK5RcG/qEmD/tz2HspCrjZ9rGZjCFTOGtKRUjKkGWcRZZKNh+Al+I?= =?us-ascii?Q?J4y2LtvHDk9EQj9O5EfqtfgAQMe8ENZr3tuUHV9n9TBs+kwNhBnhcNLiwvLB?= =?us-ascii?Q?31YSwaZWhYYjvGv7M5WzmtF/1Vy+lgs69BM9hULWL3z5YDi1qYOuiqPpzB/E?= =?us-ascii?Q?2BNzqAuEC4xZ0qCDaNfBQndrJA5W1knSTh1JU6jWMjegRjcn0KOdojPtV9qi?= =?us-ascii?Q?JhnxT//xwh2fPa87YLXR4PAtxB9bL3Aw63+Ogcp8AZqc6v3VzN8SXzZ9SfXb?= =?us-ascii?Q?avdMv9XE6szU0Dy9vfE6plukjgvypz38pQZbTGBoRbvRtJt9SowTHpkBH6zh?= =?us-ascii?Q?C70Xxv39L1nMb/V+5g297Ak0k0ugu3jIk/FCpk9NRmMv3DcEQu3Hepa2QKZY?= =?us-ascii?Q?CbXJ17Oe0n0PXRHOYgjXy4f+OUlWyqJC8gtrHU6LKCoyfxP6o/mV7Ta8T4mh?= =?us-ascii?Q?do9W91/86Q=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c071fff-6cf3-4290-6d2e-08df056d8c2c X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:33:37.2371 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uQ8L13HTQFs9tEVWwqg0TyZkjdycZ1f+jI8DnEN2JaYkrnC2OHsg4rVgtvWK1Bv+hJ8+n/H7UF/1hhmKOJ68Tg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SAVPR12MB999121 Content-Type: text/plain; charset="utf-8" The GSP posts unsolicited events on the same queue it posts replies on, so a caller waiting for one message dispatches whatever else arrives first and reads again. Each of those reads started a fresh five-second timeout, so a steady stream of events extended the wait without bound. Compute one absolute deadline when the wait begins and pass the time remaining to each read, so the whole wait is bounded however many events arrive first. GSP boot waits for two unsolicited events. Move that loop into a helper so both take the same bound. Assisted-by: Cursor:claude-opus-5 Signed-off-by: John Hubbard --- drivers/gpu/nova-core/gsp/cmdq.rs | 52 ++++++++++++++++++++++---- drivers/gpu/nova-core/gsp/commands.rs | 8 +--- drivers/gpu/nova-core/gsp/sequencer.rs | 8 +--- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/= cmdq.rs index fc4c229b8b9a..76d51155c49f 100644 --- a/drivers/gpu/nova-core/gsp/cmdq.rs +++ b/drivers/gpu/nova-core/gsp/cmdq.rs @@ -30,7 +30,11 @@ aref::ARef, Mutex, // }, - time::Delta, + time::{ + Delta, + Instant, + Monotonic, // + }, transmute::{ AsBytes, FromBytes, // @@ -558,8 +562,9 @@ fn notify_gsp(bar: Bar0<'_>) { /// /// # Errors /// - /// - `ETIMEDOUT` if space does not become available to send the comma= nd, or if the reply is - /// not received within the timeout. + /// - `ETIMEDOUT` if space does not become available to send the comma= nd, or if the reply does + /// not arrive within [`Self::RECEIVE_TIMEOUT`] of the send, however= many events are + /// dispatched while waiting. /// - `EIO` if the variable payload requested by the command has not b= een entirely /// written to by its [`CommandToGsp::init_variable_payload`] method. /// @@ -574,8 +579,13 @@ pub(crate) fn send_command(&self, bar: Bar0<'_>, co= mmand: M) -> Result::now() + Self::RECEIVE_TIMEO= UT; loop { - match inner.receive_msg::(Self::RECEIVE_TIMEOUT, Som= e(expected_seq)) { + let remaining =3D deadline - Instant::::now(); + if remaining.is_negative() { + break Err(ETIMEDOUT); + } + match inner.receive_msg::(remaining, Some(expected_s= eq)) { Ok(reply) =3D> break Ok(reply), Err(ERANGE) =3D> continue, Err(e) =3D> break Err(e), @@ -600,17 +610,43 @@ pub(crate) fn send_command_no_wait(&self, bar: Bar= 0<'_>, command: M) -> Resul self.inner.lock().send_command(bar, command).map(|_| ()) } =20 - /// Receive a message from the GSP. + /// Receive a message from the GSP, matching on the function code alon= e. /// - /// Matches on the function code alone, for a caller awaiting an unsol= icited GSP event rather - /// than a reply to a command. See [`CmdqInner::receive_msg`]. - pub(crate) fn receive_msg(&self, timeout: Delta) ->= Result + /// Returns `ERANGE` if the message that arrives is not of type `M`. S= ee + /// [`CmdqInner::receive_msg`]. + fn receive_msg(&self, timeout: Delta) -> Result where // This allows all error types, including `Infallible`, to be used= for `M::InitError`. Error: From, { self.inner.lock().receive_msg(timeout, None) } + + /// Waits for an unsolicited GSP event of type `M`, dispatching any ot= her event that arrives + /// first. + /// + /// # Errors + /// + /// - `ETIMEDOUT` if the event does not arrive within [`Self::RECEIVE_= TIMEOUT`] of the call, + /// however many other events are dispatched while waiting. + pub(crate) fn await_msg(&self) -> Result + where + // This allows all error types, including `Infallible`, to be used= for `M::InitError`. + Error: From, + { + let deadline =3D Instant::::now() + Self::RECEIVE_TIMEO= UT; + loop { + let remaining =3D deadline - Instant::::now(); + if remaining.is_negative() { + break Err(ETIMEDOUT); + } + match self.receive_msg::(remaining) { + Ok(msg) =3D> break Ok(msg), + Err(ERANGE) =3D> continue, + Err(e) =3D> break Err(e), + } + } + } } =20 /// Inner mutex protected state of [`Cmdq`]. diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/= gsp/commands.rs index ffc25fd8c47b..61fe93db9e7e 100644 --- a/drivers/gpu/nova-core/gsp/commands.rs +++ b/drivers/gpu/nova-core/gsp/commands.rs @@ -188,13 +188,7 @@ fn read( =20 /// Waits for GSP initialization to complete. pub(crate) fn wait_gsp_init_done(cmdq: &Cmdq) -> Result { - loop { - match cmdq.receive_msg::(Cmdq::RECEIVE_TIMEOUT) { - Ok(_) =3D> break Ok(()), - Err(ERANGE) =3D> continue, - Err(e) =3D> break Err(e), - } - } + cmdq.await_msg::().map(|_| ()) } =20 /// The `GetGspStaticInfo` command. diff --git a/drivers/gpu/nova-core/gsp/sequencer.rs b/drivers/gpu/nova-core= /gsp/sequencer.rs index bcad1421953a..e2f1da129d8f 100644 --- a/drivers/gpu/nova-core/gsp/sequencer.rs +++ b/drivers/gpu/nova-core/gsp/sequencer.rs @@ -343,13 +343,7 @@ pub(crate) fn run( libos: &'a Coherent<[LibosMemoryRegionInitArgument]>, bootloader_app_version: u32, ) -> Result { - let seq_info =3D loop { - match cmdq.receive_msg::(Cmdq::RECEIVE_TIMEOUT) { - Ok(seq_info) =3D> break seq_info, - Err(ERANGE) =3D> continue, - Err(e) =3D> return Err(e), - } - }; + let seq_info =3D cmdq.await_msg::()?; =20 let sequencer =3D GspSequencer { bar: ctx.bar, --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011041.outbound.protection.outlook.com [52.101.52.41]) (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 206ED39A4D6 for ; Sat, 29 Aug 2026 01:33:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967234; cv=fail; b=NlVjKicY646VMrDGo+0ba24LviOMBL7/WyoRwfxdHY/ikP9ZZRaXJrIYoNGAfW6Rv3LwCWffjLM9ehRtYf7kl5e9gjQD6809fkGC8tcoz6nFQdW2cur9ZmhF+P1TxM9zohZA4M3ebUOGSHi9ZJVuSAi+RAHv33pghRRkT/GxC/g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967234; c=relaxed/simple; bh=J/dyCHhcrnzOF9fm/msHvuQss/wEPS0PbbH9oV0GBb0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=IZU5k4bEXPsRg7HIy1HOFojx+r0IYnjkgggc3OIZuB2VZKTJFuCKsny7S440P85mOZ1Qtr/RdBTZEnfqkH8rSYFOCAChcDjRaasZwxQSue2oT2FKbIKYtnPHsUUjSkxE3G9hik39YjbZ/sM8MYxijt+FhNAhdCUAS/w6yg0TOc0= 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=GRd1riTA; arc=fail smtp.client-ip=52.101.52.41 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="GRd1riTA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FIPlSnFyGLExKuLKOkQxgnKApVSJpRQjAuLjfDRB48I4c8BeHsw/ULuPjFkaAtFXhnEck6BatZnb4E3IowQBRFxTEnCm6mmNcB9+tjNqL4b8liW5hYXwO7N6B4WXJ8AmwbCJX+PqZEI05vDZ2njnYGDOxW4aR50UX63EdGEWIrGhPwmnl4PCTNhu6KWckV/Vc4kfQrYrgrMKy1lOwtTJikTs0pISqiU+Klu2qhyB5LUe0v9IlA840EGJ7lJCpQQfdzkDWhzpd8tM5LWOCF+TBkEMCjAvs7GTYENuOSGk0Kn0Kr8poO7p3SW31dlIpU/oi88+5Yt6NHGXDkKcTRUcfw== 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=IO3YohQa/XyioYZOC6vqqlO684thwv0yciMuSfUQXNs=; b=c3F7wg/gNHSG9m9nZV1yaaj4wmUogAgEgMGLdnQq9XOzv0YBGVUHfv066F1i2MGIqxneX+MS2I2IHzJCW3nt9XWnGDTePF7zhNA6RqwySNRwa9lVKjmQrAuINaQ20kAMR7MnASR+h17Y4LVec75nPpct/CoHPyXGcAYImfqQDWlR8lwuBXpTQSmYyhOGE2sG7bcsSfjZ2PDuN8xr/y3txLd+XgVYFimzriKKC1xj5GwAQKiM9xHh86PA8N25J+H+6qSl2mvRN3EyzCjZNj+QQPgsEYhpoM8DSDO/js/9BoYMRsQdcbxbz9dmLTVZ8zEJWMEb9JgO1WDnO1Q1zG6GEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IO3YohQa/XyioYZOC6vqqlO684thwv0yciMuSfUQXNs=; b=GRd1riTA197aSPNzeOxt74ieo96QWNvtdpveaqPlTsGlWpwiu2pbqHki/EnNNrkhcTEj5S+OImF4eCMry/t7H1eVf9sji7OuCmsqV/wC3OG9p8BUEzjDgQ4CW0WpUI6yzf8zCD8Wd+AaM1lVvTMmZ23Rnh/fFNZb//sy7e6gXwsEV+YIZXUaddx4M4YXjoG1JVekBJZDyTLMn6Ln98r1R4l2fucc+z94Zscy09mg1E/0ZqH8j+SYGx6tklv3OuU6aIGQILVpPBBtYZYXTdUsuIWFg+QEHryE/YNAqAQ7gEgsfl2njYXTCoxWhADqGDJOW6zkf247Oxql3VtkJ3wQxw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by SAVPR12MB999121.namprd12.prod.outlook.com (2603:10b6:806:4e7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:33:38 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:33:38 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard , Will Pierce Subject: [PATCH v2 12/15] gpu: nova-core: drive GSP events with the SWGEN0 interrupt Date: Fri, 28 Aug 2026 18:33:31 -0700 Message-ID: <20260829013324.499542-17-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BY3PR04CA0004.namprd04.prod.outlook.com (2603:10b6:a03:217::9) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|SAVPR12MB999121:EE_ X-MS-Office365-Filtering-Correlation-Id: 664e9992-5072-44a5-36fa-08df056d8cc7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|1800799024|366016|7136999003|6133799003|3023799007|10067099003|56012099006|5023799004|11063799006|18002099003|22082099003|11062099010; X-Microsoft-Antispam-Message-Info: iknJIOHqGrpnRVXBjr1MlNCVDfnH1WAmCYPxIUVPwG8miubKj6dW9GZVGqbxP7InM/v+/br1sgH/wh49/bwCSkJYbeF7xjWJPSX5srzAPeayIDBkp7Uq5mM76gfVFZ6fkDNNnjsB54qHNHEaEVddLbS1F+Jh/xRDgQBb/3XrQAmyUo8lVUiqq2CnkRu0ZpEPq07yoii2//aDw9rRnLOKO7YwRaKXmqUNWvSZwHUI+0XKNSH4nzeD6NergS9UJb8cZNjYwYH7rRxd0TnKH89mNVTBR8uLZf/mYgc7qq46pyflR6KLa+Plwvif6E9b1OhQu8ffR1SaAgm5zveQ+OOMO6cgZ3hZpLEShjQmvuqPyH6LGGWwyl00HdYfwXlSy8DeY9wUdfzWVBDyqU6uewNmRvW/mUZKIu1qUei2t9DGYb6RWDY2BiHpE+wn5cC9Y+j4dVYhIciq1P/IVdRJN8mUGnjkv2Y1xOXbmogiFN1+vAnmDBwoPddA85KnhidLC+NB8PzdHkgXLD46T4tmE5AMLAPsnogzQCTP0JG5qQL60Ezvz7SF5DaqawCXVNjqV8McRdq6RqbnAr7k9RZuaIs0cLjNkdDpMvL08xzJmanIrrD3BUtONLKLOqrIXBOSJCRJKOiVe4WEFwxfb6TzAPcTaSDzblAwwvgjcMbp1Fedm8E= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(1800799024)(366016)(7136999003)(6133799003)(3023799007)(10067099003)(56012099006)(5023799004)(11063799006)(18002099003)(22082099003)(11062099010);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?YfUfroCCDMnHEigVqudpWnAgXJfTN13BYocw0kPfR1kZeMkSG1YIOTfuBIs8?= =?us-ascii?Q?mVimXsyki3yLK4ts+oVY/8DxaP1pmSrYWFt25kFztsZFGkp/Rd6Vnd/OD5EJ?= =?us-ascii?Q?yk4fU51c6XwBYWoMyLfTV+W/4Nqaxq0O63GqHJ6Ai7ul/iLHSyHy4SDp5sFd?= =?us-ascii?Q?nKF/+PHabDSEPdFR0/qbBuuH16XFb0mjHIwbIA8yA851avXzVuNbOmnED3fK?= =?us-ascii?Q?Odp89ex88Jcpo01zRZ2RgErwSgx3NzMCcS44c+Wv2wHV5qZpZKidqt7Kwrzw?= =?us-ascii?Q?pcRNGNQS44OxoC34RSazJgSDK2yqqGFw++EjIOSX5itKCtJErrawQkrmcMsA?= =?us-ascii?Q?PMSxyWAOy21JRXGaJOopp1BJxBx6HEa6GCBBBXSnLGvokeHmOV90gileoydJ?= =?us-ascii?Q?DOPRMCvCavr+qKvFRPPshew/fLuAWq0UPOrqw8QWD5SV5ZTEorKUSsIs2QFv?= =?us-ascii?Q?4fLy9ROuXRKagL13zb8wQB2+QJdY6TSlkIpaipeV3TNE5YmhZRy4YLCLNnJU?= =?us-ascii?Q?zwzEeGh7QEaQQ24IUAKEDyl+2uHN0YHDfrs1ZIx2Sq9yJ2RotgvxnXZN1VoS?= =?us-ascii?Q?CcClOZezDwCOzaSqP68G6E4MjKjSfrub9UfJMqEwdnJXAAwz6Jx1odbNNjvR?= =?us-ascii?Q?NDS95F71OzlcxXm4c+69u8H1CcL1wunFDNZfHP6eHjVkolnw6WJ00mQGjAnw?= =?us-ascii?Q?Qzes68LM9g9lyXhUbmrtEMWPNZ8jgSejE3JK/4999P+jhxYj72O2A7pQ8SwC?= =?us-ascii?Q?0WEX7ASPdvoD8+21c1AKvH5B97KNDIg/u9yLvLzUbE5ydjQFkmvdfCzV7Ebl?= =?us-ascii?Q?69ifeSHg2AywqIjQnq1SLnNAtvWoeGlubQUoZnYUdnd8IDR4+pEsXf5oJ3hq?= =?us-ascii?Q?Ah73oPwX8QfOzPbL9opXRcVXLU7iTdoc1AlBFnVoM1Trn5BNgZR5CGLqH5If?= =?us-ascii?Q?BepqKTlZ3Adz+YerWd+xOrjdfJkgYSTNg5jf+l6MRlZduBJFaqYeR8Xx1PKl?= =?us-ascii?Q?vfXCWWTSdjdly9gEcLKIoahKeKiaHUMHMHOT/gbzhTruYCtI09/SPSyoofXb?= =?us-ascii?Q?tXWKrbZwox4X8odGrcs2CDmaUsLebe7e1vZLdOnmvZsjk3sy0dkbSjjJQvDQ?= =?us-ascii?Q?aho3C9f3xhVm0d1vDbJ49+mJQQE6RHXSDcuXOsCxih6WZ43rvOojaks9/hpn?= =?us-ascii?Q?2rlxRxHxM5XikOUDar7WSV7u+N+JuwQuzhbTqEOixpPiEeDiFOAtFpfFwfZk?= =?us-ascii?Q?0MfO9aPMYZ+cdDnks9b94hq6HGoec/Jj8wMOBcfR50a2/VYPNqWByy4xoZdw?= =?us-ascii?Q?bEq3ilHMj7DFTkDi08oyPo/D3o+PhnxeLwH1stTMC3qxcTLKXBkFrLAaz+Mc?= =?us-ascii?Q?S39LR6gGkfvWRgQIBb0SHT4dUEroLdJ7/gcftlfYcKe2QcWskvgDJV/tgNO+?= =?us-ascii?Q?gjObzTkSGvWJGAFaShMCcapQy/ePmm941VRP3eth4LVQ6MIbvWGsdNQgtenz?= =?us-ascii?Q?rSZHTqpM/Zn2ev9KI/Qw/kP/21BEbXir9CGYt903QOViMZpWn4cxzHZ6LRvW?= =?us-ascii?Q?V50oXT6BVHeMezgNVvAaG06qadXegRQU1aT+AlfQDAm2DMqN2hm7K6RfRe4K?= =?us-ascii?Q?lsQG901z6c5HRE/OePMzcorKWkxS8n9JOURJVFCBoV2N/oriekQ98f4Sq/sG?= =?us-ascii?Q?vv4aKVGMrZfUQSolAGUVk0DKkTreJzaPMscN42kFOftNhM2fvjv3WLc8TyDd?= =?us-ascii?Q?jecvYteCrg=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 664e9992-5072-44a5-36fa-08df056d8cc7 X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:33:38.3040 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kTV10KgCK7Bacm4DuwO5WWNEPay3oISohsiPc45BVajjrPqlrEw3Ob7I3Xe+vXBfRWRCWZt1as34EA7Iz00Srg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SAVPR12MB999121 Content-Type: text/plain; charset="utf-8" The GSP posts events, logs and error records to the GSP-to-CPU queue and raises the falcon SWGEN0 output. GSP boot polls for its own notifications, which leaves the latch set and pending bits in the tree. nova-core drained the queue only while polling for a command reply, so an event sat unread until the next command was sent. Service the queue from a threaded handler on the GSP notification vector. The top half runs in hard interrupt context and touches only registers: it clears the GIN leaf, takes the falcon's SWGEN0 latch and rearms PCI delivery. Draining the queue takes the command-queue mutex, which can sleep, so the top half wakes the IRQ thread to do it. Quiesce the tree, clear the latch and rearm PCI delivery before registering the handler, so none of that boot state reaches it. Pre-Hopper MSI rearms through a configuration-space write that the tree drain does not perform, and an interrupt delivered before probe leaves delivery un-armed. Move the vector allocation out of the self-test and into probe, because the vectors are allocated once for the whole PCI device rather than per handler. The self-test and the GSP handler each take the vector for the subtree they service. Assisted-by: Cursor:claude-opus-5 Reviewed-by: Will Pierce Signed-off-by: John Hubbard --- drivers/gpu/nova-core/driver.rs | 55 ++++- drivers/gpu/nova-core/falcon/gsp.rs | 35 +++- drivers/gpu/nova-core/gpu.rs | 22 +- drivers/gpu/nova-core/gsp.rs | 17 +- drivers/gpu/nova-core/gsp/cmdq.rs | 42 ++++ drivers/gpu/nova-core/irq.rs | 1 + drivers/gpu/nova-core/irq/doorbell_test.rs | 34 ++-- drivers/gpu/nova-core/irq/gsp.rs | 215 ++++++++++++++++++++ drivers/gpu/nova-core/irq/interrupt_tree.rs | 1 - drivers/gpu/nova-core/nova_core.rs | 1 - drivers/gpu/nova-core/regs.rs | 4 + 11 files changed, 394 insertions(+), 33 deletions(-) create mode 100644 drivers/gpu/nova-core/irq/gsp.rs diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver= .rs index 5738d4ac521b..3b713d621bd1 100644 --- a/drivers/gpu/nova-core/driver.rs +++ b/drivers/gpu/nova-core/driver.rs @@ -18,18 +18,36 @@ types::ForLt, }; =20 -use crate::gpu::Gpu; +use crate::{ + gpu::Gpu, + irq::{ + gsp::GspIrq, + SubtreeVectors, // + }, +}; =20 /// Counter for generating unique auxiliary device IDs. static AUXILIARY_ID_COUNTER: Atomic =3D Atomic::new(0); =20 #[pin_data] pub(crate) struct NovaCore<'bound> { + /// GSP event interrupt registration. + /// + /// Declared first so it is dropped first: `free_irq` runs (waiting ou= t any in-flight handler) + /// before the GSP is unloaded (`gpu`) or the BAR mapping is released = (`bar`). + #[pin] + _gsp_irq: GspIrq<'bound>, #[pin] pub(crate) gpu: Gpu<'bound>, bar: pci::Bar<'bound, BAR0_SIZE>, #[allow(clippy::type_complexity)] _reg: auxiliary::Registration<'bound, ForLt!(())>, + /// Self-referential borrow of `vectors`, so this does not have to be = repeated in the + /// constructor. Will go away with self-referential pin-init. + vectors_ref: &'bound SubtreeVectors<'bound>, + /// PCI interrupt vector allocation. Dropped last (struct field drop o= rder). + #[pin] + vectors: SubtreeVectors<'bound>, } =20 pub(crate) struct NovaCoreDriver; @@ -79,13 +97,42 @@ fn probe<'bound>( pdev.set_master(); =20 Ok(try_pin_init!(NovaCore { + vectors: crate::irq::alloc_vectors(pdev, crate::irq::gsp::= GSP_SUBTREE.into())?, + // SAFETY: `vectors` is initialized above, lives at a pinn= ed stable address, and + // is dropped after all fields that use `vectors_ref` (str= uct field drop order). + vectors_ref: unsafe { &*core::ptr::from_ref(vectors.as_ref= ().get_ref()) }, bar: pdev.iomap_region_sized::(0, c"nova-core/b= ar0")?, // TODO: Use `&bar` self-referential pin-init syntax once = available. // // SAFETY: `bar` is initialized before this expression is = evaluated - // (`try_pin_init!()` initializes fields in declaration or= der), lives at a pinned - // stable address, and is dropped after `gpu` (struct fiel= d drop order). - gpu <- Gpu::new(pdev, unsafe { &*core::ptr::from_ref(bar) = }), + // (`try_pin_init!()` initializes fields in the order they= appear here), lives at a + // pinned stable address, and is dropped after `gpu` (stru= ct field drop order). + gpu <- Gpu::new(pdev, unsafe { &*core::ptr::from_ref(bar) = }, vectors_ref), + // Quiesce the interrupt tree before registering the handl= er below. + _: { + // SAFETY: as for the `bar` borrow above. + let bar =3D unsafe { &*core::ptr::from_ref(bar) }; + crate::irq::gsp::quiesce(bar, gpu.chipset(), vectors_r= ef.irq_type()); + }, + // Register the permanent GSP SWGEN0 handler, which enable= s the interrupt. + // + // SAFETY: `bar` and `vectors` are initialized and pinned = (see above). `_gsp_irq` + // is declared before `vectors` in the struct, so it is dr= opped first, ensuring + // `free_irq` runs before the vectors are freed. The regis= tration is stored in + // `NovaCore` and never leaked. + _gsp_irq <- unsafe { + GspIrq::new( + pdev, + vectors_ref, + &*core::ptr::from_ref(bar), + gpu.cmdq(), + gpu.chipset(), + ) + }, + // Drain the messages the GSP posted during boot, before r= elying on the interrupt. + _: { + gpu.cmdq().drain()?; + }, _reg: auxiliary::Registration::new( pdev.as_ref(), c"nova-drm", diff --git a/drivers/gpu/nova-core/falcon/gsp.rs b/drivers/gpu/nova-core/fa= lcon/gsp.rs index ae32f401aeb0..f9d9e8e0386b 100644 --- a/drivers/gpu/nova-core/falcon/gsp.rs +++ b/drivers/gpu/nova-core/falcon/gsp.rs @@ -14,6 +14,7 @@ }; =20 use crate::{ + driver::Bar0, falcon::{ Falcon, FalconEngine, @@ -36,14 +37,40 @@ impl RegisterBase for Gsp { =20 impl FalconEngine for Gsp {} =20 +impl Gsp { + /// Clears the GSP falcon SWGEN0 interrupt latch. + /// + /// The latch holds until it is cleared, and the GSP drives no new edg= e into the interrupt + /// tree while it is set, so a caller that consumed a notification by = any means other than the + /// interrupt handler must clear it or no further notification is deli= vered. + pub(crate) fn clear_swgen0_intr(bar: Bar0<'_>) { + bar.write( + WithBase::of::(), + regs::NV_PFALCON_FALCON_IRQSCLR::zeroed().with_swgen0(true), + ); + } + + /// Reads the GSP falcon interrupt status, clearing the SWGEN0 latch i= f it was set. + /// + /// Returns the status as it was read, before the clear. The GSP raise= s SWGEN0 when it has + /// posted messages in the GSP-to-CPU queue. The interrupt tree routes= every falcon cause to + /// a single vector, so the rest of the status identifies a cause othe= r than a posted message. + pub(crate) fn take_swgen0_intr(bar: Bar0<'_>) -> regs::NV_PFALCON_FALC= ON_IRQSTAT { + let status =3D bar.read(regs::NV_PFALCON_FALCON_IRQSTAT::of::()); + + if status.swgen0() { + Self::clear_swgen0_intr(bar); + } + + status + } +} + impl<'a> Falcon<'a, Gsp> { /// Clears the SWGEN0 bit in the Falcon's IRQ status clear register to /// allow GSP to signal CPU for processing new messages in message que= ue. pub(crate) fn clear_swgen0_intr(&self) { - self.bar.write( - WithBase::of::(), - regs::NV_PFALCON_FALCON_IRQSCLR::zeroed().with_swgen0(true), - ); + Gsp::clear_swgen0_intr(self.bar); } =20 /// Checks if GSP reload/resume has completed during the boot process. diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs index 589b4b210a22..932e39e012f0 100644 --- a/drivers/gpu/nova-core/gpu.rs +++ b/drivers/gpu/nova-core/gpu.rs @@ -10,7 +10,8 @@ num::Bounded, pci, prelude::*, - sizes::SizeConstants, // + sizes::SizeConstants, + sync::Arc, // }; =20 use crate::{ @@ -25,10 +26,12 @@ fsp::Fsp, gsp::{ self, + cmdq::Cmdq, commands::GetGspStaticInfoReply, Gsp, GspBootContext, // }, + irq::SubtreeVectors, vgpu::VgpuManager, // }; =20 @@ -323,12 +326,27 @@ fn drop(self: Pin<&mut Self>) { } =20 impl<'gpu> Gpu<'gpu> { + /// Returns the chipset this GPU was identified as. + pub(crate) fn chipset(&self) -> Chipset { + self.spec.chipset + } + + /// Returns a shared handle to the GSP command queue. + pub(crate) fn cmdq(&self) -> Arc { + self.gsp_resources.gsp.cmdq() + } + pub(crate) fn new( pdev: &'gpu pci::Device>, bar: Bar0<'gpu>, + vectors: &'gpu SubtreeVectors<'gpu>, ) -> impl PinInit + 'gpu { let dev =3D pdev.as_ref(); =20 + // `vectors` exists for the interrupt self-test below, which this = configuration omits. + #[cfg(not(CONFIG_NOVA_CORE_IRQ_SELFTEST))] + let _ =3D vectors; + try_pin_init!(Self { spec: Spec::new(dev, bar).inspect(|spec| { dev_info!(dev,"NVIDIA ({})\n", spec); @@ -352,7 +370,7 @@ pub(crate) fn new( // never observes or clears GSP or PRIV_RING interrupts. _: { #[cfg(CONFIG_NOVA_CORE_IRQ_SELFTEST)] - crate::irq::doorbell_test::run_selftest(pdev, bar, spec.ch= ipset)?; + crate::irq::doorbell_test::run_selftest(pdev, bar, spec.ch= ipset, vectors)?; }, =20 // Initialize this early because `gsp_resources` depends on it. diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs index 13f361406a6c..43eec3f4f573 100644 --- a/drivers/gpu/nova-core/gsp.rs +++ b/drivers/gpu/nova-core/gsp.rs @@ -18,7 +18,8 @@ Io, // }, pci, - prelude::*, // + prelude::*, + sync::Arc, // }; =20 pub(crate) mod cmdq; @@ -152,9 +153,8 @@ pub(crate) struct Gsp { /// Log buffers, optionally exposed via debugfs. #[pin] logs: debugfs::Scope, - /// Command queue. - #[pin] - pub(crate) cmdq: Cmdq, + /// Command queue, shared with the GSP event interrupt handler. + pub(crate) cmdq: Arc, /// RM arguments. rmargs: Coherent, } @@ -173,8 +173,8 @@ pub(crate) fn new(pdev: &pci::Device) ->= impl PinInit) -= > impl PinInit) -> Result { self.cmdq.send_command(bar, commands::GetGspStaticInfo) } + + /// Returns a shared handle to the GSP command queue. + pub(crate) fn cmdq(&self) -> Arc { + self.cmdq.clone() + } } =20 /// Opaque bundle required to unload the GSP. Created by [`Gsp::boot`], co= nsumed by [`Gsp::unload`]. diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/= cmdq.rs index 76d51155c49f..ac3e6642031a 100644 --- a/drivers/gpu/nova-core/gsp/cmdq.rs +++ b/drivers/gpu/nova-core/gsp/cmdq.rs @@ -647,6 +647,18 @@ pub(crate) fn await_msg(&self) -> R= esult } } } + + /// Drains and dispatches every message currently pending in the GSP-t= o-CPU queue. + /// + /// Routes each message the GSP has already posted through [`CmdqInner= ::dispatch_event`] and + /// returns without waiting for more. + /// + /// # Errors + /// + /// Propagates a receive error, in particular the `EIO` of a queue poi= soned by corrupt framing. + pub(crate) fn drain(&self) -> Result { + self.inner.lock().drain() + } } =20 /// Inner mutex protected state of [`Cmdq`]. @@ -977,4 +989,34 @@ fn dispatch_event(&self, function: Result, seq: u32) { } } } + + /// Drains and dispatches all messages currently pending in the GSP-to= -CPU queue. + /// + /// Processes whatever the GSP has already posted, dispatching each me= ssage as an event, and + /// stops once the queue is empty. There is no awaited reply during a = drain, so every message + /// is routed to [`Self::dispatch_event`]. + /// + /// # Errors + /// + /// Returns the receive error that stopped the drain, in particular th= e `EIO` of a queue + /// poisoned by corrupt framing (see [`Self::wait_for_msg`]). + fn drain(&mut self) -> Result { + while !self.gsp_mem.driver_read_area().0.is_empty() { + // A message is available, so this returns without waiting. + let msg =3D self.wait_for_msg(Delta::ZERO)?; + + let pages =3D + u32::try_from(msg.header.length().div_ceil(GSP_PAGE_SIZE))= .map_err(|_| { + dev_err!(&self.dev, "GSP drain: message length overflo= w\n"); + EIO + })?; + let function =3D msg.header.function(); + let seq =3D msg.header.sequence(); + + self.gsp_mem.advance_cpu_read_ptr(pages); + self.dispatch_event(function, seq); + } + + Ok(()) + } } diff --git a/drivers/gpu/nova-core/irq.rs b/drivers/gpu/nova-core/irq.rs index 37dea5abf833..cced226a7582 100644 --- a/drivers/gpu/nova-core/irq.rs +++ b/drivers/gpu/nova-core/irq.rs @@ -10,6 +10,7 @@ =20 #[cfg(CONFIG_NOVA_CORE_IRQ_SELFTEST)] pub(crate) mod doorbell_test; +pub(crate) mod gsp; mod hal; mod interrupt_tree; mod regs; diff --git a/drivers/gpu/nova-core/irq/doorbell_test.rs b/drivers/gpu/nova-= core/irq/doorbell_test.rs index 3fd8b26e135e..c9712fa1bd18 100644 --- a/drivers/gpu/nova-core/irq/doorbell_test.rs +++ b/drivers/gpu/nova-core/irq/doorbell_test.rs @@ -28,13 +28,16 @@ time, // }; =20 -use super::interrupt_tree::{ - GinVector, - LeafEnableGuard, - LeafMask, - Subtree, - TopEnableGuard, - Tree, // +use super::{ + interrupt_tree::{ + GinVector, + LeafEnableGuard, + LeafMask, + Subtree, + TopEnableGuard, + Tree, // + }, + SubtreeVectors, // }; use crate::{ driver::Bar0, @@ -49,8 +52,8 @@ =20 /// Subtree carrying the doorbell vector, and the only subtree this test s= ervices. /// -/// Derived from the vector so that changing `DOORBELL_VECTOR` moves the a= llocation, the subtree it -/// enables, and the handler together. +/// Derived from the vector so that changing `DOORBELL_VECTOR` moves the s= ubtree it enables and the +/// handler together. const DOORBELL_SUBTREE: Subtree =3D DOORBELL_VECTOR.subtree(); =20 /// Time allowed for each of the two deliveries to arrive. @@ -153,17 +156,18 @@ fn quiesce_source(&self) { /// /// # Errors /// -/// `EIO` if the doorbell is already pending before the test, if the deliv= ery count is not two, if -/// the doorbell bit is still set once the source is stopped, or if either= delivery found a pending -/// bit other than the doorbell. `ETIMEDOUT` if either delivery does not a= rrive within the timeout. +/// `EINVAL` if the doorbell's subtree is not one nova-core services. `EIO= ` if the doorbell is +/// already pending before the test, if the delivery count is not two, if = the doorbell bit is still +/// set once the source is stopped, or if either delivery found a pending = bit other than the +/// doorbell. `ETIMEDOUT` if either delivery does not arrive within the ti= meout. pub(crate) fn run_selftest<'a>( pdev: &'a pci::Device, bar: Bar0<'a>, chipset: Chipset, + vectors: &'a SubtreeVectors<'a>, ) -> Result { - // The allocated interrupt type decides how the handler rearms deliver= y, so the vectors are - // allocated before the tree is built. - let vectors =3D super::alloc_vectors(pdev, DOORBELL_SUBTREE.into())?; + // The interrupt type decides how the handler rearms delivery, so the = tree takes it from + // probe's allocation. let request =3D vectors.request_for(DOORBELL_SUBTREE)?; let irq_type =3D vectors.irq_type(); let tree =3D Tree::new(bar, chipset, irq_type, DOORBELL_SUBTREE.into()= ); diff --git a/drivers/gpu/nova-core/irq/gsp.rs b/drivers/gpu/nova-core/irq/g= sp.rs new file mode 100644 index 000000000000..6366380eef98 --- /dev/null +++ b/drivers/gpu/nova-core/irq/gsp.rs @@ -0,0 +1,215 @@ +// SPDX-License-Identifier: GPL-2.0 +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIA= TES. All rights reserved. + +//! GSP event (SWGEN0) interrupt handling. +//! +//! The GSP firmware raises SWGEN0 when it has posted messages in the GSP-= to-CPU queue. That +//! signal reaches the CPU as a PCI interrupt through the GIN tree. This m= odule provides the +//! threaded IRQ handler for it. The top half services the GIN leaf and th= e falcon SWGEN0 latch, +//! and the IRQ thread drains the message queue. +//! +//! See `Documentation/gpu/nova/core/interrupts.rst`. + +use kernel::{ + device, irq, pci, + prelude::*, + sync::{ + aref::ARef, + Arc, // + }, +}; + +use super::{ + interrupt_tree::{ + GinVector, + LeafEnableGuard, + Subtree, + Tree, // + }, + SubtreeVectors, // +}; +use crate::{ + driver::Bar0, + falcon::gsp::Gsp as GspFalcon, + gpu::Chipset, + gsp::cmdq::Cmdq, // +}; + +/// Fixed GSP notification vector. +/// +/// The resource manager pins the GSP SWGEN0 notification to this vector o= n every supported chip, +/// so nova-core uses the constant directly instead of discovering it at r= untime. The leaf and bit +/// serviced by the handler are derived from it. +const GSP_INTR_0_VECTOR: GinVector =3D GinVector::new::<155>(); + +/// Subtree carrying the GSP notification vector, and the only subtree nov= a-core services. +/// +/// Probe allocates PCI vectors for this subtree, and the GSP handler name= s it as the subtree it +/// serves, both when it takes its vector and when it rearms. +pub(crate) const GSP_SUBTREE: Subtree =3D GSP_INTR_0_VECTOR.subtree(); + +/// Clears the interrupt state that GSP boot left behind. +/// +/// Disables every vector in every implemented leaf, clears the falcon's S= WGEN0 latch, clears the +/// tree's pending bits, and rearms PCI interrupt delivery. On return no v= ector is enabled, so the +/// tree delivers nothing. +pub(crate) fn quiesce(bar: Bar0<'_>, chipset: Chipset, irq_type: pci::IrqT= ype) { + let tree =3D Tree::new(bar, chipset, irq_type, GSP_SUBTREE.into()); + tree.disable_all_leaves(); + // GSP boot consumes its notifications by polling the queue, which lea= ves SWGEN0 latched. + // Clear it before the tree drain below, so the drain clears the tree = state the clear sets. + // Messages already posted raise no interrupt of their own, and the ca= ller's queue drain + // covers them. + GspFalcon::clear_swgen0_intr(bar); + tree.drain(); + // The `TOP_EN` cycle in `drain` is the rearm for the two enable-cycle= methods, but pre-Hopper + // MSI rearms through a configuration-space write instead. An interrup= t delivered before probe + // leaves delivery un-armed on that path, with no handler to have rear= med it. + tree.rearm_pci_irq(GSP_SUBTREE); +} + +/// Threaded IRQ handler for the GSP SWGEN0 event. +/// +/// The top half clears the GIN leaf and reads the falcon SWGEN0 latch. Th= e IRQ thread drains the +/// GSP-to-CPU message queue, which takes the command-queue lock. +#[pin_data] +pub(crate) struct GspInterrupt<'a> { + /// Borrowed BAR0, for falcon register access from interrupt context. + bar: Bar0<'a>, + /// The GSP command queue, drained by the IRQ thread. + cmdq: Arc, + /// The GIN interrupt tree for this chipset. + tree: Tree<'a>, + /// Device, for logging from interrupt context without taking the comm= and-queue lock. + dev: ARef, +} + +impl<'a> GspInterrupt<'a> { + /// Creates the handler for `chipset`, borrowing `bar` and sharing `cm= dq` with the rest of the + /// driver. + pub(crate) fn new( + bar: Bar0<'a>, + cmdq: Arc, + chipset: Chipset, + irq_type: pci::IrqType, + dev: ARef, + ) -> impl PinInit + 'a { + try_pin_init!(Self { + bar, + cmdq, + tree: Tree::new(bar, chipset, irq_type, GSP_SUBTREE.into()), + dev, + }? Error) + } +} + +impl irq::ThreadedHandler for GspInterrupt<'_> { + /// Top half: clears the GIN leaf, takes the falcon SWGEN0 latch, and = rearms PCI interrupt + /// delivery. + fn handle(&self) -> irq::ThreadedIrqReturn { + // Only service our own vector: require the GSP bit in the leaf an= d clear just that bit, so + // a co-pending vector in the same leaf stays pending for whoever = services it. The subtree + // stays enabled, so there is no whole-tree disable and enable. + let leaf =3D self.tree.read_pending(GSP_INTR_0_VECTOR.leaf_index()= ); + if !leaf.vectors().contains(GSP_INTR_0_VECTOR.leaf_mask()) { + // Nothing to service, but nova-core is the only consumer of t= his PCI interrupt, so + // skipping the rearm here would silence every later interrupt= as well. + self.tree.rearm_pci_irq(GSP_SUBTREE); + return irq::ThreadedIrqReturn::None; + } + leaf.clear_vectors(GSP_INTR_0_VECTOR.leaf_mask()); + + // SWGEN0 is the message-queue notification, so wake the IRQ threa= d to drain it. + let status =3D GspFalcon::take_swgen0_intr(self.bar); + let ret =3D if status.swgen0() { + irq::ThreadedIrqReturn::WakeThread + } else { + // The tree routes every falcon cause to this vector, so somet= hing other than a posted + // message fired it, for example a HALT from a GSP crash. Ther= e is no recovery path for + // those causes, so report the status rather than discarding i= t. + dev_err!( + &self.dev, + "GSP interrupt with no SWGEN0, falcon IRQSTAT {:#x}\n", + status.into_raw() + ); + irq::ThreadedIrqReturn::Handled + }; + + // Delivery resumes only after this, so it must happen on every pa= th that services the + // vector, including the fault path above. + self.tree.rearm_pci_irq(GSP_SUBTREE); + + ret + } + + /// IRQ thread: drains and dispatches the GSP-to-CPU message queue. + fn handle_threaded(&self) -> irq::IrqReturn { + if let Err(e) =3D self.cmdq.drain() { + // A queue that fails to drain cannot advance past the message= that failed, so every + // later notification would repeat this failure. Disable the s= ource instead. + self.tree.disable_leaf( + GSP_INTR_0_VECTOR.leaf_index(), + GSP_INTR_0_VECTOR.leaf_mask(), + ); + dev_err!( + &self.dev, + "GSP event drain failed ({:?}), the message queue is no lo= nger serviced\n", + e + ); + } + irq::IrqReturn::Handled + } +} + +/// The registered GSP event interrupt. +/// +/// The fields tear down in declaration order, which is the order this nee= ds: dropping the guard +/// disables the GSP vector, and only then does `reg` drop and run `free_i= rq`. That closes the +/// window, including a probe partial-unwind, in which an interrupt could = be delivered to a handler +/// being freed. +#[pin_data] +pub(crate) struct GspIrq<'a> { + _leaf_guard: LeafEnableGuard<'a>, + #[pin] + reg: irq::ThreadedRegistration<'a, GspInterrupt<'a>>, +} + +impl<'a> GspIrq<'a> { + /// Registers the GSP SWGEN0 threaded handler for the GSP subtree in `= vectors`, then enables + /// the GSP notification vector. + /// + /// # Safety + /// + /// The caller must not leak the returned value: its [`Drop`] runs `fr= ee_irq`. + pub(crate) unsafe fn new( + pdev: &'a pci::Device, + vectors: &'a SubtreeVectors<'a>, + bar: Bar0<'a>, + cmdq: Arc, + chipset: Chipset, + ) -> impl PinInit + 'a { + let dev: ARef =3D pdev.as_ref().into(); + let tree =3D Tree::new(bar, chipset, vectors.irq_type(), GSP_SUBTR= EE.into()); + + // The fields below are initialized in the opposite order to the o= ne they are declared in, + // so that the handler is registered before the vector it serves i= s enabled. + try_pin_init!(Self { + // SAFETY: the caller guarantees the returned `GspIrq` is not = leaked, so this + // registration's `Drop` (`free_irq`) always runs. + reg <- unsafe { + irq::ThreadedRegistration::new( + vectors.request_for(GSP_SUBTREE)?, + irq::Flags::TRIGGER_NONE, + c"nova-core", + GspInterrupt::new(bar, cmdq, chipset, vectors.irq_type= (), dev), + ) + }, + // A message posted during `quiesce` latches this leaf bit whi= le the vector is still + // disabled, so enabling it raises that interrupt rather than = losing the message. + _leaf_guard: tree.enable_leaf_guarded( + GSP_INTR_0_VECTOR.leaf_index(), + GSP_INTR_0_VECTOR.leaf_mask(), + ), + }) + } +} diff --git a/drivers/gpu/nova-core/irq/interrupt_tree.rs b/drivers/gpu/nova= -core/irq/interrupt_tree.rs index 1d26ca408dc3..02077184fd17 100644 --- a/drivers/gpu/nova-core/irq/interrupt_tree.rs +++ b/drivers/gpu/nova-core/irq/interrupt_tree.rs @@ -412,7 +412,6 @@ pub(super) fn trigger(&self, vector: GinVector) -> Resu= lt { /// /// This clears enables outside the subtrees nova-core services, so it= is a probe-time /// operation only. - #[expect(dead_code)] pub(super) fn disable_all_leaves(&self) { for index in 0..self.leaves.into_raw() { if let Some(leaf) =3D LeafIndex::try_new(index) { diff --git a/drivers/gpu/nova-core/nova_core.rs b/drivers/gpu/nova-core/nov= a_core.rs index 65ce547bd44e..68b5abfe494d 100644 --- a/drivers/gpu/nova-core/nova_core.rs +++ b/drivers/gpu/nova-core/nova_core.rs @@ -17,7 +17,6 @@ mod fsp; mod gpu; mod gsp; -#[cfg_attr(not(CONFIG_NOVA_CORE_IRQ_SELFTEST), expect(dead_code))] mod irq; mod mctp; #[macro_use] diff --git a/drivers/gpu/nova-core/regs.rs b/drivers/gpu/nova-core/regs.rs index 3422b49df7a7..e360a6d25c60 100644 --- a/drivers/gpu/nova-core/regs.rs +++ b/drivers/gpu/nova-core/regs.rs @@ -120,6 +120,10 @@ pub(crate) fn usable_fb_size(self) -> u64 { 4:4 halt =3D> bool; } =20 + pub(crate) NV_PFALCON_FALCON_IRQSTAT(u32) @ PFalconBase + 0x00000008 { + 6:6 swgen0 =3D> bool; + } + pub(crate) NV_PFALCON_FALCON_MAILBOX0(u32) @ PFalconBase + 0x00000040 { 31:0 value =3D> u32; } --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011041.outbound.protection.outlook.com [52.101.52.41]) (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 00195399350 for ; Sat, 29 Aug 2026 01:33:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967237; cv=fail; b=hlq36wINR9iUeGznP+mHK4jq7vmGvcJ86QqKlOxSnDzXPDlAt12DbWtIi1YjhyKfQd/UqCuxkM/mJd+GWPQanmlR7lVrx6I0iKVCOfJXl73M735ST7RTujo8JQ9JJE25NkOQctiyz36aBH4reIHd+l7KyZNSSpebQdsQQp5qrhU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967237; c=relaxed/simple; bh=3l3a4O8/kdCSPhyDq2pbd3dksEbK2dvWgE+a90JNv30=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=QkTet2qtONXbbARKBLgtQ5IgJ8IHvqiEOsARnI1Vxt0uIJikyREorX7OcWLLS4wfpSeh+Vlxb1Pi33rJDqeZftVWguuEWf+/NhNB4BJR/3MxQm7crJeOUTJeN7PqH5QSAkV80bRh5QKF89IgIlZL9CFeYmQpxgrg0rLICYf5svs= 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=YLRxV31v; arc=fail smtp.client-ip=52.101.52.41 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="YLRxV31v" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rBt6A/OmrA1to9PQAe86MB6iMXQ4/EhDmbjNL6sTqrplSPb7e2e9D/hqkIH/7GZCtwkIzCKeN26lCg0LDfBLUas/c6dWKbZGolmms1SFCj1Vm01TpjNiUulpogd3crbtfW+IO9SLmqZ1gQf4fN2XcNBHALUOOHv/4oInm1HNIyygf/w//tVtjIcj9xwnty/Y3YECwsfIs//EyJyOAmm/5MXyb04ochktHvEfAfq9IST37LqgI7KhiMQOMpcnwlbW8bW5BzrBogzyiz6h9ZbGoPSTkBU9g8b/tJV+bWQT85E3wkyLWQDlF8CZZRxuTik+izGfsyLv1JeOzu0B9h76AQ== 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=zS55A6UY2pASP01OQ1yUtOSQSfIaQMkfjsuJ99WV+Pc=; b=WV7Zv80pdGKf6p+9kzwSccibsmFJqTf6Dzs1UmGwRe5Xd7eL+QXb8pCC1su43Vc1gT+69akknFpsbtO1qEXjyehOC1tLX3zQS9lRDkOcKFLk/1zeiPPpph12ZJuhUY/viDu6d+HGerFFuSvY76z9u+rdQlIwGqSskpzQOyhvpLXjq8FXeaJv4Dw4tw9e9XN2f6IQLyrKqzhLKwx2xIV0O8RbQgzEFLg0+RUHjwnTQnP7txcdrmvp7ZjzS4UNvDKQIo5p+Ivemo7LmAs5MSSW3rc/UdHKbzY61sWOffNmjP0UMgreN8/mjIaHzz8EsvwIpziWYigV3yMqFb2dxIUIpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zS55A6UY2pASP01OQ1yUtOSQSfIaQMkfjsuJ99WV+Pc=; b=YLRxV31v1RcYDs+5va3nGQnwWRc2Zqx0cd3uJSljwLW8nrDvWGVf6spNAThxn0iKv2PkVg87gGO4OuNQvvY3/rAbS2eaMePrGy4qCLBQmwrhv/KzhjLqSofxkOm5Rt5wom57AeRkkfj5adqe4HAAv5lv9dmBkuUWcm9DLth7SFCIJqpcsHJ2TZDyWkufAvpU1phgAh7eFGelmhKhwuA2Oqoqt60k9lsRTbgsjOSxPtUhNY2H3L3xEhQW1JF/0QPuINj9h8u7/FdU1Uetv9rzdsfeTdAL0b9kLCDfCAPYjutlEXxxIuxl87jsi3wdk8Q4auU63rzbrmE/bOwgjxVcXw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by SAVPR12MB999121.namprd12.prod.outlook.com (2603:10b6:806:4e7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:33:39 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:33:39 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard , Will Pierce Subject: [PATCH v2 13/15] gpu: nova-core: retrigger the GSP falcon and clear every latched cause Date: Fri, 28 Aug 2026 18:33:32 -0700 Message-ID: <20260829013324.499542-18-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR13CA0160.namprd13.prod.outlook.com (2603:10b6:a03:2c7::15) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|SAVPR12MB999121:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e3c373f-bc1c-4768-390b-08df056d8d97 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|1800799024|366016|6133799003|10067099003|56012099006|5023799004|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 5jrhUGIvPDNUO7dQiN3WDouaLNHu4huygYTukOPClQisYE5QVUKmCsmNnsiz1DkduZmDN6yytChHIO3nXysiV4jajgY1+APB4Jd447yzjrRadnWj+bKOFH+XwRoW6f9aUuPzjHd73OtssGL4WGq0Y1pIzYd+TYjfpY4tYPmSMy+Ixoi9SxrqDBUzfWz3ltXwhXPs0jhT7zbllOYXN31uHdN6NFFZZjDgVJvIin8uO3e/Mt68xyIRVVh2KVYLdtJicx7BcDaCe5OBQ4T4+34AHw0R1cx4mUrEeqCZarjT/sJYJOJ9kq0lFPRsnnVZTBBfAuimtDQbJt78+kSBFRvfatbo+YwllPSZtuDYthwykUO7CR8hDivC93P7+XsCWoDWl1H9OJQo7y8t44zfItWz+dhyPApz0XtHHVFndJeAbWsqET7gyaqMHaudLL2r7fYaKbwjGFcgzuudM/OuDW1+f9w4HMa5FzBwCSENpvgDiSKWx5I79uPAtZJxnmtKJm1+/ggdaYhmntP39fKQn/AmFnMvlIbo/tCaYbJLT5g3dU6Iuj+9I6kzBl3+Bpcb3DgwAhOL/tHngMWvW5SCrJFqfmd6zH/CCHUT+zfls3/Ibv5LVTQrBHS4AZqzUrJh1a4YIaX/A6K5AfIWXhRw/eX7gyg8HJRoMUFUvx/I7f+F/8U= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(1800799024)(366016)(6133799003)(10067099003)(56012099006)(5023799004)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?5yoXuG97Jag/A0EuMvhmQCAfUYyojzf1L9yk4PbS2I/6hSvm2nXIzJBJm1/D?= =?us-ascii?Q?oSrhiGpifc0fxF7RvUvP6F0XO21pRhRUBclmmQTZqR+NqWktey7oszUcOBTX?= =?us-ascii?Q?jV25KVAY6tvbULLo1Ja0RUaQ/nk/r2PtKhFCK/bB/pTf1qUYTVjHW4Ew7UHG?= =?us-ascii?Q?/OoeypHcUkLm5r7EH7UGaSYaLLyYrHeicPux53FJHpnSZREE1R5XBw6As2fu?= =?us-ascii?Q?J9pAczxFnpuaaWvxgn3M2DAKAL3qO/vIAigAspbOQMdCBbGvWRdG4ytXGRVj?= =?us-ascii?Q?j6D1jdAXPRW2tMHbf7AP3FLHzb23V1rG2OTXCk4aoHRWAN8gtOd0gI3r7kNz?= =?us-ascii?Q?vHBKJfbae77Cm2KSW3pPcUsYtApjV/3zN9U3M1ACsQdXHASqg5KpQZG+xFje?= =?us-ascii?Q?IR4Mxu8U0Q8aV6P3z6F4s813808+wXxUAUj5hJS0pDKj8LAJNyBaxV5iCnTz?= =?us-ascii?Q?5lMGzlncxZsPUlrm1Piau08aYvU1fkUXWvXWCemYuD7m+XS7lVMh8uULi1Qx?= =?us-ascii?Q?LF5LqdIK4kE2sWcQd6+GP5F1rBvJVG6+WqR7GTD7Crunz1VXUNbsXqcnLPOA?= =?us-ascii?Q?tMDLeHzsge/7G8e3Yriyukf7CtiTQ8MZqytQMk8VF3cqB23xVjttfoiwLmhf?= =?us-ascii?Q?rVLkGyORTdsPyBrj+BO6Ym/rm0Qcq1M4bSmQ8Wpud7ZNPUUcmeWsm4GPAxMI?= =?us-ascii?Q?IAwOyo8jwoARMfc0lX8a2jsGni76xsIw+VK5n+UDoVLjMPbTTLcLcJqnivPN?= =?us-ascii?Q?tX1HLkVvb8K3K0i63UUKkY5L5qBMGO7ad/C0hr24rGL3nWL3ZqFISFhcmZiN?= =?us-ascii?Q?KjY3odUYnlEG3Lng70mX8X41nCH4psP24gIUUS9qljOOZ0L8zafbaw5gxwPT?= =?us-ascii?Q?tpGSmgLVCFLHzAbwMR77O9QQmbqlhuOqmqD/nIZLjwRHxx602ySolHwStZey?= =?us-ascii?Q?RNONffAF0NSTRQHPXr0rE4WBqmidXIYgK1fl4PTXDCLpfNF39wGz//4w/p0D?= =?us-ascii?Q?grAWc2MsHL2loODwTp1FgL+6CGLZApWdBG08RlNd/uMDR2qs1JO72jl1qR6+?= =?us-ascii?Q?HVkoh4jj2uA6GvNEJ+94Y/BiO0qZiOaWTUwk9GpJGQZgAIMdRbXKxMZY6vIv?= =?us-ascii?Q?3M81WKLgncIUOMYxXVUeJzODYcFw9M9aV73h8vhLospoMy60Fsi1+FzGazBC?= =?us-ascii?Q?+x+5TsH7NtRQY4jFp5RunsgHaqQFB8dUMHLoEIOttGGZrEna0P9mEHBTDirz?= =?us-ascii?Q?BwcpbVIFDTqCb9i+ReZJJ4F5JwERLenAQbUZNIZ1GLx7qxbvuCEDd5jwxf33?= =?us-ascii?Q?163dVl6g7LMJC24kMkNo+7ampBnRkvbS5sHR3tW1nHUYWo+GytGpUbr3V3W9?= =?us-ascii?Q?k215/uXMfSCVOfJeybdoLMnbM+yZgJcJxzcFnhVgIMKMTLG/QW2hpXV2LD5S?= =?us-ascii?Q?wJCb+Mx1/HAjTnAFG1L7d32OEP85KPK+cG6jF71/fyeZe9JpnzKB9dc1oKXQ?= =?us-ascii?Q?2ssMh/JLjhRSlSVv1fNOM7bI34YaBceOBpkOP+PKiBYBO2aWBCUA4GDmeFHa?= =?us-ascii?Q?H5aulewLXqCIdLWK9h70n7avvWEqAny1IM37LLMnTsrXsgdmnxcHZEKQ1orb?= =?us-ascii?Q?gTil08vT0IWcFRx8H1fVrHFMcPQyODcHrlTcR/YU8bwNce1TA8w/ast2N5mY?= =?us-ascii?Q?qbes5ZH7wCbaM0/+SIOtgPuHtnFd9lKm2e6yRmqI++J3N32b5pPxd0elSlUz?= =?us-ascii?Q?YAt5He+hrw=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e3c373f-bc1c-4768-390b-08df056d8d97 X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:33:39.6075 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ut36cHaRZfYydBdljWWon/DaCX3OXMyaG8dXNqWzjD5FAv+nVZ2bB/FwOflg9t4X7w7+OnjfrNvuIAx5ElSG4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SAVPR12MB999121 Content-Type: text/plain; charset="utf-8" A falcon signals the interrupt tree when its set of enabled causes goes from empty to non-empty. While any enabled cause stays latched, later causes produce no signal, and Turing falcons have no INTR_RETRIGGER register with which to supply one. The GSP handler cleared its GIN leaf bit and then cleared the falcon's SWGEN0 latch. A cause that arrived between the two left no record: the leaf clear discarded it, and the falcon had nothing left to signal. Swapping the two clears moves the window rather than closing it. The handler serviced SWGEN0 or reported an unserviceable cause, never both, so a HALT co-pending with SWGEN0 stayed latched. nova-core's probe cleared the SWGEN0 latch before draining the tree, so a message posted in between set a leaf bit that the drain then erased. In every case the GSP went silent for the life of the device. Write the falcon's INTR_RETRIGGER register after every clear of the GSP vector. That supplies the missing signal from whatever causes remain enabled. Turing falcons have no such register, so skip the write there. Handle every cause the falcon reports on one invocation, masking the ones with no recovery path so the re-emit does not raise them again. Clear the SWGEN0 latch after the tree drain instead of before it. Neither of these depends on INTR_RETRIGGER, so both apply on Turing. Assisted-by: Cursor:claude-opus-5 Reviewed-by: Will Pierce Signed-off-by: John Hubbard --- drivers/gpu/nova-core/falcon/gsp.rs | 36 +++++++++++++++++ drivers/gpu/nova-core/falcon/hal.rs | 8 ++++ drivers/gpu/nova-core/irq/gsp.rs | 61 ++++++++++++++++++----------- drivers/gpu/nova-core/regs.rs | 20 ++++++++++ 4 files changed, 103 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/nova-core/falcon/gsp.rs b/drivers/gpu/nova-core/fa= lcon/gsp.rs index f9d9e8e0386b..6ee5c1ef1af7 100644 --- a/drivers/gpu/nova-core/falcon/gsp.rs +++ b/drivers/gpu/nova-core/falcon/gsp.rs @@ -16,11 +16,13 @@ use crate::{ driver::Bar0, falcon::{ + hal, Falcon, FalconEngine, PFalcon2Base, PFalconBase, // }, + gpu::Chipset, regs, }; =20 @@ -64,6 +66,40 @@ pub(crate) fn take_swgen0_intr(bar: Bar0<'_>) -> regs::N= V_PFALCON_FALCON_IRQSTAT =20 status } + + /// Masks and clears every interrupt cause set in `status`. + /// + /// A masked cause leaves the falcon's enabled set, so it neither rais= es the tree again nor + /// holds that set non-empty. + pub(crate) fn mask_and_clear_intr(bar: Bar0<'_>, status: regs::NV_PFAL= CON_FALCON_IRQSTAT) { + let causes =3D status.into_raw(); + + bar.write( + WithBase::of::(), + regs::NV_PFALCON_FALCON_IRQMCLR::zeroed().with_value(causes), + ); + bar.write( + WithBase::of::(), + regs::NV_PFALCON_FALCON_IRQSCLR::from(causes), + ); + } + + /// Re-emits the falcon's enabled interrupt causes into the interrupt = tree. + /// + /// The falcon signals the tree on a transition of its enabled causes,= so clearing the tree + /// leaf while a cause is still latched leaves no transition and no fu= rther vector. + /// + /// Does nothing on Turing, whose falcons do not implement the registe= r. + pub(crate) fn retrigger_intr(bar: Bar0<'_>, chipset: Chipset) { + if !hal::has_intr_retrigger(chipset) { + return; + } + + bar.write( + WithBase::of::().at(0), + regs::NV_PFALCON_FALCON_INTR_RETRIGGER::zeroed().with_trigger(= true), + ); + } } =20 impl<'a> Falcon<'a, Gsp> { diff --git a/drivers/gpu/nova-core/falcon/hal.rs b/drivers/gpu/nova-core/fa= lcon/hal.rs index 7e532889a1f4..f0828b32aebb 100644 --- a/drivers/gpu/nova-core/falcon/hal.rs +++ b/drivers/gpu/nova-core/falcon/hal.rs @@ -72,6 +72,14 @@ fn signature_reg_fuse_version( fn load_method(&self) -> LoadMethod; } =20 +/// Returns whether `chipset`'s falcons implement `NV_PFALCON_FALCON_INTR_= RETRIGGER`. +/// +/// Turing falcons do not. Ampere and later do, including GA100, whose fal= con otherwise uses the +/// Turing HAL, so this is keyed on the architecture rather than provided = through [`FalconHal`]. +pub(crate) fn has_intr_retrigger(chipset: Chipset) -> bool { + !matches!(chipset.arch(), Architecture::Turing) +} + /// Returns a boxed falcon HAL adequate for `chipset`. /// /// We use a heap-allocated trait object instead of a statically defined o= ne because the diff --git a/drivers/gpu/nova-core/irq/gsp.rs b/drivers/gpu/nova-core/irq/g= sp.rs index 6366380eef98..a1030d66cc70 100644 --- a/drivers/gpu/nova-core/irq/gsp.rs +++ b/drivers/gpu/nova-core/irq/gsp.rs @@ -50,18 +50,17 @@ =20 /// Clears the interrupt state that GSP boot left behind. /// -/// Disables every vector in every implemented leaf, clears the falcon's S= WGEN0 latch, clears the -/// tree's pending bits, and rearms PCI interrupt delivery. On return no v= ector is enabled, so the -/// tree delivers nothing. +/// Disables every vector in every implemented leaf, clears the tree's pen= ding bits, clears the +/// falcon's SWGEN0 latch, and rearms PCI interrupt delivery. On return no= vector is enabled, so +/// the tree delivers nothing. pub(crate) fn quiesce(bar: Bar0<'_>, chipset: Chipset, irq_type: pci::IrqT= ype) { let tree =3D Tree::new(bar, chipset, irq_type, GSP_SUBTREE.into()); tree.disable_all_leaves(); - // GSP boot consumes its notifications by polling the queue, which lea= ves SWGEN0 latched. - // Clear it before the tree drain below, so the drain clears the tree = state the clear sets. - // Messages already posted raise no interrupt of their own, and the ca= ller's queue drain - // covers them. - GspFalcon::clear_swgen0_intr(bar); tree.drain(); + // GSP boot consumes its notifications by polling the queue, which lea= ves SWGEN0 latched, and + // the GSP drives no new signal while it is set. Clear it after the tr= ee drain, which erases + // every leaf bit and would erase the one a message posted since the c= lear had set. + GspFalcon::clear_swgen0_intr(bar); // The `TOP_EN` cycle in `drain` is the rearm for the two enable-cycle= methods, but pre-Hopper // MSI rearms through a configuration-space write instead. An interrup= t delivered before probe // leaves delivery un-armed on that path, with no handler to have rear= med it. @@ -80,6 +79,8 @@ pub(crate) struct GspInterrupt<'a> { cmdq: Arc, /// The GIN interrupt tree for this chipset. tree: Tree<'a>, + /// Chipset, for the falcon retrigger, which Turing does not implement. + chipset: Chipset, /// Device, for logging from interrupt context without taking the comm= and-queue lock. dev: ARef, } @@ -98,15 +99,18 @@ pub(crate) fn new( bar, cmdq, tree: Tree::new(bar, chipset, irq_type, GSP_SUBTREE.into()), + chipset, dev, }? Error) } } =20 impl irq::ThreadedHandler for GspInterrupt<'_> { - /// Top half: clears the GIN leaf, takes the falcon SWGEN0 latch, and = rearms PCI interrupt - /// delivery. + /// Top half: clears the GIN leaf, takes every cause the falcon report= s, and rearms PCI + /// interrupt delivery. fn handle(&self) -> irq::ThreadedIrqReturn { + let bar =3D self.bar; + // Only service our own vector: require the GSP bit in the leaf an= d clear just that bit, so // a co-pending vector in the same leaf stays pending for whoever = services it. The subtree // stays enabled, so there is no whole-tree disable and enable. @@ -119,27 +123,40 @@ fn handle(&self) -> irq::ThreadedIrqReturn { } leaf.clear_vectors(GSP_INTR_0_VECTOR.leaf_mask()); =20 - // SWGEN0 is the message-queue notification, so wake the IRQ threa= d to drain it. - let status =3D GspFalcon::take_swgen0_intr(self.bar); - let ret =3D if status.swgen0() { - irq::ThreadedIrqReturn::WakeThread - } else { - // The tree routes every falcon cause to this vector, so somet= hing other than a posted - // message fired it, for example a HALT from a GSP crash. Ther= e is no recovery path for - // those causes, so report the status rather than discarding i= t. + let status =3D GspFalcon::take_swgen0_intr(bar); + + // Every cause the falcon reports leaves the falcon's enabled set = on this invocation. A + // cause left latched holds that set non-empty, and the falcon sig= nals the tree only on a + // transition of the set, so no later SWGEN0 would signal at all. + let unserviceable =3D status.with_swgen0(false); + if unserviceable.into_raw() !=3D 0 { + // The tree routes every falcon cause to this vector, so a cau= se other than a posted + // message also arrives here, for example a HALT from a GSP cr= ash. nova-core has no + // recovery path for those, so report the status rather than d= iscarding it, then mask + // the cause. dev_err!( &self.dev, - "GSP interrupt with no SWGEN0, falcon IRQSTAT {:#x}\n", + "unserviceable GSP falcon interrupt, IRQSTAT {:#x}\n", status.into_raw() ); - irq::ThreadedIrqReturn::Handled - }; + GspFalcon::mask_and_clear_intr(bar, unserviceable); + } + + // The leaf clear above consumed the tree's record of this interru= pt, and the falcon signals + // the tree only on a transition of its enabled causes, so a cause= that arrived while this + // handler ran would never reach the CPU. Re-emit to supply that t= ransition. + GspFalcon::retrigger_intr(bar, self.chipset); =20 // Delivery resumes only after this, so it must happen on every pa= th that services the // vector, including the fault path above. self.tree.rearm_pci_irq(GSP_SUBTREE); =20 - ret + // SWGEN0 is the message-queue notification, so wake the IRQ threa= d to drain it. + if status.swgen0() { + irq::ThreadedIrqReturn::WakeThread + } else { + irq::ThreadedIrqReturn::Handled + } } =20 /// IRQ thread: drains and dispatches the GSP-to-CPU message queue. diff --git a/drivers/gpu/nova-core/regs.rs b/drivers/gpu/nova-core/regs.rs index e360a6d25c60..925600825434 100644 --- a/drivers/gpu/nova-core/regs.rs +++ b/drivers/gpu/nova-core/regs.rs @@ -124,6 +124,15 @@ pub(crate) fn usable_fb_size(self) -> u64 { 6:6 swgen0 =3D> bool; } =20 + /// Masks interrupt causes at the falcon, one bit per cause, in the la= yout of + /// `NV_PFALCON_FALCON_IRQSTAT`. + /// + /// A masked cause is excluded from the enabled set the falcon signals= on, so it cannot be + /// raised again by `NV_PFALCON_FALCON_INTR_RETRIGGER`. + pub(crate) NV_PFALCON_FALCON_IRQMCLR(u32) @ PFalconBase + 0x00000014 { + 31:0 value =3D> u32; + } + pub(crate) NV_PFALCON_FALCON_MAILBOX0(u32) @ PFalconBase + 0x00000040 { 31:0 value =3D> u32; } @@ -251,6 +260,17 @@ pub(crate) fn usable_fb_size(self) -> u64 { 0:0 reset =3D> bool; } =20 + /// Re-emits the falcon's enabled interrupt causes into the interrupt = tree. + /// + /// Write-only. A falcon signals the tree on a transition of its enabl= ed causes, so a handler + /// that cleared the tree leaf while a cause was still latched has lef= t no transition behind, + /// and this write supplies one. Turing falcons do not implement this = register. + /// + /// OpenRM declares two elements and uses only the first. + pub(crate) NV_PFALCON_FALCON_INTR_RETRIGGER(u32)[2] @ PFalconBase + 0x= 000003e8 { + 0:0 trigger =3D> bool; + } + pub(crate) NV_PFALCON_FBIF_TRANSCFG(u32)[8] @ PFalconBase + 0x00000600= { 2:2 mem_type =3D> FalconFbifMemType; 1:0 target ?=3D> FalconFbifTarget; --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011041.outbound.protection.outlook.com [52.101.52.41]) (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 806A7387346 for ; Sat, 29 Aug 2026 01:33:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967244; cv=fail; b=GbRUr3A1jwNsDTAPGRlW7hSMHPo34itibwudlVZ75daUmLbmWN90LUmZ2YVnTW1ni4LwrPU+0fX+ywC2JQzWpPzAoKnHKworojPzZ/Eyd65Z7+CpwcByxzlbOKE/bo+1G1H+FyBolSCdc5ux6X3VqRUd7HT2qYMqDeKtx1uO8rI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967244; c=relaxed/simple; bh=2egL3ZyqdBWKKkEQkTqM6cUmYnj2oTA2wg/EfhdCipU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=d1XZ1DK597IJ1NyBmGAFx8QC2QvKmKiANMg2v9i33Ff97RYGnPrHPC3xwnpQpnHLHDcJjt/pF4QQrFvapcBN5+tIuUO83lBEeLE60WtFTlYAt2shq4IHEAi2vUxmUMpkSWE2d3TAwUPmxLxsL0PMS2uf99ZZdwoCVhb4+IgZMNU= 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=OgBMtIHE; arc=fail smtp.client-ip=52.101.52.41 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="OgBMtIHE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f7sCrRSUku97AeTgNgdryupMSkZJFJ8ZJ7mDPy69vez7B9OdhmdBm0wv1rBTNy4B5ZmN5FTFw/4TyWXBz5VYqSVWK/YtNOtryHvILGqTJghnM4iuBtKY+GLAzYg9kQ6IDKVTSfnc2YaYeQgIcxaKfWDwqPxrgYxDOx7m970OMSe+ZG0CJeVEvGVt5wMkbpomxlLP2bEhpPGlWy4qeZRZN6Gb0mvbfqvY+teOt8ymQDTAFug4JsfUssXeL4rrqZsXwSfjDvPUULTStTRXSrAW8Ub7xMO9TuyX2quMugz17vVjIOEBCN5qu/IjplXLjxlo8OB36vEvC8EPvQnnKEnQkg== 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=S+KMev0mAAQ09bBL9hHweW0zxJpovDPdwWNeG6Sc4cE=; b=xiHtjPJMP/wkz7cptV2ZZivB4dj8l3u9U3n574DT5UmNNXV3PuhRlUdqNuDFnPC8kaqZ2XeRUrgM12UIRuddaJH9zhUvY1QMJxxNCHp6dWfFTi80PsosAR7sEMWgplR0PMXSatArCHLmLKk6WjV6U6jXVNILwATKpzUyiJOxi55lXp0ZwRn8cmQjtZ7uIZmTg+YrIGLNbk1uTHvnOIs34rwAPhQLcfZJag4Bb/jr4bTgGoJ2erC81ppUp301wP7g2UifeYHDpSf/tZLTDFeBmk/kEK1etJGSQl2zjuZvhKRQyoubhCMf+G9rpNn7+7UriL1wkbTIF8mzUnnEGepyag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S+KMev0mAAQ09bBL9hHweW0zxJpovDPdwWNeG6Sc4cE=; b=OgBMtIHEDSACduCEIY3zHclo/lIDxegjfgYp5S/ZzJpLXwqy/voeT94NpY6lr9B3iifvNVD8FYnqrWBzzVlBkbm6OptApEXP+TlFnL8fzVJp6L6BLInEll7mlqjlncXlPAxufMCJQ7EBcPPOBo6XFYHegQhawo36kr+CFvXFUPJcjBAIaZqikU/V0LSlgR8UPUjvS1RMTshd2xvKx+ZWGrT77ZsmMdGTBBUQZP9WFHGl5pTbVWgZtxgBXQc1hzKse0qnxGIvIfxLmHz/K86vw1KsaZWUhge3ZDM3IrcbJYg0R5LPyfO2SZdasg5MslcZqsLit2sF9Gw/Tu4Trjg9Pw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by SAVPR12MB999121.namprd12.prod.outlook.com (2603:10b6:806:4e7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:33:41 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:33:41 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard , Will Pierce Subject: [PATCH v2 14/15] gpu: nova-core: add KUnit tests for the interrupt tree and HALs Date: Fri, 28 Aug 2026 18:33:33 -0700 Message-ID: <20260829013324.499542-19-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR05CA0157.namprd05.prod.outlook.com (2603:10b6:a03:339::12) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|SAVPR12MB999121:EE_ X-MS-Office365-Filtering-Correlation-Id: 8dc82c62-5aa8-402d-4b21-08df056d8e6d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|1800799024|366016|6133799003|10067099003|56012099006|5023799004|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: wA3Lz5DKzVS00Kzpt5SwtnleYoZvLnZDZ+5+gWfyRwhOybTb7jbulDOwcoimrUs/zoOsU+tR80kenxF/mdhjJleB2IiovOvGFmoUjZv8yZrT3/+A+AbKznFYcRl4rleqfw7CosVG1ufHsIvmgtkQR5UdhNxh9A+gSi5Evn2Go+9eVcG97zXEAgeMPjYXZ5gCA9z7+++DPjwrLmuRBivVp+n5eR9jWyhvnj4MFA+e2eh6S7DVIC2ePt4sLm4NnuIWm/2Vk0bjnB5o25KxwJ9LrXGNFW0eZI2GeixVo/7cmnMPlXMXLQLD61H0eD2nz8Pl/Z8tIr5E30SdHTxt1XSXi/CDeF6vZ0AanDoVFc/Fp0IvtZIwZxJsu50QDVxd2LlcQlcNcVEapjqzWC0OnndStC9WTcS+2fZjgYUXtBmj9S2NlwMlI//T4N0HaGDVCEecCVhXk4Gcnf8xBpMDfUZja0ToWm8eGtSimFglSKwteOkmLkWwBiCDC1bUaAnFHiOyYLHYdXPkOZcIZ3xHFaL3R38etZKDfH20Mh3VOGaVRyvZTbK8bZ7K87L23QoGEYob97AdBtOw5lwdP4VJrmv6FMy239v3CjofrX+2h33MH2KOMDkKy5jU9jNTTrYzE6yXVKExWG6bV/F9DnJRp9pIc3RPtw9p5x6CLCUaIU6yfL0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(1800799024)(366016)(6133799003)(10067099003)(56012099006)(5023799004)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?fzrxRCV+piUSjseOOKMrOGvgeFe4O8qgqHhub2Om5XHGDlG6rFz92XHQ8dCY?= =?us-ascii?Q?2lxoVLkxPiI4zfM8WYHhwCDYSUawJlvn17gKyHFid1P/d/FnRQueTSm2PmID?= =?us-ascii?Q?kFclLs9eMrO5rBORAKRbyUDkYQm8fEkjn8RVHmIMmaIIw7qgzmbwCVywdg1z?= =?us-ascii?Q?sSnQmn/+NMgVa3s84E6N6+zlkycb2Onm5aDIMvMgVUGJZ8XHsZhEiC94Pgct?= =?us-ascii?Q?gNMFGK5IQD6tKGGC9NWj/y32fI84yg0BxpdJJQzZflWmJWO6VATBJKQRVQpq?= =?us-ascii?Q?2IXRTIMibu9Gns9TcqwpiITgnEw/0gy2xeULN1N/RvWSDydkXob85SdlhHhk?= =?us-ascii?Q?LU3LvqIJJ0iRu80Z4wWwV+iEsygjX7RU+08XuY7y6B97cy3diKvQkpuAF9bj?= =?us-ascii?Q?058oZCgh1HQQ/nn2izoymtNR8sVvkwHf0mlbUSj4Rao+7OTQdIMo0ak7hmug?= =?us-ascii?Q?XlTxzQz5eOO2Yv9OGxbnREkCGcrFYS5mGRdQ+/XvOT+OtBNMvLQmQKdbCjOL?= =?us-ascii?Q?CjiGXWEvdAacbuiJyNl3QXVc+6nQ7lVSJgwtFhinb+Ri8eZbAji6rqSUVCU5?= =?us-ascii?Q?iVXMDzZtyCgymrr3PggmXOXncMX+N+CAqY/j1ym5ANJnOBKQbUOuVzvZ7vMh?= =?us-ascii?Q?oHFJS5IhfJL7B0QOcbASmi3LUY+H/BgGapVbjF2Ei6xdweAuY29W10zTSj8V?= =?us-ascii?Q?/2oO//Zaet3M3JQ1y+Rbt2hTvV0baSMc0IqPLi55hVlMUaJfGA49JJ2BpqOu?= =?us-ascii?Q?kWof/NKl9j/gm7UFw9EQjqV91GSGrJXHD/7xUq2ZkhMUeNwGSzRcnq8lkYND?= =?us-ascii?Q?4vDATr5mxkp5LkvKABssJ1M4OGaMX2minbX1hcr2/Ct/jqUK0H5T3ELZSRfp?= =?us-ascii?Q?fC5tYWn7b91hlGhDkS6pab/VvUDynHV1Da7Wv0C8jL/Ot3Qc0DSVKnsnZkRf?= =?us-ascii?Q?ZEtkZg7UVQP6K8cvLkxdlhFaNCVb88t2hFT8OUbps+pv98VnEfMnipQgDfqe?= =?us-ascii?Q?/KkY2QEi9hcQ0GeXcwPYWjgmVEE3C97UrHxZBnff9crUUBgqqe4PdcUop6OQ?= =?us-ascii?Q?9I3GAWCEacB5LGyTIIQAGzWHR2p4r/9iRDfbDh7SYvgJ4h65UloMz9lTr4wX?= =?us-ascii?Q?DaHPPwXOABf9PeyBwmvR/y/QOT/dKGmd9YhL6H+F8fcHj56e4iiEeVjlenPP?= =?us-ascii?Q?bwLWsmyo6MKfnVqvCCkbdcN2FZ23SQUIIC6T/cJjJJ8A1igSysBLEEUovYpf?= =?us-ascii?Q?ZVayWTKo2+XoJ/7V9ooLOQbK8ynrTa7URa9mAtAd6cxLcN1WBZyLKil1w7Qg?= =?us-ascii?Q?DEEs2OAPpdm45DD/o3T2MT04cEz9HEmhnn1EjIp6friaMm39JMcHn8oLNKdy?= =?us-ascii?Q?u9H1SR+d59Hig5zJOIO8DLWYHaWqFeHjR/Dqr5+UK/OF5Xj1zcLxFbe3IbpR?= =?us-ascii?Q?zOIdZL+BXNy96d8FC3ZiYMHnGNvsONfcfcJX3fQmvu3vrnFPD4vtxQdHKL5C?= =?us-ascii?Q?PqW4bVtP+GJ4EJZF+qwinA4nXF7p6tquuZtfLLbHXCLJONH4r8HAoxBsaW4m?= =?us-ascii?Q?hgOP5iSBO0K+ZScp4BKjZE7HoikyXy1rIzPUcQE7HkX0PtUs0c6peGV47Q30?= =?us-ascii?Q?CdeDGCxiSeZt974klF5wdl+HMoBgnX6IgZDeaRD6x7Ue4DmeRV0S1lfsfx+L?= =?us-ascii?Q?tObpbliTElxKW+D/CHssPpZP9RDQm7BwWF2TP5neu3B32jsPj/4oH2nZxvE2?= =?us-ascii?Q?QpumwSsPDQ=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8dc82c62-5aa8-402d-4b21-08df056d8e6d X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:33:41.0052 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gN2TdD/DN1ra160nRUQSHnnom6sZJGt8M9o9au0oHmDSS5jDoMvKk8+9HDciam6j9OWR18ldYY2iiaIUfW78JQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SAVPR12MB999121 Content-Type: text/plain; charset="utf-8" Neither the per-architecture interrupt policy nor the vector arithmetic touches hardware, so KUnit can cover both without a GPU. Add three suites: * nova_core_gin_tree covers the leaf index bounds, what a leaf count derives, the subtree-to-leaf mapping and its out-of-range filtering, where a vector lands in the tree, the bound that rejects a vector outside it, the subtree set operations, and that every supported chipset implements the subtree carrying the GSP notification. * nova_core_gin_hal covers the tree size on each family, and the rearm method for each combination of family and interrupt type. * nova_core_falcon_hal covers the falcon retrigger gate. It is keyed on the architecture rather than the HAL, because GA100 shares the Turing HAL but does have the register. Assisted-by: Cursor:claude-opus-5 Reviewed-by: Will Pierce Signed-off-by: John Hubbard --- drivers/gpu/nova-core/falcon/hal.rs | 24 +++++ drivers/gpu/nova-core/irq/hal.rs | 83 ++++++++++++++- drivers/gpu/nova-core/irq/interrupt_tree.rs | 110 ++++++++++++++++++++ 3 files changed, 216 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nova-core/falcon/hal.rs b/drivers/gpu/nova-core/fa= lcon/hal.rs index f0828b32aebb..6bff9fea1a79 100644 --- a/drivers/gpu/nova-core/falcon/hal.rs +++ b/drivers/gpu/nova-core/falcon/hal.rs @@ -107,3 +107,27 @@ pub(super) fn falcon_hal( =20 Ok(hal) } + +#[kunit_tests(nova_core_falcon_hal)] +mod tests { + use super::*; + + /// Only Turing falcons lack the interrupt retrigger register. GA100 h= as it even though + /// [`falcon_hal`] gives GA100 the Turing HAL, which is why the gate i= s keyed on the + /// architecture instead. + #[test] + fn intr_retrigger_gate_per_arch() { + assert!(!has_intr_retrigger(Chipset::TU102)); + + for chipset in [ + Chipset::GA100, + Chipset::GA102, + Chipset::AD102, + Chipset::GH100, + Chipset::GB100, + Chipset::GB202, + ] { + assert!(has_intr_retrigger(chipset)); + } + } +} diff --git a/drivers/gpu/nova-core/irq/hal.rs b/drivers/gpu/nova-core/irq/h= al.rs index ee354859b965..c7ecdc44144b 100644 --- a/drivers/gpu/nova-core/irq/hal.rs +++ b/drivers/gpu/nova-core/irq/hal.rs @@ -8,7 +8,8 @@ =20 use kernel::{ io::Io, - pci::IrqType, // + pci::IrqType, + prelude::*, // }; =20 use crate::{ @@ -109,3 +110,83 @@ pub(super) fn cpu_interrupt_hal(chipset: Chipset) -> &= 'static dyn CpuInterruptHa } } } + +#[kunit_tests(nova_core_gin_hal)] +mod tests { + use super::*; + + use crate::gpu::Chipset; + + /// Pre-Hopper parts have an 8-leaf tree. + #[test] + fn pre_hopper_tree_size() { + for chipset in [Chipset::TU102, Chipset::GA102, Chipset::AD102] { + assert_eq!(cpu_interrupt_hal(chipset).leaf_count(), LeafCount:= :Eight); + } + } + + /// Hopper and later implement a 16-leaf tree. + #[test] + fn hopper_plus_tree_size() { + for chipset in [Chipset::GH100, Chipset::GB100, Chipset::GB202] { + assert_eq!(cpu_interrupt_hal(chipset).leaf_count(), LeafCount:= :Sixteen); + } + } + + /// Only pre-Hopper MSI rearms through the configuration-space mirror.= MSI on Hopper and later + /// cycles the `TOP` enables of every serviced subtree. + #[test] + fn msi_rearm_method_per_arch() { + for chipset in [Chipset::TU102, Chipset::GA102, Chipset::AD102] { + let hal =3D cpu_interrupt_hal(chipset); + assert_eq!( + hal.pci_irq_rearm_method(IrqType::Msi), + Some(PciIrqRearmMethod::ConfigMirrorEoi) + ); + } + + for chipset in [Chipset::GH100, Chipset::GB100, Chipset::GB202] { + let hal =3D cpu_interrupt_hal(chipset); + assert_eq!( + hal.pci_irq_rearm_method(IrqType::Msi), + Some(PciIrqRearmMethod::TopEnableCycleServiced) + ); + } + } + + /// MSI-X gives each subtree its own table entry, so on every architec= ture its rearm cycles + /// only the subtree the handler serves. + #[test] + fn msix_rearms_one_subtree_on_every_arch() { + for chipset in [ + Chipset::TU102, + Chipset::GA102, + Chipset::AD102, + Chipset::GH100, + Chipset::GB100, + Chipset::GB202, + ] { + let hal =3D cpu_interrupt_hal(chipset); + assert_eq!( + hal.pci_irq_rearm_method(IrqType::MsiX), + Some(PciIrqRearmMethod::TopEnableCycleSubtree) + ); + } + } + + /// `INTx` is level-triggered and needs no rearm write on any architec= ture. + #[test] + fn intx_needs_no_rearm() { + for chipset in [ + Chipset::TU102, + Chipset::GA102, + Chipset::AD102, + Chipset::GH100, + Chipset::GB100, + Chipset::GB202, + ] { + let hal =3D cpu_interrupt_hal(chipset); + assert_eq!(hal.pci_irq_rearm_method(IrqType::Intx), None); + } + } +} diff --git a/drivers/gpu/nova-core/irq/interrupt_tree.rs b/drivers/gpu/nova= -core/irq/interrupt_tree.rs index 02077184fd17..7277ffcb33a1 100644 --- a/drivers/gpu/nova-core/irq/interrupt_tree.rs +++ b/drivers/gpu/nova-core/irq/interrupt_tree.rs @@ -503,3 +503,113 @@ fn drop(&mut self) { clear_top_enables(self.bar, self.serviced); } } + +#[kunit_tests(nova_core_gin_tree)] +mod tests { + use super::*; + + /// A leaf index is a `Bounded`, so it accepts 0..=3D15 and = rejects 16. + #[test] + fn leaf_index_bounds() { + assert!(LeafIndex::try_new(0).is_some()); + assert!(LeafIndex::try_new(15).is_some()); + assert!(LeafIndex::try_new(16).is_none()); + } + + /// A leaf count yields one subtree per pair of leaves, and 32 vectors= per leaf. + #[test] + fn leaf_count_derives_subtrees_and_vectors() { + assert_eq!(LeafCount::Eight.subtree_count(), 4); + assert_eq!(LeafCount::Eight.subtree_set().into_raw(), 0x0f); + assert_eq!(LeafCount::Eight.vector_count(), 256); + + assert_eq!(LeafCount::Sixteen.subtree_count(), 8); + assert_eq!(LeafCount::Sixteen.subtree_set().into_raw(), 0xff); + assert_eq!(LeafCount::Sixteen.vector_count(), 512); + } + + /// Subtree `N` covers the two adjacent leaves `2N` and `2N + 1`, and = an index past the leaf + /// register arrays yields nothing. + #[test] + fn subtree_covers_two_adjacent_leaves() { + for index in 0..8u32 { + let first =3D crate::num::u32_as_usize(index) * 2; + let mut leaves =3D subtree_leaves(index); + + assert_eq!(leaves.next().map(LeafIndex::get), Some(first)); + assert_eq!(leaves.next().map(LeafIndex::get), Some(first + 1)); + assert!(leaves.next().is_none()); + } + + // Subtree 8 would cover leaves 16 and 17, both beyond the leaf in= dex range. + assert!(subtree_leaves(8).next().is_none()); + } + + /// A vector maps to its leaf, its bit within that leaf, and its subtr= ee. The fixed doorbell + /// (129) and GSP (155) vectors share a subtree, so one allocation and= one enabled subtree + /// serve both. + #[test] + fn vector_maps_to_leaf_bit_and_subtree() { + let doorbell =3D GinVector::new::<129>(); + let gsp =3D GinVector::new::<155>(); + + assert_eq!(doorbell.leaf_index().get(), 4); + assert_eq!(doorbell.leaf_mask().into_raw(), 1 << 1); + assert_eq!(doorbell.subtree().index(), 2); + + assert_eq!(gsp.leaf_index().get(), 4); + assert_eq!(gsp.leaf_mask().into_raw(), 1 << 27); + assert_eq!(gsp.subtree().index(), 2); + + assert_eq!(doorbell.subtree(), gsp.subtree()); + } + + /// Both fixed vectors lie within the 8-leaf tree, so every supported = part carries them. + #[test] + fn fixed_vectors_fit_the_narrowest_tree() { + assert!(GinVector::new::<129>().validate(LeafCount::Eight).is_ok()= ); + assert!(GinVector::new::<155>().validate(LeafCount::Eight).is_ok()= ); + + // The first vector beyond an 8-leaf tree. + assert!(GinVector::new::<256>().validate(LeafCount::Eight).is_err(= )); + assert!(GinVector::new::<256>().validate(LeafCount::Sixteen).is_ok= ()); + } + + /// A subtree set reports membership, intersection, and how far it ext= ends from subtree 0. + #[test] + fn subtree_set_operations() { + let gsp =3D GinVector::new::<155>().subtree(); + + assert!(LeafCount::Eight.subtree_set().contains(gsp)); + assert!(!LeafCount::Eight.subtree_set().is_empty()); + + // Subtree 2 is the highest the GSP needs, so an MSI-X request cov= ers entries 0 through 2. + assert_eq!(SubtreeSet::from(gsp).span(), 3); + + // Hopper implements every subtree an 8-leaf tree does. + assert_eq!( + LeafCount::Sixteen + .subtree_set() + .intersection(LeafCount::Eight.subtree_set()), + LeafCount::Eight.subtree_set() + ); + } + + /// Every supported chipset implements the subtree that carries the GS= P notification. + #[test] + fn gsp_subtree_is_implemented_everywhere() { + for chipset in [ + Chipset::TU102, + Chipset::GA102, + Chipset::AD102, + Chipset::GH100, + Chipset::GB100, + Chipset::GB202, + ] { + assert!(cpu_interrupt_hal(chipset) + .leaf_count() + .subtree_set() + .contains(crate::irq::gsp::GSP_SUBTREE)); + } + } +} --=20 2.55.0 From nobody Sat Sep 26 22:34:18 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011041.outbound.protection.outlook.com [52.101.52.41]) (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 DDAA23A9D8A for ; Sat, 29 Aug 2026 01:34:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967247; cv=fail; b=Sjezmp8jjr7LaVYpol0BlJg7hWkNoyeNPGBNDcO3Kx3aOagwrhFOwRD8NkwMQmW2FtFBvllYJf1ZjtapqYhwgRuRdD1PNrzxa4JnVpebn9cyXhGIR5RaMPOYG85KInDjjDO3ORAz8ZBpI4+raeSae+nRg3ce5Tsc1oWal3NAnM4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787967247; c=relaxed/simple; bh=TbNU/Gr0ldnc6PzDHVXdfTj5jhyRxjTIiNKhES1e4qM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=s+O/cwtv065/wDV3o7pN/vbMznsgk+OnGiSMjRKtPE7K7fn0thyY8OTtJal1qydqv+hXn++lh6kM7vctjNriqPIKfo72xNPzby/Q8mXzdtfjqOPH1Cjy7y40r9Bgs9O1HubIVtQr2apWhex42G3UGCiryETVYzQR9cNW1WiUZj4= 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=q1iYPZqN; arc=fail smtp.client-ip=52.101.52.41 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="q1iYPZqN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WMc/XL1Mj3Vd3ON9w90juC3Vqepuuy1MwQkx6ct8O5ZDDqi23hZDatHfGVXZgbgkUjdlOzCxerF1i7pfBCugBjl/EfbtqfHGwsqVUOvP2yVq71dwPeT2m+eCsflSIeRLfS+RW8pozDe7gyl6IjVpijpXA9WPPjTlKODOA230md9UvctDbF/4+z/M7n4iM4ny26/QtQR50WeFJnJUwo0/dRN68L58tJmIm/+HS7YPzqFdCExdG0+swFtos8BabxIHpHBVjm0arnFe3qMkBUrVjfQziK3FuKvgs7uqLDeejV3J+DJ/EcER2FMLKRE2eJae/hx8ay8K7Wh/tgzDg0W1rw== 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=rEdsY905ndNaaRQleyAqGn7tT7H8i5Id2eIyDkIyiXo=; b=o83poKLla3Epuwme4VQclx1bIz3P1wASkxtNOcb/VU7gcayPm0nDqjQqs4uMnzgpIArW+ZU33DJtkwPESdmLOP5ODB5H7HTzj190u0WDDC51SXmOE+joH45KvuEFJbeyzS2OdHBGss8F+PrXyzfDYbeni3/LNYGL5RipDbedb8JBCYLzodKazpscg1LIN1TMa4oAZx9Hs0EwznL+bJNDkekmGmO0onF5y+e+1Du6jzdWB1qQuoNR8SHY2UDAGL9Uk/WcfbuMMA0xi8WHanvtFxZwRI9IU1CzTdwe/SaxYSF4X4vf57nxatadnibIER0Cy4jj8yAS2OnSUVaolG4Xug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rEdsY905ndNaaRQleyAqGn7tT7H8i5Id2eIyDkIyiXo=; b=q1iYPZqN7cmyRqs/K6Yz8vfGY+v+82b1FOUEnict90MLtX25qR+rjtn6E9GQNDqMfBpsNLQrw3fomXibg6RwukJoYMmTN9bDtgrfUcVytVMxUa65OXKksKLRqtJAsilXFiRBihR8IWib1Gaqvg0nUhRT7b4jMTqIsrha3RMxS2vd1QHmy7qVuihWikBTClEDuWxgYN6NwJQ75LdQVS42fXcDTBkYW2BiecJS9yrKjCxsDBYKRPvCTXNtFtuB++VFBWhEObRPBigjI6tRnKlcsUyvHAUzMECi2nL57Fi9T4YmvwABiJGY8JKEPIAIBDyRZsyliSBV3Au7qkV0UcTBWw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by SAVPR12MB999121.namprd12.prod.outlook.com (2603:10b6:806:4e7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.11; Sat, 29 Aug 2026 01:33:42 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 01:33:42 +0000 From: John Hubbard To: Danilo Krummrich , Alexandre Courbot Cc: Timur Tabi , Alistair Popple , Eliot Courtney , Zhi Wang , David Airlie , Simona Vetter , Bjorn Helgaas , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nova-gpu@lists.linux.dev, LKML , John Hubbard , Will Pierce Subject: [PATCH v2 15/15] gpu: nova-core: document the GIN interrupt controller and GSP events Date: Fri, 28 Aug 2026 18:33:34 -0700 Message-ID: <20260829013324.499542-20-jhubbard@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829012243.496697-1-jhubbard@nvidia.com> References: <20260829012243.496697-1-jhubbard@nvidia.com> X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR05CA0151.namprd05.prod.outlook.com (2603:10b6:a03:339::6) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|SAVPR12MB999121:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b54ca36-a7e2-4724-fd0f-08df056d8f2a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|1800799024|366016|6133799003|3023799007|10067099003|56012099006|5023799004|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: P0gq81dlc0/9NitTy59cvGnKUGYvrsWHIglj0kYwdkLQS41dC2hahQhcQgk13tn/IRNF8pCiy7/H85/Saf6YOIE+nhgvXqWkVkr1L/c+tWPqkD7++WYItPbNqXvrwiZ7pkOPC6X0pwJHTRQRAg2bGEIUAN3oQcJ4D3WBpYKiqBFDqvZtaoKKrEK0hspm7u7P8UFKS/Qec70bU5nPSGJ2IJXFjs7POBwT5b+peH4ND58pI+OKuYq24DUJPJ/y8ftULwoPgWlRGEZoXFXgQ1sz6Crc5Byxi//hel4Xk3UEVTa+F9dDd52xhkH7WptCj+QhCsH6GFGy+GPhjK+Tk8IUQnRiAtGf6hGkiYcvoS4rnSVM87H4AvXpWoCRYzup1hzrZ90jcHL0Gf7dZ/afWYNy0DvjfvCM+F8ZLVk5YUlL/SesMGrHjoS3XDJ6EbWFx7pJCMiXrv5jnwV6OVxU9Dt119CO78wV2ZetFUReFQoCtFBYELjXVb+jCNaDJCReIDQXu3ACI/V/skuGOaBfw0vi2uInwVM8qVbZK51VAOovO7Ak8FkvtCWplFWHr1QBjhkov3Jp+cZSjtkoied0Sjimmhrng1GxjdCptqWWX/5DrEyGMtAg6UQfXAMRyPxlTzxoQZzArcRxgNRLQlBZsFju33uvymXByJjsi2PBHivPWbw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(1800799024)(366016)(6133799003)(3023799007)(10067099003)(56012099006)(5023799004)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?6N5PfJ2mMoWun0htUBs+svzeOkxYiPw+nNQMFZI9zxjM2uAp8vsz57taSLEm?= =?us-ascii?Q?yZbbJvPDkTKlYiFeyMCPS79A1zZvK8Ig9p2MisIPsKjh5n7ri9ba6hOTN84j?= =?us-ascii?Q?fjbesBbx5El4ZKGXGL3ygomdAZFhfU+obMgND7lZ1bb8RBz8Pi78moh3sMUk?= =?us-ascii?Q?GKoDp/o2HzRkgTW8ZKwEfGeOzAd+BAyRyhRGUAMTuo6UUZ9GX+dRp72CJava?= =?us-ascii?Q?1wmZO34Zqxop3o4LrXomnRqrsexTpd+Ljzxr5NaCwmI8hRvIyjUud6lEymFV?= =?us-ascii?Q?dKVqKdRE7QERsA3RC0g3nSzjj1iJQdnoWGKJz2ajwGqfvsxvyGrrWt6dEwGy?= =?us-ascii?Q?+SbFSC2ET27ymbD7XYfcX3s4PrKIEq4Nb4eq7RjgkiI1s2YNHlDMl3XVLjsp?= =?us-ascii?Q?C4uJTSoal6I3Gop/hLCp1ffmxJdFXwV5SFFatwElQphK+9smEqEn2J9ofGvh?= =?us-ascii?Q?bwk0IZEg39R61AcRNa129wSK5/k+zWU09rDNCtKPTaeR/wk45jT2fbXZ4YQb?= =?us-ascii?Q?Aac2IXUFdeSbRXFk0vTXRgZoSceLRYG5O6PE2YQCSTJM4Q9FGxWTSfyBvikT?= =?us-ascii?Q?wu/Xyc2gSxHeDlbKMwPKpmApuEa8Gz2S734xLYGYs1e//OgxOq0xANtlAlK1?= =?us-ascii?Q?v9fGmeL7cDGFu5evK5HGbdAKnkgM8q3E1LSVWweJdNva6TlgCcvQ61AcTG/K?= =?us-ascii?Q?uhePbnZuWWLmowec7IqfzbdRvS0HdI+t7pocJwBPK30X+rcJfjkJqUogRIRg?= =?us-ascii?Q?GKSSblE0qzt2EpMrIj2Aqexr+6tffEsobhsCuUBeifU9Q21igDS7LSqRT7zo?= =?us-ascii?Q?Arws1ZR95xeRtTTlv5CjJKa1QeXuMxMm6QzB3nGC6tbF09QzVcxmIc1JfI45?= =?us-ascii?Q?fGs/FMfwulPJNU4M35PA9lE/5ht/uLIpbGbm3CFKOZKitXpicRlizSiqclbF?= =?us-ascii?Q?JO3a71RGdDhLiAQGbZIZymo4sS59uYFwvvb2BtDAvMOwhfZ/HqjT3YWbUdWJ?= =?us-ascii?Q?wbibJXAWGH2YTdbnshxzAPHgw310z4O2zkQ/RCnCdOKehoSPYg3vwHYRywmw?= =?us-ascii?Q?5z9u6SqNp1l8OMqzuQnfsawPGuSxFY8LTgIKRG/z3QcGnpxiQ/AJsJqgEOPV?= =?us-ascii?Q?i4BftzFIsP0B4viGpEd6I66tXSkSstIb60E1WQN+jPhURb4loNTt4U63vxil?= =?us-ascii?Q?s5WawyqQTlRHqs2FUx/BMAzmQsC7mdRZ4b/6JoR0EJ1vMycYy8jEUcfUi0hm?= =?us-ascii?Q?1bIjd38FtZE9c1QCBXATVGOxP7OFacAdpIbQEFaabKNW5sTxxbjs/NKodAzs?= =?us-ascii?Q?/ehSsiWSN8wjxLxG7zYXBUjFvy3Dv7Uwcm83sxLT7yVv7PT7WPOIdbTvZOBc?= =?us-ascii?Q?7RvL2fTS1N3g+H+yVW3Jl1ttISO6jlvGx4FXzYYzyYOXkoiTSFsmCo+gKtOE?= =?us-ascii?Q?tMKrhVb5LUpzqEdbkuOmlJI2mnIhWG3O7S+cxgfi6hXLs8j7X67M0Jiba0KJ?= =?us-ascii?Q?v/rZ29wgTDfsuSjIJqLCkTvWJfu3wJ4zU/ri3wdHFEdIQzwbvZAAGgxftOZ8?= =?us-ascii?Q?nXH9B7KlMzQ/kmQEpU7U3YlpMGHUtyHAXi7rC2fsTzpqZwa7vB0CJCW6GNA3?= =?us-ascii?Q?BW0eaHPkG8f5x18WwVaAA7Hun1vDTnQ+1KtTk7lEXlf8BQZcs+MMCLkHGXYl?= =?us-ascii?Q?7i/4CatbSKh+fP2qExQW4AvgsI8O4DHOZ17GeCek4MeDbSS7F32aEC7XNsWK?= =?us-ascii?Q?+XUhh0h33g=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b54ca36-a7e2-4724-fd0f-08df056d8f2a X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 01:33:42.3007 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WOWqwoFTcpYloNIV7lZ0Zk+DJzLy0CklOPaV9akT/ESDj+9tmTV/0fBY19jYzaW5FHZMWuL4L5zMY/N++5yKzA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SAVPR12MB999121 Content-Type: text/plain; charset="utf-8" The hardware behind nova-core's interrupt support is not obvious from the code. Delivery is edge-triggered and needs a rearm after every interrupt, the rearm operation differs by GPU family and PCI interrupt type, and a vector that latched while disabled is invisible in the TOP summary register. Three different numbers are also all called a vector, in GIN, the MSI-X table, and the Linux IRQ API. Add a design document covering the two-level register tree, how it reaches the CPU under MSI and MSI-X, and the rules those behaviors impose on a handler. It also covers the GSP event: the falcon retrigger, the handoff from boot-time polling to interrupts, and how its messages are classified. A glossary names each term after the register or the specification that defines it. Assisted-by: Cursor:claude-opus-5 Reviewed-by: Will Pierce Signed-off-by: John Hubbard --- Documentation/gpu/nova/core/interrupts.rst | 686 +++++++++++++++++++++ Documentation/gpu/nova/index.rst | 1 + 2 files changed, 687 insertions(+) create mode 100644 Documentation/gpu/nova/core/interrupts.rst diff --git a/Documentation/gpu/nova/core/interrupts.rst b/Documentation/gpu= /nova/core/interrupts.rst new file mode 100644 index 000000000000..840012671511 --- /dev/null +++ b/Documentation/gpu/nova/core/interrupts.rst @@ -0,0 +1,686 @@ +.. SPDX-License-Identifier: GPL-2.0 +.. SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIA= TES. All rights reserved. + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +GPU interrupt handling: GIN and the GSP event +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +This document describes how nova-core receives interrupts from the GPU on = Turing +and later parts. It covers the GPU Interrupt and Notification unit (GIN), = which +is the GPU's interrupt controller, and the GSP event interrupt. + +Throughout, *CPU* means the CPU and the nova-core driver running on it. Th= e GPU +also has on-chip processors that run their own firmware and receive their = own +interrupts, and the GSP (GPU System Processor) is one of them. + +The register names in this document are the names from the GPU hardware +reference headers. The CPU tree's registers live in the per-function +``NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_*`` aperture on every supported part, = and +the controller itself has a second name on pre-Hopper parts (see "Register +naming"). + +Terminology +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Three different numbers are all called a "vector" in the surrounding mater= ial. +This document gives each one its own name and never uses "vector" on its o= wn. + +GIN vector + The GPU-internal interrupt source number, 0 through 511 on Hopper. It = is a + bit address within the tree: leaf ``vector / 32``, bit ``vector % 32``= . The + CPU doorbell is GIN vector 129 and the GSP event is GIN vector 155. + +MSI-X entry + An index into the device's MSI-X table, 0 through 7 on Hopper. Linux's + ``struct msix_entry`` names its Linux IRQ number ``.vector``, which is= a + third meaning. + +Linux IRQ number + What ``request_irq()`` takes, obtained from ``pci_irq_vector()``. + +The remaining terms, each named for the register or the specification that= owns +it: + +enable / disable a GIN vector + ``LEAF_EN_SET`` and ``LEAF_EN_CLEAR``. + +enable / disable a subtree + ``TOP_EN_SET`` and ``TOP_EN_CLEAR``. + +serviced subtree + A subtree nova-core enables and has a handler for. + +rearm + Restoring PCI interrupt delivery after servicing an interrupt. It is a + ``TOP_EN`` disable-then-enable cycle everywhere except under pre-Hopper + MSI, where it is a write to the end-of-interrupt (EOI) register in the= BAR0 + configuration-space mirror (see "Rearming PCI interrupt delivery"). + +mask + Reserved for the two places hardware and the PCI specification use the + word: the MSI-X per-entry Vector Control mask bit, which Linux owns, a= nd + the falcon cause masks. It never names a GIN enable. + +latched, pending + A ``LEAF`` bit records its source whether or not the GIN vector is ena= bled. + A disabled vector's pending bit never appears in ``TOP``. + +clear a leaf vector + Write a 1 to the vector's bit in ``LEAF``. Open RM spells the same + operation ``intrClearLeafVector_HAL``. + +pending bits + The plain bitmask value read from a ``LEAF`` register. + +unit + A generic interrupt-raising block. "Engine" is reserved for the blocks= that + do usermode work: GR, CE, NVDEC, and the like. + +The GIN controller +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +A GPU has many interrupt sources: the GSP, copy engines, the graphics engi= ne, +video decode and encode, the MMU fault path, timers, and others. Each one = has a +GIN vector number, which is internal to the controller and is not a PCI ve= ctor +index. + +GIN records which vectors are pending in its own two-level register tree a= nd +raises the PCI interrupt when an enabled vector becomes pending. The CPU's +handler reads that tree to tell the sources apart, clears the pending vect= ors, +and runs the work for each. + +How the tree reaches the CPU over PCI +------------------------------------- + +How many PCI interrupts the tree needs depends on the interrupt type Linux +grants. + +MSI has a single message, and every subtree raises that one message. One +allocated vector serves the whole tree. + +MSI-X raises a separate table entry per subtree, so a subtree's interrupts +arrive on the table entry whose index is the subtree number. Linux masks e= ach +table entry a driver did not allocate, and a masked entry sends no message= : the +request sets a bit in the pending-bit array and waits for an unmask that n= ever +comes. A driver that leaves out the entry its subtree raises loses every +interrupt on that subtree, and loses it silently, with the GIN leaf and TOP +registers showing the vector pending and enabled while no handler runs. + +The serviced-subtree invariant +------------------------------ + +Every subtree enabled at TOP must have an allocated PCI vector with a regi= stered +handler. + +MSI satisfies this with one message that every subtree raises. MSI-X needs= one +allocated, unmasked entry per serviced subtree, and a PCI allocation canno= t be +sparse, so it runs from entry 0 through the highest serviced subtree:: + + MSI-X, with subtree 2 serviced: + + subtree 0 -> entry 0 allocated, no handler, stays masked + subtree 1 -> entry 1 allocated, no handler, stays masked + subtree 2 -> entry 2 handler here, and its rearm covers subtree 2 + + MSI, with any serviced set: + + every serviced subtree -> the one allocated vector, whose handler's + rearm covers the whole serviced set + +The entries allocated below a serviced subtree that the driver does not se= rvice +cost nothing: Linux unmasks an entry only when its interrupt is requested,= and a +disabled subtree raises nothing. + +nova-core services exactly one subtree, subtree 2, because both the vector= s it +uses are in leaf 4: the GSP event (155) and the self-test doorbell (129). = That +is also the subtree the resource manager assigns to its ``UVM_SHARED`` int= errupt +category on every chipset nova-core supports. + +Interrupt trees +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +GIN keeps a separate interrupt tree for each place an interrupt can be sen= t to: + +* One tree per PCIe function. The Physical Function (PF) has a tree, and e= ach + Virtual Function (VF) has a tree. +* One tree per on-chip microcontroller that receives interrupts, starting = with + the GSP. + +Each destination reaches its own tree through its own BAR0 and cannot reac= h any +other tree. GSP firmware selects the tree each unit's interrupt is sent to. + +nova-core services the CPU tree of one function. The VF trees and the +microcontroller trees belong to firmware or to virtual functions. + +The two-level tree +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Each tree has two levels. The bottom level is the LEAF registers, which ho= ld one +pending bit per vector. The top level is the single TOP register, which +summarizes the leaves. + +* Each ``LEAF(i)`` is a 32-bit register holding the pending bits for vecto= rs + ``i * 32`` through ``i * 32 + 31``. A set bit means that vector is pendi= ng. +* ``TOP`` is a single 32-bit read-only register. Each of its bits summariz= es one + *subtree*, which is a pair of adjacent leaves. TOP bit ``N`` reflects + ``LEAF[2N]`` and ``LEAF[2N + 1]`` as filtered by their leaf enables, so a + vector that latched while disabled does not appear in TOP. + +A subtree is two leaves, so a part with L leaves has L / 2 subtrees and us= es +that many TOP bits. An 8-leaf part uses TOP bits 0 through 3, and the othe= r 28 +bits always read 0. A 16-leaf part uses TOP bits 0 through 7:: + + TOP (one 32-bit register, and an 8-leaf part uses only bits 0..3) + + bit 0 -> subtree 0 -> LEAF[0], LEAF[1] vectors 0..63 + bit 1 -> subtree 1 -> LEAF[2], LEAF[3] vectors 64..127 + bit 2 -> subtree 2 -> LEAF[4], LEAF[5] vectors 128..191 + bit 3 -> subtree 3 -> LEAF[6], LEAF[7] vectors 192..255 + bits 4..31: always 0 on an 8-leaf part (a 16-leaf part uses bits 0..= 7) + + A LEAF is one 32-bit register, one bit per vector. For example, LEAF[4] + holds vectors 128..159: + + bit 1 =3D vector 129 (CPU doorbell) + bit 27 =3D vector 155 (GSP event) + +Registers +--------- + +All the registers are 32 bits, defined in ``regs.rs`` under the +``NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_*`` names. The leaf registers are arra= ys +indexed by leaf number: + +* ``LEAF(i)`` holds the pending bits for the vectors in leaf ``i``. Reading + returns the pending bits, and writing a 1 to a bit clears that vector + (write-1-to-clear). +* ``LEAF_EN_SET(i)`` and ``LEAF_EN_CLEAR(i)`` enable and disable individual + vectors in leaf ``i``. +* ``TOP`` is the read-only summary: bit N is set when an enabled vector is + pending in ``LEAF[2N]`` or ``LEAF[2N + 1]``. A vector that latched while= its + leaf enable was clear does not appear. +* ``TOP_EN_SET`` and ``TOP_EN_CLEAR`` enable and disable subtrees. +* ``LEAF_TRIGGER`` makes a vector pending in software. The self-test uses = it. + +Mapping a vector to the tree +---------------------------- + +Each vector occupies one bit of one leaf, and each leaf belongs to one +subtree:: + + leaf =3D v / 32 + bit =3D v % 32 + subtree =3D leaf / 2 + +Both of the vectors nova-core names by number fall in leaf 4: vector 129 a= t bit +1 and vector 155 at bit 27, so both arrive under subtree 2. + +Enabling and clearing +--------------------- + +Each bit of a set or clear register acts on its own: writing a 1 performs = the +action for that bit, and writing a 0 leaves the bit's state alone. No call= er +ever needs a read-modify-write. + +* ``LEAF(i)`` is write-1-to-clear. Reading returns the pending bits. Each = bit + must be cleared before its vector is serviced. +* ``LEAF_EN_SET(i)`` and ``LEAF_EN_CLEAR(i)`` enable and disable individual + vectors in a leaf. +* ``TOP_EN_SET`` and ``TOP_EN_CLEAR`` enable and disable whole subtrees. + +A vector reaches the CPU only when both its leaf enable bit and its subtre= e's +TOP enable bit are set. The leaf enable governs delivery and the TOP summa= ry, +but not the latch: a disabled vector still latches its LEAF bit, and that = bit is +visible only by reading the leaf directly. + +How a unit interrupt reaches the CPU +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +A unit does not write a LEAF register itself. Each unit has an interrupt r= outing +register, and GSP firmware programs it once at boot. Firmware writes three +things into it: the unit's VECTOR (which leaf bit it uses), its GFID (whic= h tree +to post to: the PF or a specific VF), and its destination flags (which con= sumers +get it: the CPU, the GSP, or another on-chip microcontroller). + +Later, when a unit has an event, three things happen in turn:: + + 1. The unit sends an interrupt message to GIN, carrying the VECTOR, GF= ID, + and destination flags from its routing register. + 2. GIN sets bit (VECTOR % 32) in LEAF[VECTOR / 32], in the tree that t= he + GFID and destination flags select. + 3. If that vector is enabled and its subtree is enabled, GIN raises th= e PCI + interrupt to the CPU. + +Because firmware assigns the vectors, nova-core does not hardcode which ve= ctor +belongs to which unit. The one exception nova-core relies on is the GSP ev= ent +vector, which firmware pins to a fixed number (see "The GSP event vector"). + +Edge behavior and rearm +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The pieces behave as follows: + +* A LEAF bit is a latch. It is set on the rising edge of its source and st= ays set + until the CPU writes a 1 to it. A source that stays high does not set th= e bit + again. +* TOP is read-only and reports the subtree's *enabled* pending state. A ve= ctor + that latched while its leaf enable was clear does not appear in TOP. +* LEAF_EN and TOP_EN are CPU-controlled enables that allow or block delive= ry. +* GIN raises the PCI interrupt for subtree N when the subtree's enabled pe= nding + state goes from low to high:: + + Per vector, in leaf i at bit b: + LEAF[i][b] AND LEAF_EN[i][b] + + Per subtree N, across its leaves 2N and 2N + 1: + OR of every enabled pending bit -> TOP[N] + + Delivery for subtree N: + TOP[N] AND TOP_EN[N] -> rising edge -> PCI interrupt + + TOP_EN applies below TOP, so disabling a subtree halts delivery and le= aves + what TOP reports unchanged. + +Because a disabled vector is invisible in TOP, code that must find every p= ending +bit cannot descend from TOP. It has to read the leaves directly. Open RM d= oes +the same: its stalling-interrupt path never reads TOP, and instead walks e= very +subtree it implements reading LEAF registers. + +Because delivery is edge-triggered, writing ``TOP_EN_SET`` while an enable= d leaf +bit is still set produces a new edge. A full tree walk uses this: after it +clears the leaves, it writes ``TOP_EN_SET`` so an interrupt that arrived d= uring +servicing is still delivered. + +A unit that holds an internal level signal high does not produce a new lea= f edge +after the CPU clears the bit, so rearming alone does not re-deliver it. Su= ch +units have an ``INTR_RETRIGGER`` register that forces a new edge. + +Retriggering a falcon +--------------------- + +A falcon signals the tree on a transition of its enabled interrupt causes. +Clearing the tree leaf while a cause is still latched leaves no transition= , so +the vector stays clear however many further causes arrive. Both clear orde= rs +have that window, so a handler on a falcon vector writes ``INTR_RETRIGGER`= ` on +every path that services the vector. + +That re-emit must not be able to raise a cause that nothing clears. A caus= e the +handler does not service is removed from the falcon's enabled set with +``IRQMCLR`` and cleared with ``IRQSCLR`` before the re-emit. + +``INTR_RETRIGGER`` is absent on Turing falcons and present from GA100 onwa= rd, so +the write is conditional on the architecture. A Turing handler cannot supp= ly a +transition that went missing, so it must leave no cause latched: it reads = the +status once and takes every cause that status reports, rather than stoppin= g at +the first one it recognizes. A cause left behind holds the falcon's enable= d set +non-empty, and no later cause from that falcon signals the tree at all. + +One window stays open on Turing. A cause that arrives between the status r= ead +and the clears is not in the status, so it stays latched after the tree le= af has +been cleared. Open RM has the same window: ``kgspService_TU102`` ends with +``kflcnIntrRetrigger``, which is implemented from GA100 onward and does no= thing +on Turing. + +Rearming PCI interrupt delivery +------------------------------- + +Clearing the GIN state is not enough. A message-signaled interrupt is +delivered once per edge, and the PCI side delivers no further interrupt un= til the +CPU rearms it. Which operation does that depends on the GPU family and on = the +interrupt type Linux granted: + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Architecture Type Rearm operation +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Turing through Ada MSI write the configuration-mirror EOI register +Hopper and later MSI clear then set the serviced TOP enables +Any MSI-X clear then set the handler's own TOP enable +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The MSI forms cover every serviced subtree, because one message serves all= of +them. The MSI-X form covers one subtree, because each serviced subtree has= its +own table entry and its own handler. + +INTx is level-triggered and needs no rearm write. nova-core does not alloc= ate it, +so it never reaches a handler. + +A handler must rearm once per delivered interrupt, on every path that serv= ices +one. A handler that skips the rearm receives no further interrupts at all. + +The rearm is separate from the TOP restore at the end of a full tree walk,= even +though two of the three forms write the same registers. The walk clears TO= P_EN +on entry so that it can read and clear without new interrupts arriving, an= d sets +it again on exit. For the two enable-cycle forms that restore also rearms,= but +pre-Hopper MSI rearms through the configuration mirror, which the walk nev= er +writes, so the startup sequence rearms explicitly after the walk. + +Servicing an interrupt +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +nova-core services the tree in one of two ways, depending on which code ha= ndles +the interrupt. + +The GSP event handler services one vector, so it leaves its subtree enable= d and +reads and clears only its own leaf bit, touching a single leaf per interru= pt. + +The startup drain walks the whole tree instead, because it must clear what= ever is +pending across every subtree rather than one known vector. It disables the +subtrees, clears every pending leaf, then enables them again. + +The drain reads every implemented leaf rather than descending from TOP. Bo= ot +latches vectors while they are still disabled, and those bits do not appea= r in +TOP, so a TOP-driven walk would skip exactly the state the drain has to cl= ear. + +The two paths as register operations:: + + Full tree walk (the one-time startup drain): + write TOP_EN_CLEAR =3D serviced disable, to stop new interr= upts + for each implemented subtree N, for i in {2N, 2N+1}: + pending =3D read LEAF[i] pending vectors in this leaf + write LEAF[i] =3D pending clear (write-1-to-clear) + write TOP_EN_SET =3D serviced restore TOP_EN + + Notification, subtree stays enabled (the GSP event handler, and the + self-test, which deliberately mirrors it): + pending =3D read LEAF[gsp_leaf] is our vector's bit set? + write LEAF[gsp_leaf] =3D gsp_bit clear only our bit + rearm PCI interrupt delivery see "Rearming PCI interrupt + delivery" + +Two rules for the full walk: + +* Clear every pending leaf bit, including bits nova-core does not handle. = An + uncleared bit holds its subtree in the pending state, and restoring TOP_= EN + over it produces a delivery edge straight away. The walk writes back eve= ry bit + it read. +* Restore TOP_EN only after clearing every pending leaf. Otherwise a still= -set + bit raises the interrupt again while the walk is still running. + +The notification path clears one bit, so a vector pending alongside it in = the +same leaf keeps its bit and stays pending for whoever services it. Both pa= ths +must rearm PCI delivery for the interrupt they serviced. + +Interrupts and notifications +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D + +Two kinds of source use the tree: + +* An interrupt means a unit needs servicing. +* A notification means a unit is reporting that something happened, such a= s a log + record or completed work. + +The GSP event is a notification. Its handler leaves the subtree enabled and +clears only the GSP leaf bit. + +The hardware manuals also split the vector space into "stall" and "nonstal= l" +ranges. Those name address ranges rather than describing behavior. nova-co= re +does not service the stall range. + +Per-architecture differences +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D + +The tree is the same on every supported GPU except for its size, and there= are +only two sizes, split at Hopper: + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D= =3D =3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D +GPUs Leaves Subtrees Implemented subtrees +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D= =3D =3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D +Turing, Ampere, Ada 8 4 ``0x0f`` +Hopper and later 16 8 ``0xff`` +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D= =3D =3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D + +Only the lower eight leaves exist before Hopper, so TOP bits 4 through 31 = read +zero there. Hopper and later have 16 leaves, though sources do not populat= e all +of them. + +The implemented subtrees bound which TOP bits mean anything. That set is w= ider +than the set nova-core enables, which is the subtrees it services, per the +serviced-subtree invariant. The startup drain still reads every implemented +leaf, because a vector that latched while disabled is invisible in TOP and= can +be in any leaf. + +The HAL provides the leaf count, and the subtree count (leaves / 2) and the +implemented-subtree set derive from it. The rearm method is the HAL's other +per-architecture value. + +Multi-die parts +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +On multi-die parts the controller is replicated per die, with an aggregati= on +level above the per-die TOP registers. nova-core services the CPU tree of = one +function on a single-die part, so it does not drive the aggregation level. + +The GSP event +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +When the GSP has output for the CPU (log records, error records, and other +events), it writes the messages into the GSP-to-CPU queue in shared memory= and +raises SWGEN0, one of the software-generated interrupt outputs of the GSP +microcontroller (a "falcon" in NVIDIA hardware). SWGEN0 is routed through = a GIN +vector, so it reaches the CPU as a PCI interrupt:: + + GSP writes messages into the GSP-to-CPU queue + GSP raises SWGEN0 + GIN sets the GSP leaf bit, and the subtree becomes pending + PCI interrupt -> Linux IRQ -> nova-core top half, in IRQ context, which + must not sleep: + read the GSP leaf bit and clear it (subtree stays enabled) + read the GSP falcon IRQ status, clearing SWGEN0 if it was set + for every other cause that status reports: report it, then remove = it + from the falcon's enabled set and clear it + retrigger the falcon + rearm PCI interrupt delivery + wake the IRQ thread if SWGEN0 was set + IRQ thread, which may sleep: take the command-queue lock and drain the + GSP-to-CPU queue, routing each message + +A halt and a posted message can be pending together, so the top half handl= es +every cause the status reports rather than choosing between them (see +"Retriggering a falcon"). + +The interrupt is only the trigger to drain the queue. A thread polling for= a +command reply routes the messages it reads through the same classifier (see +"Draining and classifying the GSP-to-CPU queue"). + +If the drain fails, the queue cannot advance past the message it could not= parse, +so every later notification would repeat the same failure. The IRQ thread +disables the GSP vector before reporting the failure, which leaves the que= ue +unserviced until the device is reset. + +Enabling the GSP event +---------------------- + +SWGEN0 is a latch, and the GSP drives no new edge into the tree while it s= tays +set. GSP boot consumes its notifications by polling the queue, which leave= s the +latch set and leaves stale state in the tree, so the handoff from polling = to +interrupts has a required order:: + + disable every implemented vector drop enables left by boot or by a + driver that ran before this one + drain the tree (full walk) clear stale GIN state from boot + clear the SWGEN0 latch so the next assertion makes an edge + rearm PCI interrupt delivery the walk does not do it under + pre-Hopper MSI + register the threaded IRQ handler nothing can reach it yet + enable the GSP vector at its leaf deliveries become possible here + drain the GSP-to-CPU queue messages posted before the clear + +Clearing the latch makes the first interrupt possible. Messages the GSP po= sted +before that clear produce no interrupt, so the queue drain follows. + +The tree is quiesced before the handler is registered. Registering unmasks= the +PCI interrupt, and a leaf enable that boot left set would reach a handler = that +services one vector and has no way to service any other. Open RM clears all +leaf enables at the same point for the same reason. + +The latch is cleared after the tree walk, not before. The walk erases ever= y leaf +bit, so a message posted between an earlier clear and the walk would leave= the +latch set with nothing in the tree to show for it, and on Turing no later +message would signal the tree at all. Clearing last can instead leave the = GSP +vector pending with the latch already clear, so enabling the vector delive= rs one +interrupt whose ``IRQSTAT`` reads zero. The queue drain that follows reads= the +message. + +The GSP event vector +-------------------- + +The GSP event uses a fixed vector, ``GSP_INTR_0_VECTOR`` (155), on Turing +through Blackwell. Vector 155 is leaf 4, bit 27, subtree 2. nova-core enab= les +that leaf bit and services it, with no runtime vector discovery. + +A full unit-to-vector table can be fetched from the GSP by RPC. nova-core = does +not fetch it, because a pinned vector needs no lookup. + +Draining and classifying the GSP-to-CPU queue +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The queue carries both command replies and unsolicited events. Each messag= e is +routed by its function code and its RPC sequence number, into one of three +classes: + +* Function code and sequence both match the awaited reply. The message is + decoded and returned to the caller that sent the command. +* The function code matches but the sequence does not. This is a reply to a + command that already timed out, so it is logged at warning level and dro= pped + rather than satisfying a later command that reused the same function cod= e. +* Anything else is an unsolicited event. OS-error and robust-channel recor= ds are + logged at error level. An unrecognized function code is logged at warning + level. Other known events (GSP logs, libos prints, assertion records, + lifecycle notices) need no action and are not logged again, because the = RPC + receive trace already records their arrival. + +The read pointer advances past the message in all three cases, and also wh= en a +matched message fails to decode, so a message is never left at the queue h= ead +for the next receive to parse again. + +Corrupt framing is the exception. A message carries its length inside the +region the checksum covers, so once the framing or the checksum fails ther= e is +no trustworthy length with which to skip the message. Such a failure poiso= ns the +queue and every later receive fails, which the IRQ thread reports before +disabling the GSP vector. + +The classifier is a fixed set of function codes rather than a handler regi= stry. +The events that need action are handled directly in it. + +Both the polling path and the IRQ thread route messages through this class= ifier +under the command-queue lock. Replies and events share one queue and one s= et of +read pointers, so one lock covers the whole drain. A thread waiting for a = reply +dispatches any event it reads first and keeps waiting, under a single dead= line +for the whole wait rather than a fresh timeout after each message. + +One lock means a drain waits for an in-flight command's receive to finish = or +time out. For log and error records that delay does not matter. + +Design notes +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Register naming +--------------- + +nova-core uses the ``NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_*`` names for the C= PU +tree on both pre-Hopper and Hopper-plus parts. Any function reaches its ow= n tree +through that aperture. The Hopper-plus central aperture (``NV_GIN_CPU_INTR= _*``) +configures other functions and is not used by the CPU path. + +The controller has two names in the hardware headers and in Open RM. +``NV_CTRL`` names the tree on pre-Hopper parts, and ``NV_GIN`` names the +Hopper+ unit that contains the tree along with arbiter logic. This document +calls the controller GIN throughout, because the tree nova-core drives is = the +same on every supported part. + +Tree API +-------- + +Servicing a leaf has a required order: read its pending bits, then clear t= hem. +Reading a leaf is what produces the handle that clears it, so clearing a l= eaf +before reading it does not compile. Enabling and disabling a vector or a s= ubtree +takes no such order, so those are operations on the tree itself. + +The handle orders the calls that service one leaf. It is not a lock and it= does +not coordinate the tree as a whole. Nothing stops two walks from running a= gainst +the tree at once. nova-core does not run concurrent walks: the GSP event h= andler +touches only its own leaf and never walks the tree, and the only whole-tree +walk, the startup drain, runs once during probe. + +Threaded handler +---------------- + +The drain sleeps: it takes the command-queue mutex and walks shared memory= , so it +cannot run in hard-IRQ context. nova-core uses a threaded IRQ handler. The= top +half clears the GIN leaf, takes every cause the falcon reports, rearms del= ivery, +and wakes the IRQ thread if SWGEN0 was among them. The thread takes the lo= ck and +drains the queue. The self-test does no sleeping work and uses a non-threa= ded +handler with a completion. + +Shared BAR0 mapping +------------------- + +The GPU, the self-test, and the GSP event handler read the same BAR0 regis= ters. +nova-core keeps one BAR0 mapping and lets each of them borrow it. An inter= rupt +handler is torn down when the device unbinds, so it only runs while the ma= pping +is alive. + +Self-test +=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The self-test runs during driver probe. It registers a real interrupt hand= ler +and confirms that an interrupt injected at the GPU is delivered all the wa= y to +that handler, so it needs a working GPU and PCI interrupt path. It is gate= d by +``CONFIG_NOVA_CORE_IRQ_SELFTEST`` and runs before GSP boot, so it never to= uches +GSP interrupt state. + +The parts with no hardware dependency are covered by KUnit tests instead: = the +vector encoding, the subtree and leaf arithmetic, and the per-architecture= rearm +policy. + +The test drives ``LEAF_TRIGGER``, a hardware register that every supported= part +implements. Writing a vector number to it latches that vector exactly as i= ts +unit would, after which the vector takes the ordinary path to the CPU unde= r the +ordinary enables. + +The test drives vector 129, at leaf 4 bit 1. It registers a handler for th= at +vector and triggers it twice, waiting for the first delivery before trigge= ring +the second. Its handler deliberately mirrors the notification path: it cle= ars +only its own leaf bit and rearms PCI interrupt delivery, rather than walki= ng the +tree. + +The two interrupts cannot coalesce into one, because the second is trigger= ed +only after the first handler has finished. A handler that fails to rearm t= imes +out on the second delivery instead of passing. A single delivery serviced = by a +full tree walk cannot detect that, because the walk's own TOP_EN restore +produces an edge by itself. + +The test passes only if both deliveries arrive, each one finds the doorbel= l bit +and nothing else pending in the leaf, and the leaf is clear once the sourc= e is +stopped. Anything else fails probe. Requiring the exact mask on the second +delivery shows that the first handler's clear reached the hardware. The te= st +runs before GSP boot on a leaf the drain has just cleared, so no other vec= tor in +that leaf can be active and the exact mask costs nothing. + +The test borrows the allocation that probe made for the serviced subtrees = rather +than allocating its own, and looks up the vector for the doorbell's own su= btree. +A doorbell vector moved to a subtree nova-core does not service fails that +lookup, and with it the self-test and probe, rather than being misrouted +silently. + +The test exercises the interrupt path from the GPU to the handler without = GSP +firmware, which is useful when bringing up PCI, MSI, MSI-X, and passthrough +setups. Under MSI-X a pass also shows that the per-subtree table entry rou= ting +works, since the delivery arrives on the entry belonging to the serviced +subtree. + +Virtualization +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The per-function trees, the GFID routing, and the central ``NV_GIN`` apert= ure +support virtualization: each VF gets its own tree, and the PF or firmware = routes +a unit's interrupt to the right function. MIG (multi-instance GPU) partiti= oning +adds more structure. nova-core services the CPU tree of one function, and +implements no VF tree management, GFID routing, or MIG support. + +References +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +* nova-core source: the register definitions in ``regs.rs``, the interrupt= HAL + and tree API in the ``irq`` module, and the GSP command queue in the ``g= sp`` + module. diff --git a/Documentation/gpu/nova/index.rst b/Documentation/gpu/nova/inde= x.rst index 2afa58e8f08d..2130d1caf4c3 100644 --- a/Documentation/gpu/nova/index.rst +++ b/Documentation/gpu/nova/index.rst @@ -34,3 +34,4 @@ vGPU manager VFIO driver and the nova-drm driver. core/fwsec core/falcon core/tlv + core/interrupts --=20 2.55.0