Re: [PATCH FOR REFERENCE v8 10/10] gpu: nova-core: use the kernel `register!` macro

From: Gary Guo

Date: Mon Mar 09 2026 - 14:28:45 EST


On Mon Mar 9, 2026 at 6:01 PM GMT, John Hubbard wrote:
> On 3/9/26 10:51 AM, Joel Fernandes wrote:
>> On 3/9/2026 1:34 PM, John Hubbard wrote:
>>> On 3/9/26 8:43 AM, Joel Fernandes wrote:
>>>> On 3/9/2026 11:14 AM, Alexandre Courbot wrote:
> ...
>>>> TBH, this is quite a readability hit, the previous was much more readable IMHO.
>>>
>>> Yes, I think so too, except that "WithBase::of::<E>" makes a lot more
>>> sense on-screen, than "&E::ID". The latter just looks quite random,
>>> so this part is an improvement.
>>>
>>> Let's break down the remaining troublesome part a bit:
>>>
>>> regs::NV_PFALCON_FALCON_MAILBOX1::zeroed().with_value(mbox1)
>>>
>>> * "regs::" can be omitted with a "use" statement, right?
>>>
>>> * ::zeroed() maybe should be the default behavior here, and then
>>> it could also be omitted?
>>
>> The issue with omitting it is it still needs a constructor? so if not zeroed()
>> it would still need ::default() I think.
>>
>>>
>>> * .with_value(mbox1) I'm sure this is necessary, but the construction
>>> is unfortunately much less clear than .write(value)! Thoughts?
>>
>> yeah, also perhaps the whole thing should have a macro! to de-sugar. The
>> patterns seem somewhat repetitive.

Once we agreed on how bitfield macros should work, this could just be

bar.write(WithBase::of::<E>(), bitfield!(NV_PFCALON_FALCON_MAILBOX1 { value: mbox1 }))

or something similar.

Or as Danilo pointed out, for the generic mailbox using bitfields isn't really
meaningful, so the bitfield should eventually be removed and replaced with a
direct write of primitive integer.

>
> Yes, and actually, I don't immediately see why we have to specify both
> a base value and a register name, because registers have a fixed base
> address.
>
> What about this instead (*very* approximately):
>
> // set up or construct NV_PFALCON_FALCON_MAILBOX1:
>
> let reg = NV_PFALCON_FALCON_MAILBOX1::zeroed(&bar);

This doesn't really make sense. What does "zeroed(&bar)" even mean? You're
neither zeroing the register on the bar, nor constructing a zeroed value?

Best,
Gary

>
> reg.write(NV_PFALCON_FALCON_MAILBOX1, new_mbox1_val);

>
>
>
> thanks,