gpu: nova: add boot42 support for next-gen GPUs
Subsystems (4)
v9 cover gpu: nova: add boot42 support for next-gen GPUs
Changes in v9:
1) Simplified the Revision updates, so that Revision's member fields can remain private (thanks to Alex Courbot).
2) Restore a missing documentation comment line for chipset().
3) Removed the patch that changed from ENODEV to ENOTSUPP, and used ENODEV to mean "GPU is not supported", because the driver core expects that specific error code.
4) Rebased onto drm-rust-next, which already has patch 1/1 from v8, so that one no longer appears in v9.
Changes in v8:
1) Added two new patches: convert the remaining ENODEV cases to ENOTSUPP, and add dev_err!() report for some (most) cases of unsupported GPUs.
2) Corrected some comments.
3) Added Joel's Reviewed-by, but not yet to the two new patches.
Changes in v7:
1) Added a TODO to eventually remove the Default trait from Architecture.
2) Further refined the logic and comments for reading boot0, then boot42.
Changes in v6:
1) Split out a separate patch for implementing Display for Spec.
2) Moved Spec implementation code to its proper location.
3) Significantly changed the use_boot42_instead() logic, and updated the comments accordingly.
4) Fixed the boot42 register and field values, which were wrong (and had not been exercised before).
5) Imported Revision, to save a few ::'s.
6) Rebased to the very latest drm-rust-next, which now includes the new "one 'use' item per line" updates.
Changes in v5:
Two fixes, both from Timur's review feedback (thanks!):
1) Updated both the cover letter, and patch 3 commit description, with the correct description of the future contents of NV_PMC_BOOT_0.
2) Removed a trailing "boot42" typo from a comment in the code.
Changes in v4:
1) Simplified and improved the decision logic: reads both arch_0 and arch_1 fields in boot0, and skips the unnecessary is_nv04() logic as well. Thanks to Timur Tabi and Danilo for noticing these issues.
2) Added a patch to represent Architecture as a u8. This simplifies a few things. (Thanks to Alex Courbot. I added your Suggested-by to that patch.)
3) Enhanced the Revision type to do more, which simplifies the callers. (Thanks to Danilo.)
Changes in v3:
1) Restored the Revision type as recommended by Danilo, but decoupled it from boot0.
2) Applied Alex Courbot's suggestion to use TryFrom<NV_PMC_BOOT_0/42> for Spec.
3) Reflowed the new comment documentation to 100 cols, to avoid wasting a few vertical lines.
Changes in v2:
1) Restored the Spec type, and used that to encapsulate the subsequent boot42 enhancements. Thanks to Danilo Krummrich's feedback for that improvement.
v1 cover letter (with typos fixed)
NVIDIA GPUs are moving away from using NV_PMC_BOOT_0 to contain architecture and revision details, and will instead use NV_PMC_BOOT_42 in the future. NV_PMC_BOOT_0 will contain a specific set of values that will mean "go read NV_PMC_BOOT_42 instead".
Change the selection logic in Nova so that it will claim Turing and later GPUs. This will work for the foreseeable future, without any further code changes here, because all NVIDIA GPUs are considered, from the oldest supported on Linux (NV04), through the future GPUs.
Add some comment documentation to explain, chronologically, how boot0 and boot42 change with the GPU eras, and how that affects the selection logic.
Also, remove the Revision type, because Revision is no longer valuable as a stand-alone type, because we only ever want the full information that Spec provides.
This is based on today's drm-rust-next, which in turn is based on Linux 6.18-rc2.
John Hubbard (4):
gpu: nova-core: prepare Spec and Revision types for boot0/boot42
gpu: nova-core: make Architecture behave as a u8 type
gpu: nova-core: add boot42 support for next-gen GPUs
gpu: nova-core: provide a clear error report for unsupported GPUs
drivers/gpu/nova-core/gpu.rs | 72 ++++++++++++++++++++++++++++++----- drivers/gpu/nova-core/regs.rs | 39 ++++++++++++++++--- 2 files changed, 97 insertions(+), 14 deletions(-)
base-commit: 38b7cc448a5b6772cad2b853a011f507ad95306a
Signature · 1 line
2.51.2
PATCH v9 1/4 gpu: nova-core: prepare Spec and Revision types for boot0/boot42
Allow a both Revision and Spec to be constructed directly from a NV_PMC_BOOT_0 register.
Also, slightly enhance the comment about Spec, to be more precise.
--- drivers/gpu/nova-core/gpu.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/nova-core/gpu.rs +12 -5
@@ -147,8 +147,8 @@ pub(crate) struct Revision { minor: u8, } -impl Revision { -fn from_boot0 (boot0: regs::NV_PMC_BOOT_0 ) ->Self { +impl From <regs::NV_PMC_BOOT_0 >for Revision { +fn from (boot0: regs::NV_PMC_BOOT_0 ) ->Self {Self { major: boot0.major_revision (), minor: boot0.minor_revision (),
@@ -162,10 +162,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } -/// Structure holding the metadata of the GPU. +/// Structure holding a basic description of the GPU: `Chipset` and `Revision`. pub (crate )struct Spec { chipset:Chipset , -/// The revision of the chipset. revision:Revision , }
@@ -173,9 +172,17 @@ impl Spec {fn new (bar: &Bar0 ) ->Result <Spec > {let boot0 = regs::NV_PMC_BOOT_0 ::read (bar); +Spec ::try_from (boot0) + } +} + +impl TryFrom <regs::NV_PMC_BOOT_0 >for Spec { +type Error =Error ; + +fn try_from (boot0: regs::NV_PMC_BOOT_0 ) ->Result <Self > {Ok (Self { chipset: boot0.chipset ()?, - revision:Revision ::from_boot0 (boot0), + revision: boot0.into (), }) } }
Signature · 1 line
2.51.2
PATCH v9 2/4 gpu: nova-core: make Architecture behave as a u8 type
In reply to John HubbardThis allows Architecture to be passed into register!() and bitfield!() macro calls. That in turn requires a default implementation for Architecture.
This simplifies transforming BOOT0 (and later, BOOT42) register values into GPU architectures.
--- drivers/gpu/nova-core/gpu.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/nova-core/gpu.rs +14 -1
@@ -122,8 +122,14 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { }/// Enum representation of the GPU generation. -#[derive(fmt:: Debug )] +/// +/// TODO: remove the `Default` trait implementation, and the `#[default]` +/// attribute, once the register!() macro (which creates Architecture items) no +/// longer requires it for read-only fields. +#[derive(fmt:: Debug , Default , Copy , Clone )] +#[repr( u8 )] pub (crate )enum Architecture { +#[default] Turing =0x16 ,Ampere =0x17 ,Ada =0x19 ,
@@ -142,6 +148,13 @@ fn try_from(value: u8) -> Result<Self> { } } +impl From <Architecture >for u8 { +fn from (value:Architecture ) ->Self { +// CAST: `Architecture` is `repr(u8)`, so this cast is always lossless. + valueas u8 + } +} +pub (crate )struct Revision { major:u8 , minor:u8 ,
Signature · 1 line
2.51.2
PATCH v9 3/4 gpu: nova-core: add boot42 support for next-gen GPUs
In reply to John HubbardNVIDIA GPUs are moving away from using NV_PMC_BOOT_0 to contain architecture and revision details, and will instead use NV_PMC_BOOT_42 in the future. NV_PMC_BOOT_0 will contain a specific set of values that will mean "go read NV_PMC_BOOT_42 instead".
Change the selection logic in Nova so that it will claim Turing and later GPUs. This will work for the foreseeable future, without any further code changes here, because all NVIDIA GPUs are considered, from the oldest supported on Linux (NV04), through the future GPUs.
Add some comment documentation to explain, chronologically, how boot0 and boot42 change with the GPU eras, and how that affects the selection logic.
--- drivers/gpu/nova-core/gpu.rs | 41 ++++++++++++++++++++++++++++++----- drivers/gpu/nova-core/regs.rs | 21 +++++++++++++----- 2 files changed, 52 insertions(+), 10 deletions(-)
drivers/gpu/nova-core/gpu.rs +36 -5
@@ -169,6 +169,15 @@ fn from(boot0: regs::NV_PMC_BOOT_0) -> Self { } } +impl From <regs::NV_PMC_BOOT_42 >for Revision { +fn from (boot0: regs::NV_PMC_BOOT_42 ) ->Self { +Self { + major: boot0.major_revision (), + minor: boot0.minor_revision (), + } + } +} +impl fmt::Display for Revision {fn fmt (&self, f: &mut fmt::Formatter <'_>) -> fmt::Result {write! (f,"{:x}.{:x}" , self.major, self.minor)
@@ -183,19 +192,41 @@ pub(crate) struct Spec {impl Spec {fn new (bar: &Bar0 ) ->Result <Spec > { +// Some brief notes about boot0 and boot42, in chronological order: +// +// NV04 through NV50: +// +// Not supported by Nova. boot0 is necessary and sufficient to identify these GPUs. +// boot42 may not even exist on some of these GPUs. +// +// Fermi through Volta: +// +// Not supported by Nova. boot0 is still sufficient to identify these GPUs, but boot42 +// is also guaranteed to be both present and accurate. +// +// Turing and later: +// +// Supported by Nova. Identified by first checking boot0 to ensure that the GPU is not +// from an earlier (pre-Fermi) era, and then using boot42 to precisely identify the GPU. +// Somewhere in the Rubin timeframe, boot0 will no longer have space to add new GPU IDs. +let boot0 = regs::NV_PMC_BOOT_0 ::read (bar); -Spec ::try_from (boot0) +if boot0.is_older_than_fermi () { +return Err (ENODEV ); + } + +Spec ::try_from (regs::NV_PMC_BOOT_42 ::read (bar)) } } -impl TryFrom <regs::NV_PMC_BOOT_0 >for Spec { +impl TryFrom <regs::NV_PMC_BOOT_42 >for Spec {type Error =Error ; -fn try_from (boot0: regs::NV_PMC_BOOT_0 ) ->Result <Self > { +fn try_from (boot42: regs::NV_PMC_BOOT_42 ) ->Result <Self > {Ok (Self { - chipset: boot0.chipset ()?, - revision: boot0.into (), + chipset: boot42.chipset ()?, + revision: boot42.into (), }) } }
drivers/gpu/nova-core/regs.rs +16 -5
@@ -40,13 +40,24 @@ });impl NV_PMC_BOOT_0 { -/// Combines `architecture_0` and `architecture_1` to obtain the architecture of the chip. -pub (crate )fn architecture (self) ->Result <Architecture > { -Architecture ::try_from ( - self.architecture_0 () | (self.architecture_1 () <<Self ::ARCHITECTURE_0_RANGE .len ()), - ) +pub (crate )fn is_older_than_fermi (self) ->bool { +// From https://github.com/NVIDIA/open-gpu-doc/tree/master/manuals : +const NV_PMC_BOOT_0_ARCHITECTURE_GF100 :u8 =0xc ; + +// Older chips left arch1 zeroed out. That, combined with an arch0 value that is less than +// GF100, means "older than Fermi". + self.architecture_1 () ==0 && self.architecture_0 () <NV_PMC_BOOT_0_ARCHITECTURE_GF100 } +} + +register! (NV_PMC_BOOT_42 @0x00000a00 ,"Extended architecture information" { +15 :12 minor_revisionas u8 ,"Minor revision of the chip" ; +19 :16 major_revisionas u8 ,"Major revision of the chip" ; +23 :20 implementationas u8 ,"Implementation version of the architecture" ; +29 :24 architectureas u8 ?=>Architecture ,"Architecture value" ; +}); +impl NV_PMC_BOOT_42 {/// Combines `architecture` and `implementation` to obtain a code unique to the chipset. pub (crate )fn chipset (self) ->Result <Chipset > { self.architecture ()
Signature · 1 line
2.51.2
Alexandre Courbot
maintainerRe: [PATCH v9 3/4] gpu: nova-core: add boot42 support for next-gen GPUs
Quoted 30 lines · John Hubbard
NVIDIA GPUs are moving away from using
NV_PMC_BOOT_0to contain architecture and revision details, and will instead useNV_PMC_BOOT_42in the future.NV_PMC_BOOT_0will contain a specific set of values that will mean "go readNV_PMC_BOOT_42instead".Change the selection logic in Nova so that it will claim Turing and later GPUs. This will work for the foreseeable future, without any further code changes here, because all NVIDIA GPUs are considered, from the oldest supported on Linux (NV04), through the future GPUs.
Add some comment documentation to explain, chronologically, how boot0 and boot42 change with the GPU eras, and how that affects the selection logic.
Cc Alexandre Courbot <[email protected]>Cc Danilo Krummrich <[email protected]>Cc Timur Tabi <[email protected]>Reviewed-by Joel Fernandes <[email protected]>Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/gpu.rs | 41 ++++++++++++++++++++++++++++++----- drivers/gpu/nova-core/regs.rs | 21 +++++++++++++----- 2 files changed, 52 insertions(+), 10 deletions(-)drivers/gpu/nova-core/gpu.rs +0
-0@@ -169,6 +169,15 @@ fn from(boot0: regs::NV_PMC_BOOT_0) -> Self { }
drivers/gpu/nova-core/gpu.rs fn from(boot0: regs::NV_PMC_BOOT_0) -> Self { · line 179
Quoted 10 lines
drivers/gpu/nova-core/gpu.rs +8
-0} +impl From <regs::NV_PMC_BOOT_42 >for Revision { +fn from (boot0: regs::NV_PMC_BOOT_42 ) ->Self { +Self { + major: boot0.major_revision (), + minor: boot0.minor_revision (), + } + } +}
Just one nit: similarly to how we are converting the TryFrom<BOOT_0> for Spec into a TryFrom<BOOT_42>, I think we don't need to keep From<BOOT_0> for Revision. Actually we don't even want it, as using it would mean we are relying on BOOT_0 instead of BOOT_42, which this patchset nicely makes our only source of truth.
I'll thus remove the From<BOOT_0> implementation before applying.
Re: [PATCH v9 3/4] gpu: nova-core: add boot42 support for next-gen GPUs
On 11/15/25 6:13 AM, Alexandre Courbot wrote:
...
Quoted 15 lines
drivers/gpu/nova-core/gpu.rs fn from(boot0: regs::NV_PMC_BOOT_0) -> Self { · line 179
Quoted 8 lines
drivers/gpu/nova-core/gpu.rs +8
-0+impl From <regs::NV_PMC_BOOT_42 >for Revision { +fn from (boot0: regs::NV_PMC_BOOT_42 ) ->Self { +Self { + major: boot0.major_revision (), + minor: boot0.minor_revision (), + } + } +}Just one nit: similarly to how we are converting the
TryFrom<BOOT_0> for Specinto aTryFrom<BOOT_42>, I think we don't need to keepFrom<BOOT_0> for Revision. Actually we don't even want it, as using it would mean we are relying onBOOT_0instead ofBOOT_42, which this patchset nicely makes our only source of truth.
Quoted 2 lines
I'll thus remove the
From<BOOT_0>implementation before applying.
Yes, leaving it in was an oversight, good catch.
thanks,
Signature · 1 line
John Hubbard
PATCH v9 4/4 gpu: nova-core: provide a clear error report for unsupported GPUs
In reply to John HubbardPass in a PCI device to Spec::new(), and provide a Display implementation for boot42, in order to provide a clear, concise report of what happened: the driver read NV_PMC_BOOT42, and found that the GPU is not supported.
For very old GPUs (older than Fermi), the driver still returns ENOTSUPP, but it does so without a driver-specific dmesg report. That is exactly appropriate, because if such a GPU is installed, it can only be supported by Nouveau. And if so, the user is not helped by additional error messages from Nova.
Here's the full dmesg output for a Blackwell (not yet supported) GPU:
NovaCore 0000:01:00.0: Probe Nova Core GPU driver.
NovaCore 0000:01:00.0: Unsupported chipset: boot42 = 0x1b2a1000 (architecture 0x1b, implementation 0x2) NovaCore 0000:01:00.0: probe with driver NovaCore failed with error -524
--- drivers/gpu/nova-core/gpu.rs | 9 ++++++--- drivers/gpu/nova-core/regs.rs | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-)
drivers/gpu/nova-core/gpu.rs +6 -3
@@ -191,7 +191,7 @@ pub(crate) struct Spec { }impl Spec { -fn new (bar: &Bar0 ) ->Result <Spec > { +fn new (dev: &device::Device , bar: &Bar0 ) ->Result <Spec > {// Some brief notes about boot0 and boot42, in chronological order: // // NV04 through NV50:
@@ -216,7 +216,10 @@ fn new(bar: &Bar0) -> Result<Spec> {return Err (ENODEV ); } -Spec ::try_from (regs::NV_PMC_BOOT_42 ::read (bar)) +let boot42 = regs::NV_PMC_BOOT_42 ::read (bar); +Spec ::try_from (boot42).inspect_err (|_| { +dev_err! (dev,"Unsupported chipset: {}\n" , boot42); + }) } }
@@ -268,7 +271,7 @@ pub(crate) fn new<'a>( bar: &'a Bar0, ) -> impl PinInit<Self, Error> + 'a {try_pin_init! (Self { - spec:Spec ::new (bar).inspect (|spec| { + spec:Spec ::new (pdev.as_ref (), bar).inspect (|spec| {dev_info! (pdev.as_ref (),"NVIDIA ({})\n" , spec); })?,
drivers/gpu/nova-core/regs.rs +18 -0
@@ -67,6 +67,24 @@ pub(crate) fn chipset(self) -> Result<Chipset> { }) .and_then (Chipset ::try_from) } + +/// Returns the raw architecture value from the register. +fn architecture_raw (self) ->u8 { + ((self.0 >>Self ::ARCHITECTURE_RANGE .start ()) & ((1 <<Self ::ARCHITECTURE_RANGE .len ()) -1 )) +as u8 + } +} + +impl kernel::fmt::Display for NV_PMC_BOOT_42 { +fn fmt (&self, f: &mut kernel::fmt::Formatter <'_>) -> kernel::fmt::Result { +write! ( + f, +"boot42 = 0x{:08x} (architecture 0x{:x}, implementation 0x{:x})" , + self.0 , + self.architecture_raw (), + self.implementation () + ) + } }// PBUS
Signature · 1 line
2.51.2
Re: [PATCH v9 4/4] gpu: nova-core: provide a clear error report for unsupported GPUs
Quoted 6 lines · John Hubbard
Pass in a PCI device to
Spec::new(), and provide a Display implementation for boot42, in order to provide a clear, concise report of what happened: the driver readNV_PMC_BOOT42, and found that the GPU is not supported.For very old GPUs (older than Fermi), the driver still returns ENOTSUPP,
ENODEV, actually, now.
thanks,
Signature · 1 line
John Hubbard
Quoted 84 lines
but it does so without a driver-specific dmesg report. That is exactly appropriate, because if such a GPU is installed, it can only be supported by Nouveau. And if so, the user is not helped by additional error messages from Nova.
Here's the full dmesg output for a Blackwell (not yet supported) GPU:
NovaCore 0000:01:00.0: Probe Nova Core GPU driver.
NovaCore 0000:01:00.0: Unsupported chipset: boot42 =0x1b2a1000(architecture0x1b, implementation0x2) NovaCore 0000:01:00.0: probe with driver NovaCore failed with error -524Cc Alexandre Courbot <[email protected]>Cc Danilo Krummrich <[email protected]>Cc Timur Tabi <[email protected]>Cc Joel Fernandes <[email protected]>Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/gpu.rs | 9 ++++++--- drivers/gpu/nova-core/regs.rs | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-)drivers/gpu/nova-core/gpu.rs +6
-3@@ -191,7 +191,7 @@ pub(crate) struct Spec { }impl Spec { -fn new (bar: &Bar0 ) ->Result <Spec > { +fn new (dev: &device::Device , bar: &Bar0 ) ->Result <Spec > {// Some brief notes about boot0 and boot42, in chronological order: // // NV04 through NV50: @@ -216,7 +216,10 @@ fn new(bar: &Bar0) -> Result<Spec> {return Err (ENODEV ); } -Spec ::try_from (regs::NV_PMC_BOOT_42 ::read (bar)) +let boot42 = regs::NV_PMC_BOOT_42 ::read (bar); +Spec ::try_from (boot42).inspect_err (|_| { +dev_err! (dev,"Unsupported chipset: {}\n" , boot42); + }) } }@@ -268,7 +271,7 @@ pub(crate) fn new<'a>( bar: &'a Bar0, ) -> impl PinInit<Self, Error> + 'a {try_pin_init! (Self { - spec:Spec ::new (bar).inspect (|spec| { + spec:Spec ::new (pdev.as_ref (), bar).inspect (|spec| {dev_info! (pdev.as_ref (),"NVIDIA ({})\n" , spec); })?,drivers/gpu/nova-core/regs.rs +18
-0@@ -67,6 +67,24 @@ pub(crate) fn chipset(self) -> Result<Chipset> { }) .and_then (Chipset ::try_from) } + +/// Returns the raw architecture value from the register. +fn architecture_raw (self) ->u8 { + ((self.0 >>Self ::ARCHITECTURE_RANGE .start ()) & ((1 <<Self ::ARCHITECTURE_RANGE .len ()) -1 )) +as u8 + } +} + +impl kernel::fmt::Display for NV_PMC_BOOT_42 { +fn fmt (&self, f: &mut kernel::fmt::Formatter <'_>) -> kernel::fmt::Result { +write! ( + f, +"boot42 = 0x{:08x} (architecture 0x{:x}, implementation 0x{:x})" , + self.0 , + self.architecture_raw (), + self.implementation () + ) + } }// PBUS
Alexandre Courbot
maintainerRe: [PATCH v9 4/4] gpu: nova-core: provide a clear error report for unsupported GPUs
Quoted 9 lines · John Hubbard
Quoted 6 lines · John Hubbard
Pass in a PCI device to
Spec::new(), and provide a Display implementation for boot42, in order to provide a clear, concise report of what happened: the driver readNV_PMC_BOOT42, and found that the GPU is not supported.For very old GPUs (older than Fermi), the driver still returns ENOTSUPP,
ENODEV, actually, now.
Fixed before applying - I was wondering actually, so the clarification is welcome. :)
Quoted 5 lines · John Hubbard
Changes in v9:
1) Simplified the Revision updates, so that Revision's member fields can remain private (thanks to Alex Courbot).
Quoted 8 lines
2) Restore a missing documentation comment line for
chipset().3) Removed the patch that changed from ENODEV to ENOTSUPP, and used ENODEV to mean "GPU is not supported", because the driver core expects that specific error code.
4) Rebased onto drm-rust-next, which already has patch 1/1 from v8, so that one no longer appears in v9.
Pushed to drm-rust-next, thank you!