From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CWXP265CU008.outbound.protection.outlook.com (mail-ukwestazon11020125.outbound.protection.outlook.com [52.101.195.125]) (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 DCAAD23E35F; Fri, 20 Mar 2026 20:23:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.195.125 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774038210; cv=fail; b=OweVjzgT6Uic3nEKwod2orB1PS5ucEI4lx19YZAiLCUBqPoYuGgh3Kq9KfQv9P/DxRS75Un36/pEFi41B0bGEYn1vxxKzh0UA65HN+pEzGfDK4wVrX+whH01MYYws7spIVBgrwAQEXZ+HZULPoRdytiANe0/Xi2B3wuW/P5Zd2s= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774038210; c=relaxed/simple; bh=akYeF6O1T33yMNEDdID7eioPnWqTYC6bUx0RjWB+KGA=; h=Content-Type:Date:Message-Id:Cc:Subject:From:To:References: In-Reply-To:MIME-Version; b=DE0EbtE62dOnCoX5OD3ML5UUzE8vaXV8g7XSPCqtpxIFBfZIicAlwjFt/YjOw5o6qhYf56L1W4eFlDKYEF86kNEFI5A5Kql4DMfSaURJZxiChdgzO6bnJ6r1sjBzM82diRFi2FuHAwchXm3tqy7p7UVKszA8IoxtgKhGIJKfFKY= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=garyguo.net; spf=pass smtp.mailfrom=garyguo.net; dkim=pass (1024-bit key) header.d=garyguo.net header.i=@garyguo.net header.b=i3uIDcPy; arc=fail smtp.client-ip=52.101.195.125 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=garyguo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=garyguo.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=garyguo.net header.i=@garyguo.net header.b="i3uIDcPy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AJORbRZ0tgOEH73z9I41oBmRrCeWdSbWrUeQIFIcxtAl1wMWn9FLnnDWGkpXSCKb/CoFmVyQmKB/gi0KtA5sVlt2b6W79KwoFklL6DTRVHH0OEgxpT6RsFyEpKj4WxI9z9nGmn1OZIRhHYkTRKJL+FGtwaLyV+gak63YYXyfjfmdvmg6nlM6HT2Q3avySenxrfVyuYPWxrSlfQwGXx9gUlIXSpu+kUyTlFKM2K+VkMipHhFbPqcrCWB6dPBmiVZhtmgc3ZuV+V1bTtpbe7RZEGMe4ftV/xLqYOLLNm0TAkMSE19+qeiIZFjTzSZy+botosfIestKuX00uLlUSZaoxw== 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=yRopKqhLqB19VVPA3dXSM4eLQv/QdxeCVMb1YU6C0ow=; b=AWrIZ+/Uuf6R9K33P9NikjTTyHSILasWbcTc/9JcgvtPuQb98mQ2Y8zZbX62gqQ5PNu/inBeCe2cGzO6L54O94+et3sj7B7oO/EzWV/N/9QWUVi2P9VjIo2ntlOBqnCBiQfPM/FJMcc2xwXITS2Sz7Mu7/2S70yBEN/31CgD82T0hjmw718PsmN1PTrHtvyHBRoNXNue3OlS301vJlmvUlwJjuX+W+0S6+6U5TC1k/Bo/44cCaTbiYFDqMWzr4uAK24gALfWtci5pLdRXZEJhktGYGQTrkNF6r0/SJDlOT+v6/eMYSmpntFOM1y4EcK3KuULAAAtBUZ9dm3huw9IIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=garyguo.net; dmarc=pass action=none header.from=garyguo.net; dkim=pass header.d=garyguo.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garyguo.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yRopKqhLqB19VVPA3dXSM4eLQv/QdxeCVMb1YU6C0ow=; b=i3uIDcPyMCuZdCmrd5MDEgRfqmmrviN811C5kv8qoTf3F2yG1IA8K+2+cNvZWpw6u5fa7sMseUCa7BhMTkHp56Mhma1ridMwkUNLqxdVRsjUvfcS6ObjyETfigAyoWwUIiC4+JJrg3PE70RowcThf+ATobEqWHp/Ju4dfHo0RPQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=garyguo.net; Received: from LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:488::16) by LO0P265MB6710.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:30c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9723.25; Fri, 20 Mar 2026 20:23:25 +0000 Received: from LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM ([fe80::1c3:ceba:21b4:9986]) by LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM ([fe80::1c3:ceba:21b4:9986%5]) with mapi id 15.20.9723.022; Fri, 20 Mar 2026 20:23:25 +0000 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 20 Mar 2026 20:23:24 +0000 Message-Id: Cc: "Joel Fernandes" , "Alexandre Courbot" , "Alice Ryhl" , "David Airlie" , "Simona Vetter" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "Miguel Ojeda" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , "Alistair Popple" , "Timur Tabi" , "Zhi Wang" , "Eliot Courtney" , , , , , Subject: Re: [PATCH v2 08/10] gpu: nova-core: convert falcon registers to kernel register macro From: "Gary Guo" To: "Danilo Krummrich" , "John Hubbard" X-Mailer: aerc 0.21.0 References: <20260320-b4-nova-register-v2-0-88fcf103e8d4@nvidia.com> <20260320-b4-nova-register-v2-8-88fcf103e8d4@nvidia.com> <8f9da1e2-fb86-4653-b702-333fc920af58@nvidia.com> <354b3e67-9bfb-4538-a865-695ebec6b433@kernel.org> In-Reply-To: <354b3e67-9bfb-4538-a865-695ebec6b433@kernel.org> X-ClientProxiedBy: LO4P265CA0124.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c6::14) To LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:488::16) Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LOVP265MB8871:EE_|LO0P265MB6710:EE_ X-MS-Office365-Filtering-Correlation-Id: 5412a774-b56f-4593-44cd-08de86be8a2e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|10070799003|1800799024|366016|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 0Mq47dd48UnYi3hNUDnZPP++6vVoyfK/xpUk1LBajSJITVZXfDtMVSbc/lUH8fMFAaZNgF+My4SX928S1k1nMtP8yj3PY1Bp4NRMgAvnd6s19axS7puly2RHHbTeIx8+t7kLBdv5T5joO/AGxCtGFKogjJcBeBvttqFb7NhrftpxkDkm8hcEicSiw+5YRN27P0+uzjR+5tZe+IjcJ33GAKv5rrQ2j3ApaDSjdug2/7T9Ds1HaDSdM4hV7gNcBJr1K69xVS//C/raCcZs8Kaz1FgqVwhaqop6rNylEoqMhyyGbFvt7S+5Y9vwWPq1ennCCazXdCrFkRRE31f6cjPHDgGpn6/Kz0dobZyMC9iQ8zCrW9U6o7Maoaa1//PaRWoOYPyGknXQEC2awWypwQIjCOPPj2W42kXzcIylu81MWDSqVQnsdi2H8Z+U8vkYkFlZZ8bL7CAe3XcDd6wQBvcOy7kbYOWPemCyqqcP4Ub9h/PSgJGeg8vO4sQmCnjlcPRQnT+BJwDHTux0XtkR4MukqngJl7xAgxpHWtGsZmI+6KFhrAyxz1Ec1vlSDBmLjcvDWngdZ/F29goJ96U5HqvnMhyBulPavcQsPuTBN8Xcat6a5Qq0fYP/qOposIUyJJA6w8hViQzZDJjqdhGiPAryzV5voODgHDlP9g8EBjJgYkTbhJ2ERCWhOZAJ/Ad96Jp3u6EXfDRoprIBZNVwUw5n5dFE6XfOaGA8MBAXzzqUNqw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(10070799003)(1800799024)(366016)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MkVHSnc0V0Yva1hCbytraWRsdElrb1N6RzRsaUFpTmFVMG81L2NMeFJCZG9m?= =?utf-8?B?blJTZmpTWk0wRUgxblpib0ZFdTJGK1NHT2Z3aXM2WCtsTER2bmdnVkxCMmFY?= =?utf-8?B?Mys1VmUwTXA3bVo1TkdxeEtrdGNPWkJvSWNNcm42bmN3MXpwQ0JCbGw2VnRC?= =?utf-8?B?bVRmUGtYYW84OUhJWlY2UCtmNWJZcmY2ZHp6U0hsK1Mwa3V5d25XMFlhTlAr?= =?utf-8?B?M1dXNGlGeURXaHgyYlZWTlB5bHBwQVREZ2VheU9iVEhWeG83ajkrbUx6NGZp?= =?utf-8?B?cHdEdlB5T0hkemdCelY4Y1hwVkM5c1l2UFlnbFRZM1ZiZ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Q3Q2NzZsWUY0YVlxUDZHWGd1UjNhTFFmc2Mxa0diL0lxV2dSbGgybVBQ?= =?utf-8?B?VnNwWXF2WUFLdGRBYkhibElDemI3aGhuOU5ldDFxVTQwMTVRWEVtNkF3eXFq?= =?utf-8?B?MCt3THhJdFN3Yjl2dTNLbFZpSWpPNkk4aE0rdDdWdzQvVWpFcUlLQm5heDZm?= =?utf-8?B?d25XcnQyckRxU1RvTktKNjd4eXozU3krQW5Pd1QrZkNnTWhDS1I3Zz09?= X-OriginatorOrg: garyguo.net X-MS-Exchange-CrossTenant-Network-Message-Id: 5412a774-b56f-4593-44cd-08de86be8a2e X-MS-Exchange-CrossTenant-AuthSource: LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2026 20:23:25.4410 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bbc898ad-b10f-4e10-8552-d9377b823d45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: U0McqMW9vbAheX/EiylgUJKQYijykpEnQo/MCgOSCQ3Te7cWA4UledLqzsZzgPD/8L9hCmMT+1yG6nb3p+F01w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO0P265MB6710 On Fri Mar 20, 2026 at 8:07 PM GMT, Danilo Krummrich wrote: > On 3/20/26 8:52 PM, John Hubbard wrote: >> On 3/20/26 10:38 AM, Joel Fernandes wrote: >>> Hi Alex, >>> >>> On 3/20/2026 8:19 AM, Alexandre Courbot wrote: >>>> /// Reset the controller, select the falcon core, and wait for me= mory scrubbing to complete. >>>> @@ -616,9 +462,10 @@ pub(crate) fn reset(&self, bar: &Bar0) -> Result = { >>>> self.hal.select_core(self, bar)?; >>>> self.hal.reset_wait_mem_scrubbing(bar)?; >>>> =20 >>>> - regs::NV_PFALCON_FALCON_RM::default() >>>> - .set_value(bar.read(regs::NV_PMC_BOOT_0).into()) >>>> - .write(bar, &E::ID); >>>> + bar.write( >>>> + WithBase::of::(), >>>> + regs::NV_PFALCON_FALCON_RM::from(bar.read(regs::NV_PMC_BO= OT_0).into_raw()), >>>> + ); >>>> =20 >>> >>> Overall, I think the series is good improvement but I still feel this p= art is a >>> step back in readability, and we should come up with something better. = I don't >>> think there's any chance anyone can memorize this syntax. >>=20 >> I must reluctantly (because I know this conversation has gone very >> long, across so many versions) agree. That .write() statement is just >> brutal, and we will be relying on AI in order to even figure it out, >> I fear. >>=20 >> I'd hoped that there were other, simpler forms to express this, >> is that not the case here? > > I mean, it is barely different from the above, except for the > WithBase::of::() argument instead of &E::ID. > > It becomes much more readable if you break it down (which is what we shou= ld > probably do): > > let boot0 =3D bar.read(regs::NV_PMC_BOOT_0).into_raw(); > > bar.write(WithBase::of::(), regs::NV_PFALCON_FALCON_RM::from(boot0)); > > For other cases where we read a register and write the same register we w= ill > have a way in the future that can omit WithBase::of::() entirely, see = also my > reply in [1]. > > I want to expand write_reg() to also be able to handle variable offset > registers, e.g.: > > let reg =3D bar.read_reg(regs::NV_PFALCON_FALCON_RM::of::()); > > // modify reg > > bar.write_reg(reg); If we add API that allows you to do projection based on a register, then yo= u could do: let reg: View<'_, _, _> =3D bar.project(regs::NV_PFALCON_FALCON_RM::of:= :()); let v =3D reg.read_val(); reg.write_val(v.with_foo()); I'm planning to introduce `read_val`/`write_val` on `io::View<'_, IO, integ= er primitives>` but with some traits it should be doable for register types, too. (I think `read_val`, `write_val` makes sense here because they're views of = a simple value. I cannot use `read`/`write` here because they're used by regi= ster mechanism already). Best, Gary