From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Daniel Almeida" <daniel.almeida@collabora.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Beata Michalska" <beata.michalska@arm.com>,
<nouveau@lists.freedesktop.org>,
<dri-devel@lists.freedesktop.org>,
<rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"Nouveau" <nouveau-bounces@lists.freedesktop.org>
Subject: Re: [PATCH v2 17/19] gpu: nova-core: register: add support for register arrays
Date: Mon, 28 Jul 2025 14:12:01 +0900 [thread overview]
Message-ID: <DBNFIAFL8LAS.1W647VD2TIFP9@nvidia.com> (raw)
In-Reply-To: <D0DDB132-68E8-43D0-B7EB-AA607C9BB72F@collabora.com>
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.
next prev parent reply other threads:[~2025-07-28 5:12 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-18 7:26 [PATCH v2 00/19] gpu: nova-core: register!() macro improvements Alexandre Courbot
2025-07-18 7:26 ` [PATCH v2 01/19] gpu: nova-core: register: minor grammar and spelling fixes Alexandre Courbot
2025-07-25 16:14 ` Daniel Almeida
2025-07-25 20:43 ` John Hubbard
2025-07-28 4:59 ` Alexandre Courbot
2025-07-28 7:51 ` Steven Price
2025-07-28 11:43 ` Alexandre Courbot
2025-07-28 13:25 ` Steven Price
2025-07-29 13:47 ` Alexandre Courbot
2025-07-30 9:27 ` Steven Price
2025-07-30 12:47 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 02/19] gpu: nova-core: register: fix typo Alexandre Courbot
2025-07-18 19:05 ` Boqun Feng
2025-07-22 12:38 ` Alexandre Courbot
2025-07-25 16:18 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 03/19] gpu: nova-core: register: allow fields named `offset` Alexandre Courbot
2025-07-25 16:20 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 04/19] gpu: nova-core: register: improve documentation for basic registers Alexandre Courbot
2025-07-25 16:49 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 05/19] gpu: nova-core: register: simplify @leaf_accessor rule Alexandre Courbot
2025-07-25 16:53 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 06/19] gpu: nova-core: register: remove `try_` accessors for relative registers Alexandre Courbot
2025-07-25 16:55 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 07/19] gpu: nova-core: register: move OFFSET declaration to I/O impl block Alexandre Courbot
2025-07-25 17:03 ` Daniel Almeida
2025-07-28 5:02 ` Alexandre Courbot
2025-07-18 7:26 ` [PATCH v2 08/19] gpu: nova-core: register: fix documentation and indentation Alexandre Courbot
2025-07-25 17:04 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 09/19] gpu: nova-core: register: add missing doccomments for fixed registers I/O accessors Alexandre Courbot
2025-07-25 17:06 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 10/19] gpu: nova-core: register: add fields dispatcher internal rule Alexandre Courbot
2025-07-25 17:38 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 11/19] gpu: nova-core: register: improve `Debug` implementation Alexandre Courbot
2025-07-25 17:49 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 12/19] gpu: nova-core: register: generate correct `Default` implementation Alexandre Courbot
2025-07-25 17:53 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 13/19] gpu: nova-core: register: split @io rule into fixed and relative versions Alexandre Courbot
2025-07-25 17:58 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 14/19] gpu: nova-core: register: use #[inline(always)] for all methods Alexandre Courbot
2025-07-25 17:59 ` Daniel Almeida
2025-07-18 7:26 ` [PATCH v2 15/19] gpu: nova-core: register: redesign relative registers Alexandre Courbot
2025-07-25 18:56 ` Daniel Almeida
2025-07-28 5:07 ` Alexandre Courbot
2025-07-18 7:26 ` [PATCH v2 16/19] gpu: nova-core: falcon: add distinct base address for PFALCON2 Alexandre Courbot
2025-07-18 20:23 ` John Hubbard
2025-07-22 12:39 ` Alexandre Courbot
2025-07-18 7:26 ` [PATCH v2 17/19] gpu: nova-core: register: add support for register arrays Alexandre Courbot
2025-07-25 19:12 ` Daniel Almeida
2025-07-25 19:13 ` Daniel Almeida
2025-07-28 5:12 ` Alexandre Courbot [this message]
2025-07-18 7:26 ` [PATCH v2 18/19] gpu: nova-core: falcon: use register arrays for FUSE registers Alexandre Courbot
2025-07-18 7:26 ` [PATCH v2 19/19] gpu: nova-core: register: add support for relative array registers Alexandre Courbot
2025-08-14 22:52 ` [PATCH v2 00/19] gpu: nova-core: register!() macro improvements Lyude Paul
2025-08-15 4:44 ` Alexandre Courbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DBNFIAFL8LAS.1W647VD2TIFP9@nvidia.com \
--to=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=beata.michalska@arm.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nouveau-bounces@lists.freedesktop.org \
--cc=nouveau@lists.freedesktop.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).