[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DBNFIAFL8LAS.1W647VD2TIFP9@nvidia.com>
Date: Mon, 28 Jul 2025 14:12:01 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Daniel Almeida" <daniel.almeida@...labora.com>
Cc: "Danilo Krummrich" <dakr@...nel.org>, "David Airlie"
<airlied@...il.com>, "Simona Vetter" <simona@...ll.ch>, "Maarten Lankhorst"
<maarten.lankhorst@...ux.intel.com>, "Maxime Ripard" <mripard@...nel.org>,
"Thomas Zimmermann" <tzimmermann@...e.de>, "Beata Michalska"
<beata.michalska@....com>, <nouveau@...ts.freedesktop.org>,
<dri-devel@...ts.freedesktop.org>, <rust-for-linux@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, "Nouveau"
<nouveau-bounces@...ts.freedesktop.org>
Subject: Re: [PATCH v2 17/19] gpu: nova-core: register: add support for
register arrays
On Sat Jul 26, 2025 at 4:12 AM JST, Daniel Almeida wrote:
<snip>
>> macro_rules! register {
>> // Creates a register at a fixed offset of the MMIO space.
>> ($name:ident @ $offset:literal $(, $comment:literal)? { $($fields:tt)* } ) => {
>> @@ -187,6 +238,35 @@ macro_rules! register {
>> register!(@io_relative $name @ $base [ $alias::OFFSET ]);
>> };
>>
>> + // Creates an array of registers at a fixed offset of the MMIO space.
>> + (
>> + $name:ident @ $offset:literal [ $size:expr ; $stride:expr ] $(, $comment:literal)? {
>> + $($fields:tt)*
>> + }
>> + ) => {
>> + static_assert!(::core::mem::size_of::<u32>() <= $stride);
>
> Perhaps a TODO here would be nice, since you’ll want to change it when/if
> this macros get to support non-u32 types (which is apparently on the roadmap
> IIUC).
There are many `u32`s sprinkled across that code, it would be a bit
tedious to have a TODO for each of them. And when we start making them
generic the code won't compile unless they are all replaced anyway, so I
think we are safe. :)
>
>> + register!(@core $name $(, $comment)? { $($fields)* } );
>> + register!(@io_array $name @ $offset [ $size ; $stride ]);
>> + };
>> +
>> + // Shortcut for contiguous array of registers (stride == size of element).
>> + (
>> + $name:ident @ $offset:literal [ $size:expr ] $(, $comment:literal)? {
>> + $($fields:tt)*
>> + }
>> + ) => {
>> + register!($name @ $offset [ $size ; ::core::mem::size_of::<u32>() ] $(, $comment)? {
>
> Same here.
>
>> + $($fields)*
>> + } );
>> + };
>> +
>> + // Creates an alias of register `idx` of array of registers `alias` with its own fields.
>> + ($name:ident => $alias:ident [ $idx:expr ] $(, $comment:literal)? { $($fields:tt)* }) => {
>> + static_assert!($idx < $alias::SIZE);
>> + register!(@core $name $(, $comment)? { $($fields)* } );
>> + register!(@io_fixed $name @ $alias::OFFSET + $idx * $alias::STRIDE );
>
> Why is this @io_fixed?
Because once you index a register (which the alias does), you obtain
what is effectively a fixed-address register, so these are the correct
I/O accessors here.
Powered by blists - more mailing lists