From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.61.39 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796200447; b=PmrTMbM1Yjxl32tt+DsM08GrNtpFiQ4F4eE9O+FfCDNzD8jP3M/qc5fEa7l5B7s4wmnZ RdzItcW7VNts3cDKJAxfwmWyIhU+I6woWpltJLrri44+2oJj6I2/jh5c5SaBYegPqS10V E2nhzlFwKXvMrTMgluHFeB564oJMWMdzaWPgkRbmVOWzSKDzTrKvGSyfzVPMDy7myWYTk Bm0j6/xPeYqrf5lE5RjNzMdsqzs8NsAC1TUR8y3OO87DwAzs8xUijJhdrEk81ypUKlHwQ GhORKJfyFdjnPdxcuOk76bFIZ5Yk8JU6/80h/U7R6A3XpWyY2LcfsG14hpvRYliUOOA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796200447; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:Content-Type: X-Originating-IP:X-ClientProxiedBy:X-EOPAttributedMessage: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=VEqC0bQJ/hMUbHOpbi4PeIH6sfmFxO+Kv1BghKBRAEw=; b=ZhC6wvm98hytc/8Gnr3Hqox/iQqREiMBVD2ycp4xaTy86iOlMqCTHNhE2xdOWmIWX/6s uxZuH8jTSpkZAZt8MT25JbW+cvIRSIYDD7xU+wWjt/clHNLP+36YdoX9UQ2GpUloVOwZH 0zkqbcDWLVABGg7LVzSNyciPI6pgZpOEp15xvb1nqAHlHT+dV4PbQAM8lKApnHcWcXwrT NL+KlFqQEHI8XLEuOqDj0a1bUn7D3SCVXaKM8ssDljEKUNdvlYOakfUmgrRtOgXQmLgC0 EpTNAdDAPCvb7gn3IZiveKv8Wdjw/P3E0SGiuGi8kl4f7Ed7GI3zI3HC1hKxqi9yA+Q== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=W3TpebaC; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.61.39 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010039.outbound.protection.outlook.com [52.101.61.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B630606A322; Wed, 2 Dec 2026 08:34:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2B630606A322 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, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=W3TpebaC ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hXbZxXr+DXOnG/d5PbUHmLX/3IVLaU+8IoX7Kjv3ZSsBZicWTYTTOxN53u9j4oOJcOzGtKYOZVfvj7ZZgOLXgXTC+jFUCz+p33HhmQjT9YYqf60gSJzwppkXqNmbsFA+DMaNUyv8n40hGO2VWTJ+H7X7ZxFsZPDlT/iShiK5m847OlPZB+/np6u+BXHY/YfzhQJqlqAlyU8KC4S2zMfDxdSOnFDDCaCiGmIqZXufJo81w4xl4CnbKRQT80AeGwGz7+l6Wo3cnlj0jhcodPa4ystvsRWvXTivXxkWzM+6BqmPWVfkFNCKvLdlppDBwepkPyJ/cbJnidTSKseyGONA6w== 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=VEqC0bQJ/hMUbHOpbi4PeIH6sfmFxO+Kv1BghKBRAEw=; b=hLRS0e7XFJK5/8zt5+ALbCC+SciADLhS7O4Tj8Mmg4S8t3WrfD5/EmRj5oueOEiAlIhDIJiLPCIdsMSliBlpCGpQ+rYpPCaPjr+khu8hIB5Rqkzcu0lqxRc2pbSR1FegG5+rNjiJcUnuh9E3/QXB5VJwlSQX00FN6adoUQZ0/HX0E8eYgORVbPFKn1mWNPwF1YN/corJYS9Rym0lPiamkhrFqESZWL5LM6LiPa9ZKy2TuQTBnuWRvcueZvwKrQmxX8A4VJi9yfSEKjUcxPF/PxheOuNFRi/o5vc6S/oNju7APzvVwr89iGymqSJuRsYkgeFWweb1YbYlqKEegsxS4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VEqC0bQJ/hMUbHOpbi4PeIH6sfmFxO+Kv1BghKBRAEw=; b=W3TpebaCUdPt8wdkEDcYPtWrogmpDI9u+UfU2F/uFBOfEAZtr/42Z3ezSfj7wWhiE4yJ+E0yeobuL9JN16mdiBsHMKN180/kQmPZ2Wu68aVy3jwv+dr/OdZoOixK+tb8BxmDbipqZehv1uGHixJJLnshi3qE79KpnthNqT0OnZ01XWi5EamSX8qSjRuF9ryajoUgjtXsDc7enl3b9KbtOVJrjfz1XyEpCuQO8jP/mjh9jvtPFBLWJcBUkRZLlzVGvLpQu9vj3Tk3dBqCJrAIgA8xFu6t/B2+wB1lCsDd2y/E41miYb0UzJWq36E8jqpq14yha/WAKc67nOTe0alaTw== Received: from BN9PR03CA0879.namprd03.prod.outlook.com (2603:10b6:408:13c::14) by SA3PR12MB7901.namprd12.prod.outlook.com (2603:10b6:806:306::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Wed, 2 Dec 2026 08:33:45 +0000 Received: from BN2PEPF0000A98D.namprd04.prod.outlook.com (2603:10b6:408:13c:cafe::52) by BN9PR03CA0879.outlook.office365.com (2603:10b6:408:13c::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.13 via Frontend Transport; Wed, 2 Dec 2026 08:33:43 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN2PEPF0000A98D.mail.protection.outlook.com (10.167.248.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Wed, 2 Dec 2026 08:33:43 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 00:33:26 -0800 Received: from kalok-SPC741D16QM3.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 00:33:12 -0800 From: Alok Kumar To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 05/34] gpu: nova-core: gsp: decode the FIFO engine table Date: Wed, 2 Dec 2026 13:58:29 +0530 Message-ID: <9a5586440943cfea24d87f251c1990515ffc1703.1796191007.git.alkumar@nvidia.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000A98D:EE_|SA3PR12MB7901:EE_ X-MS-Office365-Filtering-Correlation-Id: 15b2767b-d20f-4731-4686-08df504ef9e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|23010399003|36860700016|82310400026|376014|7416014|10067099003|56012099006|261026140227099003|261022105027099003|261028144727099003|261021135927099003|261021121427099003|261022075727099003|261021123027099003|261102123227099003|261009223027099003|22082099003|6133799003|18002099003|11063799006|3023799007; X-Microsoft-Antispam-Message-Info: xxpcDBQUTFmLg3k/i+izfmkMfOjPwB43ViIk94XCmwgGNYLznpolCkXspAc0BDf9ANEwi+dtE6au/n7xA6s2ON9UQYh8DUXmspi6jSx4OS84tOb1L7uSTN5tD0S/cAa2PU53YUUabB5RW08SzPr8aGvPxpYBncIbOd+Ya9UdsA4RcwjuYU7L0da4knqML+WV/fMYaadfceuL733/kAfp5amG3EUZa+zghcOiHioaK1K5nk+YnMAxTI2rw8iubTBtVP8nLWDZ43zdp9lFP/wuclnRVTUiajFSkCLG9Y/bq95x6RqGdzgmupDbHKFZbr46P31fZ/SgCeRs6XA7DC4MSJdTNOU5iw+iHFJ1iI4UF4jNgwwtGSEUb36RE/y9CC+hd5Ognp66V69679Vt7HM/PFeseILLjwbq973ZwHvfxpS4hrYzCdoxg1sH0MhYqPA8atoKC40r2obLMvmNIRC7Ye54EFOSSbKN3BHLIxTC2mYYLSPspBxD0AVnmfBbHkulLeExRHJQwXZBnpBYiRfExuG8u+3QmSgzxAkozMDGjRvmYl5UqjS0BOhLXg6oTFJPnsU/PAugt0FmuCo4OJA5C/0QGMANjKZOj2U3ijTA3DV2CIPW6FDnwmDrx2aFUzGU2bxnYq5s+RHctNoKdnfiEXxy6G68n0yzZfJbKmhca5Hw6jCanQaJRjTPUzOX9tQ2iIXm4ZhfYhZGNsajvpJCgw== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(23010399003)(36860700016)(82310400026)(376014)(7416014)(10067099003)(56012099006)(261026140227099003)(261022105027099003)(261028144727099003)(261021135927099003)(261021121427099003)(261022075727099003)(261021123027099003)(261102123227099003)(261009223027099003)(22082099003)(6133799003)(18002099003)(11063799006)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4HtaQ7dEAc+QLnn2iTRVlYW1k4wGyakHhvLP/mn/YYDoEb9vMqCS9wDQrk5Evp49HFcT287iRvvBlwn/uUuGMdFuBGUEO7pOojGrzTij4mn1uvSFv9L4vqDW3dtIUq0lsYETYtNwCxiAvo61Ce+9dv9qSufRFmceJ0FsRRoJvfgD2hnBd5XBBcb3J3u8lyg3mU42chCI4bKhiYaPvs5wbVC6DXh7Rjmmwr0tk65+HclHeJWS6fZeOXKnvcAo4udJTNnO6Hb4gIszoJhEtWaUb9jzI3X3UZGS+prSVBTQNSjyK+CpqjhmzIDov0vqdnyqTu9nVn2Osq+2+v4Hpc8v1zw3m6FKaoG1OSkC3MY9rmR+l+DV/1gUBGV1CP4yU5Q5Qfip9SPar5L2GuKLT7WC28KnTNjP7C8GFQq+HWDTv5j6sM9HYy4UlRRwF6olcq+Z X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 08:33:43.8497 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15b2767b-d20f-4731-4686-08df504ef9e1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF0000A98D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7901 GSP_INIT reports the FIFO engine topology used to build the channel map for vGPU instances. Decode the count, GMC IDs and flags into GspStaticInfo and expose host-driven engines in firmware FIFO order, retaining repeated IDs. Reject counts and indexed entries beyond the driver's 64-entry table capacity rather than silently accepting a prefix. An omitted count remains zero. Cc: Alexandre Courbot Co-developed-by: Zhi Wang Signed-off-by: Zhi Wang Signed-off-by: Alok Kumar --- drivers/gpu/nova-core/gsp/commands.rs | 10 +++ drivers/gpu/nova-core/gsp/commands/gmc.rs | 4 +- drivers/gpu/nova-core/gsp/fw/commands.rs | 77 +++++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/gsp/commands.rs index 985cfc2a958e..8a2fcae05989 100644 --- a/drivers/gpu/nova-core/gsp/commands.rs +++ b/drivers/gpu/nova-core/gsp/commands.rs @@ -11,6 +11,8 @@ use kernel::prelude::*; +use super::fw::commands::FifoEngineList; + /// The static GPU configuration, which GSP-RM reports in reply to [`GspInit`](gmc::GspInit). pub struct GspStaticInfo { gpu_name: [u8; Self::MAX_GPU_NAME_LEN], @@ -23,6 +25,8 @@ pub struct GspStaticInfo { pub(crate) usable_fb_regions: KVec>, /// Exclusive end of the FB physical address space. pub(crate) total_fb_end: u64, + /// Host-driven engines in firmware FIFO order. + fifo_engine_list: FifoEngineList, } /// Error type for [`GspStaticInfo::gpu_name`]. @@ -63,6 +67,12 @@ pub fn gpu_short_name(&self) -> Result<&str, GpuNameError> { .map_err(GpuNameError::InvalidUtf8) } + /// Returns the host-driven engines in their firmware FIFO order. + #[expect(dead_code)] + pub(crate) fn fifo_engine_list(&self) -> FifoEngineList { + self.fifo_engine_list + } + /// Returns the total usable VRAM size in bytes, i.e. the summed lengths of all usable FB /// regions. pub fn vram_size(&self) -> u64 { diff --git a/drivers/gpu/nova-core/gsp/commands/gmc.rs b/drivers/gpu/nova-core/gsp/commands/gmc.rs index 27bd67fbe93e..4f813a780d1b 100644 --- a/drivers/gpu/nova-core/gsp/commands/gmc.rs +++ b/drivers/gpu/nova-core/gsp/commands/gmc.rs @@ -144,7 +144,8 @@ impl MessageFromGsp for GspStaticInfo { /// # Errors /// /// - `EINVAL` if the payload is not a whole number of NVKV words, if the stream is malformed - /// or omits a required key, or if GSP-RM reported no framebuffer region. + /// or omits a required key, if GSP-RM reported no framebuffer region, or if the FIFO engine + /// count or indexed entries exceed the supported table capacity. /// - `ENOMEM` if the words or the decoded regions cannot be allocated. fn read(payload: &mut SBufferIter>) -> Result { let bytes = payload.flush_into_kvec(GFP_KERNEL)?; @@ -183,6 +184,7 @@ fn read(payload: &mut SBufferIter>) -> Result) -> Result { // Decode: +const MAX_FIFO_ENGINES: usize = 256; + +/// Bit mask for `NVGMC_SC_ENGINE_FLAGS_IS_HOST_DRIVEN`. +const ENGINE_FLAGS_IS_HOST_DRIVEN: u32 = 1 << 0; + +/// Host-driven GMC engine IDs in hardware FIFO order, including any repeated IDs. +/// +/// # Invariants +/// +/// `count` is at most [`MAX_FIFO_ENGINES`]. The first `count` slots are the retained engine IDs. +#[derive(Copy, Clone)] +pub(crate) struct FifoEngineList { + gmc_ids: [u32; MAX_FIFO_ENGINES], + count: usize, +} + +impl FifoEngineList { + #[expect(dead_code)] + pub(crate) fn gmc_ids(&self) -> &[u32] { + // PANIC: The type invariant bounds `count` by the array capacity. + &self.gmc_ids[..self.count] + } +} + +/// A FIFO engine count that fits the supported tables. +/// +/// # Invariants +/// +/// The count is at most [`MAX_FIFO_ENGINES`]. +#[derive(Default)] +struct FifoEngineCount(usize); + +impl TryFrom> for FifoEngineCount { + type Error = Error; + + fn try_from(value: DecoderValue<'_>) -> Result { + let count = crate::num::u32_as_usize(u32::try_from(value)?); + if count > MAX_FIFO_ENGINES { + Err(EINVAL) + } else { + // INVARIANT: The count was checked against the table capacity above. + Ok(Self(count)) + } + } +} + // Should decode with UnknownKeyPolicy::Ignore. nvkv_decode! { /// Schema for the `GSP_INIT` response. @@ -332,6 +380,9 @@ pub(crate) struct GspInitResponseSchema => GspInitResponse { fb_regions: Accumulated, bar1_pde_base: Required>, vmmu_segment_size: Key, + fifo_engine_count: Key, + fifo_engine_gmc_ids: Indexed, + fifo_engine_flags: Indexed, } } @@ -343,6 +394,9 @@ pub(crate) struct GspInitResponse { fb_regions: KVVec, bar1_pde_base: u64, vmmu_segment_size: u64, + fifo_engine_count: FifoEngineCount, + fifo_engine_gmc_ids: [u32; MAX_FIFO_ENGINES], + fifo_engine_flags: [u32; MAX_FIFO_ENGINES], } impl GspInitResponse { @@ -396,6 +450,29 @@ pub(crate) fn total_fb_end(&self) -> Option { .checked_add(1) } + /// Returns the host-driven engines in their firmware FIFO order. + pub(crate) fn fifo_engine_list(&self) -> FifoEngineList { + // INVARIANT: The list starts empty and appends at most one ID per supported input slot. + let mut fifo_engine_list = FifoEngineList { + gmc_ids: [0; MAX_FIFO_ENGINES], + count: 0, + }; + for (&gmc_id, &flags) in self + .fifo_engine_gmc_ids + .iter() + .zip(&self.fifo_engine_flags) + .take(self.fifo_engine_count.0) + { + if flags & ENGINE_FLAGS_IS_HOST_DRIVEN != 0 { + // PANIC: At most one slot is filled per input, and the input has at most + // MAX_FIFO_ENGINES entries, so the next retained ID always fits. + fifo_engine_list.gmc_ids[fifo_engine_list.count] = gmc_id; + fifo_engine_list.count += 1; + } + } + fifo_engine_list + } + /// Returns the BAR1 page directory entry base address. pub(crate) fn bar1_pde_base(&self) -> u64 { self.bar1_pde_base