All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Boris Brezillon" <boris.brezillon@collabora.com>
Cc: "Deborah Brouwer" <deborah.brouwer@collabora.com>,
	dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Miguel Ojeda" <ojeda@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Steven Price" <steven.price@arm.com>,
	"Dirk Behme" <dirk.behme@gmail.com>,
	"Boqun Feng" <boqun@kernel.org>
Subject: Re: [PATCH v2 1/5] drm/tyr: Use register! macro for GPU_CONTROL
Date: Thu, 12 Mar 2026 22:25:29 +0900	[thread overview]
Message-ID: <DH0U5S2CK89E.35JMPLGPPNF6C@nvidia.com> (raw)
In-Reply-To: <20260312093953.78f53864@fedora>

On Thu Mar 12, 2026 at 5:39 PM JST, Boris Brezillon wrote:
<snip>
>> +
>> +    impl GPU_COMMAND {
>> +        /// No operation. This is the default value.
>> +        pub(crate) const NOP: u32 = 0;
>> +        /// Reset the GPU.
>> +        pub(crate) const RESET: u32 = 1;
>> +        /// Flush caches.
>> +        pub(crate) const FLUSH_CACHES: u32 = 4;
>> +        /// Clear GPU faults.
>> +        pub(crate) const CLEAR_FAULT: u32 = 7;
>> +    }
>> +
>> +    register! {
>> +        /// GPU command register in reset mode.
>> +        /// Set command to [`GPU_COMMAND::RESET`] to set reset_mode.
>> +        pub(crate) GPU_COMMAND_RESET (u32) => GPU_COMMAND {
>> +            7:0     command;
>
> Alexandre, dunno how hard it would be to extend this alias syntax to
> provide auto-initialization/expected-value of certain fields, like:
>
> 	pub(crate) GPU_COMMAND_RESET (u32) => GPU_COMMAND {
>             7:0     command <- GPU_COMMAND::RESET;
>             11:8    reset_mode;
>         }
>
> so that when you instantiate a GPU_COMMAND_RESET, all you have to set is
> reset_mode and the command gets set to GPU_COMMAND::RESET for you.
> (that's for the write path, for the read path, you'll need some sort of
> match to do the re-interpretation anyway).

You can do this by augmenting the methods if `GPU_COMMAND_RESET` using a
dedicated impl block - in this case you probably want to implement
`Default`:

impl Default for GPU_COMMAND_RESET {
    fn default() -> Self {
        Self::zeroed().with_command(GPU_COMMAND::RESET)
    }
}

Then you can just do `GPU_COMMAND_RESET::default()` to create the
register with the expected value.

Maybe we could have a syntax to automatically generate a `Default`
implementation in the future.

I will have more comments to do on this series (notably the use of
constants), but it's great to see the register macro being used!

  reply	other threads:[~2026-03-12 13:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11 23:03 [PATCH v2 0/5] drm/tyr: Use register! macro Deborah Brouwer
2026-03-11 23:03 ` [PATCH v2 1/5] drm/tyr: Use register! macro for GPU_CONTROL Deborah Brouwer
2026-03-12  8:39   ` Boris Brezillon
2026-03-12 13:25     ` Alexandre Courbot [this message]
2026-03-13 18:29     ` Daniel Almeida
2026-03-13 19:13       ` Deborah Brouwer
2026-03-12  9:14   ` Boris Brezillon
2026-03-13 18:26   ` Daniel Almeida
2026-03-18  3:14   ` Alexandre Courbot
2026-03-20  0:15     ` Deborah Brouwer
2026-03-11 23:03 ` [PATCH v2 2/5] drm/tyr: Set interconnect coherency during probe Deborah Brouwer
2026-03-12  9:07   ` Boris Brezillon
2026-03-11 23:04 ` [PATCH v2 3/5] drm/tyr: Use register! macro for JOB_CONTROL Deborah Brouwer
2026-03-13 19:12   ` Daniel Almeida
2026-03-11 23:04 ` [PATCH v2 4/5] drm/tyr: Use register! macro for MMU_CONTROL Deborah Brouwer
2026-03-12  8:59   ` Boris Brezillon
2026-03-13 19:17   ` Daniel Almeida
2026-03-11 23:04 ` [PATCH v2 5/5] drm/tyr: Remove custom register struct Deborah Brouwer
2026-03-13 19:18   ` Daniel Almeida
2026-03-11 23:09 ` [PATCH v2 0/5] drm/tyr: Use register! macro Deborah Brouwer
2026-03-12  8:43 ` Boris Brezillon
2026-03-12  8:50   ` Boris Brezillon

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=DH0U5S2CK89E.35JMPLGPPNF6C@nvidia.com \
    --to=acourbot@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=boris.brezillon@collabora.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=deborah.brouwer@collabora.com \
    --cc=dirk.behme@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=lossin@kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=tmgross@umich.edu \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.