gpu: nova: Export parameters from nova-core to nova-drm
Subsystems (6)
v4 cover gpu: nova: Export parameters from nova-core to nova-drm
This patch series adds some basic GPU properties via a new GPU info ioctl. It builds on top of the "drm: Higher-Ranked Lifetime private data" series[1] to correctly manage lifetimes of registration data shared between DRM, auxbus and nova-core. It's also based on top of "ForLt/CovariantForLt split, auxiliary closure API and DevresLt"[2] although the functionality of that series isn't actually required.
A tree with this series applied on top of all pre-requisites is available at [3].
Properties are exported via a new NovaCoreApi type which implements methods to read data from the GPU. This has been implemented in a separate module to make the public API implementations obvious and to keep them in one place. Auxiliary bus drivers can obtain a handle to this type using NovaCoreApi::of().
This handle can then be stored as part of the DRM registration data and used to interact with the GPU via the nova-core driver.
Changes since v3:
- Use an ioctl to return all parameters rather than multiple key/value queries
Changes since v2:
- Addressed review Danilo and Alex
- Minor renames to better align with HW based on internal feedback
Changes since v1:
- Address review comments from Danilo
- Add an API call to read VRAM PCI BAR size using nova-core
[1] - https://lore.kernel.org/rust-for-linux/[email protected]/
[2] - https://lore.kernel.org/driver-core/[email protected]/
[3] - https://github.com/apopple-nvidia/linux/tree/nova-drm
Alistair Popple (7):
gpu: nova-core: Add public driver API to nova-core
drm: nova: Add DRM registration data
drm: nova: Add chipid enum to nova-drm UAPI
drm: nova: Add a GPU info ioctl
drm: nova: Add usable VRAM size to GPU info ioctl
drm: nova: Use nova-core to read VRAM_BAR_SIZE parameter
drm: nova: Expose a render node
drivers/gpu/drm/nova/driver.rs | 18 ++++++- drivers/gpu/drm/nova/file.rs | 40 +++++++++----- drivers/gpu/nova-core/api.rs | 49 +++++++++++++++++ drivers/gpu/nova-core/driver.rs | 44 +++++++++++---- drivers/gpu/nova-core/gpu.rs | 78 ++++++++++++++------------- drivers/gpu/nova-core/gsp/commands.rs | 8 +++ drivers/gpu/nova-core/gsp/hal.rs | 2 +- drivers/gpu/nova-core/nova_core.rs | 1 + include/uapi/drm/nova_drm.h | 71 ++++++++++++++++++++++++ 9 files changed, 247 insertions(+), 64 deletions(-) create mode 100644 drivers/gpu/nova-core/api.rs
Signature · 1 line
2.54.0
PATCH v4 1/7 gpu: nova-core: Add public driver API to nova-core
Nova core will be used to export core functionality to other drivers which will bind to it via auxiliary bus devices. Add a NovaCoreApi type which drivers can use to call nova-core methods.
Auxiliary bus drivers can obtain a handle to call nova-core methods on a particular GPU using NovaCoreApi::of(). This takes a reference to a bound auxiliary bus device and returns a handle to NovaCoreApi.
---
Changes since v2:
- Add accidentally dropped TODO comment
Changes since v1:
- Rework unsafe pin-init to make safety comments clearer, suggested by Danilo.
- s/allow(dead_code)/expect(unused)/
--- drivers/gpu/nova-core/api.rs | 29 ++++++++++++++++++++ drivers/gpu/nova-core/driver.rs | 44 ++++++++++++++++++++++-------- drivers/gpu/nova-core/gsp/hal.rs | 2 +- drivers/gpu/nova-core/nova_core.rs | 1 + 4 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 drivers/gpu/nova-core/api.rs
drivers/gpu/nova-core/api.rs new file +29 -0
@@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 + +//! Nova-core auxbus data. Contains all the methods used by the auxbus drivers +//! to interact with nova-core. + +use core::pin::Pin ; + +use kernel::{ + auxiliary, + device::Bound , + prelude::*, + types::CovariantForLt ,// +}; + +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 <&'boundGpu <'bound>>, +} + +impl NovaCoreApi <'_> { +/// Obtain a [`NovaCoreApi`] handle from an auxiliary device registered +/// by nova-core. +pub fn of (adev: &auxiliary::Device <Bound >) ->Result <Pin <&NovaCoreApi <'_>>> { + adev.registration_data ::<CovariantForLt! (NovaCoreApi <'_>)>() + } +}
drivers/gpu/nova-core/driver.rs +33 -11
65 lines not on this page · raw message
drivers/gpu/nova-core/gsp/hal.rs +1 -1
@@ -29,7 +29,7 @@/// The GSP unload code might run in a situation where we cannot load firmware dynamically (e.g. /// because we are in shutdown and the file system is not accessible anymore). Thus, the firmware /// required for unloading is prepared at load time, and stored here until it needs to be run. -pub (super )trait UnloadBundle :Send { +pub (super )trait UnloadBundle :Send +Sync {/// Performs the steps required to properly reset the GSP after it has been stopped. fn run (&self, ctx: &mut GspBootContext <'_, '_>) ->Result ; }
drivers/gpu/nova-core/nova_core.rs +1 -0
@@ -10,6 +10,7 @@ InPlaceModule, // }; +pub mod api;mod driver;mod falcon;mod fb;
Signature · 1 line
2.54.0
PATCH v4 2/7 drm: nova: Add DRM registration data
In reply to Alistair PoppleCurrently the nova-drm stub driver doesn't really interact with a real device, so it doesn't have any registration data and has no way to call into nova-core.
To allow for this add a DrmRegData type which will hold a reference to the NovaCoreApi associated with the auxbus device.
---
Changes from v2:
- Add newline in crate import
Changes from v1:
- Drop unrelated device::Bound removal.
- Switch exisiting import to vertical style.
- s/allow(dead_code)/expect(unused)/
--- drivers/gpu/drm/nova/driver.rs | 17 +++++++++++++++-- drivers/gpu/drm/nova/file.rs | 12 ++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-)
drivers/gpu/drm/nova/driver.rs +15 -2
@@ -1,5 +1,7 @@// SPDX-License-Identifier: GPL-2.0 +use core::pin::Pin ; +use kernel::{ auxiliary, device::{
@@ -18,6 +20,8 @@use crate ::file::File ;use crate ::gem::NovaObject ; +use nova_core::api::NovaCoreApi ; +pub (crate )struct NovaDriver ;pub (crate )struct Nova <'bound> {
@@ -26,6 +30,12 @@ pub(crate) struct Nova<'bound> { _reg: drm::Registration<'bound, NovaDriver>, } +/// DRM registration data, accessible from ioctl handlers via the registration guard. +pub (crate )struct DrmRegData <'bound> { +#[expect(unused)] +pub (crate ) api:Pin <&'boundNovaCoreApi <'bound>>, +} +/// Convienence type alias for the DRM device type for this driver pub (crate )type NovaDevice <Ctx = drm::Normal > = drm::Device <NovaDriver ,Ctx >;
@@ -60,9 +70,12 @@ fn probe<'bound>( _info: &'bound Self::IdInfo, ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {let drm = drm::UnregisteredDevice ::<Self >::new (adev,Ok (()))?; +let reg_data =DrmRegData { + api:NovaCoreApi ::of (adev)?, + };// SAFETY: `reg` is stored in `Nova` and dropped when the driver is unbound; it is // never forgotten. -let reg =unsafe { drm::Registration ::new (adev.as_ref (), drm, (),0 )? }; +let reg =unsafe { drm::Registration ::new (adev.as_ref (), drm, reg_data,0 )? }; Ok(Nova { drm: reg.device().into(),
@@ -74,7 +87,7 @@ fn probe<'bound>(#[vtable] impl drm::Driver for NovaDriver {type Data = (); -type RegistrationData <'a> = (); +type RegistrationData <'a> =DrmRegData <'a>;type File =File ;type Object = gem::Object <NovaObject >;type ParentDevice <Ctx :DeviceContext > = auxiliary::Device <Ctx >;
drivers/gpu/drm/nova/file.rs +8 -4
@@ -1,6 +1,10 @@// SPDX-License-Identifier: GPL-2.0 -use crate ::driver::{NovaDevice ,NovaDriver }; +use crate ::driver::{ +DrmRegData , +NovaDevice , +NovaDriver ,// +};use crate ::gem::NovaObject ;use kernel::{ alloc::flags::*,
@@ -30,7 +34,7 @@ impl File {/// IOCTL: get_param: Query GPU / driver metadata. pub (crate )fn get_param ( dev: &NovaDevice <Registered >, - _reg_data: &(), + _reg_data: &DrmRegData <'_>, getparam: &mut uapi::drm_nova_getparam , _file: &drm::File <File >, ) ->Result <u32 > {
@@ -50,7 +54,7 @@ pub(crate) fn get_param(/// IOCTL: gem_create: Create a new DRM GEM object. pub (crate )fn gem_create ( dev: &NovaDevice <Registered >, - _reg_data: &(), + _reg_data: &DrmRegData <'_>, req: &mut uapi::drm_nova_gem_create , file: &drm::File <File >, ) ->Result <u32 > {
@@ -64,7 +68,7 @@ pub(crate) fn gem_create(/// IOCTL: gem_info: Query GEM metadata. pub (crate )fn gem_info ( _dev: &NovaDevice <Registered >, - _reg_data: &(), + _reg_data: &DrmRegData <'_>, req: &mut uapi::drm_nova_gem_info , file: &drm::File <File >, ) ->Result <u32 > {
Signature · 1 line
2.54.0
PATCH v4 3/7 drm: nova: Add chipid enum to nova-drm UAPI
In reply to Alistair PoppleThe chipid contains the GPU architecture and implementation and needs to be exposed to user-space. This adds a public enum to the userspace headers for each chip ID. Nova-core can then use this enum to define its chipsets.
This does create a coupling between nova-drm and nova-core whereby nova-core depends on the values defined by the user-space API for nova-drm. However this is entirely appropriate as nova-core must be bound by the UAPI headers as the enum values are read by nova-core and passed through to user-space.
Note that nova-core currently refers to the chipid as a chipset. This isn't ideal given that chipid is the preferred and more accurate term and is what should be exposed via the uAPI. Therefore a future patch series will be posted that aligns nova-core internals to using chipid rather than chipset.
---
Changes since v3:
- New for v4, split out from "drm: nova: Add GETPARAM parameter to read the GPU chipset"
--- drivers/gpu/nova-core/gpu.rs | 64 +++++++++++++++++++----------------- include/uapi/drm/nova_drm.h | 38 +++++++++++++++++++++ 2 files changed, 72 insertions(+), 30 deletions(-)
drivers/gpu/nova-core/gpu.rs +34 -30
@@ -10,7 +10,8 @@ num::Bounded, pci, prelude::*, - sizes::SizeConstants, // + sizes::SizeConstants, + uapi, // };use crate ::{
@@ -35,12 +36,13 @@mod hal;macro_rules! define_chipset { - ({ $($variant:ident = $value:expr),* $(,)* }) => + ({ $($variant:ident),* $(,)* }) => { + ::kernel::macros::paste!(/// Enum representation of the GPU chipset. #[derive(fmt:: Debug , Copy , Clone , PartialOrd , Ord , PartialEq , Eq )] pub(crate) enum Chipset { - $($variant = $value),*, + $($variant =uapi ::[<drm_nova_chipid_NOVA_DRM_CHIPID_ $variant:upper >]as isize ),*, }impl Chipset {
@@ -48,7 +50,6 @@ impl Chipset { $( Chipset::$variant, )* ]; - ::kernel::macros::paste!(/// Returns the name of this chipset, in lowercase. /// /// # Examples
@@ -64,7 +65,6 @@ pub(crate) const fn name(&self) -> &'static str { )* } } - ); }// TODO[FPRI]: replace with something like derive(FromPrimitive)
@@ -73,45 +73,49 @@ impl TryFrom<u32> for Chipset {fn try_from (value:u32 ) ->Result <Self ,Self ::Error > { match value { - $( $value => Ok(Chipset::$variant), )* + $( + uapi::[<drm_nova_chipid_NOVA_DRM_CHIPID_ $variant:upper>] + => Ok(Chipset::$variant), + )* _ => Err(ENODEV), } } } + ); } }define_chipset! ({// Turing -TU102 =0x162 , -TU104 =0x164 , -TU106 =0x166 , -TU117 =0x167 , -TU116 =0x168 , +TU102 , +TU104 , +TU106 , +TU117 , +TU116 ,// Ampere -GA100 =0x170 , -GA102 =0x172 , -GA103 =0x173 , -GA104 =0x174 , -GA106 =0x176 , -GA107 =0x177 , +GA100 , +GA102 , +GA103 , +GA104 , +GA106 , +GA107 ,// Hopper -GH100 =0x180 , +GH100 ,// Ada -AD102 =0x192 , -AD103 =0x193 , -AD104 =0x194 , -AD106 =0x196 , -AD107 =0x197 , +AD102 , +AD103 , +AD104 , +AD106 , +AD107 ,// Blackwell GB10x -GB100 =0x1a0 , -GB102 =0x1a2 , +GB100 , +GB102 ,// Blackwell GB20x -GB202 =0x1b2 , -GB203 =0x1b3 , -GB205 =0x1b5 , -GB206 =0x1b6 , -GB207 =0x1b7 , +GB202 , +GB203 , +GB205 , +GB206 , +GB207 , }); impl Chipset {
include/uapi/drm/nova_drm.h +38 -0
@@ -25,6 +25,44 @@ extern "C" {*/ #define NOVA_GETPARAM_VRAM_BAR_SIZE 0x1 +/* +* Opaque chipids. These may be used to determine what chip a particular GPU is +* based on the identifier but the values themselves should not be assumed to +* carry any particular meaning. +*/ +enum drm_nova_chipid { +/* Turing */ +NOVA_DRM_CHIPID_TU102 =0x162 , +NOVA_DRM_CHIPID_TU104 =0x164 , +NOVA_DRM_CHIPID_TU106 =0x166 , +NOVA_DRM_CHIPID_TU117 =0x167 , +NOVA_DRM_CHIPID_TU116 =0x168 , +/* Ampere */ +NOVA_DRM_CHIPID_GA100 =0x170 , +NOVA_DRM_CHIPID_GA102 =0x172 , +NOVA_DRM_CHIPID_GA103 =0x173 , +NOVA_DRM_CHIPID_GA104 =0x174 , +NOVA_DRM_CHIPID_GA106 =0x176 , +NOVA_DRM_CHIPID_GA107 =0x177 , +/* Hopper */ +NOVA_DRM_CHIPID_GH100 =0x180 , +/* Ada */ +NOVA_DRM_CHIPID_AD102 =0x192 , +NOVA_DRM_CHIPID_AD103 =0x193 , +NOVA_DRM_CHIPID_AD104 =0x194 , +NOVA_DRM_CHIPID_AD106 =0x196 , +NOVA_DRM_CHIPID_AD107 =0x197 , +/* Blackwell GB10x */ +NOVA_DRM_CHIPID_GB100 =0x1a0 , +NOVA_DRM_CHIPID_GB102 =0x1a2 , +/* Blackwell GB20x */ +NOVA_DRM_CHIPID_GB202 =0x1b2 , +NOVA_DRM_CHIPID_GB203 =0x1b3 , +NOVA_DRM_CHIPID_GB205 =0x1b5 , +NOVA_DRM_CHIPID_GB206 =0x1b6 , +NOVA_DRM_CHIPID_GB207 =0x1b7 , +}; +/** * struct drm_nova_getparam - query GPU and driver metadata */
Signature · 1 line
2.54.0
Re: [PATCH v4 3/7] drm: nova: Add chipid enum to nova-drm UAPI
Quoted 5 lines · Alistair Popple
+/*
+ * Opaque chipids. These may be used to determine what chip a particular GPU is
+ * based on the identifier but the values themselves should not be assumed to
+ * carry any particular meaning.
+ */
You say this is opaque, but the userspace MR you posted already treats the values as non-opaque in eg. sm_for_chipset.
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/43352/diffs?commit_id=945a8e7c51939577526974b342c8dc6bafc3372f
So, I guess my question is, is is opaque or not?
I don't see much of a reason to make it opaque since the chipset has had the same structure on the hardware level for 30 years, so I don't expect it to change too often. Truly treating this as opaque would likely require a small refactor on the userspace side without much value. (I realize this has already been discussed a bit on the previous version.)
Danilo Krummrich
maintainerRe: [PATCH v4 3/7] drm: nova: Add chipid enum to nova-drm UAPI
Quoted 11 lines · M Henning
Quoted 5 lines · Alistair Popple
+/*
+ * Opaque chipids. These may be used to determine what chip a particular GPU is
+ * based on the identifier but the values themselves should not be assumed to
+ * carry any particular meaning.
+ */You say this is opaque, but the userspace MR you posted already treats the values as non-opaque in eg.
sm_for_chipset.
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/43352/diffs?commit_id=945a8e7c51939577526974b342c8dc6bafc3372f
So, I guess my question is, is is opaque or not?
The PR is outdated and goes back to the first version of this patch series; what's written here is correct.
Quoted 6 lines
I don't see much of a reason to make it opaque since the chipset has had the same structure on the hardware level for 30 years, so I don't expect it to change too often. Truly treating this as opaque would likely require a small refactor on the userspace side without much value. (I realize this has already been discussed a bit on the previous version.)
I don't see much value in having userspace decode this value (again) after the kernel did it already and can easily provide the required information without making userspace commit to some encoding in the hardware (even though I do agree that it is unlikely).
OTH, the way chip IDs are derived has changed over the years (BOOT_0 / BOOT_42 with different register layouts), and I'd rather not have userspace commit to any particular encoding when the kernel already provides the decoded information.
Regarding the refactor in mesa, the Nova uAPI won't follow nouveau anyway, so I don't want to limit ourselfs here.
Re: [PATCH v4 3/7] drm: nova: Add chipid enum to nova-drm UAPI
On 2026-08-25 at 05:24 +1000, Danilo Krummrich <[email protected]> wrote...
Quoted 8 lines · M Henning
Quoted 7 lines · Alistair Popple
Quoted 5 lines
+/*
+ * Opaque chipids. These may be used to determine what chip a particular GPU is
+ * based on the identifier but the values themselves should not be assumed to
+ * carry any particular meaning.
+ */
Quoted 7 lines
Quoted 4 lines
You say this is opaque, but the userspace MR you posted already treats the values as non-opaque in eg.
sm_for_chipset.
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/43352/diffs?commit_id=945a8e7c51939577526974b342c8dc6bafc3372f
So, I guess my question is, is is opaque or not?The PR is outdated and goes back to the first version of this patch series; what's written here is correct.
Right - I was holding off on updating the PR until we'd settled on the UAPI here.
Quoted 12 lines
Quoted 6 lines
I don't see much of a reason to make it opaque since the chipset has had the same structure on the hardware level for 30 years, so I don't expect it to change too often. Truly treating this as opaque would likely require a small refactor on the userspace side without much value. (I realize this has already been discussed a bit on the previous version.)
I don't see much value in having userspace decode this value (again) after the kernel did it already and can easily provide the required information without making userspace commit to some encoding in the hardware (even though I do agree that it is unlikely).
Quoted 7 lines
OTH, the way chip IDs are derived has changed over the years (
BOOT_0/BOOT_42with different register layouts), and I'd rather not have userspace commit to any particular encoding when the kernel already provides the decoded information.Regarding the refactor in mesa, the Nova uAPI won't follow nouveau anyway, so I don't want to limit ourselfs here.
I'm not particularly wedded to either approach but I think the approach is either:
1) Keep the chip_id opaque, user-space looks up arch/implementation/etc. from a lookup table as required.
2) Keep the current scheme of just exposing the chip_id and letting user-space decode it assuming the register layout won't change.
In either case user-space needs to figure out arch/implementation/etc.
For (1) the kernel should not be responsible for decoding arch because if you're assuming the register layout can change arbitrarily then the it can't reliably figure out the arch anyway. For example if someone plugs a shiny new card with a different chip_id register layout into a machine running an older kernel they could get an incorrect arch which would be confusing. Users would get upset if for example ShinyNewCard got reported as being Turing say.
So I think it makes sense to keep this decoding in user-space regardless of whether that's exposed via documented opaque chip IDs and lookup tables for arch/implementation or by a commitment to keep the chip ID register layout the same.
Either of 1 or 2 seems fine to me.
- Alistair
Re: [PATCH v4 3/7] drm: nova: Add chipid enum to nova-drm UAPI
On 2026-08-25 at 17:13 +1000, Alistair Popple <[email protected]> wrote...
Quoted 14 lines
On 2026-08-25 at 05:24 +1000, Danilo Krummrich <[email protected]> wrote...
Quoted 13 lines · M Henning
Quoted 11 lines · Alistair Popple
Quoted 5 lines
+/*
+ * Opaque chipids. These may be used to determine what chip a particular GPU is
+ * based on the identifier but the values themselves should not be assumed to
+ * carry any particular meaning.
+ */You say this is opaque, but the userspace MR you posted already treats the values as non-opaque in eg.
sm_for_chipset.
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/43352/diffs?commit_id=945a8e7c51939577526974b342c8dc6bafc3372f
So, I guess my question is, is is opaque or not?
Quoted 17 lines
Quoted 2 lines
The PR is outdated and goes back to the first version of this patch series; what's written here is correct.
Right - I was holding off on updating the PR until we'd settled on the UAPI here.
Quoted 11 lines
Quoted 6 lines
I don't see much of a reason to make it opaque since the chipset has had the same structure on the hardware level for 30 years, so I don't expect it to change too often. Truly treating this as opaque would likely require a small refactor on the userspace side without much value. (I realize this has already been discussed a bit on the previous version.)
I don't see much value in having userspace decode this value (again) after the kernel did it already and can easily provide the required information without making userspace commit to some encoding in the hardware (even though I do agree that it is unlikely).
Userspace has to commit to some kind of encoding about HW though. If we're going to assume everything and anything about HW can change there's also no reason to assume HW would continue using a chip architecture and a chip implementation as having any meaning at all.
Quoted 7 lines
Quoted 7 lines
OTH, the way chip IDs are derived has changed over the years (
BOOT_0/BOOT_42with different register layouts), and I'd rather not have userspace commit to any particular encoding when the kernel already provides the decoded information.Regarding the refactor in mesa, the Nova uAPI won't follow nouveau anyway, so I don't want to limit ourselfs here.
On the other hand we don't need to ignore the lessons of Nouveau either and try and refactor everything - I agree there are plenty of UAPI choices that should and will be different and we shouldn't limit ourselves - but if an interface has been working well for 30 years and hasn't been causing anyone any issues then perhaps we should just stick with it for Nova as well?
Quoted 10 lines
I'm not particularly wedded to either approach but I think the approach is either:
1) Keep the
chip_idopaque, user-space looks uparch/implementation/etc. from a lookup table as required.2) Keep the current scheme of just exposing the
chip_idand letting user-space decode it assuming the register layout won't change.
Quoted 8 lines
In either case user-space needs to figure out
arch/implementation/etc.For (1) the kernel should not be responsible for decoding arch because if you're assuming the register layout can change arbitrarily then the it can't reliably figure out the arch anyway. For example if someone plugs a shiny new card with a different
chip_idregister layout into a machine running an older kernel they could get an incorrect arch which would be confusing. Users would get upset if for example ShinyNewCard got reported as being Turing say.
Thinking about this some more I think I conflated the architecutre and implementation a bit. A new arch would _probably_ require other driver changes anyway, so perhaps my example is a little contrived. The point I was trying to make was that requiring backporting of kernel patches and forced driver upgrades just to get a new impl (or maybe arch) decoding would be unfortunate.
We may well never get to the point of being able to have a (slightly) older driver support a new impl, but I still think it would be best not to bake that requirement in.
Quoted 7 lines
So I think it makes sense to keep this decoding in user-space regardless of whether that's exposed via documented opaque chip IDs and lookup tables for
arch/implementationor by a commitment to keep the chip ID register layout the same.Either of 1 or 2 seems fine to me.
- Alistair
Danilo Krummrich
maintainerRe: [PATCH v4 3/7] drm: nova: Add chipid enum to nova-drm UAPI
Quoted 5 lines · Alistair Popple
On the other hand we don't need to ignore the lessons of Nouveau either and try and refactor everything - I agree there are plenty of UAPI choices that should and will be different and we shouldn't limit ourselves - but if an interface has been working well for 30 years and hasn't been causing anyone any issues then perhaps we should just stick with it for Nova as well?
IMO this answers the wrong question; I think the questions should be:
- Why should we expose an encoded register value to userspace now that we have the chance to not do so and hide that implementation detail?
- What happens if it ever breaks?
As for the first one, I don't really see how it is a benefit to let userspace decode it independently. It's better to have a single source of truth.
Besides that, we may also need to expose the chip major/minor revision at some point, which can't be decoded from the chipid value. For this we'd need to expose the full BOOT_42 register. Which is where we already have a precedent where things changed from BOOT_0 in the past.
More in general, passing encoded values from registers to userspace isn't the best practice.
Of course, userspace has to know about how the hardware works - I mean, that's why we expose chipid, arch, etc. in the first place - but it doesn't (and shouldn't) need to know how the parts work the kernel is responsible for.
Danilo Krummrich
maintainerRe: [PATCH v4 3/7] drm: nova: Add chipid enum to nova-drm UAPI
In reply to Alistair PoppleQuoted 5 lines · Alistair Popple
I'm not particularly wedded to either approach but I think the approach is either:
1) Keep the
chip_idopaque, user-space looks uparch/implementation/etc. from a lookup table as required.
Why? The kernel already has the information, so we don't need a lookup table?
Quoted 8 lines
2) Keep the current scheme of just exposing the
chip_idand letting user-space decode it assuming the register layout won't change.In either case user-space needs to figure out
arch/implementation/etc.For (1) the kernel should not be responsible for decoding arch because if you're assuming the register layout can change arbitrarily then the it can't reliably figure out the arch anyway.
If the kernel can't figure out the architecture of a card, it means that the chip isn't known by the kernel. Without that, how can it boot the firmware, etc.?
Quoted 4 lines
For example if someone plugs a shiny new card with a different
chip_idregister layout into a machine running an older kernel they could get an incorrect arch which would be confusing. Users would get upset if for example ShinyNewCard got reported as being Turing say.
If the kernel can't deal with a chip it should never succeed probing and never expose any information to userspace in the first place.
nova-core does enforce this already; if a chipid can't be matched against an architecture it won't compile, and if the chipid is not known by nova-core it will fail to probe.
Note that nova-core binds by vendor + class, not specific PCI device IDs, so the chipset check is our only gate against unknown hardware.
If we'd hypothetically remove that gate and just allow trying to probe unknown hardware with the boot sequence of just assuming some default with the latest supported architecture, it would potentially be an even worse user experience, where instead of a clear rejection of the hardware a user might experience security/stability issues.
Quoted 4 lines
So I think it makes sense to keep this decoding in user-space regardless of whether that's exposed via documented opaque chip IDs and lookup tables for
arch/implementationor by a commitment to keep the chip ID register layout the same.
I still don't see much value in letting userspace decode this again, nor do I think lookup tables are necessary.
If the driver succeeds to probe for a device we already did decode things, so there's no need for userspace to do it again or know about this.
Re: [PATCH v4 3/7] drm: nova: Add chipid enum to nova-drm UAPI
Quoted 1 line · Danilo Krummrich
On Tue Aug 25, 2026 at 9:13 AM CEST, Alistair Popple wrote:
...>> For example if someone plugs a shiny new card with a different chip_id
Quoted 6 lines
Quoted 3 lines
register layout into a machine running an older kernel they could get an incorrect arch which would be confusing. Users would get upset if for example ShinyNewCard got reported as being Turing say.
If the kernel can't deal with a chip it should never succeed probing and never expose any information to userspace in the first place.
Agreed.
We had also some discussion about this point during the BOOT0/BOOT42 change-over. And we arrived at that same conclusion back then: don't let PCI probe succeed on an unknown new chip.
Quoted 19 lines
nova-core does enforce this already; if a chipid can't be matched against an architecture it won't compile, and if the chipid is not known by nova-core it will fail to probe.
Note that nova-core binds by vendor + class, not specific PCI device IDs, so the chipset check is our only gate against unknown hardware.
If we'd hypothetically remove that gate and just allow trying to probe unknown hardware with the boot sequence of just assuming some default with the latest supported architecture, it would potentially be an even worse user experience, where instead of a clear rejection of the hardware a user might experience
security/stabilityissues.Quoted 4 lines
So I think it makes sense to keep this decoding in user-space regardless of whether that's exposed via documented opaque chip IDs and lookup tables for
arch/implementationor by a commitment to keep the chip ID register layout the same.
Quoted 5 lines
I still don't see much value in letting userspace decode this again, nor do I think lookup tables are necessary.
If the driver succeeds to probe for a device we already did decode things, so there's no need for userspace to do it again or know about this.
Also agreed here. It's hard to see any advantage in decoding in both user space and kernel.
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH v4 3/7] drm: nova: Add chipid enum to nova-drm UAPI
On 2026-08-26 at 07:13 +1000, John Hubbard <[email protected]> wrote...
Quoted 7 lines · Danilo Krummrich
Quoted 1 line · Alistair Popple
...>> For example if someone plugs a shiny new card with a different
chip_idQuoted 4 lines
Quoted 3 lines
register layout into a machine running an older kernel they could get an incorrect arch which would be confusing. Users would get upset if for example ShinyNewCard got reported as being Turing say.
Quoted 8 lines
Quoted 2 lines
If the kernel can't deal with a chip it should never succeed probing and never expose any information to userspace in the first place.
Agreed.
We had also some discussion about this point during the BOOT0/BOOT42 change-over. And we arrived at that same conclusion back then: don't let PCI probe succeed on an unknown new chip.
Ok. I thought maybe with GSP providing a lot of the HW abstraction we might have been going somewhat in that direction. It's something I've seen done well in the past on other products.
Quoted 5 lines
Quoted 5 lines
nova-core does enforce this already; if a chipid can't be matched against an architecture it won't compile, and if the chipid is not known by nova-core it will fail to probe.
Quoted 8 lines
Quoted 8 lines
Note that nova-core binds by vendor + class, not specific PCI device IDs, so the chipset check is our only gate against unknown hardware.
If we'd hypothetically remove that gate and just allow trying to probe unknown hardware with the boot sequence of just assuming some default with the latest supported architecture, it would potentially be an even worse user experience, where instead of a clear rejection of the hardware a user might experience
security/stabilityissues.
With careful design it can work, but you're right that probably isn't something we're doing or want here and would make the experience worse.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
So I think it makes sense to keep this decoding in user-space regardless of whether that's exposed via documented opaque chip IDs and lookup tables for
arch/implementationor by a commitment to keep the chip ID register layout the same.
Quoted 8 lines
Quoted 5 lines
I still don't see much value in letting userspace decode this again, nor do I think lookup tables are necessary.
If the driver succeeds to probe for a device we already did decode things, so there's no need for userspace to do it again or know about this.
Also agreed here. It's hard to see any advantage in decoding in both user space and kernel.
Sure. Two questions:
1) Do we also need to provide the decoded implementation value?
2) If we provide the decoded values why do we need to expose the chip-id at all?
Thanks.
- Alistair
Quoted 4 lines
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH v4 3/7] drm: nova: Add chipid enum to nova-drm UAPI
Quoted 7 lines · Alistair Popple
On 2026-08-26 at 07:13 +1000, John Hubbard <[email protected]> wrote...
Quoted 3 lines · Danilo Krummrich
Quoted 1 line · Alistair Popple
...
Sure. Two questions:
1) Do we also need to provide the decoded implementation value?
User space needs to:
a) Know enough about the GPU to be able to choose an SM version (and probably a few other things) which in turn is eventually required in order to run GPU programs, as shown in your merge request[1].
b) Display GPU information to the user.
c) I'm sure to be overlooking something.
Quoted 1 line
2) If we provide the decoded values why do we need to expose the chip-id at all?
OK, so maybe we don't?
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH v4 3/7] drm: nova: Add chipid enum to nova-drm UAPI
On 2026-08-26 at 11:41 +1000, John Hubbard <[email protected]> wrote...
Quoted 7 lines · Alistair Popple
Quoted 6 lines
On 2026-08-26 at 07:13 +1000, John Hubbard <[email protected]> wrote...
Quoted 3 lines · Danilo Krummrich
Quoted 1 line · Alistair Popple
...
Sure. Two questions:
Quoted 7 lines
Quoted 1 line
1) Do we also need to provide the decoded implementation value?
User space needs to:
a) Know enough about the GPU to be able to choose an SM version (and probably a few other things) which in turn is eventually required in order to run GPU programs, as shown in your merge request[1].
Right - currently that comes from either chip-id lookup table or direct decoding of the chip-id (although [1] doesn't currently look at it). If we're not going to allow either of those for architecture it doesn't make sense to need it for implementation either. IOW I think kernel should provide the decoded value for implementation too.
Quoted 6 lines
b) Display GPU information to the user.
c) I'm sure to be overlooking something.
Quoted 1 line
2) If we provide the decoded values why do we need to expose the chip-id at all?
OK, so maybe we don't?
Yeah, I agree. Doesn't make sense to if we're going to do the decoding in the kernel.
- Alistair
Quoted 6 lines
thanks,
Signature · 1 line
John Hubbard
PATCH v4 4/7 drm: nova: Add a GPU info ioctl
In reply to Alistair PoppleAdd an ioctl to read basic GPU information. One of the first things a user needs to know about a GPU is its chipid, so add that as the first piece of information to return.
Other bits of information will be added over time. To facilitate this the gpu info struct contains a size field to indicate how much of the struct the kernel has filled in. A user passing in a larger struct will just get a subset of the fields supported by the kernel returned. Users passing a smaller struct than supported will just get fields truncated.
This also allows a user to probe the size of the required struct so long as the data struct passed in is large enough to hold the size.
---
Changes since v3:
- New for v4 - was previously returned as a GETPARAM parameter
--- drivers/gpu/drm/nova/driver.rs | 2 +- drivers/gpu/drm/nova/file.rs | 17 +++++++++++++++++ drivers/gpu/nova-core/api.rs | 11 +++++++++-- drivers/gpu/nova-core/gpu.rs | 8 ++++---- include/uapi/drm/nova_drm.h | 27 +++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 7 deletions(-)
drivers/gpu/drm/nova/driver.rs +1 -1
@@ -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 <&'boundNovaCoreApi <'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_GPU_INFO, drm_nova_gpu_info, ioctl::RENDER_ALLOW, File::gpu_info), } }
drivers/gpu/drm/nova/file.rs +17 -0
@@ -78,4 +78,21 @@ pub(crate) fn gem_info(Ok (0 ) } + +/// IOCTL: gpu_info: Query GPU info. +pub (crate )fn gpu_info ( + _dev: &NovaDevice <Registered >, + reg_data: &DrmRegData <'_>, + gpu_info: &mut uapi::drm_nova_gpu_info , + _file: &drm::File <File >, + ) ->Result <u32 > { +if gpu_info.pad !=0 { +return Err (EINVAL ); + } + + gpu_info.size =size_of ::<uapi::drm_nova_gpu_info >()as u64 ; + gpu_info.chipid = reg_data.api.chipset ()as u32 ; + +Ok (0 ) + } }
drivers/gpu/nova-core/api.rs +9 -2
@@ -12,11 +12,13 @@ types::CovariantForLt, // }; -use crate ::gpu::Gpu ; +use crate ::gpu::{ +Chipset , +Gpu ,// +};/// API handle for the auxiliary bus child drivers to interact with nova-core. pub struct NovaCoreApi <'bound> { -#[expect(unused)] pub (crate ) gpu:Pin <&'boundGpu <'bound>>, }
@@ -26,4 +28,9 @@ impl NovaCoreApi<'_> {pub fn of (adev: &auxiliary::Device <Bound >) ->Result <Pin <&NovaCoreApi <'_>>> { adev.registration_data ::<CovariantForLt! (NovaCoreApi <'_>)>() } + +/// Returns the chipset of this GPU. +pub fn chipset (&self) ->Chipset { + self.gpu.spec.chipset + } }
drivers/gpu/nova-core/gpu.rs +4 -4
@@ -41,7 +41,7 @@ macro_rules! define_chipset { ::kernel::macros::paste!(/// Enum representation of the GPU chipset. #[derive(fmt:: Debug , Copy , Clone , PartialOrd , Ord , PartialEq , Eq )] - pub(crate) enum Chipset { +pub enum Chipset { $($variant =uapi ::[<drm_nova_chipid_NOVA_DRM_CHIPID_ $variant:upper >]as isize ),*, }
@@ -161,7 +161,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {bounded_enum! {/// Enum representation of the GPU generation. #[derive(fmt:: Debug , Copy , Clone )] -pub (crate )enum Architecture withTryFrom <Bounded <u32 ,6 >> { +pub enum Architecture withTryFrom <Bounded <u32 ,6 >> {Turing =0x16 ,Ampere =0x17 ,Hopper =0x18 ,
@@ -195,7 +195,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 , }
@@ -281,7 +281,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.
include/uapi/drm/nova_drm.h +27 -0
@@ -118,9 +118,34 @@ struct drm_nova_gem_info {__u64 size; }; +/** +* struct drm_nova_gpu_info - query DRM GPU info. +*/ +struct drm_nova_gpu_info { +/** +* @size: The amount of space allocated by userspace for this structure. +* The kernel will return the amount of data it did/could actually write. +* User space can use this to determine how much of the struct is valid +* when running against an older kernel. +*/ +__u64 size; + +/** +* @chipid: GPU chip identifier. See &enum drm_nova_chipid for currently +* known chip identifiers. +*/ +__u32 chipid; + +/** +* @pad: 32 bit padding, must be 0. +*/ +__u32 pad; +}; +#define DRM_NOVA_GETPARAM 0x00#define DRM_NOVA_GEM_CREATE 0x01#define DRM_NOVA_GEM_INFO 0x02 +#define DRM_NOVA_GPU_INFO 0x03/* Note: this is an enum so that it can be resolved by Rust bindgen. */ enum {
@@ -130,6 +155,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_GPU_INFO =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_GPU_INFO , + struct drm_nova_gpu_info), };#if defined(__cplusplus)
Signature · 1 line
2.54.0
Danilo Krummrich
maintainerRe: [PATCH v4 4/7] drm: nova: Add a GPU info ioctl
Quoted 21 lines · Alistair Popple
include/uapi/drm/nova_drm.h +13
-0@@ -118,9 +118,34 @@ struct drm_nova_gem_info {__u64 size; }; +/** +* struct drm_nova_gpu_info - query DRM GPU info. +*/ +struct drm_nova_gpu_info { +/** +* @size: The amount of space allocated by userspace for this structure. +* The kernel will return the amount of data it did/could actually write. +* User space can use this to determine how much of the struct is valid +* when running against an older kernel. +*/ +__u64 size; + +/**
include/uapi/drm/nova_drm.h struct drm_nova_gem_info { · line 143
Quoted 10 lines
include/uapi/drm/nova_drm.h +10
-0+* @chipid: GPU chip identifier. See &enum drm_nova_chipid for currently +* known chip identifiers. +*/ +__u32 chipid; + +/** +* @pad: 32 bit padding, must be 0. +*/ +__u32 pad; +};
I think we should add the indirection we discussed in [1], i.e. have an indirection via
struct drm_nova_info {
__u32 id;
__u32 size;
__u64 info;
/* Revserved fields, just in case? */
};so we can easily add new info structures, or extend an existing one with a v2 without having to create new ioctls for this purpose.
Quoted 18 lines
include/uapi/drm/nova_drm.h +3
-0#define DRM_NOVA_GETPARAM 0x00#define DRM_NOVA_GEM_CREATE 0x01#define DRM_NOVA_GEM_INFO 0x02 +#define DRM_NOVA_GPU_INFO 0x03/* Note: this is an enum so that it can be resolved by Rust bindgen. */ enum {@@ -130,6 +155,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_GPU_INFO =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_GPU_INFO , + struct drm_nova_gpu_info), };#if defined(__cplusplus)Signature · 1 line
2.54.0
Re: [PATCH v4 4/7] drm: nova: Add a GPU info ioctl
On 2026-08-18 at 06:18 +1000, Danilo Krummrich <[email protected]> wrote...
Quoted 43 lines · Alistair Popple
Quoted 21 lines
include/uapi/drm/nova_drm.h +13
-0@@ -118,9 +118,34 @@ struct drm_nova_gem_info {__u64 size; }; +/** +* struct drm_nova_gpu_info - query DRM GPU info. +*/ +struct drm_nova_gpu_info { +/** +* @size: The amount of space allocated by userspace for this structure. +* The kernel will return the amount of data it did/could actually write. +* User space can use this to determine how much of the struct is valid +* when running against an older kernel. +*/ +__u64 size; + +/** include/uapi/drm/nova_drm.h struct drm_nova_gem_info { · line 143
Quoted 10 lines
include/uapi/drm/nova_drm.h +10
-0+* @chipid: GPU chip identifier. See &enum drm_nova_chipid for currently +* known chip identifiers. +*/ +__u32 chipid; + +/** +* @pad: 32 bit padding, must be 0. +*/ +__u32 pad; +};I think we should add the indirection we discussed in [1], i.e. have an indirection via
struct drm_nova_info { __u32 id; __u32 size; __u64 info; /* Revserved fields, just in case? */ };
Quoted 2 lines
so we can easily add new info structures, or extend an existing one with a v2 without having to create new ioctls for this purpose.
Sorry, I should have called this difference out more explicitly.
Basically I ended up doing it this way because it didn't make much sense to me putting an ioctl interface within an ioctl interface when DRM ioctl handling can already deal with matching numbers and truncating/extending the struct as required. It just leads to more code comparing ID's, etc and I'm not really sure what the advantage is. Are we concerned about running out of ioctls if we have to add other types of info struct?
Doing this as top-level ioctl makes the strace decoders simpler and means we can just rely on the existing DRM ioctl handling to get everything right rather than duplicating that in nova-drm. Or is there some other advantage to [1] that I've missed that isn't solved here?
Thanks for looking.
- Alistair
Quoted 22 lines
[1] https://lore.kernel.org/nova-gpu/[email protected]/
Quoted 18 lines
include/uapi/drm/nova_drm.h +3
-0#define DRM_NOVA_GETPARAM 0x00#define DRM_NOVA_GEM_CREATE 0x01#define DRM_NOVA_GEM_INFO 0x02 +#define DRM_NOVA_GPU_INFO 0x03/* Note: this is an enum so that it can be resolved by Rust bindgen. */ enum {@@ -130,6 +155,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_GPU_INFO =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_GPU_INFO , + struct drm_nova_gpu_info), };#if defined(__cplusplus)Signature · 1 line
2.54.0
Danilo Krummrich
maintainerRe: [PATCH v4 4/7] drm: nova: Add a GPU info ioctl
Quoted 19 lines · Alistair Popple
On 2026-08-18 at 06:18 +1000, Danilo Krummrich <[email protected]> wrote...
Quoted 18 lines · Alistair Popple
Quoted 17 lines
include/uapi/drm/nova_drm.h +9
-0@@ -118,9 +118,34 @@ struct drm_nova_gem_info {__u64 size; }; +/** +* struct drm_nova_gpu_info - query DRM GPU info. +*/ +struct drm_nova_gpu_info { +/** +* @size: The amount of space allocated by userspace for this structure. +* The kernel will return the amount of data it did/could actually write. +* User space can use this to determine how much of the struct is valid +* when running against an older kernel.
Quoted 8 lines
Quoted 8 lines
include/uapi/drm/nova_drm.h struct drm_nova_gem_info { · line 137
Quoted 8 lines
include/uapi/drm/nova_drm.h +8
-0+*/ +__u64 size; + +/** +* @chipid: GPU chip identifier. See &enum drm_nova_chipid for currently +* known chip identifiers. +*/ +__u32 chipid;
I think we now also want to add a field for the architecture now that chipid is considered opaque.
Quoted 29 lines
Quoted 17 lines
include/uapi/drm/nova_drm.h struct drm_nova_gem_info { · line 143
Quoted 6 lines
include/uapi/drm/nova_drm.h +6
-0+ +/** +* @pad: 32 bit padding, must be 0. +*/ +__u32 pad; +};I think we should add the indirection we discussed in [1], i.e. have an indirection via
struct drm_nova_info { __u32 id; __u32 size; __u64 info; /* Revserved fields, just in case? */ };Quoted 2 lines
so we can easily add new info structures, or extend an existing one with a v2 without having to create new ioctls for this purpose.
Sorry, I should have called this difference out more explicitly.
Basically I ended up doing it this way because it didn't make much sense to me putting an ioctl interface within an ioctl interface when DRM ioctl handling can already deal with matching numbers and truncating/extending the struct as required. It just leads to more code comparing ID's, etc and I'm not really sure what the advantage is. Are we concerned about running out of ioctls if we have to add other types of info struct?
Quoted 4 lines
Doing this as top-level ioctl makes the strace decoders simpler and means we can just rely on the existing DRM ioctl handling to get everything right rather than duplicating that in nova-drm. Or is there some other advantage to [1] that I've missed that isn't solved here?
I don't think we are really concerned about running out of ioctls, but it seems cleaner and more self-contained than having N ioctls for different info structs and in the worst case having v2...vN info ioctls.
It also allows us to define a new info type struct whenever we think something is a new logical info group. Making it per ioctl will always raise the question of "do we really need a new ioctl for this, can't we just fit it in X", which over time tends to get messy.
I think eventually we will have a bunch of different info categories. OpenRM seems to have quite some as well (not too many categories, but with lots of fields), Xe and amdgpu have even more categories.
Quoted 26 lines
Thanks for looking.
- Alistair
Quoted 22 lines
[1] https://lore.kernel.org/nova-gpu/[email protected]/
Quoted 18 lines
include/uapi/drm/nova_drm.h +3
-0#define DRM_NOVA_GETPARAM 0x00#define DRM_NOVA_GEM_CREATE 0x01#define DRM_NOVA_GEM_INFO 0x02 +#define DRM_NOVA_GPU_INFO 0x03/* Note: this is an enum so that it can be resolved by Rust bindgen. */ enum {@@ -130,6 +155,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_GPU_INFO =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_GPU_INFO , + struct drm_nova_gpu_info), };#if defined(__cplusplus)Signature · 1 line
2.54.0
Re: [PATCH v4 4/7] drm: nova: Add a GPU info ioctl
On 2026-08-25 at 05:10 +1000, Danilo Krummrich <[email protected]> wrote...
Quoted 23 lines · Alistair Popple
Quoted 22 lines
On 2026-08-18 at 06:18 +1000, Danilo Krummrich <[email protected]> wrote...
Quoted 21 lines · Alistair Popple
Quoted 20 lines
include/uapi/drm/nova_drm.h +12
-0@@ -118,9 +118,34 @@ struct drm_nova_gem_info {__u64 size; }; +/** +* struct drm_nova_gpu_info - query DRM GPU info. +*/ +struct drm_nova_gpu_info { +/** +* @size: The amount of space allocated by userspace for this structure. +* The kernel will return the amount of data it did/could actually write. +* User space can use this to determine how much of the struct is valid +* when running against an older kernel. +*/ +__u64 size; +
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
include/uapi/drm/nova_drm.h struct drm_nova_gem_info { · line 137
Quoted 5 lines
include/uapi/drm/nova_drm.h +5
-0+/** +* @chipid: GPU chip identifier. See &enum drm_nova_chipid for currently +* known chip identifiers. +*/ +__u32 chipid;I think we now also want to add a field for the architecture now that chipid is considered opaque.
I don't think so - see my response to patch 3 but I think the architecture decoding needs to stay in user-space.
Quoted 29 lines
Quoted 29 lines
Quoted 17 lines
include/uapi/drm/nova_drm.h struct drm_nova_gem_info { · line 143
Quoted 6 lines
include/uapi/drm/nova_drm.h +6
-0+ +/** +* @pad: 32 bit padding, must be 0. +*/ +__u32 pad; +};I think we should add the indirection we discussed in [1], i.e. have an indirection via
struct drm_nova_info { __u32 id; __u32 size; __u64 info; /* Revserved fields, just in case? */ };Quoted 2 lines
so we can easily add new info structures, or extend an existing one with a v2 without having to create new ioctls for this purpose.
Sorry, I should have called this difference out more explicitly.
Basically I ended up doing it this way because it didn't make much sense to me putting an ioctl interface within an ioctl interface when DRM ioctl handling can already deal with matching numbers and truncating/extending the struct as required. It just leads to more code comparing ID's, etc and I'm not really sure what the advantage is. Are we concerned about running out of ioctls if we have to add other types of info struct?
Quoted 8 lines
Quoted 4 lines
Doing this as top-level ioctl makes the strace decoders simpler and means we can just rely on the existing DRM ioctl handling to get everything right rather than duplicating that in nova-drm. Or is there some other advantage to [1] that I've missed that isn't solved here?
I don't think we are really concerned about running out of ioctls, but it seems cleaner and more self-contained than having N ioctls for different info structs and in the worst case having v2...vN info ioctls.
But isn't v2...vN info ioctls dealt with in the usual way by extending the existing struct and bumping the size? That seems like a pretty clean and self-contained API to me.
Quoted 4 lines
It also allows us to define a new info type struct whenever we think something is a new logical info group. Making it per ioctl will always raise the question of "do we really need a new ioctl for this, can't we just fit it in X", which over time tends to get messy.
Doesn't that question also apply to adding GETPARAM N+1 though? If we're not worried about running out of top-level ioctls I don't understand why they are considered special enough to warrant the extra complexity of creating and decoding a hiearchy of sub-ioctls.
Quoted 3 lines
I think eventually we will have a bunch of different info categories. OpenRM seems to have quite some as well (not too many categories, but with lots of fields), Xe and amdgpu have even more categories.
Sure, we could just reserve a block of top-level ioctls for info though if we really cared about them being grouped together numerically. I'm not sure why keeping them group numerically really matters though, it's nice to have but I don't think it warrants any extra code.
But perhaps seeing an actual user of this API would be helpful for this discussion, I will aim to do a pull request to drm-test this week to demonstrate.
- Alistair
Quoted 27 lines
Quoted 26 lines
Thanks for looking.
- Alistair
Quoted 22 lines
[1] https://lore.kernel.org/nova-gpu/[email protected]/
Quoted 18 lines
include/uapi/drm/nova_drm.h +3
-0#define DRM_NOVA_GETPARAM 0x00#define DRM_NOVA_GEM_CREATE 0x01#define DRM_NOVA_GEM_INFO 0x02 +#define DRM_NOVA_GPU_INFO 0x03/* Note: this is an enum so that it can be resolved by Rust bindgen. */ enum {@@ -130,6 +155,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_GPU_INFO =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_GPU_INFO , + struct drm_nova_gpu_info), };#if defined(__cplusplus)Signature · 1 line
2.54.0
Danilo Krummrich
maintainerRe: [PATCH v4 4/7] drm: nova: Add a GPU info ioctl
Quoted 8 lines · Alistair Popple
On 2026-08-25 at 05:10 +1000, Danilo Krummrich <[email protected]> wrote...
Quoted 3 lines
I don't think we are really concerned about running out of ioctls, but it seems cleaner and more self-contained than having N ioctls for different info structs and in the worst case having v2...vN info ioctls.
But isn't v2...vN info ioctls dealt with in the usual way by extending the existing struct and bumping the size? That seems like a pretty clean and self-contained API to me.
To be clear, my main point is that having a single info ioctl with different info types is more self-contained and provides more flexibility to introduce new info types whenever we think it is warranted. Long term I expect it to be the cleaner API.
Quoted 9 lines
Quoted 4 lines
It also allows us to define a new info type struct whenever we think something is a new logical info group. Making it per ioctl will always raise the question of "do we really need a new ioctl for this, can't we just fit it in X", which over time tends to get messy.
Doesn't that question also apply to adding GETPARAM N+1 though? If we're not worried about running out of top-level ioctls I don't understand why they are considered special enough to warrant the extra complexity of creating and decoding a hiearchy of sub-ioctls.
I think the code would be rather trivial:
fn write_info<T: AsBytes>(info: &mut uapi::drm_nova_info, value: &T) -> Result {
let len = size_of_val(value).min(info.size);
let uptr = UserPtr::from_addr(info.data);
let mut writer = UserSlice::new(uptr, len).writer();
// Note: I made this up, as I think we want to add this method to
// `UserSliceWriter`, to avoid having to call `as_bytes()`.
writer.write_truncated(&value)?;
info.size = len;
Ok(())
}
match info.id {
uapi::DRM_NOVA_INFO_GPU => write_info(info, &uapi::drm_nova_gpu_info { ... })?,
uapi::DRM_NOVA_INFO_MEM => write_info(info, &uapi::drm_nova_mem_info { ... })?,
_ => return Err(EINVAL),
}Honestly, I think this is even less complicated that adding a new ioctl for a new info struct.
And on the userspace side:
fn query_info<T: Default>(fd: &DrmDevice, id: DrmNovaInfoId) -> Result<T> {
let mut value = T::default();
let mut info = drm_nova_info {
id: id.as_raw(),
size: size_of::<T>(),
data: ptr::from_mut(&mut value) as u64,
};
fd.ioctl(DRM_IOCTL_NOVA_INFO, &mut info)?;
Ok(value)
}
let gpu_info: drm_nova_gpu_info = query_info(&dev, DRM_NOVA_INFO_GPU)?;
let mem_info: drm_nova_mem_info = query_info(&dev, DRM_NOVA_INFO_MEM)?;(I pushed a few cleanups to drm-test, so this code should work.)
Re: [PATCH v4 4/7] drm: nova: Add a GPU info ioctl
On 2026-08-26 at 08:37 +1000, Danilo Krummrich <[email protected]> wrote...
Quoted 20 lines · Alistair Popple
Quoted 8 lines
On 2026-08-25 at 05:10 +1000, Danilo Krummrich <[email protected]> wrote...
Quoted 3 lines
I don't think we are really concerned about running out of ioctls, but it seems cleaner and more self-contained than having N ioctls for different info structs and in the worst case having v2...vN info ioctls.
But isn't v2...vN info ioctls dealt with in the usual way by extending the existing struct and bumping the size? That seems like a pretty clean and self-contained API to me.
To be clear, my main point is that having a single info ioctl with different info types is more self-contained and provides more flexibility to introduce new info types whenever we think it is warranted. Long term I expect it to be the cleaner API.
Quoted 5 lines
Quoted 4 lines
It also allows us to define a new info type struct whenever we think something is a new logical info group. Making it per ioctl will always raise the question of "do we really need a new ioctl for this, can't we just fit it in X", which over time tends to get messy.
Quoted 6 lines
Quoted 4 lines
Doesn't that question also apply to adding GETPARAM N+1 though? If we're not worried about running out of top-level ioctls I don't understand why they are considered special enough to warrant the extra complexity of creating and decoding a hiearchy of sub-ioctls.
I think the code would be rather trivial:
Yeah, I agree it's nothing too complicated. It is still more code though, and therefore more code for people to grok and more code for every userspace user to implement (not always in Rust!) rather than relying on existing code. And it does add another layer of semantics to understand, even if they are similar, so in that sense I regard it as more complex.
But it seems unlikely further discussion will change much here and I'd like to get this merged soon. Obviously you consider this worthwhile so I'll just go ahead with this approach for v5.
Quoted 40 lines
fn write_info<T: AsBytes>(info: &mut uapi::drm_nova_info, value: &T) -> Result { let len = size_of_val(value).min(info.size); let uptr = UserPtr::from_addr(info.data); let mut writer = UserSlice::new(uptr, len).writer(); // Note: I made this up, as I think we want to add this method to // `UserSliceWriter`, to avoid having to call `as_bytes()`. writer.write_truncated(&value)?; info.size = len; Ok(()) } match info.id { uapi::DRM_NOVA_INFO_GPU => write_info(info, &uapi::drm_nova_gpu_info { ... })?, uapi::DRM_NOVA_INFO_MEM => write_info(info, &uapi::drm_nova_mem_info { ... })?, _ => return Err(EINVAL), }Honestly, I think this is even less complicated that adding a new ioctl for a new info struct.
And on the userspace side:
fn query_info<T: Default>(fd: &DrmDevice, id: DrmNovaInfoId) -> Result<T> { let mut value = T::default(); let mut info = drm_nova_info { id: id.as_raw(), size: size_of::<T>(), data: ptr::from_mut(&mut value) as u64, }; fd.ioctl(DRM_IOCTL_NOVA_INFO, &mut info)?; Ok(value) } let gpu_info: drm_nova_gpu_info = query_info(&dev, DRM_NOVA_INFO_GPU)?; let mem_info: drm_nova_mem_info = query_info(&dev, DRM_NOVA_INFO_MEM)?;
Quoted 1 line
(I pushed a few cleanups to drm-test, so this code should work.)
Thanks. I've already taken a look at drm-test, seems fairly easy to follow.
- Alistair
Danilo Krummrich
maintainerRe: [PATCH v4 4/7] drm: nova: Add a GPU info ioctl
In reply to Alistair PoppleQuoted 1 line · Alistair Popple
include/uapi/drm/nova_drm.h | 27 +++++++++++++++++++++++++++
Btw. I think it would be nice to have project to play around with and write tests directly on top of the uAPI before we can run the big test suites.
When I implemented the VM_BIND uAPI for nouveau I used IGT for this (but didn't enjoy it too much). It turned out to be very useful to test and benchmark the implementation before being able to complete VK CTS.
When I sent the first nova-drm skeleton, I also submitted [1]; maybe we can extend this further accordingly?
I'm also open for other ideas, but I'd really like to have something like this as we develop nova-drm.
Re: [PATCH v4 4/7] drm: nova: Add a GPU info ioctl
Quoted 5 lines · Danilo Krummrich
Quoted 1 line · Alistair Popple
include/uapi/drm/nova_drm.h | 27 +++++++++++++++++++++++++++Btw. I think it would be nice to have project to play around with and write tests directly on top of the uAPI before we can run the big test suites.
Yes, I think it's reasonable to do something like that. Seeing a new API from both sides, caller and callee, is always illuminating during review, for one thing.
Quoted 5 lines
When I implemented the
VM_BINDuAPI for nouveau I used IGT for this (but didn't enjoy it too much). It turned out to be very useful to test and benchmark the implementation before being able to complete VK CTS.
Quoted 7 lines
When I sent the first nova-drm skeleton, I also submitted [1]; maybe we can extend this further accordingly?
I'm also open for other ideas, but I'd really like to have something like this as we develop nova-drm.
I was thinking about where this sort of thing should go, and this location seems as good, or slightly better than the main alternatives, to get started anyway.
Alternatives include:
1) The kernel's kselftests (tools/testings/selftests). These are helpful in many cases, but some minor issues include:
a) Oddly tight coupling to kernel code, even though the whole point of these is to exercise the kernel from user space. (Otherwise, these days one would use KUnit.) I've personally working on mitigating the coupling-induced problems and ran into other, bigger problems along the way, such as:
b) Confused build system and an arguably wrong way of invoking
the tests (from Make(1) !).
2) Some other github-like location to host user space tests for nova. The idea is, do we want to set up a well-known location that people should keep updated? Or let a thousand github small test sites bloom?
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH v4 4/7] drm: nova: Add a GPU info ioctl
On 2026-08-25 at 06:04 +1000, John Hubbard <[email protected]> wrote...
Quoted 10 lines · Danilo Krummrich
Quoted 5 lines · Alistair Popple
Quoted 1 line
include/uapi/drm/nova_drm.h | 27 +++++++++++++++++++++++++++Btw. I think it would be nice to have project to play around with and write tests directly on top of the uAPI before we can run the big test suites.
Yes, I think it's reasonable to do something like that. Seeing a new API from both sides, caller and callee, is always illuminating during review, for one thing.
Yes, I had meant to do this so thanks for the reminder. You can of course see the other side of the API here:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/43352
But that's a user of the UAPI rather than a tester of it which makes it hard to exercise everything or specific parts of the API. I did actually end up writing my own standalone test case for these, similar to [1] but never got around to tidying it up and posting it. Looking at [1] it seems reasonable as a simple stand-alone test so I will do that ahead of the next revision for this series.
Quoted 13 lines
Quoted 5 lines
When I implemented the
VM_BINDuAPI for nouveau I used IGT for this (but didn't enjoy it too much). It turned out to be very useful to test and benchmark the implementation before being able to complete VK CTS.Quoted 7 lines
When I sent the first nova-drm skeleton, I also submitted [1]; maybe we can extend this further accordingly?
I'm also open for other ideas, but I'd really like to have something like this as we develop nova-drm.
Quoted 8 lines
I was thinking about where this sort of thing should go, and this location seems as good, or slightly better than the main alternatives, to get started anyway.
Alternatives include:
1) The kernel's kselftests (
tools/testings/selftests). These are helpful in many cases, but some minor issues include:
Yeah, I don't think these style of tests belong in kselftests if only because they're never going to be self-contained as at a minimum they will require specific HW. It might make sense for unit-test style things, but I (think) Rust-for-Linux already has that covered.
Quoted 6 lines
a) Oddly tight coupling to kernel code, even though the whole point of these is to exercise the kernel from user space. (Otherwise, these days one would use KUnit.) I've personally working on mitigating the coupling-induced problems and ran into other, bigger problems along the way, such as:
Quoted 7 lines
b) Confused build system and an arguably wrong way of invoking
the tests (from Make(1) !).2) Some other github-like location to host user space tests for nova. The idea is, do we want to set up a well-known location that people should keep updated? Or let a thousand github small test sites bloom?
We obviously can't stop a thousand small test sites blooming if people create them, but I think it would be good to establish a well-known location for core Nova developers to contribute to at least.
Quoted 4 lines
thanks,
Signature · 1 line
John Hubbard
PATCH v4 5/7 drm: nova: Add usable VRAM size to GPU info ioctl
In reply to Alistair PoppleAdd a parameter to the GPU info ioctl to return the total usable framebuffer size. The usable framebuffer excludes GSP carveouts and other protected regions so may differ in size from BAR size and total physical VRAM.
---
Changes since v3:
- Partially new for v4 - previously this used GETPARAM
--- drivers/gpu/drm/nova/file.rs | 1 + drivers/gpu/nova-core/api.rs | 5 +++++ drivers/gpu/nova-core/gpu.rs | 6 ++---- drivers/gpu/nova-core/gsp/commands.rs | 8 ++++++++ include/uapi/drm/nova_drm.h | 6 ++++++ 5 files changed, 22 insertions(+), 4 deletions(-)
drivers/gpu/drm/nova/file.rs +1 -0
@@ -92,6 +92,7 @@ pub(crate) fn gpu_info( gpu_info.size =size_of ::<uapi::drm_nova_gpu_info >()as u64 ; gpu_info.chipid = reg_data.api.chipset ()as u32 ; + gpu_info.vram_size = reg_data.api.vram_size ();Ok (0 ) }
drivers/gpu/nova-core/api.rs +5 -0
@@ -33,4 +33,9 @@ pub fn of(adev: &auxiliary::Device<Bound>) -> Result<Pin<&NovaCoreApi<'_>>> {pub fn chipset (&self) ->Chipset { self.gpu.spec.chipset } + +/// Returns the total usable VRAM size of this GPU in bytes. +pub fn vram_size (&self) ->u64 { + self.gpu.gsp_static_info.vram_size () + } }
drivers/gpu/nova-core/gpu.rs +2 -4
@@ -283,7 +283,7 @@ struct GspResources<'gpu> {pub (crate )struct Gpu <'gpu> {pub (crate ) spec:Spec ,/// Static GPU information as provided by the GSP. - gsp_static_info:GetGspStaticInfoReply , +pub (crate ) gsp_static_info:GetGspStaticInfoReply ,/// GSP and its resources. #[pin] gsp_resources:GspResources <'gpu>,
@@ -400,9 +400,7 @@ pub(crate) fn new(dev_dbg! ( dev,"Total usable VRAM: {} MiB\n" , - info.usable_fb_regions.iter ().fold (0u64 , |res, region| res - .saturating_add (region.end - region.start)) - /u64 ::SZ_1M + info.vram_size () /u64 ::SZ_1M ); }
drivers/gpu/nova-core/gsp/commands.rs +8 -0
@@ -252,6 +252,14 @@ pub(crate) fn gpu_name(&self) -> core::result::Result<&str, GpuNameError> { .to_str() .map_err (GpuNameError ::InvalidUtf8 ) } + +/// Returns the total usable VRAM size in bytes, i.e. the summed lengths of all usable FB +/// regions. +pub (crate )fn vram_size (&self) ->u64 { + self.usable_fb_regions.iter ().fold (0 , |size, region| { + size.saturating_add (region.end - region.start) + }) + } }pub (crate )use fw::commands::PowerStateLevel ;
include/uapi/drm/nova_drm.h +6 -0
@@ -140,6 +140,12 @@ struct drm_nova_gpu_info {* @pad: 32 bit padding, must be 0. */ __u32 pad; + +/** +* @vram_size: Amount of usable FB, excluding GSP carveouts and protected +* regions. +*/ +__u64 vram_size; };#define DRM_NOVA_GETPARAM 0x00
Signature · 1 line
2.54.0
PATCH v4 6/7 drm: nova: Use nova-core to read VRAM_BAR_SIZE parameter
In reply to Alistair PoppleCurrently nova-drm reads the VRAM BAR size directly from the PCIe device which requires trying to cast the parent device into a PCIe device. This obviously requires the parent device to actually be a PCIe bus device. Whilst that is true today it may not always be the case, and there is no reason to make this assumption now that NovaCoreApi can hold a reference to the bound PCIe device.
So convert nova-drm to using nova-core to obtain the VRAM_BAR_SIZE parameter.
---
Changes from v2:
- Update nova-core API to use bar1_size() instead of vram_bar_size() as this is used internally throughout our chip HW.
--- drivers/gpu/drm/nova/file.rs | 12 +++--------- drivers/gpu/nova-core/api.rs | 8 ++++++++ drivers/gpu/nova-core/driver.rs | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-)
drivers/gpu/drm/nova/file.rs +3 -9
@@ -8,14 +8,11 @@use crate ::gem::NovaObject ;use kernel::{ alloc::flags::*, - auxiliary, - device::Bound , drm::{ self, gem::BaseObject ,Registered ,// }, - pci, prelude::*, uapi, };
@@ -33,16 +30,13 @@ 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 <'_>, + _dev: &NovaDevice <Registered >, + reg_data: &DrmRegData <'_>, getparam: &mut uapi::drm_nova_getparam , _file: &drm::File <File >, ) ->Result <u32 > { -let adev: &auxiliary::Device <Bound > = dev.as_ref (); -let pdev: &pci::Device <Bound > = adev.parent ().try_into ()?; -let value =match getparam.paramas u32 { - uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => pdev.resource_len (1 )?, + uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => reg_data.api.bar1_size ()?, _ =>return Err (EINVAL ), };
drivers/gpu/nova-core/api.rs +8 -0
@@ -8,6 +8,7 @@use kernel::{ auxiliary, device::Bound , + pci, prelude::*, types::CovariantForLt ,// };
@@ -20,6 +21,7 @@/// API handle for the auxiliary bus child drivers to interact with nova-core. pub struct NovaCoreApi <'bound> {pub (crate ) gpu:Pin <&'boundGpu <'bound>>, +pub (crate ) pdev: &'bound pci::Device <Bound >, }impl NovaCoreApi <'_> {
@@ -34,6 +36,12 @@ pub fn chipset(&self) -> Chipset { self.gpu.spec.chipset } +/// Returns the size of the PCIe BAR used for accessing VRAM, typically +/// BAR1. +pub fn bar1_size (&self) ->Result <u64 > { + self.pdev.resource_len (1 ) + } +/// Returns the total usable VRAM size of this GPU in bytes. pub fn vram_size (&self) ->u64 { self.gpu.gsp_static_info.vram_size ()
drivers/gpu/nova-core/driver.rs +1 -1
@@ -113,7 +113,7 @@ fn probe<'bound>(// never recycles IDs. AUXILIARY_ID_COUNTER.fetch_add(1, Relaxed), crate::MODULE_NAME, - NovaCoreApi { gpu }, + NovaCoreApi { gpu, pdev }, )? } },
Signature · 1 line
2.54.0
Danilo Krummrich
maintainerRe: [PATCH v4 6/7] drm: nova: Use nova-core to read VRAM_BAR_SIZE parameter
Quoted 11 lines · Alistair Popple
Currently nova-drm reads the VRAM BAR size directly from the PCIe device which requires trying to cast the parent device into a PCIe device. This obviously requires the parent device to actually be a PCIe bus device. Whilst that is true today it may not always be the case, and there is no reason to make this assumption now that NovaCoreApi can hold a reference to the bound PCIe device.
So convert nova-drm to using nova-core to obtain the
VRAM_BAR_SIZEparameter.Signed-off-by Alistair Popple <[email protected]>
Quoted 9 lines
drivers/gpu/drm/nova/file.rs +2
-2@@ -33,16 +30,13 @@ 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 <'_>, + _dev: &NovaDevice <Registered >, + reg_data: &DrmRegData <'_>, getparam: &mut uapi::drm_nova_getparam,
drivers/gpu/drm/nova/file.rs fn open(_dev: &NovaDevice) -> Result<Pin<KBox<Self>>> { · line 41
Quoted 10 lines
drivers/gpu/drm/nova/file.rs +1
-4_file: &drm::File<File>, ) -> Result<u32> { -let adev: &auxiliary::Device <Bound > = dev.as_ref (); -let pdev: &pci::Device <Bound > = adev.parent ().try_into ()?; -let value =match getparam.paramas u32 { - uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => pdev.resource_len (1 )?, + uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => reg_data.api.bar1_size ()?, _ =>return Err (EINVAL ), };
That's much cleaner, thanks for adding this patch!
Once this landed we can remove the
impl<Ctx: device::DeviceContext> TryFrom<&device::Device<Ctx>> for &Device<Ctx>
impl in rust/kernel/pci.rs. (I think platform should have the same impl to get rid of independently.)
If your are interested, feel free to send a follow-up patch (or include it in this series).
Re: [PATCH v4 6/7] drm: nova: Use nova-core to read VRAM_BAR_SIZE parameter
On 2026-08-18 at 06:11 +1000, Danilo Krummrich <[email protected]> wrote...
Quoted 28 lines · Alistair Popple
Quoted 11 lines
Currently nova-drm reads the VRAM BAR size directly from the PCIe device which requires trying to cast the parent device into a PCIe device. This obviously requires the parent device to actually be a PCIe bus device. Whilst that is true today it may not always be the case, and there is no reason to make this assumption now that NovaCoreApi can hold a reference to the bound PCIe device.
So convert nova-drm to using nova-core to obtain the
VRAM_BAR_SIZEparameter.Signed-off-by Alistair Popple <[email protected]>Suggested-by Danilo Krummrich <[email protected]>Quoted 13 lines
drivers/gpu/drm/nova/file.rs +2
-4@@ -33,16 +30,13 @@ 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 <'_>, + _dev: &NovaDevice <Registered >, + reg_data: &DrmRegData <'_>, getparam: &mut uapi::drm_nova_getparam , _file: &drm::File <File >, ) ->Result <u32 > { -let adev: &auxiliary::Device <Bound > = dev.as_ref (); -let pdev: &pci::Device <Bound > = adev.parent ().try_into ()?;
Quoted 8 lines
drivers/gpu/drm/nova/file.rs fn open(_dev: &NovaDevice) -> Result<Pin<KBox<Self>>> { · line 41
Quoted 6 lines
drivers/gpu/drm/nova/file.rs +1
-2-let value =match getparam.paramas u32 { - uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => pdev.resource_len (1 )?, + uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => reg_data.api.bar1_size ()?, _ =>return Err (EINVAL ), };That's much cleaner, thanks for adding this patch!
No problem! Agree it's much nicer.
Quoted 9 lines
Once this landed we can remove the
impl<Ctx:
device::DeviceContext> TryFrom<&device::Device<Ctx>> for &Device<Ctx>impl in
rust/kernel/pci.rs. (I think platform should have the same impl to get rid of independently.)If your are interested, feel free to send a follow-up patch (or include it in this series).
Happy to do either. Seems like it might be easiest just to add it to this series so will add it to v5.
PATCH v4 7/7 drm: nova: Expose a render node
In reply to Alistair Popplenova-drm currently only exposes a primary node even though all of its ioctls are already marked DRM_RENDER_ALLOW. Set the DRIVER_RENDER feature so that a render node (/dev/dri/renderDXX) is created as well.
This is required to allow render and compute clients to interact with nova-drm.
---
Changes since v2:
- New for v3.
--- drivers/gpu/drm/nova/driver.rs | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/nova/driver.rs +1 -0
@@ -92,6 +92,7 @@ impl drm::Driver for NovaDriver {type ParentDevice <Ctx :DeviceContext > = auxiliary::Device <Ctx >;const INFO : drm::DriverInfo =INFO ; +const FEAT_RENDER :bool =true ; kernel::declare_drm_ioctls! { (NOVA_GETPARAM , drm_nova_getparam, ioctl::RENDER_ALLOW ,File ::get_param),
Signature · 1 line
2.54.0