Re: [PATCH FOR REFERENCE v8 10/10] gpu: nova-core: use the kernel `register!` macro
From: John Hubbard
Date: Mon Mar 09 2026 - 14:05:38 EST
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.
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);
reg.write(NV_PFALCON_FALCON_MAILBOX1, new_mbox1_val);
thanks,
--
John Hubbard