From: Danilo Krummrich <dakr@kernel.org>
To: Alexandre Courbot <acourbot@nvidia.com>
Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
rust-for-linux@vger.kernel.org, Miguel Ojeda <ojeda@kernel.org>
Subject: Re: [PATCH 1/2] gpu: nova-core: impl From for u32 for enums used from register!
Date: Tue, 24 Jun 2025 16:09:15 +0200 [thread overview]
Message-ID: <aFqxi7AvQiBLl528@pollux> (raw)
In-Reply-To: <DAUT7K6AFAXI.I6R4SBSYLRKP@nvidia.com>
On Tue, Jun 24, 2025 at 10:48:57PM +0900, Alexandre Courbot wrote:
> On Tue Jun 24, 2025 at 10:23 PM JST, Danilo Krummrich wrote:
> > Implement From for u32 for all enum types used within the register!()
> > macro.
> >
> > This avoids a conflict with [1] as reported in [2].
> >
> > Cc: Alexandre Courbot <acourbot@nvidia.com>
> > Cc: Miguel Ojeda <ojeda@kernel.org>
> > Link: https://lore.kernel.org/r/20250615-ptr-as-ptr-v12-5-f43b024581e8@gmail.com [1]
> > Link: https://lore.kernel.org/all/20250624173114.3be38990@canb.auug.org.au/ [2]
> > Signed-off-by: Danilo Krummrich <dakr@kernel.org>
>
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
>
> Also confirmed that Ampere still successfully probed with this:
>
> Tested-by: Alexandre Courbot <acourbot@nvidia.com>
>
> One small comment and question below.
>
> > ---
> > drivers/gpu/nova-core/falcon.rs | 18 ++++++++++++++++++
> > 1 file changed, 18 insertions(+)
> >
> > diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon.rs
> > index 07be1c30668c..1affffb109ec 100644
> > --- a/drivers/gpu/nova-core/falcon.rs
> > +++ b/drivers/gpu/nova-core/falcon.rs
> > @@ -20,6 +20,16 @@
> > mod hal;
> > pub(crate) mod sec2;
> >
> > +macro_rules! impl_from_enum_to_u32 {
> > + ($enum_type:ty) => {
> > + impl From<$enum_type> for u32 {
> > + fn from(value: $enum_type) -> Self {
> > + value as u32
> > + }
> > + }
> > + };
> > +}
>
> We might need some equivalent in other modules as well in the future -
> do you think we should move it to the root of the driver, and explain
> its purpose with a comment?
Let's do that once we need it in other modules.
> I am also thinking that we might want to turn this into a derive macro
> in the future, similar to `FromPrimitive` - so maybe a TODO item is
> warranted for this. I haven't looked closely at the `FromPrimitive`
> patchset yet but it would be neat if we could leverage it somehow.
This sounds exactly like what IntoPrimitive does. So, yes, I can add a comment
to replace the macro with IntoPrimitive in the future.
next prev parent reply other threads:[~2025-06-24 14:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 13:23 [PATCH 1/2] gpu: nova-core: impl From for u32 for enums used from register! Danilo Krummrich
2025-06-24 13:23 ` [PATCH 2/2] gpu: nova-core: consider `clippy::cast_lossless` Danilo Krummrich
2025-06-24 13:50 ` Alexandre Courbot
2025-06-24 23:29 ` Danilo Krummrich
2025-06-24 13:48 ` [PATCH 1/2] gpu: nova-core: impl From for u32 for enums used from register! Alexandre Courbot
2025-06-24 14:09 ` Danilo Krummrich [this message]
2025-06-24 23:29 ` Danilo Krummrich
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=aFqxi7AvQiBLl528@pollux \
--to=dakr@kernel.org \
--cc=acourbot@nvidia.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=nouveau@lists.freedesktop.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
/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).