On Thu Jul 9, 2026 at 5:52 PM JST, Alistair Popple wrote:
> One of the first things a user needs to know about a GPU is its chipset,
> so add an ioctl to return that.

We are not adding an ioctl though, just a GETPARAM parameter.

<...>
> diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
> index 43c3f4f8df71..1f4c5f3aa8ea 100644
> --- a/drivers/gpu/nova-core/gpu.rs
> +++ b/drivers/gpu/nova-core/gpu.rs
> @@ -10,7 +10,8 @@
>      num::Bounded,
>      pci,
>      prelude::*,
> -    sizes::SizeConstants, //
> +    sizes::SizeConstants,
> +    uapi, //
>  };
>  
>  use crate::{
> @@ -34,12 +35,12 @@
>  mod hal;
>  
>  macro_rules! define_chipset {
> -    ({ $($variant:ident = $value:expr),* $(,)* }) =>
> +    ({ $($variant:ident = $value:path),* $(,)* }) =>
>      {
>          /// Enum representation of the GPU chipset.
>          #[derive(fmt::Debug, Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
> -        pub(crate) enum Chipset {
> -            $($variant = $value),*,
> +        pub enum Chipset {
> +            $($variant = $value as isize),*,
>          }
>  
>          impl Chipset {
> @@ -82,39 +83,39 @@ fn try_from(value: u32) -> Result<Self, Self::Error> {
>  
>  define_chipset!({
>      // Turing
> -    TU102 = 0x162,
> -    TU104 = 0x164,
> -    TU106 = 0x166,
> -    TU117 = 0x167,
> -    TU116 = 0x168,
> +    TU102 = uapi::drm_nova_chipset_NOVA_DRM_CHIPSET_TU102,
> +    TU104 = uapi::drm_nova_chipset_NOVA_DRM_CHIPSET_TU104,
> +    TU106 = uapi::drm_nova_chipset_NOVA_DRM_CHIPSET_TU106,
> +    TU117 = uapi::drm_nova_chipset_NOVA_DRM_CHIPSET_TU117,
> +    TU116 = uapi::drm_nova_chipset_NOVA_DRM_CHIPSET_TU116,

If we are going to remove the actual values, let's at least generate the
right-hand side in the macro as it is just verbose without bringing any
new information. The following diff lets you remove the `= uapi::...`
for each chipset declaration.

The UAPI definitions come technically from nova-drm (and are defined as
such), which introduces a dependency of sorts from nova-core to
nova-drm. I'm not saying this is a problem, but mentioning it as we want
to make that decision consciously.

I also think the introduction of UAPI variants and modification of
`define_chipset` should be its own patch, as these are pretty
mechanical.

diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
index 202adfbfa176..5b67f25399de 100644
--- a/drivers/gpu/nova-core/gpu.rs
+++ b/drivers/gpu/nova-core/gpu.rs
@@ -35,12 +35,13 @@
 mod hal;

 macro_rules! define_chipset {
-    ({ $($variant:ident = $value:path),* $(,)* }) =>
+    ({ $($variant:ident),* $(,)* }) =>
     {
+        ::kernel::macros::paste!(
         /// Enum representation of the GPU chipset.
         #[derive(fmt::Debug, Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
         pub enum Chipset {
-            $($variant = $value as isize),*,
+            $($variant = uapi::[<drm_nova_chipset_NOVA_DRM_CHIPSET_ 
$variant:upper>] as isize),*,
         }

         impl Chipset {
@@ -48,7 +49,6 @@ impl Chipset {
                 $( Chipset::$variant, )*
             ];

-            ::kernel::macros::paste!(
             /// Returns the name of this chipset, in lowercase.
             ///
             /// # Examples
@@ -64,7 +64,6 @@ pub(crate) const fn name(&self) -> &'static str {
                 )*
                 }
             }
-            );
         }

         // TODO[FPRI]: replace with something like derive(FromPrimitive)
@@ -73,45 +72,49 @@ impl TryFrom<u32> for Chipset {

             fn try_from(value: u32) -> Result<Self, Self::Error> {
                 match value {
-                    $( $value => Ok(Chipset::$variant), )*
+                    $(
+                        uapi::[<drm_nova_chipset_NOVA_DRM_CHIPSET_ 
$variant:upper>]
+                            => Ok(Chipset::$variant),
+                    )*
                     _ => Err(ENODEV),
                 }
             }
         }
+        );
     }
 }

Reply via email to