From: Alistair Popple <apopple@nvidia.com>
To: nova-gpu <nova-gpu@lists.linux.dev>
Cc: Alistair Popple <apopple@nvidia.com>,
M Henning <mhenning@darkrefraction.com>,
Danilo Krummrich <dakr@kernel.org>,
Alice Ryhl <aliceryhl@google.com>,
David Airlie <airlied@gmail.com>,
Alexandre Courbot <acourbot@nvidia.com>,
Benno Lossin <lossin@kernel.org>, Gary Guo <gary@garyguo.net>,
Eliot Courtney <ecourtney@nvidia.com>,
John Hubbard <jhubbard@nvidia.com>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
rust-for-linux@vger.kernel.org
Subject: [PATCH v5 05/11] drm: nova: Add an info ioctl
Date: Fri, 28 Aug 2026 13:35:25 +1000 [thread overview]
Message-ID: <20260828033531.1117754-6-apopple@nvidia.com> (raw)
In-Reply-To: <20260828033531.1117754-1-apopple@nvidia.com>
Add an extensible info ioctl and use it to report basic GPU information.
One of the first things userspace needs to know about a GPU is its
architecture and implementation, so add that as the first field in the
GPU info result.
The ioctl selects an information type by ID and writes the result through
a sized userspace buffer. The kernel truncates results to the supplied
size, allowing information structures to grow and new logical information
groups to be added without introducing new ioctls.
Signed-off-by: Alistair Popple <apopple@nvidia.com>
---
Changes since v4:
- Add a new info ioctl interface as suggested by Danilo
Changes since v3:
- New for v4 - chipid was previously returned as a GETPARAM parameter
---
drivers/gpu/drm/nova/driver.rs | 2 +-
drivers/gpu/drm/nova/file.rs | 57 ++++++++++++++++++++++++++++++++++
drivers/gpu/nova-core/api.rs | 15 +++++++--
drivers/gpu/nova-core/gpu.rs | 9 ++++--
include/uapi/drm/nova_drm.h | 49 +++++++++++++++++++++++++++++
5 files changed, 127 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/nova/driver.rs b/drivers/gpu/drm/nova/driver.rs
index 632137d1c6d7..38f82a7e1738 100644
--- a/drivers/gpu/drm/nova/driver.rs
+++ b/drivers/gpu/drm/nova/driver.rs
@@ -32,7 +32,6 @@ pub(crate) struct Nova<'bound> {
/// DRM registration data, accessible from ioctl handlers via the registration guard.
pub(crate) struct DrmRegData<'bound> {
- #[expect(unused)]
pub(crate) api: Pin<&'bound NovaCoreApi<'bound>>,
}
@@ -98,5 +97,6 @@ impl drm::Driver for NovaDriver {
(NOVA_GETPARAM, drm_nova_getparam, ioctl::RENDER_ALLOW, File::get_param),
(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),
}
}
diff --git a/drivers/gpu/drm/nova/file.rs b/drivers/gpu/drm/nova/file.rs
index 1156df51c533..097bf607485c 100644
--- a/drivers/gpu/drm/nova/file.rs
+++ b/drivers/gpu/drm/nova/file.rs
@@ -17,11 +17,45 @@
},
pci,
prelude::*,
+ transmute::AsBytes,
+ uaccess::UserSlice,
uapi,
};
pub(crate) struct File;
+/// GPU information returned to userspace.
+///
+/// # Invariants
+///
+/// - The layout of this type is identical to `struct drm_nova_gpu_info`.
+/// - All bytes in the value are initialized.
+#[repr(transparent)]
+struct GpuInfo(uapi::drm_nova_gpu_info);
+
+impl GpuInfo {
+ fn new(reg_data: &DrmRegData<'_>) -> Self {
+ Self(uapi::drm_nova_gpu_info {
+ architecture: reg_data.api.architecture(),
+ implementation: reg_data.api.implementation(),
+ })
+ }
+}
+
+// SAFETY: `GpuInfo` has no implicit padding, kernel pointers, or interior
+// mutability, and all of its fields are initialized before it is written to
+// userspace.
+unsafe impl AsBytes for GpuInfo {}
+
+fn write_info<T: AsBytes>(info: &mut uapi::drm_nova_info, value: &T) -> Result {
+ let mut writer =
+ UserSlice::new(UserPtr::from_addr(info.data as usize), info.size as usize).writer();
+
+ info.size = writer.write_truncated(value)? as u32;
+
+ Ok(())
+}
+
impl drm::file::DriverFile for File {
type Driver = NovaDriver;
@@ -78,4 +112,27 @@ pub(crate) fn gem_info(
Ok(0)
}
+
+ /// IOCTL: info: Query device information.
+ pub(crate) fn info(
+ _dev: &NovaDevice<Registered>,
+ reg_data: &DrmRegData<'_>,
+ info: &mut uapi::drm_nova_info,
+ _file: &drm::File<File>,
+ ) -> Result<u32> {
+ if info.data == 0 {
+ info.size = match info.id {
+ uapi::DRM_NOVA_INFO_GPU => size_of::<GpuInfo>() as u32,
+ _ => return Err(EINVAL),
+ };
+ return Ok(0);
+ }
+
+ match info.id {
+ uapi::DRM_NOVA_INFO_GPU => write_info(info, &GpuInfo::new(reg_data))?,
+ _ => return Err(EINVAL),
+ }
+
+ Ok(0)
+ }
}
diff --git a/drivers/gpu/nova-core/api.rs b/drivers/gpu/nova-core/api.rs
index 610cfc01111e..cff730a38c1d 100644
--- a/drivers/gpu/nova-core/api.rs
+++ b/drivers/gpu/nova-core/api.rs
@@ -12,11 +12,12 @@
types::CovariantForLt, //
};
-use crate::gpu::Gpu;
+use crate::gpu::{
+ Gpu, //
+};
/// API handle for the auxiliary bus child drivers to interact with nova-core.
pub struct NovaCoreApi<'bound> {
- #[expect(unused)]
pub(crate) gpu: Pin<&'bound Gpu<'bound>>,
}
@@ -26,4 +27,14 @@ impl NovaCoreApi<'_> {
pub fn of(adev: &auxiliary::Device<Bound>) -> Result<Pin<&NovaCoreApi<'_>>> {
adev.registration_data::<CovariantForLt!(NovaCoreApi<'_>)>()
}
+
+ /// Returns the architecture identifier of this GPU.
+ pub fn architecture(&self) -> u32 {
+ self.gpu.spec.chipset.arch() as u32
+ }
+
+ /// Returns the implementation identifier of this GPU.
+ pub fn implementation(&self) -> u32 {
+ self.gpu.spec.chipset.implementation()
+ }
}
diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
index 0c12ef145981..740466af268d 100644
--- a/drivers/gpu/nova-core/gpu.rs
+++ b/drivers/gpu/nova-core/gpu.rs
@@ -138,6 +138,11 @@ pub(crate) const fn arch(self) -> Architecture {
}
}
+ /// Returns the implementation identifier of this chipset.
+ pub(crate) const fn implementation(self) -> u32 {
+ self as u32 & 0xf
+ }
+
/// Returns the address range of the PCI config mirror space.
pub(crate) fn pci_config_mirror_range(self) -> Range<u32> {
hal::gpu_hal(self).pci_config_mirror_range()
@@ -198,7 +203,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// Structure holding a basic description of the GPU: `Chipset` and `Revision`.
#[derive(Clone, Copy)]
pub(crate) struct Spec {
- chipset: Chipset,
+ pub(crate) chipset: Chipset,
revision: Revision,
}
@@ -286,7 +291,7 @@ struct GspResources<'gpu> {
/// Structure holding the resources required to operate the GPU.
#[pin_data]
pub(crate) struct Gpu<'gpu> {
- spec: Spec,
+ pub(crate) spec: Spec,
/// Static GPU information as provided by the GSP.
gsp_static_info: GetGspStaticInfoReply,
/// GSP and its resources.
diff --git a/include/uapi/drm/nova_drm.h b/include/uapi/drm/nova_drm.h
index f0dcbca1908d..300285b520a3 100644
--- a/include/uapi/drm/nova_drm.h
+++ b/include/uapi/drm/nova_drm.h
@@ -92,9 +92,56 @@ struct drm_nova_gem_info {
__u64 size;
};
+/**
+ * struct drm_nova_info - query device information
+ */
+struct drm_nova_info {
+ /**
+ * @id: The identifier of the information to query.
+ */
+ __u32 id;
+
+ /**
+ * @size: The amount of space allocated by userspace at @data. The kernel
+ * will return the number of bytes it wrote.
+ */
+ __u32 size;
+
+ /**
+ * @data: Pointer to the userspace buffer into which the queried
+ * information will be written.
+ */
+ __u64 data;
+};
+
+/**
+ * DRM_NOVA_INFO_GPU
+ *
+ * Query GPU information. The result is returned in a
+ * &struct drm_nova_gpu_info.
+ */
+#define DRM_NOVA_INFO_GPU 0x00
+
+/**
+ * struct drm_nova_gpu_info - GPU information
+ */
+struct drm_nova_gpu_info {
+ /**
+ * @architecture: GPU architecture identifier. See
+ * &enum drm_nova_architecture for currently known architectures.
+ */
+ __u32 architecture;
+
+ /**
+ * @implementation: GPU implementation identifier.
+ */
+ __u32 implementation;
+};
+
#define DRM_NOVA_GETPARAM 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 {
@@ -104,6 +151,8 @@ enum {
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)
--
2.54.0
next prev parent reply other threads:[~2026-08-28 3:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 3:35 [PATCH v5 00/11] gpu: nova: Export parameters from nova-core to nova-drm Alistair Popple
2026-08-28 3:35 ` [PATCH v5 01/11] gpu: nova-core: Add public driver API to nova-core Alistair Popple
2026-08-28 3:35 ` [PATCH v5 02/11] drm: nova: Add DRM registration data Alistair Popple
2026-08-28 3:35 ` [PATCH v5 03/11] drm: nova: Add GPU architecture enum to nova-drm UAPI Alistair Popple
2026-08-28 3:35 ` [PATCH v5 04/11] rust: uaccess: add UserSliceWriter::write_truncated() Alistair Popple
2026-08-28 3:35 ` Alistair Popple [this message]
2026-08-28 3:35 ` [PATCH v5 06/11] drm: nova: Add usable VRAM size to GPU info Alistair Popple
2026-08-28 3:35 ` [PATCH v5 07/11] drm: nova: Use nova-core to read VRAM_BAR_SIZE parameter Alistair Popple
2026-08-28 3:35 ` [PATCH v5 08/11] drm: nova: Expose a render node Alistair Popple
2026-08-28 3:35 ` [PATCH v5 09/11] drm: nova: Report GPU name in GPU info Alistair Popple
2026-08-28 3:35 ` [PATCH v5 10/11] drm: nova: Report GPU short " Alistair Popple
2026-08-28 3:35 ` [PATCH v5 11/11] drm: nova: Report GPU GID " Alistair Popple
2026-08-28 6:04 ` [PATCH v5 00/11] gpu: nova: Export parameters from nova-core to nova-drm Alistair Popple
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=20260828033531.1117754-6-apopple@nvidia.com \
--to=apopple@nvidia.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mhenning@darkrefraction.com \
--cc=nova-gpu@lists.linux.dev \
--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 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.