Skip to contentSkip to conversation

drm: nova: Move VRAM BAR size query to GPU info

PATCH Applied Danilo Krummrich 4 participants 5 messages Sep 27 – Oct 5

Subsystems (5)
lore
Share & tools
lore

Danilo Krummrich

author maintainer
#0 lore raw

PATCH 1/1 drm: nova: Move VRAM BAR size query to GPU info

Nova exposes static information via its DRM_IOCTL_NOVA_INFO ioctl, thus add vram_bar_size to struct drm_nova_info_gpu and remove DRM_IOCTL_NOVA_GETPARAM and its uAPI definitions.

This breaks the uAPI, which is still fine at this point. It requires the corresponding drm-test change in [1].

---
 drivers/gpu/drm/nova/driver.rs |  3 +--
 drivers/gpu/drm/nova/file.rs   | 18 +----------------
 include/uapi/drm/nova_drm.h    | 36 ++++++++--------------------------
 3 files changed, 10 insertions(+), 47 deletions(-)
drivers/gpu/drm/nova/driver.rs +1 -2
index 46e13fe795eb..851d50b4dd15 100644
@@ -95,9 +95,8 @@ impl drm::Driver for NovaDriver {
     const FEAT_RENDER: bool = true;
 
     kernel::declare_drm_ioctls! {
-        (NOVA_GETPARAM, drm_nova_getparam, ioctl::RENDER_ALLOW, File::get_param),
+        (NOVA_INFO, drm_nova_info, ioctl::RENDER_ALLOW, File::info),
         (NOVA_GEM_CREATE, drm_nova_gem_create, ioctl::AUTH | ioctl::RENDER_ALLOW, File::gem_create),
         (NOVA_GEM_INFO, drm_nova_gem_info, ioctl::AUTH | ioctl::RENDER_ALLOW, File::gem_info),
-        (NOVA_INFO, drm_nova_info, ioctl::RENDER_ALLOW, File::info),
     }
 }
drivers/gpu/drm/nova/file.rs +1 -17
index 766a6ddb7e10..a05264917a0b 100644
@@ -60,6 +60,7 @@ fn new(reg_data: &DrmRegData<'_>) -> Result<Self> {
             architecture: spec.chipset.arch().into(),
             chipid: spec.chipset.into(),
             vram_size: gsp_static_info.vram_size(),
+            vram_bar_size: reg_data.api.with(|api| api.bar1_size())?,
             gpu_gid: gsp_static_info.gpu_gid,
             ..pin_init::zeroed()
         };
@@ -108,23 +109,6 @@ fn open(_dev: &NovaDevice) -> Result<Pin<KBox<Self>>> {
 }
 
 impl File {
-    /// IOCTL: get_param: Query GPU / driver metadata.
-    pub(crate) fn get_param(
-        _dev: &NovaDevice<Registered>,
-        reg_data: &DrmRegData<'_>,
-        getparam: &mut uapi::drm_nova_getparam,
-        _file: &drm::File<File>,
-    ) -> Result<u32> {
-        let value = match getparam.param.try_into()? {
-            uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => reg_data.api.with(|api| api.bar1_size())?,
-            _ => return Err(EINVAL),
-        };
-
-        getparam.value = Into::<u64>::into(value);
-
-        Ok(0)
-    }
-
     /// IOCTL: gem_create: Create a new DRM GEM object.
     pub(crate) fn gem_create(
         dev: &NovaDevice<Registered>,
include/uapi/drm/nova_drm.h +8 -28
index a74daba6ea94..d7017ed17143 100644
@@ -18,13 +18,6 @@
 extern "C" {
 #endif
 
-/*
- * NOVA_GETPARAM_VRAM_BAR_SIZE
- *
- * Query the VRAM BAR size in bytes.
- */
-#define NOVA_GETPARAM_VRAM_BAR_SIZE	0x1
-
 /**
  * enum drm_nova_architecture - GPU architecture identifier
  */
@@ -77,21 +70,6 @@ enum drm_nova_chipid {
 	NOVA_DRM_CHIPID_GB207			= 0x1b7,
 };
 
-/**
- * struct drm_nova_getparam - query GPU and driver metadata
- */
-struct drm_nova_getparam {
-	/**
-	 * @param: The identifier of the parameter to query.
-	 */
-	__u64 param;
-
-	/**
-	 * @value: The value for the specified parameter.
-	 */
-	__u64 value;
-};
-
 /**
  * struct drm_nova_gem_create - create a new DRM GEM object
  */
@@ -189,6 +167,11 @@ struct drm_nova_info_gpu {
 	 */
 	__u64 vram_size;
 
+	/**
+	 * @vram_bar_size: Size of the PCI BAR aperture used to access VRAM, in bytes.
+	 */
+	__u64 vram_bar_size;
+
 	/**
 	 * @gpu_name: NUL-terminated full GPU name.
 	 */
@@ -205,21 +188,18 @@ struct drm_nova_info_gpu {
 	__u8 gpu_gid[16];
 };
 
-#define DRM_NOVA_GETPARAM		0x00
+#define DRM_NOVA_INFO			0x00
 #define DRM_NOVA_GEM_CREATE		0x01
 #define DRM_NOVA_GEM_INFO		0x02
-#define DRM_NOVA_INFO			0x03
 
 /* Note: this is an enum so that it can be resolved by Rust bindgen. */
 enum {
-	DRM_IOCTL_NOVA_GETPARAM		= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_GETPARAM,
-						   struct drm_nova_getparam),
+	DRM_IOCTL_NOVA_INFO		= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_INFO,
+						   struct drm_nova_info),
 	DRM_IOCTL_NOVA_GEM_CREATE	= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_GEM_CREATE,
 						   struct drm_nova_gem_create),
 	DRM_IOCTL_NOVA_GEM_INFO		= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_GEM_INFO,
 						   struct drm_nova_gem_info),
-	DRM_IOCTL_NOVA_INFO		= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_INFO,
-						   struct drm_nova_info),
 };
 
 #if defined(__cplusplus)

base-commit: 10a6623a24a85708650efad7be15182289403cd7

Signature · 1 line
2.55.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Danilo Krummrich

Nova exposes static information via its DRM_IOCTL_NOVA_INFO ioctl, thus add vram_bar_size to struct drm_nova_info_gpu and remove DRM_IOCTL_NOVA_GETPARAM and its uAPI definitions.

This breaks the uAPI, which is still fine at this point. It requires the corresponding drm-test change in [1].

Reviewed-by on v1 1/1
#2 lore raw
In reply to Danilo Krummrich
Quoted 10 lines · Danilo Krummrich

Nova exposes static information via its DRM_IOCTL_NOVA_INFO ioctl, thus add vram_bar_size to struct drm_nova_info_gpu and remove DRM_IOCTL_NOVA_GETPARAM and its uAPI definitions.

This breaks the uAPI, which is still fine at this point. It requires the corresponding drm-test change in [1].

---

Reviewed-by on v1 1/1
#3 lore raw
In reply to Danilo Krummrich

On 2026-09-28 at 00:22 +1000, Danilo Krummrich <[email protected]> wrote...

Quoted 3 lines

Nova exposes static information via its DRM_IOCTL_NOVA_INFO ioctl, thus add vram_bar_size to struct drm_nova_info_gpu and remove DRM_IOCTL_NOVA_GETPARAM and its uAPI definitions.

I see everyone else has already jumped on this but feel free to add my RB as well:

Quoted 144 lines

This breaks the uAPI, which is still fine at this point. It requires the corresponding drm-test change in [1].

---
 drivers/gpu/drm/nova/driver.rs |  3 +--
 drivers/gpu/drm/nova/file.rs   | 18 +----------------
 include/uapi/drm/nova_drm.h    | 36 ++++++++--------------------------
 3 files changed, 10 insertions(+), 47 deletions(-)
drivers/gpu/drm/nova/driver.rs +1 -2
index 46e13fe795eb..851d50b4dd15 100644
@@ -95,9 +95,8 @@ impl drm::Driver for NovaDriver {
     const FEAT_RENDER: bool = true;
 
     kernel::declare_drm_ioctls! {
-        (NOVA_GETPARAM, drm_nova_getparam, ioctl::RENDER_ALLOW, File::get_param),
+        (NOVA_INFO, drm_nova_info, ioctl::RENDER_ALLOW, File::info),
         (NOVA_GEM_CREATE, drm_nova_gem_create, ioctl::AUTH | ioctl::RENDER_ALLOW, File::gem_create),
         (NOVA_GEM_INFO, drm_nova_gem_info, ioctl::AUTH | ioctl::RENDER_ALLOW, File::gem_info),
-        (NOVA_INFO, drm_nova_info, ioctl::RENDER_ALLOW, File::info),
     }
 }
drivers/gpu/drm/nova/file.rs +1 -17
index 766a6ddb7e10..a05264917a0b 100644
@@ -60,6 +60,7 @@ fn new(reg_data: &DrmRegData<'_>) -> Result<Self> {
             architecture: spec.chipset.arch().into(),
             chipid: spec.chipset.into(),
             vram_size: gsp_static_info.vram_size(),
+            vram_bar_size: reg_data.api.with(|api| api.bar1_size())?,
             gpu_gid: gsp_static_info.gpu_gid,
             ..pin_init::zeroed()
         };
@@ -108,23 +109,6 @@ fn open(_dev: &NovaDevice) -> Result<Pin<KBox<Self>>> {
 }
 
 impl File {
-    /// IOCTL: get_param: Query GPU / driver metadata.
-    pub(crate) fn get_param(
-        _dev: &NovaDevice<Registered>,
-        reg_data: &DrmRegData<'_>,
-        getparam: &mut uapi::drm_nova_getparam,
-        _file: &drm::File<File>,
-    ) -> Result<u32> {
-        let value = match getparam.param.try_into()? {
-            uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => reg_data.api.with(|api| api.bar1_size())?,
-            _ => return Err(EINVAL),
-        };
-
-        getparam.value = Into::<u64>::into(value);
-
-        Ok(0)
-    }
-
     /// IOCTL: gem_create: Create a new DRM GEM object.
     pub(crate) fn gem_create(
         dev: &NovaDevice<Registered>,
include/uapi/drm/nova_drm.h +8 -28
index a74daba6ea94..d7017ed17143 100644
@@ -18,13 +18,6 @@
 extern "C" {
 #endif
 
-/*
- * NOVA_GETPARAM_VRAM_BAR_SIZE
- *
- * Query the VRAM BAR size in bytes.
- */
-#define NOVA_GETPARAM_VRAM_BAR_SIZE	0x1
-
 /**
  * enum drm_nova_architecture - GPU architecture identifier
  */
@@ -77,21 +70,6 @@ enum drm_nova_chipid {
 	NOVA_DRM_CHIPID_GB207			= 0x1b7,
 };
 
-/**
- * struct drm_nova_getparam - query GPU and driver metadata
- */
-struct drm_nova_getparam {
-	/**
-	 * @param: The identifier of the parameter to query.
-	 */
-	__u64 param;
-
-	/**
-	 * @value: The value for the specified parameter.
-	 */
-	__u64 value;
-};
-
 /**
  * struct drm_nova_gem_create - create a new DRM GEM object
  */
@@ -189,6 +167,11 @@ struct drm_nova_info_gpu {
 	 */
 	__u64 vram_size;
 
+	/**
+	 * @vram_bar_size: Size of the PCI BAR aperture used to access VRAM, in bytes.
+	 */
+	__u64 vram_bar_size;
+
 	/**
 	 * @gpu_name: NUL-terminated full GPU name.
 	 */
@@ -205,21 +188,18 @@ struct drm_nova_info_gpu {
 	__u8 gpu_gid[16];
 };
 
-#define DRM_NOVA_GETPARAM		0x00
+#define DRM_NOVA_INFO			0x00
 #define DRM_NOVA_GEM_CREATE		0x01
 #define DRM_NOVA_GEM_INFO		0x02
-#define DRM_NOVA_INFO			0x03
 
 /* Note: this is an enum so that it can be resolved by Rust bindgen. */
 enum {
-	DRM_IOCTL_NOVA_GETPARAM		= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_GETPARAM,
-						   struct drm_nova_getparam),
+	DRM_IOCTL_NOVA_INFO		= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_INFO,
+						   struct drm_nova_info),
 	DRM_IOCTL_NOVA_GEM_CREATE	= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_GEM_CREATE,
 						   struct drm_nova_gem_create),
 	DRM_IOCTL_NOVA_GEM_INFO		= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_GEM_INFO,
 						   struct drm_nova_gem_info),
-	DRM_IOCTL_NOVA_INFO		= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_INFO,
-						   struct drm_nova_info),
 };
 
 #if defined(__cplusplus)

base-commit: 10a6623a24a85708650efad7be15182289403cd7

Signature · 1 line
2.55.0
author maintainer Applied
#4 lore raw
In reply to Danilo Krummrich
Quoted 1 line · Danilo Krummrich

[PATCH] drm: nova: Move VRAM BAR size query to GPU info

Applied, thanks!

Branch: drm-rust-next
Tree: https://gitlab.freedesktop.org/drm/rust/kernel.git

[1/1] drm: nova: Move VRAM BAR size query to GPU info

      commit: 04476103b7bc

The patch will appear in the next linux-next integration (typically within 24 hours on weekdays).

The patch is queued up for the upcoming merge window for the next major kernel release.