[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DDXV1SHI0R3A.2A1HQNM843OR0@nvidia.com>
Date: Sun, 02 Nov 2025 11:41:23 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "John Hubbard" <jhubbard@...dia.com>, "Alexandre Courbot"
<acourbot@...dia.com>, "Danilo Krummrich" <dakr@...nel.org>
Cc: "Joel Fernandes" <joelagnelf@...dia.com>, "Timur Tabi"
<ttabi@...dia.com>, "Alistair Popple" <apopple@...dia.com>, "Edwin Peer"
<epeer@...dia.com>, "Zhi Wang" <zhiw@...dia.com>, "David Airlie"
<airlied@...il.com>, "Simona Vetter" <simona@...ll.ch>, "Bjorn Helgaas"
<bhelgaas@...gle.com>, "Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor"
<alex.gaynor@...il.com>, "Boqun Feng" <boqun.feng@...il.com>, "Gary Guo"
<gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Benno Lossin" <lossin@...nel.org>, "Andreas
Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl" <aliceryhl@...gle.com>,
"Trevor Gross" <tmgross@...ch.edu>, <nouveau@...ts.freedesktop.org>,
<rust-for-linux@...r.kernel.org>, "LKML" <linux-kernel@...r.kernel.org>,
"Nouveau" <nouveau-bounces@...ts.freedesktop.org>
Subject: Re: [PATCH v3 2/2] gpu: nova-core: add boot42 support for next-gen
GPUs
On Sun Nov 2, 2025 at 9:34 AM JST, John Hubbard wrote:
> On 10/29/25 7:05 AM, Alexandre Courbot wrote:
>> On Wed Oct 29, 2025 at 12:03 PM JST, John Hubbard wrote:
>> <snip>
>> This allows the implementation of `NV_PMC_BOOT_42` to mirror that of
>> `NV_PMC_BOOT_0`:
>>
>> impl NV_PMC_BOOT_42 {
>> pub(crate) fn chipset(self) -> Result<Chipset> {
>> self.architecture()
>> .map(|arch| {
>> ((arch as u32) << Self::IMPLEMENTATION_RANGE.len())
>
> A quick note: _RANGE() and related functions are (I think?) deeply,
> madly undocumented. Not only is bitfield a macro within a macro, but
> bitfield itself leaves the user with only the following as "documentation":
>
> ::kernel::macros::paste!(
> const [<$field:upper _RANGE>]: ::core::ops::RangeInclusive<u8> = $lo..=$hi;
>
> The net result is that those of us who did not author or carefully
> review register!() and bitfield!() are going to have a rough time
> using these facilities.
>
> I'm not sure of the best way to add documentation here, but just
> thought I'd better give an early warning about this.
We can always add doccomments in the macro, as in the patch below. These
will be displayed by LSP when one highlights or tries to use one of
these constants.
If you think that's adequate, I will send a patch.
--- a/drivers/gpu/nova-core/bitfield.rs
+++ b/drivers/gpu/nova-core/bitfield.rs
@@ -249,7 +249,10 @@ impl $name {
{ $process:expr } $prim_type:tt $to_type:ty => $res_type:ty $(, $comment:literal)?;
) => {
::kernel::macros::paste!(
+ /// Inclusive range of the bits covered by this field.
const [<$field:upper _RANGE>]: ::core::ops::RangeInclusive<u8> = $lo..=$hi;
+
+ /// Mask of the bits making up this field.
const [<$field:upper _MASK>]: $storage = {
// Generate mask for shifting
match ::core::mem::size_of::<$storage>() {
@@ -260,6 +263,8 @@ impl $name {
_ => ::kernel::build_error!("Unsupported storage type size")
}
};
+
+ /// Shift to apply to a value to align it with the start of this field.
const [<$field:upper _SHIFT>]: u32 = $lo;
);
Powered by blists - more mailing lists