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=40.93.194.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796402790; b=b7JYXU7tLr76tFYee11Q15l03TQr76Oi3X0aVJv3Z1/3+T6UCr3oBZrfD6YgwNKTaGEV 7wm9dS6s1yGMrVmg7U9uXo2mdhzuyHGs1cDAe3ZeoEUuItQTvTrFY+ZGeZ6YicZRcp7Op 2rFdqjgB8bHJ0XxLTWOw6zRIZjYX6LOMY+x+KFgbaQUHpHrtHaOCL0YF2wcBtyJeNbnS5 9kOO3/Dc8EPtUdgpMm/6qg47DY1IBxYJrQBhOPeFl2wRJ+VTsh1MDdMcNd8FE3EH2DdzZ C9RnWQXsR9xeNeZf7Ro8KxUwzADVibqLielPtmVk8ExSGnGPvkhh39WJOM6cxiaEuEg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796402790; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:Received:Date:From:To:CC:Subject:Message-ID:In-Reply-To: References:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding:X-NV-OnPremToCloud: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=IT6V7j4eQfiUQs5ltl+EdoISwg3XkscHoL4IA+/pVo8=; b=RkpRNYOgX/BZBDjx9kG0Ww6TntPG47L0VJXuOTJ2Z/qgCphhrs0AP8ZDEcFjIIsNgQyz s8PtN0ADnmCTYbdGUqJBGF5j0giAaVKvYKfs3paBmPOQcmgz7BZEPKwBgYUzOU6BT4iQl BnaZ4eHlYKtFCJB+WBpjd6+puWe/UNDRTXfuweyHgdHbPEQruynb2T+/5Vmnd63S1/iHI Iu75jf1oQw/3lHtC8gRsqdLkylLXCnL4kpIEQKTkcUieHwEo8ngAlrm+/IyVSrBoD/44C z8dwOW1lkI5qI5x/n3cty45hTTagv+94TgAW/9G+2ArkF5sTJaPZe8oYg6tNRSI4psg== 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=sTc4VT0S; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.194.1 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011001.outbound.protection.outlook.com [40.93.194.1]) (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 F1669606A334 for ; Fri, 4 Dec 2026 16:46:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F1669606A334 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=sTc4VT0S ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XXgjB0t9/vyi+xPrUs3/DXhaBLx9BgpYc1udjJxercmvv/CSULhPJa4YsW8iHFjrYozGWfGwepGIti9cSeyF6EBF1DTKs8HG2fz7hAixwK+93HD5/vB8EjJx5c3sOCMY9Ifb7FRENLBVwsIj7bACkiYt7DlH5dPf/0ylxBEgeuTSTcsHZrEHOHuvUVSt3W/W89pxo9BODx0vodSfmB2mTm8/dOVzhE8IfV9lrS+0aXhc6a5RjezvhMVJSGhJ0aFkxvpgYJY+R8ByXggCBDzgm6uTVf5BGQTqJCjgvhNizmKETXnWhFDsntswhEAClTHmZ+l28PgdppxkoYEco21KDw== 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=IT6V7j4eQfiUQs5ltl+EdoISwg3XkscHoL4IA+/pVo8=; b=iXTmgslYwI33S9nupHv1mw+XhK3QvBd+aXKTYA5dDjzuUWpvumWkiDyl3ph0t7tztVQ3rDLFQ4dCBoH/m56xaOVnS/2tUpW9unR2e4f74139IPijOjwEJHEIIYm2eXq6EqgUr0Le2v2UDi93f49rxnS2kT4BRhP9Yoe7d2myghGEO8DFpYLFNNHTuQb69MkqvmWOQd8P3tTJOIoMW12ygvknCk0BK7kpqC1EV+No9YFbLvsHBtgrKYfaVZKE0cxzfHTli8BlUu3CX7PG8WsUqxFupfIorvDFqaWBSvpUzPp+T3vZ1mj5oOu7U+/tm+6q59e5F1AdAeLb9UDwiHmhDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=posteo.de 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=IT6V7j4eQfiUQs5ltl+EdoISwg3XkscHoL4IA+/pVo8=; b=sTc4VT0SfOaeH0z6mGPMFBJq1UL0usZA6do+oPxL6n1jkWUNz8XDIq4kKFldTXXv6dDNvkdQ0fF7gv5BI/AqpXh/k1ch3MldPd+eW7+dZzTwC1jzMDRT4ELZ0q3lx1w4YQP+wU82smGGDdGakyzOFfZdTZZrFtp3IyRwPUArRXBTp4d+ZOTmqfTKXhIVx08fSrLTrVig+Ypi3+9LwUsadkmuHHpHrBvPfQGJ3IpJwn/GjDtyy8v5T6M4mzE+cahFhEzGvZWGtizTOULNn2VCUj6fb8zxnnBK0LJxzeTOxZSaYDA0srzzFVE2Nc3RxpQD7jRKQUI6o5bRmVKNifLjgA== Received: from CH0PR03CA0287.namprd03.prod.outlook.com (2603:10b6:610:e6::22) by CYYPR12MB8655.namprd12.prod.outlook.com (2603:10b6:930:c4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.12; Fri, 4 Dec 2026 16:46:21 +0000 Received: from DM3PEPF000265BE.namprd04.prod.outlook.com (2603:10b6:610:e6:cafe::a3) by CH0PR03CA0287.outlook.office365.com (2603:10b6:610:e6::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.13 via Frontend Transport; Fri, 4 Dec 2026 16:46:21 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM3PEPF000265BE.mail.protection.outlook.com (10.167.23.251) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.709.6 via Frontend Transport; Fri, 4 Dec 2026 16:46:19 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Fri, 4 Dec 2026 08:45:56 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Fri, 4 Dec 2026 08:45:55 -0800 Received: from inno-dell (10.127.8.12) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Fri, 4 Dec 2026 08:45:43 -0800 Date: Fri, 4 Dec 2026 18:45:34 +0200 From: Zhi Wang To: Simon Song CC: Alok Kumar , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v6 05/34] gpu: nova-core: gsp: decode the FIFO engine table Message-ID: <20261204184526.1ffb8210@inno-dell> In-Reply-To: References: <9a5586440943cfea24d87f251c1990515ffc1703.1796191007.git.alkumar@nvidia.com> X-Mailer: Claws Mail 4.3.1 (GTK 3.24.52; x86_64-pc-linux-gnu) X-Mailing-List: nova-gpu@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PEPF000265BE:EE_|CYYPR12MB8655:EE_ X-MS-Office365-Filtering-Correlation-Id: 969eec02-e710-46bb-53f0-08df52261f58 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|36860700016|23010399003|1800799024|4143699003|11063799006|261009223027099003|3023799007|22082099003|18002099003|56012099006|261026121527099003|261102123227099003|261022105027099003|261028144727099003|261026140227099003|261021121427099003|10067099003|261021135927099003; X-Microsoft-Antispam-Message-Info: a+wUH+K8+KQLml0mt8KMm7mImySPu7gPfG2KNRlz/289NmNH6HRnfn2UNhEEY91+BcWYYxfhfXwFgcG0DxwWheEBIP3qipWJO6PR4wwAWZy2rHzrHzcUo4R6ahzUbLv/3f3A0oSn/lTjsmK1EuwPdLNQGev0c7btzamq0N9D8Hzc9sEltbSWROJAfLcEbXohFkHVsTMpmG66tmuqEqjH5EysDKlu7K/AVyXvn7kXkENemBaG7WnPbS3ngeT6y2zELqZlbpDVY64bHL6CFUT3uH41CrmCNXY7S0iCeuAdQeIZtNVRYrh2vcVKlru3ypM4EXOkoTrswTww8juscHtwzqe1ZKAvn0UV5D4IOcwfSD9tsinAjaqXV3OCEu/5D5kEsUSncS6eLwCkMNmVFVcxPeDcLPCYGzjBAH1m83q17itMuHlE+eou8C5eeN9Diwcq6PaND1l2jCeKLGjEH5yAm5OVF94hIjUJPNmcB5oii3ywKVEylvCU7ZKSLVvgfh+FklyGGGELxuKtsfBeuy8HeGVTI+Qs9jAniRt7ZGHvuVL4JMjCwwf4/cWqHaXmaMXhACXitPnVpp++4Fu/EDZxLgBgxxoEzCwXJBYcNCqapyqgf+uhCl4ZOt1W85UKxRmoVNvwZdB7TabrKtsESzBcTXlbR372tfe/T5MaR+SmCnjdWoSUt02CIGJdWzZOhZvzrJqXZV9q4YBwKWzRtGRdkA== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(376014)(36860700016)(23010399003)(1800799024)(4143699003)(11063799006)(261009223027099003)(3023799007)(22082099003)(18002099003)(56012099006)(261026121527099003)(261102123227099003)(261022105027099003)(261028144727099003)(261026140227099003)(261021121427099003)(10067099003)(261021135927099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NTDplJropiAqw6XwYYSOA3FuzX9yAV0WJrcsaeFlscAyYSqm9Eixs7H7yuPCAdLu+Rtf33Y8AylUDXXVGgdYW7rkoqMrrBXWIBuI3tDtJkxG8v2e+AYkMJqSaecUfBM4QPw1F0j5WKcggvqsWsV2WKeXK6yraZ+zURYtJIFs1w1xKBqt4EuVU10SicE+Jyw5jHgBt/UEsvlNVVUnXJvxWFGrE4m/VIOGHkVWD4MW2tWkk0DzT9u0NrGgb9O5OSaNSt0vbEAfACJHEyL87lvF6SA0FiEEur8xvNLP1EROfXdAy7XD6TKoxrAnziYAMKk/JwYGfXZ0dCuBdZi2yK4XJCfeRLXmY6fbGVjTJ8GG2SJMAsM3eFCrAiKuwuiYb+KGBcxyjQTAu88pf22S5JOpVn69wqTC4L9Tb1E/JQ5TWHvWkfOsdK4cAfg2TwltTsvx X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 16:46:19.6975 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 969eec02-e710-46bb-53f0-08df52261f58 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM3PEPF000265BE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8655 On Fri, 4 Dec 2026 11:32:41 -0500 Simon Song wrote: > On 12/2/2026 3:28 AM, Alok Kumar wrote: > [...] > > // 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, > > +} > > with MAX_FIFO_ENGINES increased to 256, and FifoEngineList > implemented with Copy, it could overflow the stack, could we consider > moving this to heap, similar to what's done in openRM? > We can also latch this const from the bindings if there is one, suppose this value ties to the return of a specific version of GSP-RM. > something like this: > > --- a/drivers/gpu/nova-core/gsp/fw/commands.rs > +++ b/drivers/gpu/nova-core/gsp/fw/commands.rs > @@ -331,19 +331,21 @@ > /// 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)] > +/// The IDs are kept on the heap, so that the list can be moved > without copying them. pub(crate) struct FifoEngineList { > - gmc_ids: [u32; MAX_FIFO_ENGINES], > - count: usize, > + gmc_ids: KVec, > } > > impl FifoEngineList { > pub(crate) fn gmc_ids(&self) -> &[u32] { > - // PANIC: The type invariant bounds `count` by the array > capacity. > - &self.gmc_ids[..self.count] > + &self.gmc_ids > + } > + > + /// Returns a copy of the list. > + pub(crate) fn try_clone(&self) -> Result { > + let mut gmc_ids = KVec::with_capacity(self.gmc_ids.len(), > GFP_KERNEL)?; > + gmc_ids.extend_from_slice(&self.gmc_ids, GFP_KERNEL)?; > + Ok(Self { gmc_ids }) > } > } > @@ -450,12 +452,8 @@ > /// 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, > - }; > + pub(crate) fn fifo_engine_list(&self) -> Result { > + let mut gmc_ids = KVec::new(); > for (&gmc_id, &flags) in self > .fifo_engine_gmc_ids > .iter() > @@ -463,13 +461,10 @@ > 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; > + gmc_ids.push(gmc_id, GFP_KERNEL)?; > } > } > - fifo_engine_list > + Ok(FifoEngineList { gmc_ids }) > } > > --- a/drivers/gpu/nova-core/gsp/commands.rs > +++ b/drivers/gpu/nova-core/gsp/commands.rs > @@ -70,8 +70,8 @@ > /// Returns the host-driven engines in their firmware FIFO order. > - pub(crate) fn fifo_engine_list(&self) -> FifoEngineList { > - self.fifo_engine_list > + pub(crate) fn fifo_engine_list(&self) -> &FifoEngineList { > + &self.fifo_engine_list > } > > --- a/drivers/gpu/nova-core/gsp/commands/gmc.rs > +++ b/drivers/gpu/nova-core/gsp/commands/gmc.rs > @@ -172,7 +172,7 @@ > - fifo_engine_list: reply.fifo_engine_list(), > + fifo_engine_list: reply.fifo_engine_list()?, > > --- a/drivers/gpu/nova-core/vgpu.rs > +++ b/drivers/gpu/nova-core/vgpu.rs > @@ -164,10 +164,10 @@ > - ) -> impl PinInit + use<'gpu> { > - let fifo_engine_list = info.fifo_engine_list(); > + ) -> Result + use<'gpu>> { > + let fifo_engine_list = info.fifo_engine_list().try_clone()?; > let vmmu_segment_size = info.vmmu_segment_size; > - pin_init!(Self { > + Ok(pin_init!(Self { > @@ -180,7 +180,7 @@ > fifo_engine_list, > }), > - }) > + })) > > --- a/drivers/gpu/nova-core/gpu.rs > +++ b/drivers/gpu/nova-core/gpu.rs > @@ -634,7 +634,7 @@ > &gsp_resources.boot_result.static_info, > TOTAL_CHANNELS, > - ), > + )?, > GFP_KERNEL, >