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.201.32 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796200570; b=YDy12jEC67hGfGSNGSdxpS11Fc5z2FT+KaEgQrpCCaYleOSKUEEFcxM7o3eF89l40jj4 XzYvBDQ3CLPyClhp/dsm4M05mFUBlR0D7DgamYRbHaX+1oO2t2eImsqwgHTyYF+kvumZr ScZjoftRTT6wmExgxF+G1fCj0J/g3Kc9A4UMVz/MCXM6G5H+Y6wcPq7qPi9+1Y2J5ikha R5Mgy2EjayfR/L0+gBididlTa5cI9i86S7b80BwO3auI4Z+03d/YFnm8TmcoDn36tyeUr Gldvfd2SfS8d6G0N6Hif6Ol5Quw7MxPx43CBVl6heL3lOsa0NgidTO29bHv3iQV59QA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796200570; 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=4ilu0cx2UnJAAl76CcvbnWR7DayGMpSgmSFqEe2W7Jo=; b=IdyYXWXAok8dYUQmH6s9h2OLDxxXPuoNaAL3dDXn7J29eGekWFByogeM88AbBSR7zeyq 1SVksSXEdvAx/tEtCBOwHhRySn9vtavWP/C4Et3bj8KfWJc56Il6ar322uf1ekQ0o753/ plQcY0Nc7SZaAwhN5yUiBnaIqQXC6YRfGCpzYGWN7KXTtu7KAdzG480sg7uOs7dPZaauz x696cV7CQ7jQGs+phhQKFU2BLELOvR536LrPsuktOlzEEiPtIVEbn0se5cxYMphVFmLie dOMY/8hlh7vqJyCVPoMaT6iD2V/Eb84wHKgW+iSZPs6gvxcgRFDyUjfWGFNod9auqNg== 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=cmTcCMOp; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.201.32 Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azon11010032.outbound.protection.outlook.com [52.101.201.32]) (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 3ED39606A330 for ; Wed, 2 Dec 2026 08:36:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3ED39606A330 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=cmTcCMOp ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w24zCmi4YSjY8FQ4TdeBWK2c8zXgCUIjmnpGM5TCcTpk7fqsYzCpbzm0vI7/lgy0Y1IzGyP7h+VTN3thCLvQOyDjivqbE8YvSsod4dxpy7FGi/nf/VG1fDsqTFdifE1rBSyj2tCHQp3GPgMfLjoJzyY9NBM/ksI9+oloI3WR1McXezUQNllzuj8QxfTTH92z0KGqS5r9sY+oEK71nBbTdjAPvTQFwlpuCrZeQdlGX/xeFvptwdZlqnoG2QG+Kaa7nWQqq/xjj8teZPiqMGwGSj1K0SbDrAyLAFGA5HnZHrIosHlyBKqBg6kcbBlKtldWDBj9CL4noUGI6TwOJxz8Kg== 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=4ilu0cx2UnJAAl76CcvbnWR7DayGMpSgmSFqEe2W7Jo=; b=nArgl67qAIEeJxpGDt1cODjUnyKpQLqPVajMK0roaS4i2wkZKeRKd/LUNg+o4I0cY5hC7krEIF42lpDQ1bOcsPEASO2+oDFzY5crbbW+fPe9WGHi8wj5wyPqoDUZULTtpmfA19m0xfl3OHUlu1nlI2vgJonvVbi+1moLsIF91oaTuqt5qOV8KrNJwHqwh6eYaKVff6LDFLr76Pk86+OETR8N6Z5M6Xrge3yap9fv3l6Npj0yFl1fEGArSoZgkHUG8Gy0NQKGcgy4EF0fvkVtQSy3uXrqiT6KQiQlOf8fJAMcBpy0PpeWuTQqWQxLFSG5gQp/kGmDBUCF0BUg//X5hg== 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=4ilu0cx2UnJAAl76CcvbnWR7DayGMpSgmSFqEe2W7Jo=; b=cmTcCMOpXOj8swG6im903hCM1Sm2GNJnzlubt6TA2LwG2KJ+oNVRnSUlKeE31YPTrRxNe8jYEVUfl0isabr1EhRy7dONnu5Qr0Il8FtK4u1C7x6zYiKzfcCBXXQg83JJjV2HtKkzkJXrHZzX++vCG9+4Y2f9uL1y5vTshH5Y4MduHMl2D48iVNzh368QRtKbsPbuUvWCcvsAfKkC77Xls6QKMksYzCmw+ctXxSLt000w4t8ZxMx4WAOGxoHnKcOR+gg1WP6Y4dfdcEeGR3bLqYFdqoSh0zxI0qP6DnjJ5yWq+2Z7wQiAUtuJbf/DyrlARl0BhKAZqZUppV4yj9rbNg== Received: from SJ0PR05CA0077.namprd05.prod.outlook.com (2603:10b6:a03:332::22) by BL1PR12MB5827.namprd12.prod.outlook.com (2603:10b6:208:396::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Wed, 2 Dec 2026 08:35:59 +0000 Received: from BY1PEPF0001AE1D.namprd04.prod.outlook.com (2603:10b6:a03:332:cafe::50) by SJ0PR05CA0077.outlook.office365.com (2603:10b6:a03:332::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.4 via Frontend Transport; Wed, 2 Dec 2026 08:35:58 +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 BY1PEPF0001AE1D.mail.protection.outlook.com (10.167.242.106) 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:35:58 +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:35:46 -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:35:32 -0800 From: Alok Kumar To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 15/34] gpu: nova-core: gsp: cmdq: gmc: add types for variable-length payloads Date: Wed, 2 Dec 2026 13:58:39 +0530 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: 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-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: BY1PEPF0001AE1D:EE_|BL1PR12MB5827:EE_ X-MS-Office365-Filtering-Correlation-Id: 3fffb70a-a841-488f-c36a-08df504f49fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|1800799024|7416014|36860700016|376014|18002099003|22082099003|3023799007|56012099006|10067099003|11063799006|5023799004|261102123227099003|261028144727099003|261021123027099003|261026121527099003|261021121427099003|261022105027099003|261022075727099003|261026140227099003|261009223027099003; X-Microsoft-Antispam-Message-Info: HRpeco3F1+8YwBfrltm6i4JqrzPmvk4WfWO/kOgOFPFmDByGR/D9jMklTIVcEln+QucE9optO3917eV8OTkT5x/WVLeFasRcQ/YVrLcPqBVIyb7MAX2Hy4Qy0ULjAUzIl5qmb8bWHWc8wQTlNqNCbdXFCkMx4dLYdbvcH5Fo8KQIdTc9eDtjgAP9bqToXH4iisrkpZ/5O2aZbJWd01zCGkctJ1ZzlDE3hi7PGXSVIR30+qtz5MSFkAEjc7h7CA22BkgoejE9n58hXGkkPICsWfxyA6bTBh+a9yvmWvySldGZHilHrtYkQJXD6Qhi273YCOY9Nd7HFpbtWgtiudJdAq0g3rZLCwOGIRLhwMfB+cKDQX8L5hAPDEX8Kv0CLctFpsILiqSCXgemNV/sPocCO2pTGmLi+y6SRSPmm5Tj0Wd4hfKXZc3g2AvZjKHUKGVpKKeVQtoPVaHZwmjmCHEtjwLZyuZlVQalACORMVA09EzyvrlDyr0usFxB50YUyPxCW1wpHfK4xEBNZT8HZxy2pOSjvE0A96BBzQdqcGY0/HUgX2o9Qdc+t+XBzxD6eevDsrBSX2B4lBjhOdcFYK7MhojFSlUeKPm3w15nXlduO8e99Ue5u3d/Vj1xfwMc2LpcmUBjvOj2N3ydelGs7oti7Bz3DgbVULnA/xG1Q13oD5azwIFL/wy3zi5RCtDghjHeqsmtXMXz/QLpkUKr7M2VSw== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(23010399003)(1800799024)(7416014)(36860700016)(376014)(18002099003)(22082099003)(3023799007)(56012099006)(10067099003)(11063799006)(5023799004)(261102123227099003)(261028144727099003)(261021123027099003)(261026121527099003)(261021121427099003)(261022105027099003)(261022075727099003)(261026140227099003)(261009223027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jjbWXoGdY1jdsycMdOl6FjMoDmQkSSx1kfTkQIzimOLUIWnhcCEktlcI196tNhZ6IbZTwFjQsYfesH+FStEryW6cmOyeTySXK3iRG9OtWqX7aAr/PSbfeGaaE39dpePG71TU7WYL7Uhl5IiLP555sq3BTZMtYEaUlmERdtwgP/FnUvOWeynvy5I76+9kVluNxpVR5/kZMSVLFCokwe6WBf9e1ojowLt23X/4jtHFhBVlyBb3aLNRIypQxQkxfP/U3Og4wegqsN9j3I0YsmKlM4xEDAKbyLX7mJuEkGN823fN5hmmgDlBgk4/PhpOuUYkVg8Bftk1TbZioismfgM1b1e30m/ufG46XlzYK1a4c0v46XdtJ7A05OFpmeno354UIMcQ+EyITeZEtG7/TlJA5193+47JsbA7WECbpPRPz0ORZwmbUYncojFdN7jqncae X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 08:35:58.3455 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3fffb70a-a841-488f-c36a-08df504f49fa 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: BY1PEPF0001AE1D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5827 From: Alexandre Courbot Both the `CommandToGsp` and `MessageFromGsp` traits support a variable-length payload, described using a `SBufferIter` of two slices to represent the fact that the payload might wrap around the message queue. The type of this slice is rather convoluted, and does not convey its purpose, eventually getting in the way of writing clean implementations of the traits. Define two type aliases, `CommandPayload` and `MessagePayload` that are shorter to type and obvious as to their purpose, and use them where relevant. Signed-off-by: Alexandre Courbot Signed-off-by: Alok Kumar --- drivers/gpu/nova-core/gsp/cmdq/gmc.rs | 25 ++++++---- drivers/gpu/nova-core/gsp/commands/gmc.rs | 56 +++++++++++------------ drivers/gpu/nova-core/gsp/load_exec.rs | 9 ++-- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/nova-core/gsp/cmdq/gmc.rs b/drivers/gpu/nova-core/gsp/cmdq/gmc.rs index 9e6c9400f3aa..af99e7d8e19c 100644 --- a/drivers/gpu/nova-core/gsp/cmdq/gmc.rs +++ b/drivers/gpu/nova-core/gsp/cmdq/gmc.rs @@ -37,6 +37,18 @@ sbuffer::SBufferIter, // }; +/// Payload of a GMC command. +/// +/// Since the command queue is circular, the payload may loop onto the start of the queue. Hence it +/// is presented as a [`SBufferIter`] of potentially two elements. +pub(crate) type CommandPayload<'a> = SBufferIter>; + +/// Payload of a GMC message. +/// +/// Since the message queue is circular, the payload may loop onto the start of the queue. Hence it +/// is presented as a [`SBufferIter`] of potentially two elements. +pub(crate) type MessagePayload<'a> = SBufferIter>; + /// Trait implemented by types representing a GMC command to send to the GSP. /// /// The main purpose of this trait is to provide [`Cmdq`] with the information it needs to send @@ -94,10 +106,7 @@ fn variable_payload_len(&self) -> usize { /// unwritten space will lead to an error. /// /// Most commands don't have a variable-length payload, so this does nothing by default. - fn init_variable_payload( - &self, - _dst: &mut SBufferIter>, - ) -> Result { + fn init_variable_payload(&self, _dst: &mut CommandPayload<'_>) -> Result { Ok(()) } @@ -178,18 +187,14 @@ pub(crate) trait MessageFromGsp: Sized { type InitError; /// Method reading the reply from the payload of the message and returning it. - fn read( - payload: &mut SBufferIter>, - ) -> Result; + fn read(payload: &mut MessagePayload<'_>) -> Result; } /// Reply type for commands that the GSP answers with a status and no payload. impl MessageFromGsp for () { type InitError = Infallible; - fn read( - _payload: &mut SBufferIter>, - ) -> Result { + fn read(_payload: &mut MessagePayload<'_>) -> Result { Ok(()) } } diff --git a/drivers/gpu/nova-core/gsp/commands/gmc.rs b/drivers/gpu/nova-core/gsp/commands/gmc.rs index 14e04db90594..e1d47e86c82e 100644 --- a/drivers/gpu/nova-core/gsp/commands/gmc.rs +++ b/drivers/gpu/nova-core/gsp/commands/gmc.rs @@ -11,34 +11,33 @@ transmute::AsBytes, // }; -use crate::{ - gsp::{ - cmdq::{ - gmc::{ - CommandToGsp, - MessageFromGsp, // - }, - NoReply, // +use crate::gsp::{ + cmdq::{ + gmc::{ + CommandPayload, + CommandToGsp, + MessageFromGsp, + MessagePayload, // }, - commands::GspStaticInfo, - fw::{ - self, - commands::{ - GspInitRequest, - GspInitResponseSchema, // - }, - GmcCommandId, // - }, - nvkv::{ - Decoder, - Encodable, - Encoder, - Schema, - UnknownKeyPolicy, // + NoReply, + }, + commands::GspStaticInfo, + fw::{ + self, + commands::{ + GspInitRequest, + GspInitResponseSchema, // }, - GspBootContext, // + GmcCommandId, + }, + nvkv::{ + Decoder, + Encodable, + Encoder, + Schema, + UnknownKeyPolicy, // }, - sbuffer::SBufferIter, // + GspBootContext, }; /// The `GSP_INIT` command, which carries the system information and registry keys to GSP-RM. @@ -88,10 +87,7 @@ fn variable_payload_len(&self) -> usize { self.payload_bytes().len() } - fn init_variable_payload( - &self, - dst: &mut SBufferIter>, - ) -> Result { + fn init_variable_payload(&self, dst: &mut CommandPayload<'_>) -> Result { dst.write_all(self.payload_bytes()) } } @@ -147,7 +143,7 @@ impl MessageFromGsp for GspStaticInfo { /// 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 { + fn read(payload: &mut MessagePayload<'_>) -> Result { let bytes = payload.flush_into_kvec(GFP_KERNEL)?; let chunks = bytes.chunks_exact(size_of::()); diff --git a/drivers/gpu/nova-core/gsp/load_exec.rs b/drivers/gpu/nova-core/gsp/load_exec.rs index 6c3dcb0f80d8..e5cec38e049f 100644 --- a/drivers/gpu/nova-core/gsp/load_exec.rs +++ b/drivers/gpu/nova-core/gsp/load_exec.rs @@ -12,8 +12,6 @@ //! memory (DMEM) of a falcon, and the DMA engine that loads a binary into them. The DMA engine //! accesses the framebuffer or system memory through the FBIF (Framebuffer Interface). -use core::array; - use kernel::{ device, dma::DmaAddress, @@ -42,7 +40,8 @@ gsp::{ cmdq::gmc::{ GmcMessage, - MessageFromGsp, // + MessageFromGsp, + MessagePayload, // }, fw::GmcCommandId, GspBootContext, // @@ -384,7 +383,7 @@ struct HsBinaryParams { impl MessageFromGsp for HsBinaryParams { type InitError = Error; - fn read(payload: &mut SBufferIter>) -> Result { + fn read(payload: &mut MessagePayload<'_>) -> Result { let mut params = Self::new_zeroed(); payload.read_exact(params.as_mut_bytes())?; @@ -500,7 +499,7 @@ fn fbif_target(&self) -> Result { impl MessageFromGsp for GenericBootloaderParams { type InitError = Error; - fn read(payload: &mut SBufferIter>) -> Result { + fn read(payload: &mut MessagePayload<'_>) -> Result { let mut params = Self::new_zeroed(); payload.read_exact(params.as_mut_bytes())?;