From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010014.outbound.protection.outlook.com [40.93.198.14]) (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 0A254364933; Mon, 14 Sep 2026 04:46:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.198.14 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789361173; cv=fail; b=NXu7lloOKgsHNt6wslCd/3oPNYQi6JAoPd5yOdK13vArMKoANkqtuYyzl5tfNe5ipN4CZ5TAfwZDxsrf9Ssd3ybl1JrtnUKspnhVWoFMCU+/IKlneJnkJ6N026CBITrM90e1sVgRGToPZ3RQAzZaZAqC3WUbzJJ57Dw8ZqnfW7M= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789361173; c=relaxed/simple; bh=K/zcjBo/gpG/L5hy2zWvH4rZJZ2BdHBEdIn7vPfEu14=; h=Content-Type:Date:Message-Id:Subject:From:To:Cc:References: In-Reply-To:MIME-Version; b=AuUgrknRZJJcz3Ivwbc1Shl5ueMLHsjAOSUifUv/Lk9gUpvLVWiJ2X+5vJmkgn/h9ozcHCSdwhdTgqjcQNwwsaDh7S/5veKLRuO756QEzgzYJUxWIAokG3HV6cqTs/uf0h6rlwtu1XnXnB8DKbv77ANpjYUdCVIVvF49dDQEtcU= 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=G2+y4zUW; arc=fail smtp.client-ip=40.93.198.14 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="G2+y4zUW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PJKEf4F39jOyAoPqS6dBH8TCicngwQ4CYLsvPlPvW4BxgcplwZG3xl2HeONtAn87JbB6DMJtfMRK0yM3AJjuP1qBxkWskWgDPRZcyFAO/gugHI4LhMy0ukw/UdYWpnPNBPkk3r1/lBEIBsgPhBNVINp57bmB9shb1jOCfN+NzastZdc6cSr3XQvMa8F1TX3Lt6nB6xxpSH79i8lda/CSdXcjOzzeOH/Z4uDE+fP/kb+pIDvoes4bzC3i0eSXGbDC58o7dE7d9M2bq6StR9hoRvbVG9C2kS0PuFQaANXt9+Xn1bYePj7S5KLzPIVUuJYeO+DY9pSRGFY1H2vYjfNv4g== 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=2eugNITPidWpAfsGfYfXuThkbUk9pbfgbV57TTR0INs=; b=bLrZiuQ6c26e31ccn/B0Lnn4hu/pWJrlsaZQOUYVk98KZGb1cUHLWB1u6xA4TZa6ZKX2RGXzt6eiQlNklXLCQm6oO1NKbgwMJNrECx2/WgIyp7FNphLbtY09gUyDXcS0ey0BToRUtu1rSjo6JKn3I9axnVEJgRKYjzsRCm/wRoTpPgWSWkwMSztLTntMQWjvd0/dPqmvaik12Hjo4RvRZbreDK0Ek0cmbiBHNayQNpe/qNOn5N8E1RPmGElqzNjJgOWsVriiKy1bM722HHr1lEhHupzT9oDQEmFkulzpOfR6+PcT4dh77B9FoIBr7TDpSILvwoIsDRxWSZaNY6pHXA== 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=2eugNITPidWpAfsGfYfXuThkbUk9pbfgbV57TTR0INs=; b=G2+y4zUWNLiIIKUsqW2I1cFBwW7TNg6yZN6bFxBc43lvxpGnNpUSEu/iKverxm4BZ0X9eQogqa67IETGRW6bd9FW+nZ5o3959M2xC/sBrhjysMbW+Z3//h4LioRQ0i/L4/7TAjDwSf+UfV6P8ZrE93GNRkINuVveWQY7aub3VnmSaH7jMiq5NsROBZ9/d5grtz3Wrmnb93e7S/H0kwMZomGjSal1qz1MWP9YS4c22O3zGhJFr8SlR5aIDxuR15EJEx7FObpv+XllTbwrmXI31dSVdJaLUMPANzYh+mJk5ynFJZ6qsLN4zXQnrMCloZAcqz68NaOs7bhscKbYYQx6rw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB6413.namprd12.prod.outlook.com (2603:10b6:8:ce::10) by DM6PR12MB4124.namprd12.prod.outlook.com (2603:10b6:5:221::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Mon, 14 Sep 2026 04:46:06 +0000 Received: from DS0PR12MB6413.namprd12.prod.outlook.com ([fe80::e82a:6673:4142:37fa]) by DS0PR12MB6413.namprd12.prod.outlook.com ([fe80::e82a:6673:4142:37fa%5]) with mapi id 15.21.0406.007; Mon, 14 Sep 2026 04:46:06 +0000 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 14 Sep 2026 13:46:02 +0900 Message-Id: Subject: Re: [PATCH v2 6/8] gpu: nova-core: add NVKV typed encoding From: "Eliot Courtney" To: "Alexandre Courbot" , "Eliot Courtney" Cc: "Danilo Krummrich" , "Lorenzo Stoakes" , "Vlastimil Babka" , "Liam R. Howlett" , "Uladzislau Rezki" , "Miguel Ojeda" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Daniel Almeida" , "Tamir Duberstein" , =?utf-8?q?Onur_=C3=96zkan?= , "David Airlie" , "Simona Vetter" , "John Hubbard" , "Alistair Popple" , "Timur Tabi" , , , , , "dri-devel" X-Mailer: aerc 0.22.0-0-gc2f86b7abde3 References: <20260827-b4-nvkv-v2-0-0de9d5c8658c@nvidia.com> <20260827-b4-nvkv-v2-6-0de9d5c8658c@nvidia.com> In-Reply-To: X-ClientProxiedBy: TYWPR01CA0029.jpnprd01.prod.outlook.com (2603:1096:400:aa::16) To DS0PR12MB6413.namprd12.prod.outlook.com (2603:10b6:8:ce::10) 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: DS0PR12MB6413:EE_|DM6PR12MB4124:EE_ X-MS-Office365-Filtering-Correlation-Id: e168603a-8075-43f4-9944-08df121b1658 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|366016|10070799003|23010399003|22082099003|18002099003|3023799007|11063799006|4143699003|5023799004|10067099003|56012099006; X-Microsoft-Antispam-Message-Info: uO8qA4nCrr/M1GbzLbuZd8HvG7+nA5sQHivAjVBXrlRcFvM0Y4gQ2sSfb57on6fMRSdPwpxMe8Ls45WC1APM8AiTbLjsr0p5Dssd5ch5fw3N3q8jaTawThwE559CzuOP4GKZQPNiFQvOxwjsd5/ulhdyCNx87MtT+LdlugVSTc7oC5DKzSh/BF1BwJL7BEmeG9m0Pu0PGBYtVj2GicTSar6qoIJkGlOvheni/l/DT/M0yeJvVJlFXln9Q6SWhK+ExNkBdURpB01Z9ixS2fdZ8NfvwcjAqzP0baJ1OHWuQ7HDpncABgNGAZYoNuqH5JdyS4bHeT80Ke7wpJZGv3/6qrhXva/ACVU0gM7X0BtNQT7FbKfilVGTok2PZ5ubahhwVLNwA4MLXJ36V4aDAYGLZOqSyPJiCnE2iz4RkStmi6jYMg+EYyWc3cDoM6yd2jJn9Mxt5HHlwJ8pCnOCIpwGA3m1HyddzFfVW7MPmrJVbcgrIQRJ6IC+X2qMv4y2cWZgSCRRcJHZbllQhJuLLucFAtWdjb/0rs18gBMOmiz11qoPBpdz3XMvAgNBiXkzuBfSC5Qquhrq38PZSehdUPjmaMK2sqCn8gh2uqPy4dKzD8cR7MdPIkukJObtEFnbKaEeLtfwgb/WhHeLUhPbnB4ZnuCe+v9pis04a/19Vm3++IM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB6413.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(366016)(10070799003)(23010399003)(22082099003)(18002099003)(3023799007)(11063799006)(4143699003)(5023799004)(10067099003)(56012099006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?K2lUOGp3THRlUVJaTjgzS3JqY0ZubnZSa1RWWWFuUW1UNUNVejZpdTJ4R2tR?= =?utf-8?B?bDRKK3ZFalMzaUpPMm9lb0xVWkVxVjJhYXY3TitoekRJakpZMWE5VHlDaW9S?= =?utf-8?B?bmNzNkNPQWNQZ3hVTE5qNkRvUXB1ZlgxYVRtZDJ3cGVXRGZoQUhzekVnMzZs?= =?utf-8?B?UXJUSGdVZjVKakxHQno5ZFRPZjE0Y2tYRzU5USsvSEo5dEhYZVNLSmpQS2ll?= =?utf-8?B?OWNvQnUxb0pJ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jNxZUFu?= =?utf-8?B?Z2hRaUxpV0FlNk4xTk9sMmVxNXk4UmlEYy9CLzErOEFwR0hCL2g5WXRnSGpR?= =?utf-8?B?VFRLS0U4ZlFPR0FTa3VDT1R6MTJoczd1aExPWW1vQ1BQZjBRTGtyQStEWXo2?= =?utf-8?B?ZEFqUDdPTmZyQ2t0UzZoZk9Ndi8xYU1jRWZqRG9xclZrREYrVDNjS1U0L1Ri?= =?utf-8?B?dFJVWlhBOWhickJFdjRMUENQYVRlZ25HbGhNdFZLVmpQTnJXMVg5aDRtNEZz?= =?utf-8?B?UXFsY3YyYk45RjJNbytQNFpjYlBhazlFdGFpbVE1UFk1ZHQzZjJSbm45TlpF?= =?utf-8?Q?abCGkGq8v8K/iGeSLcyWDpD+d4v8PzFG18q8rdUk11DfJ?= X-MS-Exchange-AntiSpam-MessageData-1: 9yBg4nUs9c3d2w== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e168603a-8075-43f4-9944-08df121b1658 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB6413.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2026 04:46:05.9219 (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: oc7cONbl0l+/7hVJR0Sv+DUQ0bmasCFhanxQxXstksvxUGDJ4HvRPpJA1Lye/M40dza/c9ykYXz5R43V+AlZRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4124 On Fri Sep 11, 2026 at 8:18 PM JST, Alexandre Courbot wrote: > On Fri Sep 11, 2026 at 2:28 PM JST, Eliot Courtney wrote: >> On Fri Sep 11, 2026 at 2:17 PM JST, Alexandre Courbot wrote: >>> On Thu Sep 10, 2026 at 5:10 PM JST, Alexandre Courbot wrote: >>>> On Thu Aug 27, 2026 at 11:12 PM JST, Eliot Courtney wrote: >>>>> For struct-like GMCAPI messages encoding field by field manually is >>>>> noisy. Add some type machinery and a macro to automate encoding of >>>>> struct-like messages. The `Encodeable` trait can be implemented by an= y >>>>> type to say that it can be encoded into an NVKV `Encoder`. Add a simp= le >>>>> `nvkv_encode!` macro that works on structs and encodes each field in >>>>> order. Provide some base types, such as `Key` which statically >>>>> associates a NVKV key with some value, to avoid having to make a lot = of >>>>> newtypes and implement `Encodeable` on them. >>>>> >>>>> Signed-off-by: Eliot Courtney >>>>> --- >>>>> drivers/gpu/nova-core/gsp/nvkv.rs | 49 ++++++++- >>>>> drivers/gpu/nova-core/gsp/nvkv/encode.rs | 178 +++++++++++++++++++++= ++++++++++ >>>>> 2 files changed, 226 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/drivers/gpu/nova-core/gsp/nvkv.rs b/drivers/gpu/nova-cor= e/gsp/nvkv.rs >>>>> index cbeee7f376b6..10dcbb9e602c 100644 >>>>> --- a/drivers/gpu/nova-core/gsp/nvkv.rs >>>>> +++ b/drivers/gpu/nova-core/gsp/nvkv.rs >>>>> @@ -10,8 +10,13 @@ >>>>> //! naturally maps to storing a &str with the GPU name. >>>>> =20 >>>>> #![expect(unused_imports)] >>>>> +#![cfg_attr(not(CONFIG_KUNIT), expect(unused_macros))] >>>>> =20 >>>>> -use core::ops::Deref; >>>>> +use core::marker::PhantomData; >>>>> +use core::ops::{ >>>>> + Deref, >>>>> + DerefMut, // >>>>> +}; >>>>> =20 >>>>> use kernel::{ >>>>> alloc::{ >>>>> @@ -92,6 +97,48 @@ fn deref(&self) -> &Self::Target { >>>>> /// The index of an NVKV value. >>>>> pub(crate) type Index =3D Bounded; >>>>> =20 >>>>> +/// A static association between an NVKV key `KEY_ID` and the storag= e of its value. >>>>> +/// >>>>> +/// Use with the encoder or decoder macros `nvkv_encode!` and `nvkv_= decode!` to let them know how to >>>>> +/// map the value `Key` to/from encoded data. For bre= vity, `As` inserts an additional >>>>> +/// conversion (`From`) to avoid having to implement [`Encodable`] f= or many types. For example, >>>>> +/// enums that are easily convertible to a u32 can have `As =3D u32`= and rely on the existing encoding >>>>> +/// for u32. >>>>> +#[repr(transparent)] >>>>> +pub(crate) struct Key(pub(crate) T= , PhantomData); >>>> >>>> Does the `T` need to be `pub(crate)`? The series builds fine with it >>>> being private. >>>> >>>> Also the relationship between `Key` and `IndexedKey` is a bit unclear >>>> with the current type layout. IIUC `Key` is basically a specialization >>>> of `IndexedKey` with an index of 0. And yet `Key` is declared in the >>>> root `nvkv` module while `IndexedKey` is in the `encode` submodule... >>>> I'm also wondering whether it would make sense to make the relationshi= p >>>> completely explicit by making `Key` a newtype embedding a `IndexedKey` >>>> with the invariant that the index is `0`, but not sure about that one = so >>>> your call. >>> >>> Ah, I guess that's because `IndexedKey` is local to `encoder`. In this >>> case keeping it there does indeed make sense. After complaining about >>> the visibility of other declarations, I should have noticed that one >>> too. :P >>> >>> What worries me more is the fact that no index larger than `0` is ever >>> created. This looks more and more like a bug to me. >> >> We currently don't send anything that wants an index other than zero. >> But, in the future we will. The way I did this so far is by having >> 'IndexedKey' which represents the most general thing that can properly >> encode anything accepted by the NVKV format. Since it's cumbersome to >> and rare to use, I added Key as a wrapper on top. It would be possible >> to hard code 0 in the index and only have `Key` but then we'd just have >> to change it later. Since nothing wants to set a non-zero index >> currently, it's private to `encoder`. > > But surely we should be able to test the non-zero path, even if we don't > have any real-life user at the moment, right? As this is part of the > NVKV spec, we should ensure this is correct. > > If `IndexedKey` is supposed to move down one module when it gains a > user, I think we should place it in its expected destination from the > get-go. You're right, let me add a test and think about moving it.