From: Daniel Almeida <daniel.almeida@collabora.com>
To: Alexandre Courbot <acourbot@nvidia.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
Subject: Re: [PATCH v2 10/19] gpu: nova-core: register: add fields dispatcher internal rule
Date: Fri, 25 Jul 2025 14:38:59 -0300 [thread overview]
Message-ID: <E29F0B67-9214-48C3-9B58-808C6B1B7659@collabora.com> (raw)
In-Reply-To: <20250718-nova-regs-v2-10-7b6a762aa1cd@nvidia.com>
> On 18 Jul 2025, at 04:26, Alexandre Courbot <acourbot@nvidia.com> wrote:
>
> Fields are complex and cumbersome to match in a rule, and were only
> captured in order to generate the field accessors. However, there are
> other places (like the `Debug` and `Default` implementations) where we
> would benefit from having access to at least some of the field
> information, but refrained from doing so because it would have meant
> matching the whole fields in a rule more complex than we need.
>
> Introduce a new `@fields_dispatcher` internal rule that captures all the
> field information and passes it to `@field_accessors`. It does not
> provide any functional change in itself, but allows us to reuse the
> captured field information partially to provide better `Debug` and
> `Default` implementations in following patches.
>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
> drivers/gpu/nova-core/regs/macros.rs | 42 +++++++++++++++++++++++++++---------
> 1 file changed, 32 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/regs/macros.rs b/drivers/gpu/nova-core/regs/macros.rs
> index 0a18a0d76b2265d3138f93ffc7c561b94bca3187..8b081242595de620cbf94b405838a2dac67b8e83 100644
> --- a/drivers/gpu/nova-core/regs/macros.rs
> +++ b/drivers/gpu/nova-core/regs/macros.rs
> @@ -88,37 +88,33 @@
> macro_rules! register {
> // Creates a register at a fixed offset of the MMIO space.
> ($name:ident @ $offset:literal $(, $comment:literal)? { $($fields:tt)* } ) => {
> - register!(@common $name $(, $comment)?);
> - register!(@field_accessors $name { $($fields)* });
> + register!(@core $name $(, $comment)? { $($fields)* } );
> register!(@io $name @ $offset);
> };
>
> // Creates an alias register of fixed offset register `alias` with its own fields.
> ($name:ident => $alias:ident $(, $comment:literal)? { $($fields:tt)* } ) => {
> - register!(@common $name $(, $comment)?);
> - register!(@field_accessors $name { $($fields)* });
> + register!(@core $name $(, $comment)? { $($fields)* } );
> register!(@io $name @ $alias::OFFSET);
> };
>
> // Creates a register at a relative offset from a base address.
> ($name:ident @ + $offset:literal $(, $comment:literal)? { $($fields:tt)* } ) => {
> - register!(@common $name $(, $comment)?);
> - register!(@field_accessors $name { $($fields)* });
> + register!(@core $name $(, $comment)? { $($fields)* } );
> register!(@io $name @ + $offset);
> };
>
> // Creates an alias register of relative offset register `alias` with its own fields.
> ($name:ident => + $alias:ident $(, $comment:literal)? { $($fields:tt)* } ) => {
> - register!(@common $name $(, $comment)?);
> - register!(@field_accessors $name { $($fields)* });
> + register!(@core $name $(, $comment)? { $($fields)* } );
> register!(@io $name @ + $alias::OFFSET);
> };
>
> // All rules below are helpers.
>
> // Defines the wrapper `$name` type, as well as its relevant implementations (`Debug`, `BitOr`,
> - // and conversion to regular `u32`).
> - (@common $name:ident $(, $comment:literal)?) => {
> + // and conversion to the value type) and field accessor methods.
> + (@core $name:ident $(, $comment:literal)? { $($fields:tt)* }) => {
> $(
> #[doc=$comment]
> )?
> @@ -149,6 +145,32 @@ fn from(reg: $name) -> u32 {
> reg.0
> }
> }
> +
> + register!(@fields_dispatcher $name { $($fields)* });
> + };
> +
> + // Captures the fields and passes them to all the implementers that require field information.
> + //
> + // Used to simplify the matching rules for implementers, so they don't need to match the entire
> + // complex fields rule even though they only make use of part of it.
> + (@fields_dispatcher $name:ident {
> + $($hi:tt:$lo:tt $field:ident as $type:tt
> + $(?=> $try_into_type:ty)?
> + $(=> $into_type:ty)?
> + $(, $comment:literal)?
> + ;
> + )*
> + }
> + ) => {
> + register!(@field_accessors $name {
> + $(
> + $hi:$lo $field as $type
> + $(?=> $try_into_type)?
> + $(=> $into_type)?
> + $(, $comment)?
> + ;
> + )*
> + });
> };
>
> // Defines all the field getter/methods methods for `$name`.
>
> --
> 2.50.1
>
>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
next prev parent reply other threads:[~2025-07-25 17:39 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 [this message]
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
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=E29F0B67-9214-48C3-9B58-808C6B1B7659@collabora.com \
--to=daniel.almeida@collabora.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=beata.michalska@arm.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.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
all inboxes | Powered by JetHome®