Skip to contentSkip to conversation

gpu: nova-core: firmware: Hopper/Blackwell support

PATCH Superseded John Hubbard 4 participants 54 messages Apr 11 – Apr 30

Subsystems (4)

v10 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v10 cover gpu: nova-core: firmware: Hopper/Blackwell support

This is based on today's Alex Courbot's drm-rust-next-staging branch[1], and a branch for this v10 is here:

https://github.com/johnhubbard/linux/tree/nova-core-blackwell-v10

My prerequisite nova-core SizeConstants patch [2] is posted separately, and also included in the above -v10 branch.

This has been re-tested on Turing, Ampere, and Blackwell. (Just recently, I installed one of each into the same test machine, without running out of PCI bar space, woohoo!):

NovaCore 0000:c1:00.0: NVIDIA (Chipset: TU117, Architecture: Turing, Revision: a.1) NovaCore 0000:c1:00.0: GPU name: NVIDIA T400 4GB

NovaCore 0000:c2:00.0: NVIDIA (Chipset: GB202, Architecture: BlackwellGB20x, Revision: a.1) NovaCore 0000:c2:00.0: GPU name: NVIDIA RTX PRO 6000 Blackwell Max-Q Workstation Edition

NovaCore 0000:01:00.0: NVIDIA (Chipset: GA104, Architecture: Ampere, Revision: a.1) NovaCore 0000:01:00.0: GPU name: NVIDIA RTX A4000

Changes in v10:

* Reordered per review (and direct assistance--thanks again) from Alexandre Courbot: the two refactoring patches (factor .fwsignature* selection, use GPU Architecture to simplify HALs) now come first, before GPU identification. The boot_via_fsp stub is introduced early and completed as FSP features arrive. The SEC2 refactoring, PCI config mirror, and reserved heap size patches are moved earlier in the series.

* Made pmuReservedSize conditional on Blackwell dGPU architectures. Open RM only sets this field for Blackwell (Turing/Ampere/Ada/Hopper all leave it zero). Added calc_pmu_reserved_size() helper and FbLayout.pmu_reserved_size field to route the value through the layout instead of using the constant unconditionally. Replaced as u32 cast with usize_into_u32 for PMU_RESERVED_SIZE. (Alexandre)

* Split the GFW boot wait HAL change into two patches: one that moves the existing behavior into a GpuHal trait, and a second that adds the Hopper/Blackwell skip.

* Removed the Spec::chipset() accessor (no longer needed after restructuring). Updated the Copy/Clone commit message accordingly.

* Rebased onto drm-rust-next-staging, which includes const_align_up(), "move firmware image parsing code to firmware.rs", "factor out an elf_str() function", and "make WPR heap sizing fallible" from the v9 series. Series is now 28 patches (was 31).

* Depends on the "rust: sizes: SizeConstants trait" series[N], which adds typed SZ_* constants (u64::SZ_1M, u32::SZ_4K, etc.). The nova-core conversion patch ("use SizeConstants trait for u64 size constants") will be posted separately, but is already included in my git branch. The Blackwell patches that introduce new SZ_* usage (larger non-WPR heap, FSP Chain of Trust boot, larger WPR2 heap) use the trait form from the start.

* Fixed the PCI config mirror commit message: corrected hex offsets to match the code (older architectures use 0x088000, Hopper/Blackwell use 0x092000).

* Dropped the never-used nvdm_type_raw() method from the MCTP/NVDM introducing patch.

* Removed stale Co-developed-by tag from the FSP Chain of Trust boot commit per Alex's request. Rewrote the commit message to remove references to the no-longer-existent fmc_full field.

* Added missing #[expect(dead_code)] on GspFmcBootParams in the FSP secure boot commit, removed when the struct becomes used in the Chain of Trust boot commit.

Changes in v9:

* Rebased onto today's drm-rust-next.

* Split Architecture::Blackwell into BlackwellGB10x and BlackwellGB20x, after Gary Guo and Sashiko pointed out that GB10x and GB20x are distinct enough to warrant separate architecture variants. This surfaced several bugs where all Blackwell chips were incorrectly treated as a single group:
* Fixed the FSP boot completion register address for GB10x. GB10x

    uses the same address as Hopper (0x000200bc), not the GB20x
    address (0x00ad00bc).
  * Made the FSP secure boot timeout architecture-dependent. GB20x
    now gets 5000ms while Hopper and GB10x keep 4000ms.

* Removed chipset-level match arms that were working around the single-variant design in fb/hal.rs, firmware/gsp.rs, and regs.rs.

* Simplified find_gsp_sigs_section() to return &'static str instead of Option<&'static str>, since the Architecture enum is now exhaustive and every variant has a known signature section name.

* Moved dma_set_mask_and_coherent from probe() into Gpu::new(), with the unsafe block narrowed to just that call. Gpu::new() now takes pci::Device<device::Core> instead of device::Bound to support this.

* Dropped the local chipset variable in Gpu::new() and accessed spec.chipset() directly, since Spec is now Copy.

* Changed Spec::chipset() to take self instead of &self, since Spec is Copy.

* Removed the unnecessary Tu102/Gh100 consts in gpu/hal.rs and used the unit structs directly.

* Kept a hold on the Firmware object in FspFirmware instead of copying the FMC ELF into a KVec<u8>.

* Moved the dev_info formatting fix and the GFW_BOOT comment removal out of the Copy/Clone patch and into the patches that actually touch those lines.

* Added Reviewed-by tags from Gary Guo and Alice Ryhl.

Changes in v8:

* Added Clone/Copy derives to Spec and Revision. Removed the unnecessary pin_init_scope wrapping in Gpu::new() that the lack of Copy had forced. Added a Spec::chipset() accessor.

* Removed implementation-detail sentence from the
Architecture::dma_mask() doccomment.

* Simplified the GPU HAL to two variants (Tu102, Gh100) instead of four. Renamed "Fsp" to "Gh100" to follow the HAL naming convention. Removed the spurious GA100 special case. Moved the GFW_BOOT wait into the HAL method itself instead of returning a bool.

* Increased the GFW_BOOT wait timeout from 4 seconds to 30 seconds, after Joel found that a different Blackwell SKU required extra time.

* Removed stray Cc lines from each patch.

* Fixed rustfmt issues in gsp/fw.rs and gsp/boot.rs reported by the kernel test robot against v7 patches 27 and 31.

Changes in v7:
* Rebased onto Alexandre Courbot's rust register!() series in drm-rust-next, including the related generic I/O accessor and IoCapable changes.

* Rebased onto drm-rust-next (v7.0-rc4 based).

* Dropped the v6 patches that are already in drm-rust-next: the aux-device fix, the pdev helper macro patch, and the one-item-per-line use cleanup.

* Reworked the GPU init pieces per review. DMA mask setup now stays in driver probe, with the mask width selected by GPU architecture, and the GFW boot policy now lives in a dedicated GPU HAL.

* Reworked firmware image parsing per review around a single ElfFormat trait with associated header types. Also added support for both ELF32 and ELF64 images, with automatic format detection.

* Reworked the MCTP/NVDM protocol code to use bitfield! and typed accessors, removing the open-coded bit handling.

* Reworked the FSP messaging part of the series so that the message structures are introduced in the first patches that use them, instead of as a standalone dead-code-only patch. Also changed fmc_full to use KVec<u8> from the start.

* Split the WPR heap overflow handling out into a separate prep patch. That patch makes management_overhead() and wpr_heap_size() fallible, uses checked arithmetic, and leaves the larger WPR2 heap patch with only the Hopper and Blackwell sizing changes.

* Added a code comment documenting the Hopper and Blackwell PCI config mirror base change.

Changes in v6:

* Rebased onto drm-rust-next (v7.0-rc1 based).

* Dropped the first two patches from v5 (aux device fix and pdev macros), which have since been merged independently.

* const_align_up(): reworked per review from Gary Guo, Miguel Ojeda, and Danilo Krummrich: now returns Option<usize> instead of panicking, takes an Alignment argument instead of a const generic, and no longer needs the inline_const feature addition in scripts/Makefile.build.

* The rust/sizes and SZ_*_U64 patches from v5 are no longer included. I plan to post those as a separate series that depends on this one.

Changes in v5:

* Rebased onto linux.git master.

* Split MCTP protocol into its own module and file.

* Many Rust-based improvements: more use of types, especially. Also used Result and Option more.

* Lots of cleanup of comments and print output and error handling.

* Added const_align_up() to rust/ and used it in nova-core. This required enabling a Rust feature: inline_const, as recommended by Miguel Ojeda.

* Refactoring various things, such as Gpu::new() to own Spec creation, and several more such things.

* Fixed three Delta::ZERO busy-polls (patches 21, 24, 31) to use non-zero sleep intervals (after just realizing that it was a bad choice to have zero in there).

* Reduced GH100/GB100 HAL duplication. Made FSP_PKEY_SIZE/FSP_SIG_SIZE consistent across patches. Replaced fragile architecture checks with chipset.arch(). Renamed LIBOS_BLACKWELL.

* Narrowed the scope of some of the #![expect(dead_code)] cases, although that really only matters within the series, not once it is fully applied.

[1] https://github.com/Gnurou/linux/commits/drm-rust-next-staging/
[2] https://lore.kernel.org/[email protected]

John Hubbard (28):
gpu: nova-core: factor .fwsignature* selection into a new
find_gsp_sigs_section()
gpu: nova-core: use GPU Architecture to simplify HAL selections
gpu: nova-core: Hopper/Blackwell: basic GPU identification
gpu: nova-core: add Copy/Clone to Spec and Revision
gpu: nova-core: set DMA mask width based on GPU architecture
gpu: nova-core: move GFW boot wait into a GPU HAL
gpu: nova-core: Hopper/Blackwell: skip GFW boot waiting
gpu: nova-core: Blackwell: calculate reserved FB heap size
gpu: nova-core: Hopper/Blackwell: new location for PCI config mirror
gpu: nova-core: refactor SEC2 booter loading into
BooterFirmware::run()
gpu: nova-core: Hopper/Blackwell: integrate FSP boot path into boot()
gpu: nova-core: don't assume 64-bit firmware images
gpu: nova-core: add support for 32-bit firmware images
gpu: nova-core: add auto-detection of 32-bit, 64-bit firmware images
gpu: nova-core: Hopper/Blackwell: add FSP falcon engine stub
gpu: nova-core: Hopper/Blackwell: add FMC firmware image, in support
of FSP
gpu: nova-core: Hopper/Blackwell: add FSP secure boot completion
waiting
gpu: nova-core: Hopper/Blackwell: add FMC signature extraction
gpu: nova-core: Hopper/Blackwell: add FSP falcon EMEM operations
gpu: nova-core: Hopper/Blackwell: add FSP message infrastructure
gpu: nova-core: add MCTP/NVDM protocol types for firmware
communication
gpu: nova-core: Hopper/Blackwell: add FSP send/receive messaging
gpu: nova-core: Hopper/Blackwell: add FspCotVersion type
gpu: nova-core: Hopper/Blackwell: larger non-WPR heap
gpu: nova-core: Hopper/Blackwell: add FSP Chain of Trust boot
gpu: nova-core: Blackwell: use correct sysmem flush registers
gpu: nova-core: Hopper/Blackwell: larger WPR2 (GSP) heap
gpu: nova-core: Hopper/Blackwell: add GSP lockdown release polling

 drivers/gpu/nova-core/driver.rs          |  16 -
 drivers/gpu/nova-core/falcon.rs          |   1 +
 drivers/gpu/nova-core/falcon/fsp.rs      | 234 ++++++++++
 drivers/gpu/nova-core/falcon/hal.rs      |  21 +-
 drivers/gpu/nova-core/fb.rs              |  51 ++-
 drivers/gpu/nova-core/fb/hal.rs          |  36 +-
 drivers/gpu/nova-core/fb/hal/ga102.rs    |   2 +-
 drivers/gpu/nova-core/fb/hal/gb100.rs    |  80 ++++
 drivers/gpu/nova-core/fb/hal/gb202.rs    |  77 ++++
 drivers/gpu/nova-core/fb/hal/gh100.rs    |  38 ++
 drivers/gpu/nova-core/firmware.rs        | 176 ++++++--
 drivers/gpu/nova-core/firmware/booter.rs |  30 ++
 drivers/gpu/nova-core/firmware/fsp.rs    |  44 ++
 drivers/gpu/nova-core/firmware/gsp.rs    |  35 +-
 drivers/gpu/nova-core/fsp.rs             | 523 +++++++++++++++++++++++
 drivers/gpu/nova-core/gfw.rs             |  76 ----
 drivers/gpu/nova-core/gpu.rs             |  62 ++-
 drivers/gpu/nova-core/gpu/hal.rs         |  28 ++
 drivers/gpu/nova-core/gpu/hal/gh100.rs   |  18 +
 drivers/gpu/nova-core/gpu/hal/tu102.rs   |  86 ++++
 drivers/gpu/nova-core/gsp/boot.rs        | 286 ++++++++++---
 drivers/gpu/nova-core/gsp/commands.rs    |   8 +-
 drivers/gpu/nova-core/gsp/fw.rs          |  62 ++-
 drivers/gpu/nova-core/gsp/fw/commands.rs |  22 +-
 drivers/gpu/nova-core/mctp.rs            | 119 ++++++
 drivers/gpu/nova-core/nova_core.rs       |   3 +-
 drivers/gpu/nova-core/regs.rs            | 104 +++++
 27 files changed, 2000 insertions(+), 238 deletions(-)
 create mode 100644 drivers/gpu/nova-core/falcon/fsp.rs
 create mode 100644 drivers/gpu/nova-core/fb/hal/gb100.rs
 create mode 100644 drivers/gpu/nova-core/fb/hal/gb202.rs
 create mode 100644 drivers/gpu/nova-core/fb/hal/gh100.rs
 create mode 100644 drivers/gpu/nova-core/firmware/fsp.rs
 create mode 100644 drivers/gpu/nova-core/fsp.rs
 delete mode 100644 drivers/gpu/nova-core/gfw.rs
 create mode 100644 drivers/gpu/nova-core/gpu/hal.rs
 create mode 100644 drivers/gpu/nova-core/gpu/hal/gh100.rs
 create mode 100644 drivers/gpu/nova-core/gpu/hal/tu102.rs
 create mode 100644 drivers/gpu/nova-core/mctp.rs

base-commit: dcba1b1052c8a7381df762597fa50a50ad2efb8d

Signature · 1 line
2.53.0
#1 lore raw

PATCH v10 1/28 gpu: nova-core: factor .fwsignature* selection into a new find_gsp_sigs_section()

Keep Gsp::new() from getting too cluttered, by factoring out the selection of .fwsignature* items. This will continue to grow as we add GPUs.

---
 drivers/gpu/nova-core/firmware/gsp.rs | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/nova-core/firmware/gsp.rs +14 -12
index 2fcc255c3bc8..1fbc2b08123a 100644
@@ -63,6 +63,19 @@ pub(crate) struct GspFirmware {
 }
 
 impl GspFirmware {
+    fn find_gsp_sigs_section(chipset: Chipset) -> &'static str {
+        match chipset.arch() {
+            Architecture::Turing if matches!(chipset, Chipset::TU116 | Chipset::TU117) => {
+                ".fwsignature_tu11x"
+            }
+            Architecture::Turing => ".fwsignature_tu10x",
+            // GA100 uses the same firmware as Turing.
+            Architecture::Ampere if chipset == Chipset::GA100 => ".fwsignature_tu10x",
+            Architecture::Ampere => ".fwsignature_ga10x",
+            Architecture::Ada => ".fwsignature_ad10x",
+        }
+    }
+
     /// Loads the GSP firmware binaries, map them into `dev`'s address-space, and creates the page
     /// tables expected by the GSP bootloader to load it.
     pub(crate) fn new<'a>(
@@ -131,18 +144,7 @@ pub(crate) fn new<'a>(
                 },
                 size,
                 signatures: {
-                    let sigs_section = match chipset.arch() {
-                        Architecture::Turing
-                            if matches!(chipset, Chipset::TU116 | Chipset::TU117) =>
-                        {
-                            ".fwsignature_tu11x"
-                        }
-                        Architecture::Turing => ".fwsignature_tu10x",
-                        // GA100 uses the same firmware as Turing
-                        Architecture::Ampere if chipset == Chipset::GA100 => ".fwsignature_tu10x",
-                        Architecture::Ampere => ".fwsignature_ga10x",
-                        Architecture::Ada => ".fwsignature_ad10x",
-                    };
+                    let sigs_section = Self::find_gsp_sigs_section(chipset);
 
                     elf::elf64_section(firmware.data(), sigs_section)
                         .ok_or(EINVAL)
Signature · 1 line
2.53.0
#2 lore raw

PATCH v10 2/28 gpu: nova-core: use GPU Architecture to simplify HAL selections

In reply to John Hubbard

Replace per-chipset match arms with Architecture-based matching in the falcon and FB HAL selection functions. This reduces the number of match arms that need updating when new chipsets are added within an existing architecture.

---
 drivers/gpu/nova-core/falcon/hal.rs | 17 ++++++++++-------
 drivers/gpu/nova-core/fb/hal.rs     | 18 +++++++++---------
 2 files changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/nova-core/falcon/hal.rs +10 -7
index 71df33c79884..3bfb42684a0e 100644
@@ -9,7 +9,10 @@
         FalconBromParams,
         FalconEngine, //
     },
-    gpu::Chipset,
+    gpu::{
+        Architecture,
+        Chipset, //
+    },
 };
 
 mod ga102;
@@ -74,16 +77,16 @@ fn signature_reg_fuse_version(
 pub(super) fn falcon_hal<E: FalconEngine + 'static>(
     chipset: Chipset,
 ) -> Result<KBox<dyn FalconHal<E>>> {
-    use Chipset::*;
-
-    let hal = match chipset {
-        TU102 | TU104 | TU106 | TU116 | TU117 => {
+    let hal = match chipset.arch() {
+        Architecture::Turing => {
             KBox::new(tu102::Tu102::<E>::new(), GFP_KERNEL)? as KBox<dyn FalconHal<E>>
         }
-        GA102 | GA103 | GA104 | GA106 | GA107 | AD102 | AD103 | AD104 | AD106 | AD107 => {
+        // TODO: support GA100. Its boot sequence is a lot like Turing, except that it handles the
+        // FRTS steps differently (specifically, it skips FWSEC-FRTS).
+        Architecture::Ampere if chipset == Chipset::GA100 => return Err(ENOTSUPP),
+        Architecture::Ampere | Architecture::Ada => {
             KBox::new(ga102::Ga102::<E>::new(), GFP_KERNEL)? as KBox<dyn FalconHal<E>>
         }
-        _ => return Err(ENOTSUPP),
     };
 
     Ok(hal)
drivers/gpu/nova-core/fb/hal.rs +9 -9
index aba0abd8ee00..5a6cb8221e78 100644
@@ -4,7 +4,10 @@
 
 use crate::{
     driver::Bar0,
-    gpu::Chipset, //
+    gpu::{
+        Architecture,
+        Chipset, //
+    },
 };
 
 mod ga100;
@@ -29,13 +32,10 @@ pub(crate) trait FbHal {
 
 /// Returns the HAL corresponding to `chipset`.
 pub(super) fn fb_hal(chipset: Chipset) -> &'static dyn FbHal {
-    use Chipset::*;
-
-    match chipset {
-        TU102 | TU104 | TU106 | TU117 | TU116 => tu102::TU102_HAL,
-        GA100 => ga100::GA100_HAL,
-        GA102 | GA103 | GA104 | GA106 | GA107 | AD102 | AD103 | AD104 | AD106 | AD107 => {
-            ga102::GA102_HAL
-        }
+    match chipset.arch() {
+        Architecture::Turing => tu102::TU102_HAL,
+        Architecture::Ampere if chipset == Chipset::GA100 => ga100::GA100_HAL,
+        Architecture::Ampere => ga102::GA102_HAL,
+        Architecture::Ada => ga102::GA102_HAL,
     }
 }
Signature · 1 line
2.53.0
reviewer Reviewed-by on v10 2/28
#3 lore raw

Re: [PATCH v10 02/28] gpu: nova-core: use GPU Architecture to simplify HAL selections

Quoted 6 lines · John Hubbard

Replace per-chipset match arms with Architecture-based matching in the falcon and FB HAL selection functions. This reduces the number of match arms that need updating when new chipsets are added within an existing architecture.

Quoted 4 lines
---
 drivers/gpu/nova-core/falcon/hal.rs | 17 ++++++++++-------
 drivers/gpu/nova-core/fb/hal.rs     | 18 +++++++++---------
 2 files changed, 19 insertions(+), 16 deletions(-)
#4 lore raw

PATCH v10 3/28 gpu: nova-core: Hopper/Blackwell: basic GPU identification

In reply to John Hubbard

Hopper (GH100) and Blackwell identification, including ELF .fwsignature_* items.

---
 drivers/gpu/nova-core/falcon/hal.rs   |  6 +++++-
 drivers/gpu/nova-core/fb/hal.rs       |  5 ++++-
 drivers/gpu/nova-core/firmware/gsp.rs |  3 +++
 drivers/gpu/nova-core/gpu.rs          | 18 ++++++++++++++++++
 4 files changed, 30 insertions(+), 2 deletions(-)
drivers/gpu/nova-core/falcon/hal.rs +5 -1
index 3bfb42684a0e..51615381b495 100644
@@ -84,7 +84,11 @@ pub(super) fn falcon_hal<E: FalconEngine + 'static>(
         // TODO: support GA100. Its boot sequence is a lot like Turing, except that it handles the
         // FRTS steps differently (specifically, it skips FWSEC-FRTS).
         Architecture::Ampere if chipset == Chipset::GA100 => return Err(ENOTSUPP),
-        Architecture::Ampere | Architecture::Ada => {
+        Architecture::Ampere
+        | Architecture::Ada
+        | Architecture::Hopper
+        | Architecture::BlackwellGB10x
+        | Architecture::BlackwellGB20x => {
             KBox::new(ga102::Ga102::<E>::new(), GFP_KERNEL)? as KBox<dyn FalconHal<E>>
         }
     };
drivers/gpu/nova-core/fb/hal.rs +4 -1
index 5a6cb8221e78..3b3bad0feed0 100644
@@ -36,6 +36,9 @@ pub(super) fn fb_hal(chipset: Chipset) -> &'static dyn FbHal {
         Architecture::Turing => tu102::TU102_HAL,
         Architecture::Ampere if chipset == Chipset::GA100 => ga100::GA100_HAL,
         Architecture::Ampere => ga102::GA102_HAL,
-        Architecture::Ada => ga102::GA102_HAL,
+        Architecture::Ada
+        | Architecture::Hopper
+        | Architecture::BlackwellGB10x
+        | Architecture::BlackwellGB20x => ga102::GA102_HAL,
     }
 }
drivers/gpu/nova-core/firmware/gsp.rs +3 -0
index 1fbc2b08123a..617ec2aaa93a 100644
@@ -73,6 +73,9 @@ fn find_gsp_sigs_section(chipset: Chipset) -> &'static str {
             Architecture::Ampere if chipset == Chipset::GA100 => ".fwsignature_tu10x",
             Architecture::Ampere => ".fwsignature_ga10x",
             Architecture::Ada => ".fwsignature_ad10x",
+            Architecture::Hopper => ".fwsignature_gh10x",
+            Architecture::BlackwellGB10x => ".fwsignature_gb10x",
+            Architecture::BlackwellGB20x => ".fwsignature_gb20x",
         }
     }
 
drivers/gpu/nova-core/gpu.rs +18 -0
index 0f6fe9a1b955..20625e8e26b7 100644
@@ -86,12 +86,22 @@ fn try_from(value: u32) -> Result<Self, Self::Error> {
     GA104 = 0x174,
     GA106 = 0x176,
     GA107 = 0x177,
+    // Hopper
+    GH100 = 0x180,
     // Ada
     AD102 = 0x192,
     AD103 = 0x193,
     AD104 = 0x194,
     AD106 = 0x196,
     AD107 = 0x197,
+    // Blackwell
+    GB100 = 0x1a0,
+    GB102 = 0x1a2,
+    GB202 = 0x1b2,
+    GB203 = 0x1b3,
+    GB205 = 0x1b5,
+    GB206 = 0x1b6,
+    GB207 = 0x1b7,
 });
 
 impl Chipset {
@@ -103,9 +113,14 @@ pub(crate) const fn arch(self) -> Architecture {
             Self::GA100 | Self::GA102 | Self::GA103 | Self::GA104 | Self::GA106 | Self::GA107 => {
                 Architecture::Ampere
             }
+            Self::GH100 => Architecture::Hopper,
             Self::AD102 | Self::AD103 | Self::AD104 | Self::AD106 | Self::AD107 => {
                 Architecture::Ada
             }
+            Self::GB100 | Self::GB102 => Architecture::BlackwellGB10x,
+            Self::GB202 | Self::GB203 | Self::GB205 | Self::GB206 | Self::GB207 => {
+                Architecture::BlackwellGB20x
+            }
         }
     }
 
@@ -137,7 +152,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
     pub(crate) enum Architecture with TryFrom<Bounded<u32, 6>> {
         Turing = 0x16,
         Ampere = 0x17,
+        Hopper = 0x18,
         Ada = 0x19,
+        BlackwellGB10x = 0x1a,
+        BlackwellGB20x = 0x1b,
     }
 }
 
Signature · 1 line
2.53.0
#5 lore raw

Re: [PATCH v10 03/28] gpu: nova-core: Hopper/Blackwell: basic GPU identification

Quoted 2 lines · John Hubbard

+        | Architecture::BlackwellGB10x
+        | Architecture::BlackwellGB20x => {

Can you add something to the patch description that explains why Blackwell, unlike all of the olther architectures, is represented by two Architecture enums?

#6 lore raw

Re: [PATCH v10 03/28] gpu: nova-core: Hopper/Blackwell: basic GPU identification

Quoted 6 lines · Timur Tabi
Quoted 2 lines · John Hubbard

+        | Architecture::BlackwellGB10x
+        | Architecture::BlackwellGB20x => {

Can you add something to the patch description that explains why Blackwell, unlike all of the olther architectures, is represented by two Architecture enums?

How's this:

Blackwell uses two Architecture variants because the hardware itself exposes two distinct architecture IDs in NV_PMC_BOOT_0: 0x1A for GB10x (GB100, GB102) and 0x1B for GB20x (GB202, GB203, GB205, GB206, GB207). Open RM maps these into separate chip families with distinct HAL routing and different firmware signature sections.

thanks,

Signature · 1 line
John Hubbard
#7 lore raw

Re: [PATCH v10 03/28] gpu: nova-core: Hopper/Blackwell: basic GPU identification

Quoted 10 lines · John Hubbard
Quoted 2 lines

Can you add something to the patch description that explains why Blackwell, unlike all of the olther architectures, is represented by two Architecture enums?

How's this:

Blackwell uses two Architecture variants because the hardware itself exposes two distinct architecture IDs in NV_PMC_BOOT_0: 0x1A for GB10x (GB100, GB102) and 0x1B for GB20x (GB202, GB203, GB205, GB206, GB207). Open RM maps these into separate chip families with distinct HAL routing and different firmware signature sections.

We don't need two arch's for Ampere to handle different firmware signature sections. Looking through your patches, the vast majority do this:

	Architecture::BlackwellGB10x | Architecture::BlackwellGB20x

Looking through your patches, it seems overkill to separate these two. The one or two instances where it makes a difference, an if-statement will suffice.

As for OpenRM, IMHO RM is very much HAL-happy. There's a whole built-in mechanism for hal-ifying any function at any chip level. Nova isn't really like that.

Anyway, I don't want to belabor this point. It just seems to me that since you have "GB10x | GB20x" more more frequently than you don't, I don't think this warrants two architecture enums.

#8 lore raw

Re: [PATCH v10 03/28] gpu: nova-core: Hopper/Blackwell: basic GPU identification

Quoted 8 lines · Timur Tabi
Quoted 7 lines · John Hubbard
Quoted 2 lines

Can you add something to the patch description that explains why Blackwell, unlike all of the olther architectures, is represented by two Architecture enums?

How's this:

Blackwell uses two Architecture variants because the hardware itself exposes two distinct architecture IDs in NV_PMC_BOOT_0: 0x1A for

This is really what drove it, for me, though: the hardware itself saw fit to identify these two variants as architectures. It's encoded into the very fabric of space-time itself! haha :)

Quoted 11 lines
Quoted 3 lines

GB10x (GB100, GB102) and 0x1B for GB20x (GB202, GB203, GB205, GB206, GB207). Open RM maps these into separate chip families with distinct HAL routing and different firmware signature sections.

We don't need two arch's for Ampere to handle different firmware signature sections. Looking through your patches, the vast majority do this:

	Architecture::BlackwellGB10x | Architecture::BlackwellGB20x

Looking through your patches, it seems overkill to separate these two. The one or two instances where it makes a difference, an if-statement will suffice.

It's arguably worse, however, to save a (very) few lines of code, in favor of adding special cases into the basic Arch/chipset categorization.

Again, it would be one thing if this were a software decision. But the HW itself set this up. So it's reasonable to follow the HW.

Quoted 3 lines

As for OpenRM, IMHO RM is very much HAL-happy. There's a whole built-in mechanism for hal-ifying any function at any chip level. Nova isn't really like that.

This is not something that Open RM did. It's something that HW did. And so while Open RM criticisms about HAL granularity are reasonable, they do not apply here.

Quoted 4 lines

Anyway, I don't want to belabor this point. It just seems to me that since you have "GB10x | GB20x" more more frequently than you don't, I don't think this warrants two architecture enums.

thanks,

Signature · 1 line
John Hubbard
#9 lore raw

Re: [PATCH v10 03/28] gpu: nova-core: Hopper/Blackwell: basic GPU identification

Quoted 5 lines · John Hubbard
Quoted 4 lines · Timur Tabi
Quoted 3 lines · John Hubbard
Quoted 2 lines

Can you add something to the patch description that explains why Blackwell, unlike all of the olther architectures, is represented by two Architecture enums?

Quoted 20 lines
Quoted 4 lines
Quoted 4 lines

How's this:

Blackwell uses two Architecture variants because the hardware itself exposes two distinct architecture IDs in NV_PMC_BOOT_0: 0x1A for

This is really what drove it, for me, though: the hardware itself saw fit to identify these two variants as architectures. It's encoded into the very fabric of space-time itself! haha :)

Quoted 11 lines
Quoted 3 lines

GB10x (GB100, GB102) and 0x1B for GB20x (GB202, GB203, GB205, GB206, GB207). Open RM maps these into separate chip families with distinct HAL routing and different firmware signature sections.

We don't need two arch's for Ampere to handle different firmware signature sections. Looking through your patches, the vast majority do this:

	Architecture::BlackwellGB10x | Architecture::BlackwellGB20x

Looking through your patches, it seems overkill to separate these two. The one or two instances where it makes a difference, an if-statement will suffice.

I have to agree here, if we didn't split then the architecture IDs 0x1a and 0x1b would need to both map to Blackwell, which makes them impossible to represent correctly using an enum.

And granted, there are lots of

Architecture::BlackwellGB10x | Architecture::BlackwellGB20x

in the code, but that catches the attention only because the variants share the same prefix. If BlackwellGB20x was named something completely different, it would go unnoticed (just like we often include Ada in the same match arms as Blackwell).

So while it does look a bit strange to have 2 Blackwells, it does reflect the hardware architecture correctly and doing things differently would result in more complexity/incorrectness. For instance until v8 there was only a single Blackwell architecture with the ID 0x1b, leaving 0x1a completely unmanaged.

#10 lore raw

Re: [PATCH v10 03/28] gpu: nova-core: Hopper/Blackwell: basic GPU identification

Quoted 22 lines · Alexandre Courbot
Quoted 21 lines · John Hubbard
Quoted 8 lines · Timur Tabi
Quoted 7 lines · John Hubbard
Quoted 2 lines

Can you add something to the patch description that explains why Blackwell, unlike all of the olther architectures, is represented by two Architecture enums?

How's this:

Blackwell uses two Architecture variants because the hardware itself exposes two distinct architecture IDs in NV_PMC_BOOT_0: 0x1A for

This is really what drove it, for me, though: the hardware itself saw fit to identify these two variants as architectures. It's encoded into the very fabric of space-time itself! haha :)

Quoted 7 lines
Quoted 3 lines

GB10x (GB100, GB102) and 0x1B for GB20x (GB202, GB203, GB205, GB206, GB207). Open RM maps these into separate chip families with distinct HAL routing and different firmware signature sections.

We don't need two arch's for Ampere to handle different firmware signature sections. Looking through your patches, the vast majority do this:

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
	Architecture::BlackwellGB10x | Architecture::BlackwellGB20x

Looking through your patches, it seems overkill to separate these two. The one or two instances where it makes a difference, an if-statement will suffice.

I have to agree here, if we didn't split then the architecture IDs 0x1a and 0x1b would need to both map to Blackwell, which makes them impossible to represent correctly using an enum.

Sorry, I misquoted the email in my reply - to clarify, I agree with John's point that GB10x and GB20x need to be represented using two different architectures. :)

reviewer Reviewed-by on v10 3/28
#11 lore raw

Re: [PATCH v10 03/28] gpu: nova-core: Hopper/Blackwell: basic GPU identification

In reply to John Hubbard
Quoted 4 lines · John Hubbard

Hopper (GH100) and Blackwell identification, including ELF .fwsignature_* items.

Quoted 6 lines
---
 drivers/gpu/nova-core/falcon/hal.rs   |  6 +++++-
 drivers/gpu/nova-core/fb/hal.rs       |  5 ++++-
 drivers/gpu/nova-core/firmware/gsp.rs |  3 +++
 drivers/gpu/nova-core/gpu.rs          | 18 ++++++++++++++++++
 4 files changed, 30 insertions(+), 2 deletions(-)
#12 lore raw

PATCH v10 4/28 gpu: nova-core: add Copy/Clone to Spec and Revision

In reply to John Hubbard

Derive Clone and Copy for Revision and Spec. Both are small value types (4 bytes total) and Copy makes them easier to use in later patches that pass them across function boundaries.

---
 drivers/gpu/nova-core/gpu.rs | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/nova-core/gpu.rs +2 -0
index 20625e8e26b7..4cf5e1ff830b 100644
@@ -159,6 +159,7 @@ pub(crate) enum Architecture with TryFrom<Bounded<u32, 6>> {
     }
 }
 
+#[derive(Clone, Copy)]
 pub(crate) struct Revision {
     major: Bounded<u8, 4>,
     minor: Bounded<u8, 4>,
@@ -180,6 +181,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,
     revision: Revision,
Signature · 1 line
2.53.0
reviewer Reviewed-by on v10 4/28
#13 lore raw

Re: [PATCH v10 04/28] gpu: nova-core: add Copy/Clone to Spec and Revision

Quoted 5 lines · John Hubbard

Derive Clone and Copy for Revision and Spec. Both are small value types (4 bytes total) and Copy makes them easier to use in later patches that pass them across function boundaries.

Quoted 3 lines
---
 drivers/gpu/nova-core/gpu.rs | 2 ++
 1 file changed, 2 insertions(+)
#14 lore raw

PATCH v10 5/28 gpu: nova-core: set DMA mask width based on GPU architecture

In reply to John Hubbard

Replace the hardcoded 47-bit DMA mask with per-architecture values. Add Architecture::dma_mask() with an exhaustive match, so new architectures get a compile-time reminder to specify their width.

Set the DMA mask in Gpu::new(). Gpu owns all DMA allocations for the device, so no concurrent allocations can exist while the constructor is still running.

---
 drivers/gpu/nova-core/driver.rs | 16 ----------------
 drivers/gpu/nova-core/gpu.rs    | 22 ++++++++++++++++++++--
 2 files changed, 20 insertions(+), 18 deletions(-)
drivers/gpu/nova-core/driver.rs +0 -16
index 84b0e1703150..3f655337ef6f 100644
@@ -4,8 +4,6 @@
     auxiliary,
     device::Core,
     devres::Devres,
-    dma::Device,
-    dma::DmaMask,
     pci,
     pci::{
         Class,
@@ -38,14 +36,6 @@ pub(crate) struct NovaCore {
 
 const BAR0_SIZE: usize = SZ_16M;
 
-// For now we only support Ampere which can use up to 47-bit DMA addresses.
-//
-// TODO: Add an abstraction for this to support newer GPUs which may support
-// larger DMA addresses. Limiting these GPUs to smaller address widths won't
-// have any adverse affects, unless installed on systems which require larger
-// DMA addresses. These systems should be quite rare.
-const GPU_DMA_BITS: u32 = 47;
-
 pub(crate) type Bar0 = pci::Bar<BAR0_SIZE>;
 
 kernel::pci_device_table!(
@@ -84,16 +74,10 @@ fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> impl PinInit<Self, E
             pdev.enable_device_mem()?;
             pdev.set_master();
 
-            // SAFETY: No concurrent DMA allocations or mappings can be made because
-            // the device is still being probed and therefore isn't being used by
-            // other threads of execution.
-            unsafe { pdev.dma_set_mask_and_coherent(DmaMask::new::<GPU_DMA_BITS>())? };
-
             let bar = Arc::pin_init(
                 pdev.iomap_region_sized::<BAR0_SIZE>(0, c"nova-core/bar0"),
                 GFP_KERNEL,
             )?;
-
             Ok(try_pin_init!(Self {
                 gpu <- Gpu::new(pdev, bar.clone(), bar.access(pdev.as_ref())?),
                 _reg <- auxiliary::Registration::new(
drivers/gpu/nova-core/gpu.rs +20 -2
index 4cf5e1ff830b..6db646a49519 100644
@@ -3,6 +3,10 @@
 use kernel::{
     device,
     devres::Devres,
+    dma::{
+        Device,
+        DmaMask, //
+    },
     fmt,
     io::Io,
     num::Bounded,
@@ -159,6 +163,16 @@ pub(crate) enum Architecture with TryFrom<Bounded<u32, 6>> {
     }
 }
 
+impl Architecture {
+    /// Returns the DMA mask supported by this architecture.
+    pub(crate) const fn dma_mask(&self) -> DmaMask {
+        match self {
+            Self::Turing | Self::Ampere | Self::Ada => DmaMask::new::<47>(),
+            Self::Hopper | Self::BlackwellGB10x | Self::BlackwellGB20x => DmaMask::new::<52>(),
+        }
+    }
+}
+
 #[derive(Clone, Copy)]
 pub(crate) struct Revision {
     major: Bounded<u8, 4>,
@@ -262,17 +276,21 @@ pub(crate) struct Gpu {
 
 impl Gpu {
     pub(crate) fn new<'a>(
-        pdev: &'a pci::Device<device::Bound>,
+        pdev: &'a pci::Device<device::Core>,
         devres_bar: Arc<Devres<Bar0>>,
         bar: &'a Bar0,
     ) -> impl PinInit<Self, Error> + 'a {
         try_pin_init!(Self {
             spec: Spec::new(pdev.as_ref(), bar).inspect(|spec| {
-                dev_info!(pdev,"NVIDIA ({})\n", spec);
+                dev_info!(pdev, "NVIDIA ({})\n", spec);
             })?,
 
             // We must wait for GFW_BOOT completion before doing any significant setup on the GPU.
             _: {
+                // SAFETY: `Gpu` owns all DMA allocations for this device, and we are
+                // still constructing it, so no concurrent DMA allocations can exist.
+                unsafe { pdev.dma_set_mask_and_coherent(spec.chipset.arch().dma_mask())? };
+
                 gfw::wait_gfw_boot_completion(bar)
                     .inspect_err(|_| dev_err!(pdev, "GFW boot did not complete\n"))?;
             },
Signature · 1 line
2.53.0
reviewer Reviewed-by on v10 5/28
#15 lore raw

Re: [PATCH v10 05/28] gpu: nova-core: set DMA mask width based on GPU architecture

Quoted 9 lines · John Hubbard

Replace the hardcoded 47-bit DMA mask with per-architecture values. Add Architecture::dma_mask() with an exhaustive match, so new architectures get a compile-time reminder to specify their width.

Set the DMA mask in Gpu::new(). Gpu owns all DMA allocations for the device, so no concurrent allocations can exist while the constructor is still running.

Quoted 4 lines
---
 drivers/gpu/nova-core/driver.rs | 16 ----------------
 drivers/gpu/nova-core/gpu.rs    | 22 ++++++++++++++++++++--
 2 files changed, 20 insertions(+), 18 deletions(-)
#16 lore raw

PATCH v10 6/28 gpu: nova-core: move GFW boot wait into a GPU HAL

In reply to John Hubbard

Introduce a GpuHal trait and per-family dispatch so GPU boot behavior can vary by architecture. Move wait_gfw_boot_completion() from the standalone gfw module into gpu/hal/tu102.rs as the first GpuHal implementation. All architectures currently dispatch to this implementation, preserving existing behavior.

---
 drivers/gpu/nova-core/gfw.rs           | 76 -----------------------
 drivers/gpu/nova-core/gpu.rs           |  5 +-
 drivers/gpu/nova-core/gpu/hal.rs       | 29 +++++++++
 drivers/gpu/nova-core/gpu/hal/tu102.rs | 86 ++++++++++++++++++++++++++
 drivers/gpu/nova-core/nova_core.rs     |  1 -
 5 files changed, 118 insertions(+), 79 deletions(-)
 delete mode 100644 drivers/gpu/nova-core/gfw.rs
 create mode 100644 drivers/gpu/nova-core/gpu/hal.rs
 create mode 100644 drivers/gpu/nova-core/gpu/hal/tu102.rs
drivers/gpu/nova-core/gfw.rs deleted +0 -76
deleted file mode 100644
index fb75dd10a172..000000000000
@@ -1,76 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-
-//! GPU Firmware (`GFW`) support, a.k.a `devinit`.
-//!
-//! Upon reset, the GPU runs some firmware code from the BIOS to setup its core parameters. Most of
-//! the GPU is considered unusable until this step is completed, so we must wait on it before
-//! performing driver initialization.
-//!
-//! A clarification about devinit terminology: devinit is a sequence of register read/writes after
-//! reset that performs tasks such as:
-//! 1. Programming VRAM memory controller timings.
-//! 2. Power sequencing.
-//! 3. Clock and PLL configuration.
-//! 4. Thermal management.
-//!
-//! devinit itself is a 'script' which is interpreted by an interpreter program typically running
-//! on the PMU microcontroller.
-//!
-//! Note that the devinit sequence also needs to run during suspend/resume.
-
-use kernel::{
-    io::{
-        poll::read_poll_timeout,
-        Io, //
-    },
-    prelude::*,
-    time::Delta, //
-};
-
-use crate::{
-    driver::Bar0,
-    regs, //
-};
-
-/// Wait for the `GFW` (GPU firmware) boot completion signal (`GFW_BOOT`), or a 4 seconds timeout.
-///
-/// Upon GPU reset, several microcontrollers (such as PMU, SEC2, GSP etc) run some firmware code to
-/// setup its core parameters. Most of the GPU is considered unusable until this step is completed,
-/// so it must be waited on very early during driver initialization.
-///
-/// The `GFW` code includes several components that need to execute before the driver loads. These
-/// components are located in the VBIOS ROM and executed in a sequence on these different
-/// microcontrollers. The devinit sequence typically runs on the PMU, and the FWSEC runs on the
-/// GSP.
-///
-/// This function waits for a signal indicating that core initialization is complete. Before this
-/// signal is received, little can be done with the GPU. This signal is set by the FWSEC running on
-/// the GSP in Heavy-secured mode.
-pub(crate) fn wait_gfw_boot_completion(bar: &Bar0) -> Result {
-    // Before accessing the completion status in `NV_PGC6_AON_SECURE_SCRATCH_GROUP_05`, we must
-    // first check `NV_PGC6_AON_SECURE_SCRATCH_GROUP_05_PRIV_LEVEL_MASK`. This is because
-    // `NV_PGC6_AON_SECURE_SCRATCH_GROUP_05` becomes accessible only after the secure firmware
-    // (FWSEC) lowers the privilege level to allow CPU (LS/Light-secured) access. We can only
-    // safely read the status register from CPU (LS/Light-secured) once the mask indicates
-    // that the privilege level has been lowered.
-    //
-    // TIMEOUT: arbitrarily large value. GFW starts running immediately after the GPU is put out of
-    // reset, and should complete in less time than that.
-    read_poll_timeout(
-        || {
-            Ok(
-                // Check that FWSEC has lowered its protection level before reading the GFW_BOOT
-                // status.
-                bar.read(regs::NV_PGC6_AON_SECURE_SCRATCH_GROUP_05_PRIV_LEVEL_MASK)
-                    .read_protection_level0()
-                    && bar
-                        .read(regs::NV_PGC6_AON_SECURE_SCRATCH_GROUP_05_0_GFW_BOOT)
-                        .completed(),
-            )
-        },
-        |&gfw_booted| gfw_booted,
-        Delta::from_millis(1),
-        Delta::from_secs(4),
-    )
-    .map(|_| ())
-}
drivers/gpu/nova-core/gpu.rs +3 -2
index 6db646a49519..0b3a62f6ad1b 100644
@@ -24,11 +24,12 @@
         Falcon, //
     },
     fb::SysmemFlush,
-    gfw,
     gsp::Gsp,
     regs,
 };
 
+mod hal;
+
 macro_rules! define_chipset {
     ({ $($variant:ident = $value:expr),* $(,)* }) =>
     {
@@ -291,7 +292,7 @@ pub(crate) fn new<'a>(
                 // still constructing it, so no concurrent DMA allocations can exist.
                 unsafe { pdev.dma_set_mask_and_coherent(spec.chipset.arch().dma_mask())? };
 
-                gfw::wait_gfw_boot_completion(bar)
+                hal::gpu_hal(spec.chipset).wait_gfw_boot_completion(bar)
                     .inspect_err(|_| dev_err!(pdev, "GFW boot did not complete\n"))?;
             },
 
drivers/gpu/nova-core/gpu/hal.rs new file +29 -0
new file mode 100644
index 000000000000..a261c6af92be
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0
+
+use kernel::prelude::*;
+
+use crate::{
+    driver::Bar0,
+    gpu::{
+        Architecture,
+        Chipset, //
+    },
+};
+
+mod tu102;
+
+pub(crate) trait GpuHal {
+    /// Waits for GFW_BOOT completion if required by this hardware family.
+    fn wait_gfw_boot_completion(&self, bar: &Bar0) -> Result;
+}
+
+pub(super) fn gpu_hal(chipset: Chipset) -> &'static dyn GpuHal {
+    match chipset.arch() {
+        Architecture::Turing
+        | Architecture::Ampere
+        | Architecture::Ada
+        | Architecture::Hopper
+        | Architecture::BlackwellGB10x
+        | Architecture::BlackwellGB20x => tu102::TU102_HAL,
+    }
+}
drivers/gpu/nova-core/gpu/hal/tu102.rs new file +86 -0

86 lines not on this page · raw message

drivers/gpu/nova-core/nova_core.rs +0 -1
index 04a1fa6b25f8..3a609f6937e4 100644
@@ -17,7 +17,6 @@
 mod falcon;
 mod fb;
 mod firmware;
-mod gfw;
 mod gpu;
 mod gsp;
 #[macro_use]
Signature · 1 line
2.53.0
#17 lore raw

PATCH v10 7/28 gpu: nova-core: Hopper/Blackwell: skip GFW boot waiting

In reply to John Hubbard

Hopper and Blackwell GPUs use FSP-based secure boot and do not require waiting for GFW_BOOT completion. Add a Gh100 GPU HAL that returns Ok(()) for wait_gfw_boot_completion(), and route Hopper and Blackwell architectures to it.

---
 drivers/gpu/nova-core/gpu/hal.rs       | 11 +++++------
 drivers/gpu/nova-core/gpu/hal/gh100.rs | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+), 6 deletions(-)
 create mode 100644 drivers/gpu/nova-core/gpu/hal/gh100.rs
drivers/gpu/nova-core/gpu/hal.rs +5 -6
index a261c6af92be..788de20ab5d3 100644
@@ -10,6 +10,7 @@
     },
 };
 
+mod gh100;
 mod tu102;
 
 pub(crate) trait GpuHal {
@@ -19,11 +20,9 @@ pub(crate) trait GpuHal {
 
 pub(super) fn gpu_hal(chipset: Chipset) -> &'static dyn GpuHal {
     match chipset.arch() {
-        Architecture::Turing
-        | Architecture::Ampere
-        | Architecture::Ada
-        | Architecture::Hopper
-        | Architecture::BlackwellGB10x
-        | Architecture::BlackwellGB20x => tu102::TU102_HAL,
+        Architecture::Turing | Architecture::Ampere | Architecture::Ada => tu102::TU102_HAL,
+        Architecture::Hopper | Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => {
+            gh100::GH100_HAL
+        }
     }
 }
drivers/gpu/nova-core/gpu/hal/gh100.rs new file +18 -0
new file mode 100644
index 000000000000..1ed5bccdda1d
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+
+use kernel::prelude::*;
+
+use crate::driver::Bar0;
+
+use super::GpuHal;
+
+struct Gh100;
+
+impl GpuHal for Gh100 {
+    fn wait_gfw_boot_completion(&self, _bar: &Bar0) -> Result {
+        Ok(())
+    }
+}
+
+const GH100: Gh100 = Gh100;
+pub(super) const GH100_HAL: &dyn GpuHal = &GH100;
Signature · 1 line
2.53.0
#18 lore raw

PATCH v10 8/28 gpu: nova-core: Blackwell: calculate reserved FB heap size

In reply to John Hubbard

Various "reserved" areas of FB (frame buffer: vidmem) have to be calculated, because the GSP booting process needs this information.

PMU_RESERVED_SIZE is computed at compile time using const_align_up() and applied only for Blackwell dGPU architectures. All other architectures leave it at zero, matching Open RM behavior.

---
 drivers/gpu/nova-core/fb.rs     | 38 ++++++++++++++++++++++++++++++---
 drivers/gpu/nova-core/gsp/fw.rs |  1 +
 2 files changed, 36 insertions(+), 3 deletions(-)
drivers/gpu/nova-core/fb.rs +35 -3
index 35899e9b2560..c2005e4b4177 100644
@@ -12,6 +12,7 @@
     io::Io,
     prelude::*,
     ptr::{
+        const_align_up,
         Alignable,
         Alignment, //
     },
@@ -22,10 +23,16 @@
 use crate::{
     driver::Bar0,
     firmware::gsp::GspFirmware,
-    gpu::Chipset,
+    gpu::{
+        Architecture,
+        Chipset, //
+    },
     gsp,
-    num::FromSafeCast,
-    regs, //
+    num::{
+        usize_into_u32,
+        FromSafeCast, //
+    },
+    regs,
 };
 
 mod hal;
@@ -168,6 +175,8 @@ pub(crate) struct FbLayout {
     pub(crate) wpr2: FbRange,
     pub(crate) heap: FbRange,
     pub(crate) vf_partition_count: u8,
+    /// PMU reserved memory size, in bytes.
+    pub(crate) pmu_reserved_size: u32,
 }
 
 impl FbLayout {
@@ -268,6 +277,29 @@ pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result<
             wpr2,
             heap,
             vf_partition_count: 0,
+            pmu_reserved_size: match chipset.arch() {
+                Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => PMU_RESERVED_SIZE,
+                _ => 0,
+            },
         })
     }
 }
+
+/// Returns the PMU reserved memory size for `chipset`.
+#[expect(dead_code)]
+pub(crate) fn calc_pmu_reserved_size(chipset: Chipset) -> u32 {
+    match chipset.arch() {
+        Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => PMU_RESERVED_SIZE,
+        _ => 0,
+    }
+}
+
+/// PMU reserved size, aligned to 128KB.
+pub(crate) const PMU_RESERVED_SIZE: u32 = usize_into_u32::<
+    {
+        match const_align_up(SZ_8M + SZ_16M + SZ_4K, Alignment::new::<SZ_128K>()) {
+            Some(v) => v,
+            None => panic!("PMU_RESERVED_SIZE: alignment overflow"),
+        }
+    },
+>();
drivers/gpu/nova-core/gsp/fw.rs +1 -0
index 3245793bbe42..5d36604ea1a3 100644
@@ -247,6 +247,7 @@ pub(crate) fn new<'a>(
             fbSize: fb_layout.fb.end - fb_layout.fb.start,
             vgaWorkspaceOffset: fb_layout.vga_workspace.start,
             vgaWorkspaceSize: fb_layout.vga_workspace.end - fb_layout.vga_workspace.start,
+            pmuReservedSize: fb_layout.pmu_reserved_size,
             ..Zeroable::init_zeroed()
         });
 
Signature · 1 line
2.53.0
#19 lore raw

Re: [PATCH v10 08/28] gpu: nova-core: Blackwell: calculate reserved FB heap size

On Sat Apr 11, 2026 at 11:49 AM JST, John Hubbard wrote:
<snip>

Quoted 10 lines
drivers/gpu/nova-core/fb.rs +2 -0
@@ -168,6 +175,8 @@ pub(crate) struct FbLayout {
     pub(crate) wpr2: FbRange,
     pub(crate) heap: FbRange,
     pub(crate) vf_partition_count: u8,
+    /// PMU reserved memory size, in bytes.
+    pub(crate) pmu_reserved_size: u32,
 }
 
 impl FbLayout {

drivers/gpu/nova-core/fb.rs pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result< · line 283

Quoted 7 lines
drivers/gpu/nova-core/fb.rs +4 -0
@@ -268,6 +277,29 @@ pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result<
             wpr2,
             heap,
             vf_partition_count: 0,
+            pmu_reserved_size: match chipset.arch() {
+                Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => PMU_RESERVED_SIZE,
+                _ => 0,
+            },

I suspect you can just call calc_pmu_reserved_size, which seem to perform the exact same computation?

drivers/gpu/nova-core/fb.rs pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result< · line 294

Quoted 11 lines
drivers/gpu/nova-core/fb.rs +8 -0
         })
     }
 }
+
+/// Returns the PMU reserved memory size for `chipset`.
+#[expect(dead_code)]
+pub(crate) fn calc_pmu_reserved_size(chipset: Chipset) -> u32 {
+    match chipset.arch() {
+        Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => PMU_RESERVED_SIZE,
+        _ => 0,
+    }

We should avoid these matches on Architecture in common code as much as possible - that's what the HALs are for. Which means that calc_pmu_reserved_size should call a HAL method to obtain the right size (I'd also rename it to just pmu_reserved_size as we are not computing anything at runtime).

drivers/gpu/nova-core/fb.rs pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result< · line 305

Quoted 11 lines
drivers/gpu/nova-core/fb.rs +11 -0
+}
+
+/// PMU reserved size, aligned to 128KB.
+pub(crate) const PMU_RESERVED_SIZE: u32 = usize_into_u32::<
+    {
+        match const_align_up(SZ_8M + SZ_16M + SZ_4K, Alignment::new::<SZ_128K>()) {
+            Some(v) => v,
+            None => panic!("PMU_RESERVED_SIZE: alignment overflow"),
+        }
+    },
+>();

Consequently, this should be moved into the Blackwell HAL - which is where is belongs, as contrary to what its name implies in the current module, this reserved size does not apply to all architectures.

#20 lore raw

Re: [PATCH v10 08/28] gpu: nova-core: Blackwell: calculate reserved FB heap size

Quoted 10 lines · Alexandre Courbot

On Sat Apr 11, 2026 at 11:49 AM JST, John Hubbard wrote:
<snip>

Quoted 8 lines
drivers/gpu/nova-core/fb.rs +2 -0
@@ -168,6 +175,8 @@ pub(crate) struct FbLayout {
     pub(crate) wpr2: FbRange,
     pub(crate) heap: FbRange,
     pub(crate) vf_partition_count: u8,
+    /// PMU reserved memory size, in bytes.
+    pub(crate) pmu_reserved_size: u32,
 }
 
Quoted 12 lines

drivers/gpu/nova-core/fb.rs pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result< · line 283

Quoted 9 lines
drivers/gpu/nova-core/fb.rs +4 -0
 impl FbLayout {
@@ -268,6 +277,29 @@ pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result<
             wpr2,
             heap,
             vf_partition_count: 0,
+            pmu_reserved_size: match chipset.arch() {
+                Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => PMU_RESERVED_SIZE,
+                _ => 0,
+            },

I suspect you can just call calc_pmu_reserved_size, which seem to perform the exact same computation?

Yes.

Quoted 10 lines
Quoted 10 lines
drivers/gpu/nova-core/fb.rs +6 -0
         })
     }
 }
+
+/// Returns the PMU reserved memory size for `chipset`.
+#[expect(dead_code)]
+pub(crate) fn calc_pmu_reserved_size(chipset: Chipset) -> u32 {
+    match chipset.arch() {
+        Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => PMU_RESERVED_SIZE,
Quoted 9 lines

Review pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result< · line 294

Quoted 2 lines
(quoted diff) +2 -0
+        _ => 0,
+    }

We should avoid these matches on Architecture in common code as much as possible - that's what the HALs are for. Which means that calc_pmu_reserved_size should call a HAL method to obtain the right size (I'd also rename it to just pmu_reserved_size as we are not computing anything at runtime).

Yes.

Quoted 7 lines
Quoted 7 lines
drivers/gpu/nova-core/fb.rs +7 -0
+}
+
+/// PMU reserved size, aligned to 128KB.
+pub(crate) const PMU_RESERVED_SIZE: u32 = usize_into_u32::<
+    {
+        match const_align_up(SZ_8M + SZ_16M + SZ_4K, Alignment::new::<SZ_128K>()) {
+            Some(v) => v,
Quoted 8 lines

drivers/gpu/nova-core/fb.rs pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result< · line 305

Quoted 4 lines
drivers/gpu/nova-core/fb.rs +4 -0
+            None => panic!("PMU_RESERVED_SIZE: alignment overflow"),
+        }
+    },
+>();

Consequently, this should be moved into the Blackwell HAL - which is where is belongs, as contrary to what its name implies in the current module, this reserved size does not apply to all architectures.

Right. This originated in bringup, when I didn't fully understand where and when PMU reserved size came into play. Now it's clear, and yes it needs a HAL.

thanks,

Signature · 1 line
John Hubbard
reviewer
#21 lore raw

Re: [PATCH v10 08/28] gpu: nova-core: Blackwell: calculate reserved FB heap size

In reply to John Hubbard
Quoted 74 lines · John Hubbard

Various "reserved" areas of FB (frame buffer: vidmem) have to be calculated, because the GSP booting process needs this information.

PMU_RESERVED_SIZE is computed at compile time using const_align_up() and applied only for Blackwell dGPU architectures. All other architectures leave it at zero, matching Open RM behavior.

---
 drivers/gpu/nova-core/fb.rs     | 38 ++++++++++++++++++++++++++++++---
 drivers/gpu/nova-core/gsp/fw.rs |  1 +
 2 files changed, 36 insertions(+), 3 deletions(-)
drivers/gpu/nova-core/fb.rs +25 -3
index 35899e9b2560..c2005e4b4177 100644
@@ -12,6 +12,7 @@
     io::Io,
     prelude::*,
     ptr::{
+        const_align_up,
         Alignable,
         Alignment, //
     },
@@ -22,10 +23,16 @@
 use crate::{
     driver::Bar0,
     firmware::gsp::GspFirmware,
-    gpu::Chipset,
+    gpu::{
+        Architecture,
+        Chipset, //
+    },
     gsp,
-    num::FromSafeCast,
-    regs, //
+    num::{
+        usize_into_u32,
+        FromSafeCast, //
+    },
+    regs,
 };
 
 mod hal;
@@ -168,6 +175,8 @@ pub(crate) struct FbLayout {
     pub(crate) wpr2: FbRange,
     pub(crate) heap: FbRange,
     pub(crate) vf_partition_count: u8,
+    /// PMU reserved memory size, in bytes.
+    pub(crate) pmu_reserved_size: u32,
 }
 
 impl FbLayout {
@@ -268,6 +277,29 @@ pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result<
             wpr2,
             heap,
             vf_partition_count: 0,
+            pmu_reserved_size: match chipset.arch() {
+                Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => PMU_RESERVED_SIZE,
+                _ => 0,
+            },
         })
     }
 }
+
+/// Returns the PMU reserved memory size for `chipset`.
+#[expect(dead_code)]
+pub(crate) fn calc_pmu_reserved_size(chipset: Chipset) -> u32 {
+    match chipset.arch() {
+        Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => PMU_RESERVED_SIZE,
+        _ => 0,
+    }
+}

drivers/gpu/nova-core/fb.rs pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result< · line 305

Quoted 10 lines
drivers/gpu/nova-core/fb.rs +10 -0
+
+/// PMU reserved size, aligned to 128KB.
+pub(crate) const PMU_RESERVED_SIZE: u32 = usize_into_u32::<
+    {
+        match const_align_up(SZ_8M + SZ_16M + SZ_4K, Alignment::new::<SZ_128K>()) {
+            Some(v) => v,
+            None => panic!("PMU_RESERVED_SIZE: alignment overflow"),
+        }
+    },
+>();

You may use .unwrap() now as MSRV has been bumped to 1.85.

(Technically, you could have used it earlier by adding it to list of allowed features, too)

Best,
Gary

Quoted 12 lines
drivers/gpu/nova-core/gsp/fw.rs +1 -0
index 3245793bbe42..5d36604ea1a3 100644
@@ -247,6 +247,7 @@ pub(crate) fn new<'a>(
             fbSize: fb_layout.fb.end - fb_layout.fb.start,
             vgaWorkspaceOffset: fb_layout.vga_workspace.start,
             vgaWorkspaceSize: fb_layout.vga_workspace.end - fb_layout.vga_workspace.start,
+            pmuReservedSize: fb_layout.pmu_reserved_size,
             ..Zeroable::init_zeroed()
         });
 
#22 lore raw

PATCH v10 9/28 gpu: nova-core: Hopper/Blackwell: new location for PCI config mirror

In reply to John Hubbard

Hopper and Blackwell GPUs use a different PCI config space mirror address (0x092000) compared to older architectures (0x088000). Update SetSystemInfo to accept a chipset parameter and select the correct address based on architecture.

---
 drivers/gpu/nova-core/gsp/boot.rs        |  2 +-
 drivers/gpu/nova-core/gsp/commands.rs    |  8 +++++---
 drivers/gpu/nova-core/gsp/fw/commands.rs | 22 +++++++++++++++++++---
 3 files changed, 25 insertions(+), 7 deletions(-)
drivers/gpu/nova-core/gsp/boot.rs +1 -1
index 18f356c9178e..1aa869693b75 100644
@@ -169,7 +169,7 @@ pub(crate) fn boot(
         let wpr_meta = Coherent::init(dev, GFP_KERNEL, GspFwWprMeta::new(&gsp_fw, &fb_layout))?;
 
         self.cmdq
-            .send_command_no_wait(bar, commands::SetSystemInfo::new(pdev))?;
+            .send_command_no_wait(bar, commands::SetSystemInfo::new(pdev, chipset))?;
         self.cmdq
             .send_command_no_wait(bar, commands::SetRegistry::new())?;
 
drivers/gpu/nova-core/gsp/commands.rs +5 -3
index c89c7b57a751..9551a789433c 100644
@@ -19,6 +19,7 @@
 
 use crate::{
     driver::Bar0,
+    gpu::Chipset,
     gsp::{
         cmdq::{
             Cmdq,
@@ -37,12 +38,13 @@
 /// The `GspSetSystemInfo` command.
 pub(crate) struct SetSystemInfo<'a> {
     pdev: &'a pci::Device<device::Bound>,
+    chipset: Chipset,
 }
 
 impl<'a> SetSystemInfo<'a> {
     /// Creates a new `GspSetSystemInfo` command using the parameters of `pdev`.
-    pub(crate) fn new(pdev: &'a pci::Device<device::Bound>) -> Self {
-        Self { pdev }
+    pub(crate) fn new(pdev: &'a pci::Device<device::Bound>, chipset: Chipset) -> Self {
+        Self { pdev, chipset }
     }
 }
 
@@ -53,7 +55,7 @@ impl<'a> CommandToGsp for SetSystemInfo<'a> {
     type InitError = Error;
 
     fn init(&self) -> impl Init<Self::Command, Self::InitError> {
-        GspSetSystemInfo::init(self.pdev)
+        GspSetSystemInfo::init(self.pdev, self.chipset)
     }
 }
 
drivers/gpu/nova-core/gsp/fw/commands.rs +19 -3
index db46276430be..c16acbb0237f 100644
@@ -10,7 +10,13 @@
     }, //
 };
 
-use crate::gsp::GSP_PAGE_SIZE;
+use crate::{
+    gpu::{
+        Architecture,
+        Chipset, //
+    },
+    gsp::GSP_PAGE_SIZE, //
+};
 
 use super::bindings;
 
@@ -24,7 +30,10 @@ pub(crate) struct GspSetSystemInfo {
 impl GspSetSystemInfo {
     /// Returns an in-place initializer for the `GspSetSystemInfo` command.
     #[allow(non_snake_case)]
-    pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, Error> + 'a {
+    pub(crate) fn init<'a>(
+        dev: &'a pci::Device<device::Bound>,
+        chipset: Chipset,
+    ) -> impl Init<Self, Error> + 'a {
         type InnerGspSystemInfo = bindings::GspSystemInfo;
         let init_inner = try_init!(InnerGspSystemInfo {
             gpuPhysAddr: dev.resource_start(0)?,
@@ -35,7 +44,14 @@ pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, E
             // Using TASK_SIZE in r535_gsp_rpc_set_system_info() seems wrong because
             // TASK_SIZE is per-task. That's probably a design issue in GSP-RM though.
             maxUserVa: (1 << 47) - 4096,
-            pciConfigMirrorBase: 0x088000,
+            // Hopper, Blackwell, and later moved the PCI config mirror window to 0x092000.
+            // Older architectures continue to use the legacy window at 0x088000.
+            pciConfigMirrorBase: match chipset.arch() {
+                Architecture::Turing | Architecture::Ampere | Architecture::Ada => 0x088000,
+                Architecture::Hopper
+                | Architecture::BlackwellGB10x
+                | Architecture::BlackwellGB20x => 0x092000,
+            },
             pciConfigMirrorSize: 0x001000,
 
             PCIDeviceID: (u32::from(dev.device_id()) << 16) | u32::from(dev.vendor_id().as_raw()),
Signature · 1 line
2.53.0
#23 lore raw

Re: [PATCH v10 09/28] gpu: nova-core: Hopper/Blackwell: new location for PCI config mirror

Quoted 96 lines · John Hubbard

Hopper and Blackwell GPUs use a different PCI config space mirror address (0x092000) compared to older architectures (0x088000). Update SetSystemInfo to accept a chipset parameter and select the correct address based on architecture.

---
 drivers/gpu/nova-core/gsp/boot.rs        |  2 +-
 drivers/gpu/nova-core/gsp/commands.rs    |  8 +++++---
 drivers/gpu/nova-core/gsp/fw/commands.rs | 22 +++++++++++++++++++---
 3 files changed, 25 insertions(+), 7 deletions(-)
drivers/gpu/nova-core/gsp/boot.rs +1 -1
index 18f356c9178e..1aa869693b75 100644
@@ -169,7 +169,7 @@ pub(crate) fn boot(
         let wpr_meta = Coherent::init(dev, GFP_KERNEL, GspFwWprMeta::new(&gsp_fw, &fb_layout))?;
 
         self.cmdq
-            .send_command_no_wait(bar, commands::SetSystemInfo::new(pdev))?;
+            .send_command_no_wait(bar, commands::SetSystemInfo::new(pdev, chipset))?;
         self.cmdq
             .send_command_no_wait(bar, commands::SetRegistry::new())?;
 
drivers/gpu/nova-core/gsp/commands.rs +5 -3
index c89c7b57a751..9551a789433c 100644
@@ -19,6 +19,7 @@
 
 use crate::{
     driver::Bar0,
+    gpu::Chipset,
     gsp::{
         cmdq::{
             Cmdq,
@@ -37,12 +38,13 @@
 /// The `GspSetSystemInfo` command.
 pub(crate) struct SetSystemInfo<'a> {
     pdev: &'a pci::Device<device::Bound>,
+    chipset: Chipset,
 }
 
 impl<'a> SetSystemInfo<'a> {
     /// Creates a new `GspSetSystemInfo` command using the parameters of `pdev`.
-    pub(crate) fn new(pdev: &'a pci::Device<device::Bound>) -> Self {
-        Self { pdev }
+    pub(crate) fn new(pdev: &'a pci::Device<device::Bound>, chipset: Chipset) -> Self {
+        Self { pdev, chipset }
     }
 }
 
@@ -53,7 +55,7 @@ impl<'a> CommandToGsp for SetSystemInfo<'a> {
     type InitError = Error;
 
     fn init(&self) -> impl Init<Self::Command, Self::InitError> {
-        GspSetSystemInfo::init(self.pdev)
+        GspSetSystemInfo::init(self.pdev, self.chipset)
     }
 }
 
drivers/gpu/nova-core/gsp/fw/commands.rs +11 -2
index db46276430be..c16acbb0237f 100644
@@ -10,7 +10,13 @@
     }, //
 };
 
-use crate::gsp::GSP_PAGE_SIZE;
+use crate::{
+    gpu::{
+        Architecture,
+        Chipset, //
+    },
+    gsp::GSP_PAGE_SIZE, //
+};
 
 use super::bindings;
 
@@ -24,7 +30,10 @@ pub(crate) struct GspSetSystemInfo {
 impl GspSetSystemInfo {
     /// Returns an in-place initializer for the `GspSetSystemInfo` command.
     #[allow(non_snake_case)]
-    pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, Error> + 'a {
+    pub(crate) fn init<'a>(
+        dev: &'a pci::Device<device::Bound>,
+        chipset: Chipset,
+    ) -> impl Init<Self, Error> + 'a {
         type InnerGspSystemInfo = bindings::GspSystemInfo;
         let init_inner = try_init!(InnerGspSystemInfo {
             gpuPhysAddr: dev.resource_start(0)?,
@@ -35,7 +44,14 @@ pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, E
             // Using TASK_SIZE in r535_gsp_rpc_set_system_info() seems wrong because
             // TASK_SIZE is per-task. That's probably a design issue in GSP-RM though.

drivers/gpu/nova-core/gsp/fw/commands.rs pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, E · line 54

Quoted 10 lines
drivers/gpu/nova-core/gsp/fw/commands.rs +8 -1
             maxUserVa: (1 << 47) - 4096,
-            pciConfigMirrorBase: 0x088000,
+            // Hopper, Blackwell, and later moved the PCI config mirror window to 0x092000.
+            // Older architectures continue to use the legacy window at 0x088000.
+            pciConfigMirrorBase: match chipset.arch() {
+                Architecture::Turing | Architecture::Ampere | Architecture::Ada => 0x088000,
+                Architecture::Hopper
+                | Architecture::BlackwellGB10x
+                | Architecture::BlackwellGB20x => 0x092000,
+            },

Mmm, similarly to the previous patch, I would prefer to have this behind a HAL, but I am not quite sure which one would fit. Any idea?

#24 lore raw

Re: [PATCH v10 09/28] gpu: nova-core: Hopper/Blackwell: new location for PCI config mirror

Quoted 1 line · Alexandre Courbot

On Sat Apr 11, 2026 at 11:49 AM JST, John Hubbard wrote:

...

Quoted 20 lines
Quoted 20 lines
drivers/gpu/nova-core/gsp/fw/commands.rs +7 -2
@@ -24,7 +30,10 @@ pub(crate) struct GspSetSystemInfo {
 impl GspSetSystemInfo {
     /// Returns an in-place initializer for the `GspSetSystemInfo` command.
     #[allow(non_snake_case)]
-    pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, Error> + 'a {
+    pub(crate) fn init<'a>(
+        dev: &'a pci::Device<device::Bound>,
+        chipset: Chipset,
+    ) -> impl Init<Self, Error> + 'a {
         type InnerGspSystemInfo = bindings::GspSystemInfo;
         let init_inner = try_init!(InnerGspSystemInfo {
             gpuPhysAddr: dev.resource_start(0)?,
@@ -35,7 +44,14 @@ pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, E
             // Using TASK_SIZE in r535_gsp_rpc_set_system_info() seems wrong because
             // TASK_SIZE is per-task. That's probably a design issue in GSP-RM though.
             maxUserVa: (1 << 47) - 4096,
-            pciConfigMirrorBase: 0x088000,
+            // Hopper, Blackwell, and later moved the PCI config mirror window to 0x092000.
+            // Older architectures continue to use the legacy window at 0x088000.
+            pciConfigMirrorBase: match chipset.arch() {
Quoted 8 lines

drivers/gpu/nova-core/gsp/fw/commands.rs pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, E · line 54

Quoted 5 lines
drivers/gpu/nova-core/gsp/fw/commands.rs +5 -0
+                Architecture::Turing | Architecture::Ampere | Architecture::Ada => 0x088000,
+                Architecture::Hopper
+                | Architecture::BlackwellGB10x
+                | Architecture::BlackwellGB20x => 0x092000,
+            },

Mmm, similarly to the previous patch, I would prefer to have this behind a HAL, but I am not quite sure which one would fit. Any idea?

This really bothered me, because I distinctly recall very recently putting this behind a HAL! And now I see that I did that in one of the "much later this year: future firmware directions" branches. ha.

I went with gpu/hal.rs for this. Yes, it could get large, but let's see how it goes. This is the first item in there. I'll apply it to this series.

thanks,

Signature · 1 line
John Hubbard
#25 lore raw

Re: [PATCH v10 09/28] gpu: nova-core: Hopper/Blackwell: new location for PCI config mirror

Quoted 32 lines · John Hubbard
Quoted 1 line · Alexandre Courbot

On Sat Apr 11, 2026 at 11:49 AM JST, John Hubbard wrote:

...

Quoted 20 lines
Quoted 20 lines
drivers/gpu/nova-core/gsp/fw/commands.rs +7 -2
@@ -24,7 +30,10 @@ pub(crate) struct GspSetSystemInfo {
 impl GspSetSystemInfo {
     /// Returns an in-place initializer for the `GspSetSystemInfo` command.
     #[allow(non_snake_case)]
-    pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, Error> + 'a {
+    pub(crate) fn init<'a>(
+        dev: &'a pci::Device<device::Bound>,
+        chipset: Chipset,
+    ) -> impl Init<Self, Error> + 'a {
         type InnerGspSystemInfo = bindings::GspSystemInfo;
         let init_inner = try_init!(InnerGspSystemInfo {
             gpuPhysAddr: dev.resource_start(0)?,
@@ -35,7 +44,14 @@ pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, E
             // Using TASK_SIZE in r535_gsp_rpc_set_system_info() seems wrong because
             // TASK_SIZE is per-task. That's probably a design issue in GSP-RM though.
             maxUserVa: (1 << 47) - 4096,
-            pciConfigMirrorBase: 0x088000,
+            // Hopper, Blackwell, and later moved the PCI config mirror window to 0x092000.
+            // Older architectures continue to use the legacy window at 0x088000.
+            pciConfigMirrorBase: match chipset.arch() {
Quoted 8 lines

drivers/gpu/nova-core/gsp/fw/commands.rs pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, E · line 54

Quoted 5 lines
drivers/gpu/nova-core/gsp/fw/commands.rs +5 -0
+                Architecture::Turing | Architecture::Ampere | Architecture::Ada => 0x088000,
+                Architecture::Hopper
+                | Architecture::BlackwellGB10x
+                | Architecture::BlackwellGB20x => 0x092000,
+            },

Mmm, similarly to the previous patch, I would prefer to have this behind a HAL, but I am not quite sure which one would fit. Any idea?

Quoted 6 lines

This really bothered me, because I distinctly recall very recently putting this behind a HAL! And now I see that I did that in one of the "much later this year: future firmware directions" branches. ha.

I went with gpu/hal.rs for this. Yes, it could get large, but let's see how it goes. This is the first item in there. I'll apply it to this series.

Oh wait, I wrote too quickly. That's not quite what I did, but anyway, let me take a closer look when I'm not so sleepy. :)

thanks,

Signature · 1 line
John Hubbard
#26 lore raw

Re: [PATCH v10 09/28] gpu: nova-core: Hopper/Blackwell: new location for PCI config mirror

Quoted 37 lines · John Hubbard
Quoted 36 lines · John Hubbard
Quoted 1 line · Alexandre Courbot

On Sat Apr 11, 2026 at 11:49 AM JST, John Hubbard wrote:

...

Quoted 20 lines
Quoted 20 lines
drivers/gpu/nova-core/gsp/fw/commands.rs +7 -2
@@ -24,7 +30,10 @@ pub(crate) struct GspSetSystemInfo {
 impl GspSetSystemInfo {
     /// Returns an in-place initializer for the `GspSetSystemInfo` command.
     #[allow(non_snake_case)]
-    pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, Error> + 'a {
+    pub(crate) fn init<'a>(
+        dev: &'a pci::Device<device::Bound>,
+        chipset: Chipset,
+    ) -> impl Init<Self, Error> + 'a {
         type InnerGspSystemInfo = bindings::GspSystemInfo;
         let init_inner = try_init!(InnerGspSystemInfo {
             gpuPhysAddr: dev.resource_start(0)?,
@@ -35,7 +44,14 @@ pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, E
             // Using TASK_SIZE in r535_gsp_rpc_set_system_info() seems wrong because
             // TASK_SIZE is per-task. That's probably a design issue in GSP-RM though.
             maxUserVa: (1 << 47) - 4096,
-            pciConfigMirrorBase: 0x088000,
+            // Hopper, Blackwell, and later moved the PCI config mirror window to 0x092000.
+            // Older architectures continue to use the legacy window at 0x088000.
+            pciConfigMirrorBase: match chipset.arch() {
Quoted 8 lines

drivers/gpu/nova-core/gsp/fw/commands.rs pub(crate) fn init<'a>(dev: &'a pci::Device<device::Bound>) -> impl Init<Self, E · line 54

Quoted 5 lines
drivers/gpu/nova-core/gsp/fw/commands.rs +5 -0
+                Architecture::Turing | Architecture::Ampere | Architecture::Ada => 0x088000,
+                Architecture::Hopper
+                | Architecture::BlackwellGB10x
+                | Architecture::BlackwellGB20x => 0x092000,
+            },

Mmm, similarly to the previous patch, I would prefer to have this behind a HAL, but I am not quite sure which one would fit. Any idea?

This really bothered me, because I distinctly recall very recently putting this behind a HAL! And now I see that I did that in one of the "much later this year: future firmware directions" branches. ha.

Quoted 5 lines
Quoted 2 lines

I went with gpu/hal.rs for this. Yes, it could get large, but let's see how it goes. This is the first item in there. I'll apply it to this series.

Oh wait, I wrote too quickly. That's not quite what I did, but anyway, let me take a closer look when I'm not so sleepy. :)

Having this in gpu/hal.rs sounds good to me, fwiw - I don't really see where else it could be anyway.

#27 lore raw

PATCH v10 10/28 gpu: nova-core: refactor SEC2 booter loading into BooterFirmware::run()

In reply to John Hubbard

Move the SEC2 reset/load/boot sequence into a BooterFirmware::run() method, and call it from a thin run_booter() helper on Gsp. This is a pure refactoring with no behavior change, done in preparation for adding an alternative FSP boot path.

---
 drivers/gpu/nova-core/firmware/booter.rs | 30 +++++++++++++++++
 drivers/gpu/nova-core/gsp/boot.rs        | 43 +++++++++++-------------
 2 files changed, 50 insertions(+), 23 deletions(-)
drivers/gpu/nova-core/firmware/booter.rs +30 -0
index de2a4536b532..6a41690e72c6 100644
@@ -8,6 +8,7 @@
 
 use kernel::{
     device,
+    dma::Coherent,
     prelude::*,
     transmute::FromBytes, //
 };
@@ -396,6 +397,35 @@ pub(crate) fn new(
             ucode: ucode_signed,
         })
     }
+
+    /// Load and run the booter firmware on SEC2.
+    ///
+    /// Resets SEC2, loads this firmware image, then boots with the WPR metadata
+    /// address passed via the SEC2 mailboxes.
+    pub(crate) fn run<T>(
+        &self,
+        dev: &device::Device<device::Bound>,
+        bar: &Bar0,
+        sec2_falcon: &Falcon<Sec2>,
+        wpr_meta: &Coherent<T>,
+    ) -> Result {
+        sec2_falcon.reset(bar)?;
+        sec2_falcon.load(dev, bar, self)?;
+        let wpr_handle = wpr_meta.dma_handle();
+        let (mbox0, mbox1) = sec2_falcon.boot(
+            bar,
+            Some(wpr_handle as u32),
+            Some((wpr_handle >> 32) as u32),
+        )?;
+        dev_dbg!(dev, "SEC2 MBOX0: {:#x}, MBOX1: {:#x}\n", mbox0, mbox1);
+
+        if mbox0 != 0 {
+            dev_err!(dev, "Booter-load failed with error {:#x}\n", mbox0);
+            return Err(ENODEV);
+        }
+
+        Ok(())
+    }
 }
 
 impl FalconDmaLoadable for BooterFirmware {
drivers/gpu/nova-core/gsp/boot.rs +20 -23

61 lines not on this page · raw message

Signature · 1 line
2.53.0
#28 lore raw

PATCH v10 11/28 gpu: nova-core: Hopper/Blackwell: integrate FSP boot path into boot()

In reply to John Hubbard

Add the FSP boot path for Hopper and Blackwell GPUs. These architectures use FSP with FMC firmware for Chain of Trust boot, rather than SEC2.

boot() now dispatches to boot_via_sec2() or boot_via_fsp() based on architecture. The SEC2 path keeps its original command ordering. The FSP path sends SetSystemInfo/SetRegistry after GSP becomes active. The GSP sequencer only runs for SEC2-based architectures.

---
 drivers/gpu/nova-core/gsp/boot.rs | 137 ++++++++++++++++++++++--------
 1 file changed, 102 insertions(+), 35 deletions(-)
drivers/gpu/nova-core/gsp/boot.rs +102 -35
index bb4f0757e084..88c7d2106052 100644
@@ -31,9 +31,13 @@
         gsp::GspFirmware,
         FIRMWARE_VERSION, //
     },
-    gpu::Chipset,
+    gpu::{
+        Architecture,
+        Chipset, //
+    },
     gsp::{
         commands,
+        fw::LibosMemoryRegionInitArgument,
         sequencer::{
             GspSequencer,
             GspSequencerParams, //
@@ -150,6 +154,58 @@ fn run_booter(
         booter.run(dev, bar, sec2_falcon, wpr_meta)
     }
 
+    /// Boot GSP via SEC2 booter firmware (Turing/Ampere/Ada path).
+    ///
+    /// This path uses FWSEC-FRTS to set up WPR2, then boots GSP directly,
+    /// then uses SEC2 to run the booter firmware.
+    #[allow(clippy::too_many_arguments)]
+    fn boot_via_sec2(
+        dev: &device::Device<device::Bound>,
+        bar: &Bar0,
+        chipset: Chipset,
+        gsp_falcon: &Falcon<Gsp>,
+        sec2_falcon: &Falcon<Sec2>,
+        fb_layout: &FbLayout,
+        libos: &Coherent<[LibosMemoryRegionInitArgument]>,
+        wpr_meta: &Coherent<GspFwWprMeta>,
+    ) -> Result {
+        // Run FWSEC-FRTS to set up the WPR2 region
+        let bios = Vbios::new(dev, bar)?;
+        Self::run_fwsec_frts(dev, chipset, gsp_falcon, bar, &bios, fb_layout)?;
+
+        // Reset and boot GSP before SEC2
+        gsp_falcon.reset(bar)?;
+        let libos_handle = libos.dma_handle();
+        let (mbox0, mbox1) = gsp_falcon.boot(
+            bar,
+            Some(libos_handle as u32),
+            Some((libos_handle >> 32) as u32),
+        )?;
+        dev_dbg!(dev, "SEC2 MBOX0: {:#x}, MBOX1: {:#x}\n", mbox0, mbox1);
+        dev_dbg!(
+            dev,
+            "Using SEC2 to load and run the booter_load firmware...\n"
+        );
+
+        // Run booter via SEC2
+        Self::run_booter(dev, bar, chipset, sec2_falcon, wpr_meta)
+    }
+
+    /// Boot GSP via FSP Chain of Trust (Hopper/Blackwell+ path).
+    ///
+    /// This path uses FSP to establish a chain of trust and boot GSP-FMC. FSP handles
+    /// the GSP boot internally - no manual GSP reset/boot is needed.
+    fn boot_via_fsp(
+        _dev: &device::Device<device::Bound>,
+        _bar: &Bar0,
+        _chipset: Chipset,
+        _gsp_falcon: &Falcon<Gsp>,
+        _wpr_meta: &Coherent<GspFwWprMeta>,
+        _libos: &Coherent<[LibosMemoryRegionInitArgument]>,
+    ) -> Result {
+        Err(ENOTSUPP)
+    }
+
     /// Attempt to boot the GSP.
     ///
     /// This is a GPU-dependent and complex procedure that involves loading firmware files from
@@ -166,39 +222,41 @@ pub(crate) fn boot(
         sec2_falcon: &Falcon<Sec2>,
     ) -> Result {
         let dev = pdev.as_ref();
-
-        let bios = Vbios::new(dev, bar)?;
+        let uses_sec2 = matches!(
+            chipset.arch(),
+            Architecture::Turing | Architecture::Ampere | Architecture::Ada
+        );
 
         let gsp_fw = KBox::pin_init(GspFirmware::new(dev, chipset, FIRMWARE_VERSION), GFP_KERNEL)?;
 
         let fb_layout = FbLayout::new(chipset, bar, &gsp_fw)?;
         dev_dbg!(dev, "{:#x?}\n", fb_layout);
 
-        Self::run_fwsec_frts(dev, chipset, gsp_falcon, bar, &bios, &fb_layout)?;
-
         let wpr_meta = Coherent::init(dev, GFP_KERNEL, GspFwWprMeta::new(&gsp_fw, &fb_layout))?;
 
-        self.cmdq
-            .send_command_no_wait(bar, commands::SetSystemInfo::new(pdev, chipset))?;
-        self.cmdq
-            .send_command_no_wait(bar, commands::SetRegistry::new())?;
+        // Architecture-specific boot path
+        if uses_sec2 {
+            // SEC2 path: send commands before GSP reset/boot (original order).
+            self.cmdq
+                .send_command_no_wait(bar, commands::SetSystemInfo::new(pdev, chipset))?;
+            self.cmdq
+                .send_command_no_wait(bar, commands::SetRegistry::new())?;
 
-        gsp_falcon.reset(bar)?;
-        let libos_handle = self.libos.dma_handle();
-        let (mbox0, mbox1) = gsp_falcon.boot(
-            bar,
-            Some(libos_handle as u32),
-            Some((libos_handle >> 32) as u32),
-        )?;
-        dev_dbg!(pdev, "GSP MBOX0: {:#x}, MBOX1: {:#x}\n", mbox0, mbox1);
-
-        dev_dbg!(
-            pdev,
-            "Using SEC2 to load and run the booter_load firmware...\n"
-        );
-
-        Self::run_booter(dev, bar, chipset, sec2_falcon, &wpr_meta)?;
+            Self::boot_via_sec2(
+                dev,
+                bar,
+                chipset,
+                gsp_falcon,
+                sec2_falcon,
+                &fb_layout,
+                &self.libos,
+                &wpr_meta,
+            )?;
+        } else {
+            Self::boot_via_fsp(dev, bar, chipset, gsp_falcon, &wpr_meta, &self.libos)?;
+        }
 
+        // Common post-boot initialization
         gsp_falcon.write_os_version(bar, gsp_fw.bootloader.app_version);
 
         // Poll for RISC-V to become active before running sequencer
@@ -209,18 +267,27 @@ pub(crate) fn boot(
             Delta::from_secs(5),
         )?;
 
-        dev_dbg!(pdev, "RISC-V active? {}\n", gsp_falcon.is_riscv_active(bar),);
+        dev_dbg!(dev, "RISC-V active? {}\n", gsp_falcon.is_riscv_active(bar));
 
-        // Create and run the GSP sequencer.
-        let seq_params = GspSequencerParams {
-            bootloader_app_version: gsp_fw.bootloader.app_version,
-            libos_dma_handle: libos_handle,
-            gsp_falcon,
-            sec2_falcon,
-            dev: pdev.as_ref().into(),
-            bar,
-        };
-        GspSequencer::run(&self.cmdq, seq_params)?;
+        // For FSP path, send commands after GSP becomes active.
+        if !uses_sec2 {
+            self.cmdq
+                .send_command_no_wait(bar, commands::SetSystemInfo::new(pdev, chipset))?;
+            self.cmdq
+                .send_command_no_wait(bar, commands::SetRegistry::new())?;
+        } else {
+            // SEC2-based architectures need to run the GSP sequencer
+            let libos_handle = self.libos.dma_handle();
+            let seq_params = GspSequencerParams {
+                bootloader_app_version: gsp_fw.bootloader.app_version,
+                libos_dma_handle: libos_handle,
+                gsp_falcon,
+                sec2_falcon,
+                dev: dev.into(),
+                bar,
+            };
+            GspSequencer::run(&self.cmdq, seq_params)?;
+        }
 
         // Wait until GSP is fully initialized.
         commands::wait_gsp_init_done(&self.cmdq)?;
Signature · 1 line
2.53.0
#29 lore raw

Re: [PATCH v10 11/28] gpu: nova-core: Hopper/Blackwell: integrate FSP boot path into boot()

On Sat Apr 11, 2026 at 11:49 AM JST, John Hubbard wrote:
<snip>

Quoted 78 lines
drivers/gpu/nova-core/gsp/boot.rs +26 -30
@@ -166,39 +222,41 @@ pub(crate) fn boot(
         sec2_falcon: &Falcon<Sec2>,
     ) -> Result {
         let dev = pdev.as_ref();
-
-        let bios = Vbios::new(dev, bar)?;
+        let uses_sec2 = matches!(
+            chipset.arch(),
+            Architecture::Turing | Architecture::Ampere | Architecture::Ada
+        );
 
         let gsp_fw = KBox::pin_init(GspFirmware::new(dev, chipset, FIRMWARE_VERSION), GFP_KERNEL)?;
 
         let fb_layout = FbLayout::new(chipset, bar, &gsp_fw)?;
         dev_dbg!(dev, "{:#x?}\n", fb_layout);
 
-        Self::run_fwsec_frts(dev, chipset, gsp_falcon, bar, &bios, &fb_layout)?;
-
         let wpr_meta = Coherent::init(dev, GFP_KERNEL, GspFwWprMeta::new(&gsp_fw, &fb_layout))?;
 
-        self.cmdq
-            .send_command_no_wait(bar, commands::SetSystemInfo::new(pdev, chipset))?;
-        self.cmdq
-            .send_command_no_wait(bar, commands::SetRegistry::new())?;
+        // Architecture-specific boot path
+        if uses_sec2 {
+            // SEC2 path: send commands before GSP reset/boot (original order).
+            self.cmdq
+                .send_command_no_wait(bar, commands::SetSystemInfo::new(pdev, chipset))?;
+            self.cmdq
+                .send_command_no_wait(bar, commands::SetRegistry::new())?;
 
-        gsp_falcon.reset(bar)?;
-        let libos_handle = self.libos.dma_handle();
-        let (mbox0, mbox1) = gsp_falcon.boot(
-            bar,
-            Some(libos_handle as u32),
-            Some((libos_handle >> 32) as u32),
-        )?;
-        dev_dbg!(pdev, "GSP MBOX0: {:#x}, MBOX1: {:#x}\n", mbox0, mbox1);
-
-        dev_dbg!(
-            pdev,
-            "Using SEC2 to load and run the booter_load firmware...\n"
-        );
-
-        Self::run_booter(dev, bar, chipset, sec2_falcon, &wpr_meta)?;
+            Self::boot_via_sec2(
+                dev,
+                bar,
+                chipset,
+                gsp_falcon,
+                sec2_falcon,
+                &fb_layout,
+                &self.libos,
+                &wpr_meta,
+            )?;
+        } else {
+            Self::boot_via_fsp(dev, bar, chipset, gsp_falcon, &wpr_meta, &self.libos)?;
+        }
 
+        // Common post-boot initialization
         gsp_falcon.write_os_version(bar, gsp_fw.bootloader.app_version);
 
         // Poll for RISC-V to become active before running sequencer
@@ -209,18 +267,27 @@ pub(crate) fn boot(
             Delta::from_secs(5),
         )?;
 
-        dev_dbg!(pdev, "RISC-V active? {}\n", gsp_falcon.is_riscv_active(bar),);
+        dev_dbg!(dev, "RISC-V active? {}\n", gsp_falcon.is_riscv_active(bar));
 
-        // Create and run the GSP sequencer.
-        let seq_params = GspSequencerParams {
-            bootloader_app_version: gsp_fw.bootloader.app_version,
-            libos_dma_handle: libos_handle,
-            gsp_falcon,
-            sec2_falcon,

drivers/gpu/nova-core/gsp/boot.rs pub(crate) fn boot( · line 277

Quoted 10 lines
drivers/gpu/nova-core/gsp/boot.rs +6 -4
-            dev: pdev.as_ref().into(),
-            bar,
-        };
-        GspSequencer::run(&self.cmdq, seq_params)?;
+        // For FSP path, send commands after GSP becomes active.
+        if !uses_sec2 {
+            self.cmdq
+                .send_command_no_wait(bar, commands::SetSystemInfo::new(pdev, chipset))?;
+            self.cmdq
+                .send_command_no_wait(bar, commands::SetRegistry::new())?;

Do you know why we need to queue these commands at a different time for the SEC2 and FSP boot methods? I don't see any reason why we couldn't pre-queue them as we do for SEC2 here, and doing that would simplify the flow considerably.

#30 lore raw

PATCH v10 12/28 gpu: nova-core: don't assume 64-bit firmware images

In reply to John Hubbard

Introduce a single ELF format abstraction that ties each ELF header type to its matching section-header type. This keeps the shared section parser ready for upcoming ELF32 support and avoids mixing 32-bit and 64-bit ELF layouts by mistake.

---
 drivers/gpu/nova-core/firmware.rs | 111 ++++++++++++++++++++++--------
 1 file changed, 84 insertions(+), 27 deletions(-)
drivers/gpu/nova-core/firmware.rs +84 -27
index 6c2ab69cb605..46c26d749a65 100644
@@ -473,17 +473,72 @@ mod elf {
         transmute::FromBytes, //
     };
 
+    /// Trait to abstract over ELF header differences.
+    trait ElfHeader: FromBytes {
+        fn shnum(&self) -> u16;
+        fn shoff(&self) -> u64;
+        fn shstrndx(&self) -> u16;
+    }
+
+    /// Trait to abstract over ELF section-header differences.
+    trait ElfSectionHeader: FromBytes {
+        fn name(&self) -> u32;
+        fn offset(&self) -> u64;
+        fn size(&self) -> u64;
+    }
+
+    /// Trait describing a matching ELF header and section-header format.
+    trait ElfFormat {
+        type Header: ElfHeader;
+        type SectionHeader: ElfSectionHeader;
+    }
+
     /// Newtype to provide a [`FromBytes`] implementation.
     #[repr(transparent)]
     struct Elf64Hdr(bindings::elf64_hdr);
     // SAFETY: all bit patterns are valid for this type, and it doesn't use interior mutability.
     unsafe impl FromBytes for Elf64Hdr {}
 
+    impl ElfHeader for Elf64Hdr {
+        fn shnum(&self) -> u16 {
+            self.0.e_shnum
+        }
+
+        fn shoff(&self) -> u64 {
+            self.0.e_shoff
+        }
+
+        fn shstrndx(&self) -> u16 {
+            self.0.e_shstrndx
+        }
+    }
+
     #[repr(transparent)]
     struct Elf64SHdr(bindings::elf64_shdr);
     // SAFETY: all bit patterns are valid for this type, and it doesn't use interior mutability.
     unsafe impl FromBytes for Elf64SHdr {}
 
+    impl ElfSectionHeader for Elf64SHdr {
+        fn name(&self) -> u32 {
+            self.0.sh_name
+        }
+
+        fn offset(&self) -> u64 {
+            self.0.sh_offset
+        }
+
+        fn size(&self) -> u64 {
+            self.0.sh_size
+        }
+    }
+
+    struct Elf64Format;
+
+    impl ElfFormat for Elf64Format {
+        type Header = Elf64Hdr;
+        type SectionHeader = Elf64SHdr;
+    }
+
     /// Returns a NULL-terminated string from the ELF image at `offset`.
     fn elf_str(elf: &[u8], offset: u64) -> Option<&str> {
         let idx = usize::try_from(offset).ok()?;
@@ -491,47 +546,49 @@ fn elf_str(elf: &[u8], offset: u64) -> Option<&str> {
         CStr::from_bytes_until_nul(bytes).ok()?.to_str().ok()
     }
 
-    /// Tries to extract section with name `name` from the ELF64 image `elf`, and returns it.
-    pub(super) fn elf64_section<'a, 'b>(elf: &'a [u8], name: &'b str) -> Option<&'a [u8]> {
-        let hdr = &elf
-            .get(0..size_of::<bindings::elf64_hdr>())
-            .and_then(Elf64Hdr::from_bytes)?
-            .0;
-
-        // Get all the section headers.
-        let mut shdr = {
-            let shdr_num = usize::from(hdr.e_shnum);
-            let shdr_start = usize::try_from(hdr.e_shoff).ok()?;
-            let shdr_end = shdr_num
-                .checked_mul(size_of::<Elf64SHdr>())
-                .and_then(|v| v.checked_add(shdr_start))?;
-
-            elf.get(shdr_start..shdr_end)
-                .map(|slice| slice.chunks_exact(size_of::<Elf64SHdr>()))?
-        };
+    fn elf_section_generic<'a, F>(elf: &'a [u8], name: &str) -> Option<&'a [u8]>
+    where
+        F: ElfFormat,
+    {
+        let hdr = F::Header::from_bytes(elf.get(0..size_of::<F::Header>())?)?;
+
+        let shdr_num = usize::from(hdr.shnum());
+        let shdr_start = usize::try_from(hdr.shoff()).ok()?;
+        let shdr_end = shdr_num
+            .checked_mul(size_of::<F::SectionHeader>())
+            .and_then(|v| v.checked_add(shdr_start))?;
+
+        // Get all the section headers as an iterator over byte chunks.
+        let shdr_bytes = elf.get(shdr_start..shdr_end)?;
+        let mut shdr_iter = shdr_bytes.chunks_exact(size_of::<F::SectionHeader>());
 
         // Get the strings table.
-        let strhdr = shdr
+        let strhdr = shdr_iter
             .clone()
-            .nth(usize::from(hdr.e_shstrndx))
-            .and_then(Elf64SHdr::from_bytes)?;
+            .nth(usize::from(hdr.shstrndx()))
+            .and_then(F::SectionHeader::from_bytes)?;
 
         // Find the section which name matches `name` and return it.
-        shdr.find_map(|sh| {
-            let hdr = Elf64SHdr::from_bytes(sh)?;
-            let name_offset = strhdr.0.sh_offset.checked_add(u64::from(hdr.0.sh_name))?;
+        shdr_iter.find_map(|sh_bytes| {
+            let sh = F::SectionHeader::from_bytes(sh_bytes)?;
+            let name_offset = strhdr.offset().checked_add(u64::from(sh.name()))?;
             let section_name = elf_str(elf, name_offset)?;
 
             if section_name != name {
                 return None;
             }
 
-            let start = usize::try_from(hdr.0.sh_offset).ok()?;
-            let end = usize::try_from(hdr.0.sh_size)
+            let start = usize::try_from(sh.offset()).ok()?;
+            let end = usize::try_from(sh.size())
                 .ok()
-                .and_then(|sh_size| start.checked_add(sh_size))?;
+                .and_then(|sz| start.checked_add(sz))?;
 
             elf.get(start..end)
         })
     }
+
+    /// Tries to extract section with name `name` from the ELF64 image `elf`, and returns it.
+    pub(super) fn elf64_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
+        elf_section_generic::<Elf64Format>(elf, name)
+    }
 }
Signature · 1 line
2.53.0
#31 lore raw

PATCH v10 13/28 gpu: nova-core: add support for 32-bit firmware images

In reply to John Hubbard

Add ELF32 header and section header newtypes with ElfHeader and ElfSectionHeader trait implementations, mirroring the existing ELF64 support. Add elf32_section() for extracting sections from ELF32 images.

---
 drivers/gpu/nova-core/firmware.rs | 53 +++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
drivers/gpu/nova-core/firmware.rs +53 -0
index 46c26d749a65..a0745c332d4d 100644
@@ -539,6 +539,53 @@ impl ElfFormat for Elf64Format {
         type SectionHeader = Elf64SHdr;
     }
 
+    /// Newtype to provide [`FromBytes`] and [`ElfHeader`] implementations for ELF32.
+    #[repr(transparent)]
+    struct Elf32Hdr(bindings::elf32_hdr);
+    // SAFETY: all bit patterns are valid for this type, and it doesn't use interior mutability.
+    unsafe impl FromBytes for Elf32Hdr {}
+
+    impl ElfHeader for Elf32Hdr {
+        fn shnum(&self) -> u16 {
+            self.0.e_shnum
+        }
+
+        fn shoff(&self) -> u64 {
+            u64::from(self.0.e_shoff)
+        }
+
+        fn shstrndx(&self) -> u16 {
+            self.0.e_shstrndx
+        }
+    }
+
+    /// Newtype to provide [`FromBytes`] and [`ElfSectionHeader`] implementations for ELF32.
+    #[repr(transparent)]
+    struct Elf32SHdr(bindings::elf32_shdr);
+    // SAFETY: all bit patterns are valid for this type, and it doesn't use interior mutability.
+    unsafe impl FromBytes for Elf32SHdr {}
+
+    impl ElfSectionHeader for Elf32SHdr {
+        fn name(&self) -> u32 {
+            self.0.sh_name
+        }
+
+        fn offset(&self) -> u64 {
+            u64::from(self.0.sh_offset)
+        }
+
+        fn size(&self) -> u64 {
+            u64::from(self.0.sh_size)
+        }
+    }
+
+    struct Elf32Format;
+
+    impl ElfFormat for Elf32Format {
+        type Header = Elf32Hdr;
+        type SectionHeader = Elf32SHdr;
+    }
+
     /// Returns a NULL-terminated string from the ELF image at `offset`.
     fn elf_str(elf: &[u8], offset: u64) -> Option<&str> {
         let idx = usize::try_from(offset).ok()?;
@@ -591,4 +638,10 @@ fn elf_section_generic<'a, F>(elf: &'a [u8], name: &str) -> Option<&'a [u8]>
     pub(super) fn elf64_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
         elf_section_generic::<Elf64Format>(elf, name)
     }
+
+    /// Extract the section with name `name` from the ELF32 image `elf`.
+    #[expect(dead_code)]
+    pub(super) fn elf32_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
+        elf_section_generic::<Elf32Format>(elf, name)
+    }
 }
Signature · 1 line
2.53.0
#32 lore raw

PATCH v10 14/28 gpu: nova-core: add auto-detection of 32-bit, 64-bit firmware images

In reply to John Hubbard

Add elf_section() which automatically detects ELF32 vs ELF64 based on the ELF header's class byte, and dispatches to the appropriate parser. Switch gsp.rs callers from elf64_section() to elf_section(), making both elf32_section() and elf64_section() private.

---
 drivers/gpu/nova-core/firmware.rs     | 22 ++++++++++++++++++----
 drivers/gpu/nova-core/firmware/gsp.rs |  4 ++--
 2 files changed, 20 insertions(+), 6 deletions(-)
drivers/gpu/nova-core/firmware.rs +18 -4
index a0745c332d4d..bc217bfc225f 100644
@@ -634,14 +634,28 @@ fn elf_section_generic<'a, F>(elf: &'a [u8], name: &str) -> Option<&'a [u8]>
         })
     }
 
-    /// Tries to extract section with name `name` from the ELF64 image `elf`, and returns it.
-    pub(super) fn elf64_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
+    /// Extract the section with name `name` from the ELF64 image `elf`.
+    fn elf64_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
         elf_section_generic::<Elf64Format>(elf, name)
     }
 
     /// Extract the section with name `name` from the ELF32 image `elf`.
-    #[expect(dead_code)]
-    pub(super) fn elf32_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
+    fn elf32_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
         elf_section_generic::<Elf32Format>(elf, name)
     }
+
+    /// Automatically detects ELF32 vs ELF64 based on the ELF header.
+    pub(super) fn elf_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
+        // Check ELF magic.
+        if elf.len() < 5 || elf.get(0..4)? != b"\x7fELF" {
+            return None;
+        }
+
+        // Check ELF class: 1 = 32-bit, 2 = 64-bit.
+        match elf.get(4)? {
+            1 => elf32_section(elf, name),
+            2 => elf64_section(elf, name),
+            _ => None,
+        }
+    }
 }
drivers/gpu/nova-core/firmware/gsp.rs +2 -2
index 617ec2aaa93a..98ef618e1eff 100644
@@ -89,7 +89,7 @@ pub(crate) fn new<'a>(
         pin_init::pin_init_scope(move || {
             let firmware = super::request_firmware(dev, chipset, "gsp", ver)?;
 
-            let fw_section = elf::elf64_section(firmware.data(), ".fwimage").ok_or(EINVAL)?;
+            let fw_section = elf::elf_section(firmware.data(), ".fwimage").ok_or(EINVAL)?;
 
             let size = fw_section.len();
 
@@ -149,7 +149,7 @@ pub(crate) fn new<'a>(
                 signatures: {
                     let sigs_section = Self::find_gsp_sigs_section(chipset);
 
-                    elf::elf64_section(firmware.data(), sigs_section)
+                    elf::elf_section(firmware.data(), sigs_section)
                         .ok_or(EINVAL)
                         .and_then(|data| Coherent::from_slice(dev, data, GFP_KERNEL))?
                 },
Signature · 1 line
2.53.0
#33 lore raw

PATCH v10 15/28 gpu: nova-core: Hopper/Blackwell: add FSP falcon engine stub

In reply to John Hubbard

Add the FSP (Firmware System Processor) falcon engine type that will handle secure boot and Chain of Trust operations on Hopper and Blackwell architectures.

The FSP falcon replaces SEC2's role in the boot sequence for these newer architectures. This initial stub just defines the falcon type and its base address.

---
 drivers/gpu/nova-core/falcon.rs     |  1 +
 drivers/gpu/nova-core/falcon/fsp.rs | 27 +++++++++++++++++++++++++++
 drivers/gpu/nova-core/gsp/boot.rs   |  7 +++++--
 3 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/nova-core/falcon/fsp.rs
drivers/gpu/nova-core/falcon.rs +1 -0
index 24cc2c26e28d..053ce5bea6cd 100644
@@ -40,6 +40,7 @@
     regs,
 };
 
+pub(crate) mod fsp;
 pub(crate) mod gsp;
 mod hal;
 pub(crate) mod sec2;
drivers/gpu/nova-core/falcon/fsp.rs new file +27 -0
new file mode 100644
index 000000000000..57817a594631
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! FSP (Firmware System Processor) falcon engine for Hopper/Blackwell GPUs.
+//!
+//! The FSP falcon handles secure boot and Chain of Trust operations
+//! on Hopper and Blackwell architectures, replacing SEC2's role.
+
+use kernel::io::register::RegisterBase;
+
+use crate::falcon::{
+    FalconEngine,
+    PFalcon2Base,
+    PFalconBase, //
+};
+
+/// Type specifying the `Fsp` falcon engine. Cannot be instantiated.
+pub(crate) struct Fsp(());
+
+impl RegisterBase<PFalconBase> for Fsp {
+    const BASE: usize = 0x8f2000;
+}
+
+impl RegisterBase<PFalcon2Base> for Fsp {
+    const BASE: usize = 0x8f3000;
+}
+
+impl FalconEngine for Fsp {}
drivers/gpu/nova-core/gsp/boot.rs +5 -2
index 88c7d2106052..84943beee9ca 100644
@@ -13,6 +13,7 @@
 use crate::{
     driver::Bar0,
     falcon::{
+        fsp::Fsp as FspEngine,
         gsp::Gsp,
         sec2::Sec2,
         Falcon, //
@@ -196,13 +197,15 @@ fn boot_via_sec2(
     /// This path uses FSP to establish a chain of trust and boot GSP-FMC. FSP handles
     /// the GSP boot internally - no manual GSP reset/boot is needed.
     fn boot_via_fsp(
-        _dev: &device::Device<device::Bound>,
+        dev: &device::Device<device::Bound>,
         _bar: &Bar0,
-        _chipset: Chipset,
+        chipset: Chipset,
         _gsp_falcon: &Falcon<Gsp>,
         _wpr_meta: &Coherent<GspFwWprMeta>,
         _libos: &Coherent<[LibosMemoryRegionInitArgument]>,
     ) -> Result {
+        let _fsp_falcon = Falcon::<FspEngine>::new(dev, chipset)?;
+
         Err(ENOTSUPP)
     }
 
Signature · 1 line
2.53.0
#34 lore raw

PATCH v10 16/28 gpu: nova-core: Hopper/Blackwell: add FMC firmware image, in support of FSP

In reply to John Hubbard

FSP is the Falcon that runs FMC firmware on Hopper and Blackwell. Load the FMC ELF in two forms: the image section that FSP boots from, and the full Firmware object for later signature extraction during Chain of Trust verification.

---
 drivers/gpu/nova-core/firmware.rs     |  1 +
 drivers/gpu/nova-core/firmware/fsp.rs | 45 +++++++++++++++++++++++++++
 drivers/gpu/nova-core/gsp/boot.rs     |  3 ++
 3 files changed, 49 insertions(+)
 create mode 100644 drivers/gpu/nova-core/firmware/fsp.rs
drivers/gpu/nova-core/firmware.rs +1 -0
index bc217bfc225f..bc26807116e4 100644
@@ -27,6 +27,7 @@
 };
 
 pub(crate) mod booter;
+pub(crate) mod fsp;
 pub(crate) mod fwsec;
 pub(crate) mod gsp;
 pub(crate) mod riscv;
drivers/gpu/nova-core/firmware/fsp.rs new file +45 -0

45 lines not on this page · raw message

drivers/gpu/nova-core/gsp/boot.rs +3 -0
index 84943beee9ca..1998bd230185 100644
@@ -24,6 +24,7 @@
             BooterFirmware,
             BooterKind, //
         },
+        fsp::FspFirmware,
         fwsec::{
             bootloader::FwsecFirmwareWithBl,
             FwsecCommand,
@@ -206,6 +207,8 @@ fn boot_via_fsp(
     ) -> Result {
         let _fsp_falcon = Falcon::<FspEngine>::new(dev, chipset)?;
 
+        let _fsp_fw = FspFirmware::new(dev, chipset, FIRMWARE_VERSION)?;
+
         Err(ENOTSUPP)
     }
 
Signature · 1 line
2.53.0
#35 lore raw

PATCH v10 17/28 gpu: nova-core: Hopper/Blackwell: add FSP secure boot completion waiting

In reply to John Hubbard

Add the FSP module with Fsp::wait_secure_boot(), which polls the I2CS thermal scratch register until FSP signals boot success or the 5-second timeout expires. Hopper and Blackwell use FSP instead of SEC2 for secure boot.

---
 drivers/gpu/nova-core/fsp.rs       | 53 ++++++++++++++++++++++++++++++
 drivers/gpu/nova-core/gsp/boot.rs  |  5 ++-
 drivers/gpu/nova-core/nova_core.rs |  1 +
 drivers/gpu/nova-core/regs.rs      | 29 ++++++++++++++++
 4 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/nova-core/fsp.rs
drivers/gpu/nova-core/fsp.rs new file +53 -0
new file mode 100644
index 000000000000..55e543e80de8
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! FSP (Firmware System Processor) interface for Hopper/Blackwell GPUs.
+//!
+//! Hopper/Blackwell use a simplified firmware boot sequence: FMC --> FSP --> GSP.
+//! Unlike Turing/Ampere/Ada, there is NO SEC2 (Security Engine 2) usage.
+//! FSP handles secure boot directly using FMC firmware + Chain of Trust.
+
+use kernel::{
+    device,
+    io::poll::read_poll_timeout,
+    prelude::*,
+    time::Delta, //
+};
+
+use crate::regs;
+
+/// FSP secure boot completion timeout in milliseconds.
+const FSP_SECURE_BOOT_TIMEOUT_MS: i64 = 5000;
+
+/// FSP interface for Hopper/Blackwell GPUs.
+pub(crate) struct Fsp;
+
+impl Fsp {
+    /// Wait for FSP secure boot completion.
+    ///
+    /// Polls the thermal scratch register until FSP signals boot completion
+    /// or timeout occurs.
+    pub(crate) fn wait_secure_boot(
+        dev: &device::Device<device::Bound>,
+        bar: &crate::driver::Bar0,
+        arch: crate::gpu::Architecture,
+    ) -> Result {
+        debug_assert!(
+            regs::read_fsp_boot_complete_status(bar, arch).is_some(),
+            "wait_secure_boot called on non-FSP architecture"
+        );
+
+        let timeout = Delta::from_millis(FSP_SECURE_BOOT_TIMEOUT_MS);
+
+        read_poll_timeout(
+            || regs::read_fsp_boot_complete_status(bar, arch).ok_or(ENOTSUPP),
+            |&status| status == regs::FSP_BOOT_COMPLETE_SUCCESS,
+            Delta::from_millis(10),
+            timeout,
+        )
+        .map_err(|_| {
+            dev_err!(dev, "FSP secure boot completion timeout\n");
+            ETIMEDOUT
+        })
+        .map(|_| ())
+    }
+}
drivers/gpu/nova-core/gsp/boot.rs +4 -1
index 1998bd230185..9609cef3ff51 100644
@@ -33,6 +33,7 @@
         gsp::GspFirmware,
         FIRMWARE_VERSION, //
     },
+    fsp::Fsp,
     gpu::{
         Architecture,
         Chipset, //
@@ -199,7 +200,7 @@ fn boot_via_sec2(
     /// the GSP boot internally - no manual GSP reset/boot is needed.
     fn boot_via_fsp(
         dev: &device::Device<device::Bound>,
-        _bar: &Bar0,
+        bar: &Bar0,
         chipset: Chipset,
         _gsp_falcon: &Falcon<Gsp>,
         _wpr_meta: &Coherent<GspFwWprMeta>,
@@ -209,6 +210,8 @@ fn boot_via_fsp(
 
         let _fsp_fw = FspFirmware::new(dev, chipset, FIRMWARE_VERSION)?;
 
+        Fsp::wait_secure_boot(dev, bar, chipset.arch())?;
+
         Err(ENOTSUPP)
     }
 
drivers/gpu/nova-core/nova_core.rs +1 -0
index 3a609f6937e4..53558ac0f619 100644
@@ -17,6 +17,7 @@
 mod falcon;
 mod fb;
 mod firmware;
+mod fsp;
 mod gpu;
 mod gsp;
 #[macro_use]
drivers/gpu/nova-core/regs.rs +29 -0
index 6faeed73901d..e4de7bfffde1 100644
@@ -511,6 +511,35 @@ pub(crate) fn mem_scrubbing_done(self) -> bool {
     }
 }
 
+// PTHERM registers
+
+// FSP secure boot completion status register used by FSP to signal boot completion.
+// This is the NV_THERM_I2CS_SCRATCH register.
+// Different architectures use different addresses:
+// - Hopper (GH100) and Blackwell GB10x: 0x000200bc
+// - Blackwell GB20x: 0x00ad00bc
+pub(crate) fn fsp_thermal_scratch_reg_addr(arch: Architecture) -> Result<usize> {
+    match arch {
+        Architecture::Hopper | Architecture::BlackwellGB10x => Ok(0x000200bc),
+        Architecture::BlackwellGB20x => Ok(0x00ad00bc),
+        _ => Err(kernel::error::code::ENOTSUPP),
+    }
+}
+
+/// FSP writes this value to indicate successful boot completion.
+pub(crate) const FSP_BOOT_COMPLETE_SUCCESS: u32 = 0xff;
+
+/// Read FSP boot completion status from the architecture-specific thermal scratch register.
+///
+/// Returns `None` if the architecture does not have an FSP.
+pub(crate) fn read_fsp_boot_complete_status(
+    bar: &crate::driver::Bar0,
+    arch: Architecture,
+) -> Option<u32> {
+    let addr = fsp_thermal_scratch_reg_addr(arch).ok()?;
+    Some(bar.read32(addr))
+}
+
 // The modules below provide registers that are not identical on all supported chips. They should
 // only be used in HAL modules.
 
Signature · 1 line
2.53.0
#36 lore raw

Re: [PATCH v10 17/28] gpu: nova-core: Hopper/Blackwell: add FSP secure boot completion waiting

Quoted 49 lines · John Hubbard

Add the FSP module with Fsp::wait_secure_boot(), which polls the I2CS thermal scratch register until FSP signals boot success or the 5-second timeout expires. Hopper and Blackwell use FSP instead of SEC2 for secure boot.

---
 drivers/gpu/nova-core/fsp.rs       | 53 ++++++++++++++++++++++++++++++
 drivers/gpu/nova-core/gsp/boot.rs  |  5 ++-
 drivers/gpu/nova-core/nova_core.rs |  1 +
 drivers/gpu/nova-core/regs.rs      | 29 ++++++++++++++++
 4 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/nova-core/fsp.rs
drivers/gpu/nova-core/fsp.rs new file +29 -0
new file mode 100644
index 000000000000..55e543e80de8
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! FSP (Firmware System Processor) interface for Hopper/Blackwell GPUs.
+//!
+//! Hopper/Blackwell use a simplified firmware boot sequence: FMC --> FSP --> GSP.
+//! Unlike Turing/Ampere/Ada, there is NO SEC2 (Security Engine 2) usage.
+//! FSP handles secure boot directly using FMC firmware + Chain of Trust.
+
+use kernel::{
+    device,
+    io::poll::read_poll_timeout,
+    prelude::*,
+    time::Delta, //
+};
+
+use crate::regs;
+
+/// FSP secure boot completion timeout in milliseconds.
+const FSP_SECURE_BOOT_TIMEOUT_MS: i64 = 5000;
+
+/// FSP interface for Hopper/Blackwell GPUs.
+pub(crate) struct Fsp;
+
+impl Fsp {
+    /// Wait for FSP secure boot completion.
+    ///
+    /// Polls the thermal scratch register until FSP signals boot completion
+    /// or timeout occurs.
+    pub(crate) fn wait_secure_boot(

drivers/gpu/nova-core/fsp.rs line 39

Quoted 10 lines
drivers/gpu/nova-core/fsp.rs new file +10 -0
+        dev: &device::Device<device::Bound>,
+        bar: &crate::driver::Bar0,
+        arch: crate::gpu::Architecture,
+    ) -> Result {
+        debug_assert!(
+            regs::read_fsp_boot_complete_status(bar, arch).is_some(),
+            "wait_secure_boot called on non-FSP architecture"
+        );
+
+        let timeout = Delta::from_millis(FSP_SECURE_BOOT_TIMEOUT_MS);

Let's inline this timeout in its only use site below, like the other timeout is.

Quoted 68 lines
drivers/gpu/nova-core/fsp.rs new file +14 -0
+
+        read_poll_timeout(
+            || regs::read_fsp_boot_complete_status(bar, arch).ok_or(ENOTSUPP),
+            |&status| status == regs::FSP_BOOT_COMPLETE_SUCCESS,
+            Delta::from_millis(10),
+            timeout,
+        )
+        .map_err(|_| {
+            dev_err!(dev, "FSP secure boot completion timeout\n");
+            ETIMEDOUT
+        })
+        .map(|_| ())
+    }
+}
drivers/gpu/nova-core/gsp/boot.rs +4 -1
index 1998bd230185..9609cef3ff51 100644
@@ -33,6 +33,7 @@
         gsp::GspFirmware,
         FIRMWARE_VERSION, //
     },
+    fsp::Fsp,
     gpu::{
         Architecture,
         Chipset, //
@@ -199,7 +200,7 @@ fn boot_via_sec2(
     /// the GSP boot internally - no manual GSP reset/boot is needed.
     fn boot_via_fsp(
         dev: &device::Device<device::Bound>,
-        _bar: &Bar0,
+        bar: &Bar0,
         chipset: Chipset,
         _gsp_falcon: &Falcon<Gsp>,
         _wpr_meta: &Coherent<GspFwWprMeta>,
@@ -209,6 +210,8 @@ fn boot_via_fsp(
 
         let _fsp_fw = FspFirmware::new(dev, chipset, FIRMWARE_VERSION)?;
 
+        Fsp::wait_secure_boot(dev, bar, chipset.arch())?;
+
         Err(ENOTSUPP)
     }
 
drivers/gpu/nova-core/nova_core.rs +1 -0
index 3a609f6937e4..53558ac0f619 100644
@@ -17,6 +17,7 @@
 mod falcon;
 mod fb;
 mod firmware;
+mod fsp;
 mod gpu;
 mod gsp;
 #[macro_use]
drivers/gpu/nova-core/regs.rs +4 -0
index 6faeed73901d..e4de7bfffde1 100644
@@ -511,6 +511,35 @@ pub(crate) fn mem_scrubbing_done(self) -> bool {
     }
 }
 
+// PTHERM registers
+
+// FSP secure boot completion status register used by FSP to signal boot completion.
+// This is the NV_THERM_I2CS_SCRATCH register.

drivers/gpu/nova-core/regs.rs pub(crate) fn mem_scrubbing_done(self) -> bool { · line 527

Quoted 10 lines
drivers/gpu/nova-core/regs.rs +10 -0
+// Different architectures use different addresses:
+// - Hopper (GH100) and Blackwell GB10x: 0x000200bc
+// - Blackwell GB20x: 0x00ad00bc
+pub(crate) fn fsp_thermal_scratch_reg_addr(arch: Architecture) -> Result<usize> {
+    match arch {
+        Architecture::Hopper | Architecture::BlackwellGB10x => Ok(0x000200bc),
+        Architecture::BlackwellGB20x => Ok(0x00ad00bc),
+        _ => Err(kernel::error::code::ENOTSUPP),
+    }
+}

This function shouldn't be public as it is only used by the function right below. But anyway, it is the wrong way to address the architectural differences since it bypasses the register mechanism entirely.

The two NV_THERM_I2CS_SCRATCH registers should be defined in gb100 and gb202 sub-modules respectively, similarly to how NV_FUSE_STATUS_OPT_DISPLAY is defined. According to OpenRM they should both have a 32-bit fsp_boot_complete field.

Then, read_fsp_boot_complete_status should rely on a FSP HAL to fetch the correct register (again, similarly to how NV_FUSE_STATUS_OPT_DISPLAY is accessed in the fb HAL).

#37 lore raw

PATCH v10 18/28 gpu: nova-core: Hopper/Blackwell: add FMC signature extraction

In reply to John Hubbard

Add extract_fmc_signatures() which extracts SHA-384 hash, RSA public key, and RSA signature from FMC ELF32 firmware sections. These are needed for FSP Chain of Trust verification.

---
 drivers/gpu/nova-core/firmware.rs |  3 +-
 drivers/gpu/nova-core/fsp.rs      | 78 +++++++++++++++++++++++++++++++
 drivers/gpu/nova-core/gsp/boot.rs |  3 +-
 3 files changed, 82 insertions(+), 2 deletions(-)
drivers/gpu/nova-core/firmware.rs +2 -1
index bc26807116e4..6d07715b3a49 100644
@@ -26,6 +26,7 @@
     },
 };
 
+pub(crate) use elf::elf_section;
 pub(crate) mod booter;
 pub(crate) mod fsp;
 pub(crate) mod fwsec;
@@ -646,7 +647,7 @@ fn elf32_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
     }
 
     /// Automatically detects ELF32 vs ELF64 based on the ELF header.
-    pub(super) fn elf_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
+    pub(crate) fn elf_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
         // Check ELF magic.
         if elf.len() < 5 || elf.get(0..4)? != b"\x7fELF" {
             return None;
drivers/gpu/nova-core/fsp.rs +78 -0

88 lines not on this page · raw message

drivers/gpu/nova-core/gsp/boot.rs +2 -1
index 9609cef3ff51..739624af1cef 100644
@@ -208,7 +208,8 @@ fn boot_via_fsp(
     ) -> Result {
         let _fsp_falcon = Falcon::<FspEngine>::new(dev, chipset)?;
 
-        let _fsp_fw = FspFirmware::new(dev, chipset, FIRMWARE_VERSION)?;
+        let fsp_fw = FspFirmware::new(dev, chipset, FIRMWARE_VERSION)?;
+        let _signatures = Fsp::extract_fmc_signatures(dev, fsp_fw.fmc_elf.data())?;
 
         Fsp::wait_secure_boot(dev, bar, chipset.arch())?;
 
Signature · 1 line
2.53.0
#38 lore raw

Re: [PATCH v10 18/28] gpu: nova-core: Hopper/Blackwell: add FMC signature extraction

Quoted 24 lines · John Hubbard

Add extract_fmc_signatures() which extracts SHA-384 hash, RSA public key, and RSA signature from FMC ELF32 firmware sections. These are needed for FSP Chain of Trust verification.

---
 drivers/gpu/nova-core/firmware.rs |  3 +-
 drivers/gpu/nova-core/fsp.rs      | 78 +++++++++++++++++++++++++++++++
 drivers/gpu/nova-core/gsp/boot.rs |  3 +-
 3 files changed, 82 insertions(+), 2 deletions(-)
drivers/gpu/nova-core/firmware.rs +1 -0
index bc26807116e4..6d07715b3a49 100644
@@ -26,6 +26,7 @@
     },
 };
 
+pub(crate) use elf::elf_section;
 pub(crate) mod booter;
 pub(crate) mod fsp;
 pub(crate) mod fwsec;

drivers/gpu/nova-core/firmware.rs fn elf32_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> { · line 650

Quoted 5 lines
drivers/gpu/nova-core/firmware.rs +1 -1
@@ -646,7 +647,7 @@ fn elf32_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
     }
 
     /// Automatically detects ELF32 vs ELF64 based on the ELF header.
-    pub(super) fn elf_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {
+    pub(crate) fn elf_section<'a>(elf: &'a [u8], name: &str) -> Option<&'a [u8]> {

We don't want to change the visibility of this method - thankfully there is an easy way to achieve this - please read on.

drivers/gpu/nova-core/fsp.rs line 21

Quoted 12 lines
drivers/gpu/nova-core/firmware.rs +0 -0
         // Check ELF magic.
         if elf.len() < 5 || elf.get(0..4)? != b"\x7fELF" {
             return None;
drivers/gpu/nova-core/fsp.rs +1 -0
index 55e543e80de8..8287bda795ca 100644
@@ -18,6 +18,18 @@
 /// FSP secure boot completion timeout in milliseconds.
 const FSP_SECURE_BOOT_TIMEOUT_MS: i64 = 5000;
 
+/// Size constraints for FSP security signatures (Hopper/Blackwell).

This doccomment is about the 3 following items but will only appears on the first one. You want one doccomment per const that reads something like "/// Expected size for X".

Quoted 15 lines
drivers/gpu/nova-core/fsp.rs +11 -0
+const FSP_HASH_SIZE: usize = 48; // SHA-384 hash
+const FSP_PKEY_SIZE: usize = 384; // RSA-3072 public key
+const FSP_SIG_SIZE: usize = 384; // RSA-3072 signature
+
+/// Structure to hold FMC signatures.
+#[derive(Debug, Clone, Copy)]
+pub(crate) struct FmcSignatures {
+    hash384: [u8; FSP_HASH_SIZE],
+    public_key: [u8; FSP_PKEY_SIZE],
+    signature: [u8; FSP_SIG_SIZE],
+}
 /// FSP interface for Hopper/Blackwell GPUs.
 pub(crate) struct Fsp;
 

drivers/gpu/nova-core/fsp.rs pub(crate) fn wait_secure_boot( · line 70

Quoted 9 lines
drivers/gpu/nova-core/fsp.rs +6 -0
@@ -50,4 +62,70 @@ pub(crate) fn wait_secure_boot(
         })
         .map(|_| ())
     }
+
+    /// Extract FMC firmware signatures for Chain of Trust verification.
+    ///
+    /// Extracts real cryptographic signatures from FMC ELF32 firmware sections.
+    /// Returns signatures in a heap-allocated structure to prevent stack overflow.
+    pub(crate) fn extract_fmc_signatures(

If you make this a method of FmcFirmware, you can keep the current visibility of elf_section, while also simplifying the caller (as it is only ever called on the data of a FmcFirmware).

Quoted 34 lines
drivers/gpu/nova-core/fsp.rs +34 -0
+        dev: &device::Device<device::Bound>,
+        fmc_fw_data: &[u8],
+    ) -> Result<KBox<FmcSignatures>> {
+        let hash_section = crate::firmware::elf_section(fmc_fw_data, "hash")
+            .ok_or(EINVAL)
+            .inspect_err(|_| dev_err!(dev, "FMC firmware missing 'hash' section\n"))?;
+
+        let pkey_section = crate::firmware::elf_section(fmc_fw_data, "publickey")
+            .ok_or(EINVAL)
+            .inspect_err(|_| dev_err!(dev, "FMC firmware missing 'publickey' section\n"))?;
+
+        let sig_section = crate::firmware::elf_section(fmc_fw_data, "signature")
+            .ok_or(EINVAL)
+            .inspect_err(|_| dev_err!(dev, "FMC firmware missing 'signature' section\n"))?;
+
+        if hash_section.len() != FSP_HASH_SIZE {
+            dev_err!(
+                dev,
+                "FMC hash section size {} != expected {}\n",
+                hash_section.len(),
+                FSP_HASH_SIZE
+            );
+            return Err(EINVAL);
+        }
+
+        if pkey_section.len() > FSP_PKEY_SIZE {
+            dev_err!(
+                dev,
+                "FMC publickey section size {} > maximum {}\n",
+                pkey_section.len(),
+                FSP_PKEY_SIZE
+            );
+            return Err(EINVAL);
+        }

drivers/gpu/nova-core/fsp.rs pub(crate) fn wait_secure_boot( · line 114

Quoted 10 lines
drivers/gpu/nova-core/fsp.rs +10 -0
+
+        if sig_section.len() > FSP_SIG_SIZE {
+            dev_err!(
+                dev,
+                "FMC signature section size {} > maximum {}\n",
+                sig_section.len(),
+                FSP_SIG_SIZE
+            );
+            return Err(EINVAL);
+        }

That's quite a bit of repeating code. I'd like to factor this out into a closure, but first a question: the length of hash_section is required to be exactly FSP_HASH_SIZE, but the other two sections are only required to be smaller. Does that really make sense or should they all be strictly equal to their expected size? Because AFAICT 384 is the only size that makes sense for them.

Assuming we can apply the same length test for all 3, you can replace all this code with just:

    /// Returns the section `name` of size `expected_len`, or EINVAL if
    /// the section doesn't exist or doesn't have the expected length.
    let get_section = |name, expected_len| {
        crate::firmware::elf_section(fmc_fw_data, name)
            .ok_or(EINVAL)
            .inspect_err(|_| dev_err!(dev, "FMC firmware missing '{}' section\n", name))
            .and_then(|section| {
                if section.len() > expected_len {
                    dev_err!(
                        dev,
                        "FMC {} section size {} != expected {}\n",
                        name,
                        section.len(),
                        expected_len
                    );
                    Err(EINVAL)
                } else {
                    Ok(section)
                }
            })
    };

    let hash_section = get_section("hash", FSP_HASH_SIZE)?;
    let pkey_section = get_section("publickey", FSP_PKEY_SIZE)?;
    let sig_section = get_section("signature", FSP_SIG_SIZE)?;

drivers/gpu/nova-core/fsp.rs pub(crate) fn wait_secure_boot( · line 127

Quoted 13 lines
drivers/gpu/nova-core/fsp.rs +13 -0
+
+        let mut signatures = KBox::new(
+            FmcSignatures {
+                hash384: [0u8; FSP_HASH_SIZE],
+                public_key: [0u8; FSP_PKEY_SIZE],
+                signature: [0u8; FSP_SIG_SIZE],
+            },
+            GFP_KERNEL,
+        )?;
+
+        signatures.hash384.copy_from_slice(hash_section);
+        signatures.public_key[..pkey_section.len()].copy_from_slice(pkey_section);
+        signatures.signature[..sig_section.len()].copy_from_slice(sig_section);

If the size assumption I make above is correct, you can remove the slices on the destination.

Also note that copy_from_slice can panic, so these statements should have a //PANIC: comment justifying why it cannot happen.

Quoted 9 lines
drivers/gpu/nova-core/fsp.rs +3 -0
+
+        Ok(signatures)
+    }
 }
drivers/gpu/nova-core/gsp/boot.rs +0 -0
index 9609cef3ff51..739624af1cef 100644

drivers/gpu/nova-core/gsp/boot.rs fn boot_via_fsp( · line 212

Quoted 6 lines
drivers/gpu/nova-core/gsp/boot.rs +2 -1
@@ -208,7 +208,8 @@ fn boot_via_fsp(
     ) -> Result {
         let _fsp_falcon = Falcon::<FspEngine>::new(dev, chipset)?;
 
-        let _fsp_fw = FspFirmware::new(dev, chipset, FIRMWARE_VERSION)?;
+        let fsp_fw = FspFirmware::new(dev, chipset, FIRMWARE_VERSION)?;
+        let _signatures = Fsp::extract_fmc_signatures(dev, fsp_fw.fmc_elf.data())?;

Once extract_fmc_signatures is a method of FspFirmware, we can remove that new line and pass fsp_fw to FmcBootArgs::new. It is more logical, and will allow it to access both the image and the signatures from this single argument.

#39 lore raw

PATCH v10 19/28 gpu: nova-core: Hopper/Blackwell: add FSP falcon EMEM operations

In reply to John Hubbard

Add external memory (EMEM) read/write operations to the GPU's FSP falcon engine. These operations use Falcon PIO (Programmed I/O) to communicate with the FSP through indirect memory access.

---
 drivers/gpu/nova-core/falcon/fsp.rs | 149 +++++++++++++++++++++++++++-
 drivers/gpu/nova-core/regs.rs       |  16 +++
 2 files changed, 160 insertions(+), 5 deletions(-)
drivers/gpu/nova-core/falcon/fsp.rs +144 -5
index 57817a594631..27344da6680c 100644
@@ -5,12 +5,29 @@
 //! The FSP falcon handles secure boot and Chain of Trust operations
 //! on Hopper and Blackwell architectures, replacing SEC2's role.
 
-use kernel::io::register::RegisterBase;
+use kernel::{
+    io::{
+        register::{
+            RegisterBase,
+            WithBase, //
+        },
+        Io,
+        IoCapable, //
+    },
+    num::Bounded,
+    prelude::*,
+    ptr::Alignment, //
+};
 
-use crate::falcon::{
-    FalconEngine,
-    PFalcon2Base,
-    PFalconBase, //
+use crate::{
+    driver::Bar0,
+    falcon::{
+        Falcon,
+        FalconEngine,
+        PFalcon2Base,
+        PFalconBase, //
+    },
+    regs,
 };
 
 /// Type specifying the `Fsp` falcon engine. Cannot be instantiated.
@@ -25,3 +42,125 @@ impl RegisterBase<PFalcon2Base> for Fsp {
 }
 
 impl FalconEngine for Fsp {}
+
+/// Maximum addressable EMEM size, derived from the 24-bit offset field
+/// in NV_PFALCON_FALCON_EMEM_CTL.
+const EMEM_MAX_SIZE: Alignment = Alignment::new::<{ 1 << 24 }>();
+
+/// I/O backend for the FSP falcon's external memory (EMEM).
+///
+/// Each 32-bit access programs a byte offset via the EMEM_CTL register,
+/// then reads or writes through the EMEM_DATA register.
+struct Emem<'a> {
+    bar: &'a Bar0,
+}
+
+impl<'a> Emem<'a> {
+    fn new(bar: &'a Bar0) -> Self {
+        Self { bar }
+    }
+}
+
+impl IoCapable<u32> for Emem<'_> {
+    unsafe fn io_read(&self, address: usize) -> u32 {
+        // PANIC: Per the `io_read` SAFETY comment, `address` is within the I/O bounds of `Self` and
+        // thus less than `EMEM_MAX_SIZE`, meaning the `else` block is never taken.
+        let Some(offset) =
+            Bounded::<usize, { EMEM_MAX_SIZE.log2() }>::try_new(address).map(Bounded::cast::<u32>)
+        else {
+            unreachable!()
+        };
+
+        self.bar.write(
+            WithBase::of::<Fsp>(),
+            regs::NV_PFALCON_FALCON_EMEM_CTL::zeroed()
+                .with_rd_mode(true)
+                .with_offset(offset),
+        );
+
+        self.bar
+            .read(regs::NV_PFALCON_FALCON_EMEM_DATA::of::<Fsp>())
+            .data()
+    }
+
+    unsafe fn io_write(&self, value: u32, address: usize) {
+        // PANIC: Per the `io_write` SAFETY comment, `address` is within the I/O bounds of `Self` and
+        // thus less than `EMEM_MAX_SIZE`, meaning the `else` block is never taken.
+        let Some(offset) =
+            Bounded::<usize, { EMEM_MAX_SIZE.log2() }>::try_new(address).map(Bounded::cast::<u32>)
+        else {
+            unreachable!()
+        };
+
+        self.bar.write(
+            WithBase::of::<Fsp>(),
+            regs::NV_PFALCON_FALCON_EMEM_CTL::zeroed()
+                .with_wr_mode(true)
+                .with_offset(offset),
+        );
+
+        self.bar.write(
+            WithBase::of::<Fsp>(),
+            regs::NV_PFALCON_FALCON_EMEM_DATA::zeroed().with_data(value),
+        );
+    }
+}
+
+impl Io for Emem<'_> {
+    fn addr(&self) -> usize {
+        0
+    }
+
+    fn maxsize(&self) -> usize {
+        EMEM_MAX_SIZE.as_usize()
+    }
+}
+
+impl Falcon<Fsp> {
+    /// Returns an EMEM I/O accessor for this FSP falcon.
+    fn emem<'a>(&self, bar: &'a Bar0) -> Emem<'a> {
+        Emem::new(bar)
+    }
+
+    /// Writes `data` to FSP external memory at byte `offset`.
+    ///
+    /// Data is interpreted as little-endian 32-bit words.
+    /// Returns `EINVAL` if offset or data length is not 4-byte aligned.
+    #[expect(dead_code)]
+    fn write_emem(&self, bar: &Bar0, offset: u32, data: &[u8]) -> Result {
+        if offset % 4 != 0 || data.len() % 4 != 0 {
+            return Err(EINVAL);
+        }
+
+        let emem = self.emem(bar);
+        let mut off = offset as usize;
+        for chunk in data.chunks_exact(4) {
+            let word = u32::from_le_bytes([chunk[0], chunk[1], chunk[2], chunk[3]]);
+            emem.try_write32(word, off)?;
+            off += 4;
+        }
+
+        Ok(())
+    }
+
+    /// Reads FSP external memory at byte `offset` into `data`.
+    ///
+    /// Data is stored as little-endian 32-bit words.
+    /// Returns `EINVAL` if offset or data length is not 4-byte aligned.
+    #[expect(dead_code)]
+    fn read_emem(&self, bar: &Bar0, offset: u32, data: &mut [u8]) -> Result {
+        if offset % 4 != 0 || data.len() % 4 != 0 {
+            return Err(EINVAL);
+        }
+
+        let emem = self.emem(bar);
+        let mut off = offset as usize;
+        for chunk in data.chunks_exact_mut(4) {
+            let word = emem.try_read32(off)?;
+            chunk.copy_from_slice(&word.to_le_bytes());
+            off += 4;
+        }
+
+        Ok(())
+    }
+}
drivers/gpu/nova-core/regs.rs +16 -0
index e4de7bfffde1..5ba6c2aedd7e 100644
@@ -425,6 +425,22 @@ pub(crate) fn vga_workspace_addr(self) -> Option<u64> {
     pub(crate) NV_PFALCON_FBIF_CTL(u32) @ PFalconBase + 0x00000624 {
         7:7     allow_phys_no_ctx => bool;
     }
+
+    // Falcon EMEM PIO registers (used by FSP on Hopper/Blackwell).
+    // These provide the falcon external memory communication interface.
+    pub(crate) NV_PFALCON_FALCON_EMEM_CTL(u32) @ PFalconBase + 0x00000ac0 {
+        /// EMEM byte offset (must be 4-byte aligned)
+        23:0    offset;
+        /// Write mode
+        24:24   wr_mode => bool;
+        /// Read mode
+        25:25   rd_mode => bool;
+    }
+
+    pub(crate) NV_PFALCON_FALCON_EMEM_DATA(u32) @ PFalconBase + 0x00000ac4 {
+        /// EMEM data register
+        31:0    data => u32;
+    }
 }
 
 impl NV_PFALCON_FALCON_DMACTL {
Signature · 1 line
2.53.0
#40 lore raw

PATCH v10 20/28 gpu: nova-core: Hopper/Blackwell: add FSP message infrastructure

In reply to John Hubbard

Add the FSP messaging infrastructure needed for Chain of Trust communication on Hopper/Blackwell GPUs.

---
 drivers/gpu/nova-core/falcon/fsp.rs | 75 ++++++++++++++++++++++++++++-
 drivers/gpu/nova-core/regs.rs       | 21 ++++++++
 2 files changed, 94 insertions(+), 2 deletions(-)
drivers/gpu/nova-core/falcon/fsp.rs +73 -2
index 27344da6680c..c2f509880c8e 100644
@@ -126,7 +126,6 @@ fn emem<'a>(&self, bar: &'a Bar0) -> Emem<'a> {
     ///
     /// Data is interpreted as little-endian 32-bit words.
     /// Returns `EINVAL` if offset or data length is not 4-byte aligned.
-    #[expect(dead_code)]
     fn write_emem(&self, bar: &Bar0, offset: u32, data: &[u8]) -> Result {
         if offset % 4 != 0 || data.len() % 4 != 0 {
             return Err(EINVAL);
@@ -147,7 +146,6 @@ fn write_emem(&self, bar: &Bar0, offset: u32, data: &[u8]) -> Result {
     ///
     /// Data is stored as little-endian 32-bit words.
     /// Returns `EINVAL` if offset or data length is not 4-byte aligned.
-    #[expect(dead_code)]
     fn read_emem(&self, bar: &Bar0, offset: u32, data: &mut [u8]) -> Result {
         if offset % 4 != 0 || data.len() % 4 != 0 {
             return Err(EINVAL);
@@ -163,4 +161,77 @@ fn read_emem(&self, bar: &Bar0, offset: u32, data: &mut [u8]) -> Result {
 
         Ok(())
     }
+
+    /// Poll FSP for incoming data.
+    ///
+    /// Returns the size of available data in bytes, or 0 if no data is available.
+    ///
+    /// The FSP message queue is not circular - pointers are reset to 0 after each
+    /// message exchange, so `tail >= head` is always true when data is present.
+    #[expect(unused)]
+    pub(crate) fn poll_msgq(&self, bar: &Bar0) -> u32 {
+        let head = bar.read(regs::NV_PFSP_MSGQ_HEAD).address();
+        let tail = bar.read(regs::NV_PFSP_MSGQ_TAIL).address();
+
+        if head == tail {
+            return 0;
+        }
+
+        // TAIL points at last DWORD written, so add 4 to get total size
+        tail.saturating_sub(head) + 4
+    }
+
+    /// Send message to FSP.
+    ///
+    /// Writes a message to FSP EMEM and updates queue pointers to notify FSP.
+    ///
+    /// # Arguments
+    /// * `bar` - BAR0 memory mapping
+    /// * `packet` - Message data (must be 4-byte aligned in length)
+    ///
+    /// # Returns
+    /// `Ok(())` on success, `Err(EINVAL)` if packet is empty or not 4-byte aligned
+    #[expect(unused)]
+    pub(crate) fn send_msg(&self, bar: &Bar0, packet: &[u8]) -> Result {
+        if packet.is_empty() {
+            return Err(EINVAL);
+        }
+
+        // Write message to EMEM at offset 0 (validates 4-byte alignment)
+        self.write_emem(bar, 0, packet)?;
+
+        // Update queue pointers - TAIL points at last DWORD written
+        let tail_offset = u32::try_from(packet.len() - 4).map_err(|_| EINVAL)?;
+        bar.write_reg(regs::NV_PFSP_QUEUE_TAIL::zeroed().with_address(tail_offset));
+        bar.write_reg(regs::NV_PFSP_QUEUE_HEAD::zeroed().with_address(0));
+
+        Ok(())
+    }
+
+    /// Receive message from FSP.
+    ///
+    /// Reads a message from FSP EMEM and resets queue pointers.
+    ///
+    /// # Arguments
+    /// * `bar` - BAR0 memory mapping
+    /// * `buffer` - Buffer to receive message data
+    /// * `size` - Size of message to read in bytes (from `poll_msgq`)
+    ///
+    /// # Returns
+    /// `Ok(bytes_read)` on success, `Err(EINVAL)` if size is 0, exceeds buffer, or not aligned
+    #[expect(unused)]
+    pub(crate) fn recv_msg(&self, bar: &Bar0, buffer: &mut [u8], size: usize) -> Result<usize> {
+        if size == 0 || size > buffer.len() {
+            return Err(EINVAL);
+        }
+
+        // Read response from EMEM at offset 0 (validates 4-byte alignment)
+        self.read_emem(bar, 0, &mut buffer[..size])?;
+
+        // Reset message queue pointers after reading
+        bar.write_reg(regs::NV_PFSP_MSGQ_TAIL::zeroed().with_address(0));
+        bar.write_reg(regs::NV_PFSP_MSGQ_HEAD::zeroed().with_address(0));
+
+        Ok(size)
+    }
 }
drivers/gpu/nova-core/regs.rs +21 -0
index 5ba6c2aedd7e..c3ccae0c235f 100644
@@ -527,6 +527,27 @@ pub(crate) fn mem_scrubbing_done(self) -> bool {
     }
 }
 
+// FSP (Firmware System Processor) queue registers for Hopper/Blackwell Chain of Trust
+// These registers manage falcon EMEM communication queues
+
+register! {
+    pub(crate) NV_PFSP_QUEUE_HEAD(u32) @ 0x008f2c00 {
+        31:0    address => u32;
+    }
+
+    pub(crate) NV_PFSP_QUEUE_TAIL(u32) @ 0x008f2c04 {
+        31:0    address => u32;
+    }
+
+    pub(crate) NV_PFSP_MSGQ_HEAD(u32) @ 0x008f2c80 {
+        31:0    address => u32;
+    }
+
+    pub(crate) NV_PFSP_MSGQ_TAIL(u32) @ 0x008f2c84 {
+        31:0    address => u32;
+    }
+}
+
 // PTHERM registers
 
 // FSP secure boot completion status register used by FSP to signal boot completion.
Signature · 1 line
2.53.0
#41 lore raw

PATCH v10 21/28 gpu: nova-core: add MCTP/NVDM protocol types for firmware communication

In reply to John Hubbard

Add the MCTP (Management Component Transport Protocol) and NVDM (NVIDIA Device Management) wire-format types used for communication between the kernel driver and GPU firmware processors.

This includes typed MCTP transport headers, NVDM message headers, and NVDM message type identifiers. Both the FSP boot path and the upcoming GSP RPC message queue share this protocol layer.

---
 drivers/gpu/nova-core/mctp.rs      | 121 +++++++++++++++++++++++++++++
 drivers/gpu/nova-core/nova_core.rs |   1 +
 2 files changed, 122 insertions(+)
 create mode 100644 drivers/gpu/nova-core/mctp.rs
drivers/gpu/nova-core/mctp.rs new file +121 -0
new file mode 100644
index 000000000000..680ed19d196e
@@ -0,0 +1,121 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! MCTP/NVDM protocol types for NVIDIA GPU firmware communication.
+//!
+//! MCTP (Management Component Transport Protocol) carries NVDM (NVIDIA
+//! Device Management) messages between the kernel driver and GPU firmware
+//! processors such as FSP and GSP.
+
+#![expect(dead_code)]
+
+/// NVDM message type identifiers carried over MCTP.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(u8)]
+pub(crate) enum NvdmType {
+    /// Chain of Trust boot message.
+    Cot = 0x14,
+    /// FSP command response.
+    FspResponse = 0x15,
+}
+
+impl TryFrom<u8> for NvdmType {
+    type Error = u8;
+
+    fn try_from(value: u8) -> Result<Self, Self::Error> {
+        match value {
+            x if x == Self::Cot as u8 => Ok(Self::Cot),
+            x if x == Self::FspResponse as u8 => Ok(Self::FspResponse),
+            _ => Err(value),
+        }
+    }
+}
+
+impl From<NvdmType> for u8 {
+    fn from(value: NvdmType) -> Self {
+        value as u8
+    }
+}
+
+bitfield! {
+    pub(crate) struct MctpHeader(u32), "MCTP transport header for NVIDIA firmware messages." {
+        31:31 som as bool, "Start-of-message bit.";
+        30:30 eom as bool, "End-of-message bit.";
+        29:28 seq as u8, "Packet sequence number.";
+        23:16 seid as u8, "Source endpoint ID.";
+    }
+}
+
+impl MctpHeader {
+    /// Build a single-packet MCTP header (SOM=1, EOM=1, SEQ=0, SEID=0).
+    pub(crate) fn single_packet() -> Self {
+        Self::default().set_som(true).set_eom(true)
+    }
+
+    /// Return the raw packed u32.
+    pub(crate) const fn raw(self) -> u32 {
+        self.0
+    }
+
+    /// Check if this is a complete single-packet message (SOM=1 and EOM=1).
+    pub(crate) fn is_single_packet(self) -> bool {
+        self.som() && self.eom()
+    }
+}
+
+impl From<u32> for MctpHeader {
+    fn from(raw: u32) -> Self {
+        Self(raw)
+    }
+}
+
+/// MCTP message type for PCI vendor-defined messages.
+const MSG_TYPE_VENDOR_PCI: u8 = 0x7e;
+
+/// NVIDIA PCI vendor ID.
+const VENDOR_ID_NV: u16 = 0x10de;
+
+bitfield! {
+    pub(crate) struct NvdmHeader(u32), "NVIDIA Vendor-Defined Message header over MCTP." {
+        31:24 raw_nvdm_type as u8, "Raw NVDM message type.";
+        23:8 vendor_id as u16, "PCI vendor ID.";
+        6:0 msg_type as u8, "MCTP vendor-defined message type.";
+    }
+}
+
+impl NvdmHeader {
+    /// Build an NVDM header for the given message type.
+    pub(crate) fn new(nvdm_type: NvdmType) -> Self {
+        Self::default()
+            .set_msg_type(MSG_TYPE_VENDOR_PCI)
+            .set_vendor_id(VENDOR_ID_NV)
+            .set_nvdm_type(nvdm_type)
+    }
+
+    /// Return the raw packed u32.
+    pub(crate) const fn raw(self) -> u32 {
+        self.0
+    }
+
+    /// Extract the NVDM type field as a typed value.
+    pub(crate) fn nvdm_type(self) -> core::result::Result<NvdmType, u8> {
+        NvdmType::try_from(self.raw_nvdm_type())
+    }
+
+    /// Set the NVDM type field from a typed value.
+    pub(crate) fn set_nvdm_type(self, nvdm_type: NvdmType) -> Self {
+        self.set_raw_nvdm_type(u8::from(nvdm_type))
+    }
+
+    /// Validate this header against the expected NVIDIA NVDM format and type.
+    pub(crate) fn validate(self, expected_type: NvdmType) -> bool {
+        self.msg_type() == MSG_TYPE_VENDOR_PCI
+            && self.vendor_id() == VENDOR_ID_NV
+            && matches!(self.nvdm_type(), Ok(nvdm_type) if nvdm_type == expected_type)
+    }
+}
+
+impl From<u32> for NvdmHeader {
+    fn from(raw: u32) -> Self {
+        Self(raw)
+    }
+}
drivers/gpu/nova-core/nova_core.rs +1 -0
index 53558ac0f619..bfa0430b07b9 100644
@@ -20,6 +20,7 @@
 mod fsp;
 mod gpu;
 mod gsp;
+mod mctp;
 #[macro_use]
 mod num;
 mod regs;
Signature · 1 line
2.53.0
#42 lore raw

PATCH v10 22/28 gpu: nova-core: Hopper/Blackwell: add FSP send/receive messaging

In reply to John Hubbard

Add send_sync_fsp() which sends an MCTP/NVDM message to FSP and waits for the response. Response validation uses the typed MctpHeader and NvdmHeader wrappers from the previous commit.

A MessageToFsp trait provides the NVDM type constant for each message struct, so send_sync_fsp() can verify that the response matches the request.

---
 drivers/gpu/nova-core/falcon/fsp.rs |   3 -
 drivers/gpu/nova-core/fsp.rs        | 123 ++++++++++++++++++++++++++++
 2 files changed, 123 insertions(+), 3 deletions(-)
drivers/gpu/nova-core/falcon/fsp.rs +0 -3
index c2f509880c8e..1e03f386d185 100644
@@ -168,7 +168,6 @@ fn read_emem(&self, bar: &Bar0, offset: u32, data: &mut [u8]) -> Result {
     ///
     /// The FSP message queue is not circular - pointers are reset to 0 after each
     /// message exchange, so `tail >= head` is always true when data is present.
-    #[expect(unused)]
     pub(crate) fn poll_msgq(&self, bar: &Bar0) -> u32 {
         let head = bar.read(regs::NV_PFSP_MSGQ_HEAD).address();
         let tail = bar.read(regs::NV_PFSP_MSGQ_TAIL).address();
@@ -191,7 +190,6 @@ pub(crate) fn poll_msgq(&self, bar: &Bar0) -> u32 {
     ///
     /// # Returns
     /// `Ok(())` on success, `Err(EINVAL)` if packet is empty or not 4-byte aligned
-    #[expect(unused)]
     pub(crate) fn send_msg(&self, bar: &Bar0, packet: &[u8]) -> Result {
         if packet.is_empty() {
             return Err(EINVAL);
@@ -219,7 +217,6 @@ pub(crate) fn send_msg(&self, bar: &Bar0, packet: &[u8]) -> Result {
     ///
     /// # Returns
     /// `Ok(bytes_read)` on success, `Err(EINVAL)` if size is 0, exceeds buffer, or not aligned
-    #[expect(unused)]
     pub(crate) fn recv_msg(&self, bar: &Bar0, buffer: &mut [u8], size: usize) -> Result<usize> {
         if size == 0 || size > buffer.len() {
             return Err(EINVAL);
drivers/gpu/nova-core/fsp.rs +123 -0

139 lines not on this page · raw message

Signature · 1 line
2.53.0
#43 lore raw

PATCH v10 23/28 gpu: nova-core: Hopper/Blackwell: add FspCotVersion type

In reply to John Hubbard

Add FspCotVersion to represent the FSP Chain of Trust protocol version, and Chipset::fsp_cot_version() which returns the version for each architecture. Hopper uses version 1, Blackwell uses version 2. Non-FSP architectures return None.

---
 drivers/gpu/nova-core/fsp.rs | 19 +++++++++++++++++++
 drivers/gpu/nova-core/gpu.rs | 16 ++++++++++++++++
 2 files changed, 35 insertions(+)
drivers/gpu/nova-core/fsp.rs +19 -0
index b489845f733a..bc98a5c3cfaa 100644
@@ -21,6 +21,25 @@
     NvdmType, //
 };
 
+/// FSP Chain of Trust protocol version.
+///
+/// Hopper (GH100) uses version 1, Blackwell uses version 2.
+#[derive(Debug, Clone, Copy)]
+pub(crate) struct FspCotVersion(u16);
+
+impl FspCotVersion {
+    /// Create a new FSP COT version.
+    pub(crate) const fn new(version: u16) -> Self {
+        Self(version)
+    }
+
+    /// Return the raw protocol version number for the wire format.
+    #[expect(dead_code)]
+    pub(crate) const fn raw(self) -> u16 {
+        self.0
+    }
+}
+
 /// FSP message timeout in milliseconds.
 const FSP_MSG_TIMEOUT_MS: i64 = 2000;
 
drivers/gpu/nova-core/gpu.rs +16 -0
index 0b3a62f6ad1b..5d7fd810687d 100644
@@ -24,6 +24,7 @@
         Falcon, //
     },
     fb::SysmemFlush,
+    fsp::FspCotVersion,
     gsp::Gsp,
     regs,
 };
@@ -135,6 +136,21 @@ pub(crate) const fn arch(self) -> Architecture {
     pub(crate) const fn needs_fwsec_bootloader(self) -> bool {
         matches!(self.arch(), Architecture::Turing) || matches!(self, Self::GA100)
     }
+
+    /// Returns the FSP Chain of Trust (COT) protocol version for this chipset.
+    ///
+    /// Hopper (GH100) uses version 1, Blackwell uses version 2.
+    /// Returns `None` for architectures that do not use FSP.
+    #[expect(dead_code)]
+    pub(crate) const fn fsp_cot_version(&self) -> Option<FspCotVersion> {
+        match self.arch() {
+            Architecture::Hopper => Some(FspCotVersion::new(1)),
+            Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => {
+                Some(FspCotVersion::new(2))
+            }
+            _ => None,
+        }
+    }
 }
 
 // TODO
Signature · 1 line
2.53.0
#44 lore raw

PATCH v10 24/28 gpu: nova-core: Hopper/Blackwell: larger non-WPR heap

In reply to John Hubbard

Add dedicated FB HALs for Hopper (GH100) and Blackwell (GB100) with architecture-specific non-WPR heap sizes. Hopper uses 2 MiB, Blackwell uses 2 MiB + 128 KiB. These are needed for the larger reserved memory regions that Hopper/Blackwell GPUs require.

Also adds the non_wpr_heap_size() method to the FbHal trait, and the total_reserved_size field to FbLayout.

---
 drivers/gpu/nova-core/fb.rs           | 14 +++++++---
 drivers/gpu/nova-core/fb/hal.rs       | 19 +++++++++-----
 drivers/gpu/nova-core/fb/hal/ga102.rs |  2 +-
 drivers/gpu/nova-core/fb/hal/gb100.rs | 38 +++++++++++++++++++++++++++
 drivers/gpu/nova-core/fb/hal/gh100.rs | 38 +++++++++++++++++++++++++++
 5 files changed, 101 insertions(+), 10 deletions(-)
 create mode 100644 drivers/gpu/nova-core/fb/hal/gb100.rs
 create mode 100644 drivers/gpu/nova-core/fb/hal/gh100.rs
drivers/gpu/nova-core/fb.rs +11 -3
index c2005e4b4177..756ff283a908 100644
@@ -103,6 +103,15 @@ pub(crate) fn unregister(&self, bar: &Bar0) {
     }
 }
 
+/// Calculate non-WPR heap size based on chipset architecture.
+/// This matches the logic used in FSP for consistency.
+pub(crate) fn calc_non_wpr_heap_size(chipset: Chipset) -> u64 {
+    hal::fb_hal(chipset)
+        .non_wpr_heap_size()
+        .map(u64::from)
+        .unwrap_or(u64::SZ_1M)
+}
+
 pub(crate) struct FbRange(Range<u64>);
 
 impl FbRange {
@@ -262,9 +271,8 @@ pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result<
         };
 
         let heap = {
-            const HEAP_SIZE: u64 = u64::SZ_1M;
-
-            FbRange(wpr2.start - HEAP_SIZE..wpr2.start)
+            let heap_size = calc_non_wpr_heap_size(chipset);
+            FbRange(wpr2.start - heap_size..wpr2.start)
         };
 
         Ok(Self {
drivers/gpu/nova-core/fb/hal.rs +13 -6
index 3b3bad0feed0..478f80d640c1 100644
@@ -12,6 +12,8 @@
 
 mod ga100;
 mod ga102;
+mod gb100;
+mod gh100;
 mod tu102;
 
 pub(crate) trait FbHal {
@@ -28,17 +30,22 @@ pub(crate) trait FbHal {
 
     /// Returns the VRAM size, in bytes.
     fn vidmem_size(&self, bar: &Bar0) -> u64;
+
+    /// Returns the non-WPR heap size for GPUs that need large reserved memory.
+    ///
+    /// Returns `None` for GPUs that don't need extra reserved memory.
+    fn non_wpr_heap_size(&self) -> Option<u32> {
+        None
+    }
 }
 
 /// Returns the HAL corresponding to `chipset`.
-pub(super) fn fb_hal(chipset: Chipset) -> &'static dyn FbHal {
+pub(crate) fn fb_hal(chipset: Chipset) -> &'static dyn FbHal {
     match chipset.arch() {
         Architecture::Turing => tu102::TU102_HAL,
         Architecture::Ampere if chipset == Chipset::GA100 => ga100::GA100_HAL,
-        Architecture::Ampere => ga102::GA102_HAL,
-        Architecture::Ada
-        | Architecture::Hopper
-        | Architecture::BlackwellGB10x
-        | Architecture::BlackwellGB20x => ga102::GA102_HAL,
+        Architecture::Ampere | Architecture::Ada => ga102::GA102_HAL,
+        Architecture::Hopper => gh100::GH100_HAL,
+        Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => gb100::GB100_HAL,
     }
 }
drivers/gpu/nova-core/fb/hal/ga102.rs +1 -1
index 4b9f0f74d0e7..79c5a44f6a29 100644
@@ -11,7 +11,7 @@
     regs, //
 };
 
-fn vidmem_size_ga102(bar: &Bar0) -> u64 {
+pub(super) fn vidmem_size_ga102(bar: &Bar0) -> u64 {
     bar.read(regs::NV_USABLE_FB_SIZE_IN_MB).usable_fb_size()
 }
 
drivers/gpu/nova-core/fb/hal/gb100.rs new file +38 -0
new file mode 100644
index 000000000000..bead99a6ca76
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+
+use kernel::prelude::*;
+
+use crate::{
+    driver::Bar0,
+    fb::hal::FbHal, //
+};
+
+struct Gb100;
+
+impl FbHal for Gb100 {
+    fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64 {
+        super::ga100::read_sysmem_flush_page_ga100(bar)
+    }
+
+    fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
+        super::ga100::write_sysmem_flush_page_ga100(bar, addr);
+
+        Ok(())
+    }
+
+    fn supports_display(&self, bar: &Bar0) -> bool {
+        super::ga100::display_enabled_ga100(bar)
+    }
+
+    fn vidmem_size(&self, bar: &Bar0) -> u64 {
+        super::ga102::vidmem_size_ga102(bar)
+    }
+
+    fn non_wpr_heap_size(&self) -> Option<u32> {
+        // 2 MiB + 128 KiB non-WPR heap for Blackwell (see Open RM: kgspCalculateFbLayout_GB100).
+        Some(0x220000)
+    }
+}
+
+const GB100: Gb100 = Gb100;
+pub(super) const GB100_HAL: &dyn FbHal = &GB100;
drivers/gpu/nova-core/fb/hal/gh100.rs new file +38 -0
new file mode 100644
index 000000000000..32d7414e6243
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+
+use kernel::prelude::*;
+
+use crate::{
+    driver::Bar0,
+    fb::hal::FbHal, //
+};
+
+struct Gh100;
+
+impl FbHal for Gh100 {
+    fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64 {
+        super::ga100::read_sysmem_flush_page_ga100(bar)
+    }
+
+    fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
+        super::ga100::write_sysmem_flush_page_ga100(bar, addr);
+
+        Ok(())
+    }
+
+    fn supports_display(&self, bar: &Bar0) -> bool {
+        super::ga100::display_enabled_ga100(bar)
+    }
+
+    fn vidmem_size(&self, bar: &Bar0) -> u64 {
+        super::ga102::vidmem_size_ga102(bar)
+    }
+
+    fn non_wpr_heap_size(&self) -> Option<u32> {
+        // 2 MiB non-WPR heap for Hopper (see Open RM: kgspCalculateFbLayout_GH100).
+        Some(0x200000)
+    }
+}
+
+const GH100: Gh100 = Gh100;
+pub(super) const GH100_HAL: &dyn FbHal = &GH100;
Signature · 1 line
2.53.0
#45 lore raw

Re: [PATCH v10 24/28] gpu: nova-core: Hopper/Blackwell: larger non-WPR heap

Quoted 9 lines · John Hubbard

Add dedicated FB HALs for Hopper (GH100) and Blackwell (GB100) with architecture-specific non-WPR heap sizes. Hopper uses 2 MiB, Blackwell uses 2 MiB + 128 KiB. These are needed for the larger reserved memory regions that Hopper/Blackwell GPUs require.

Also adds the non_wpr_heap_size() method to the FbHal trait, and the total_reserved_size field to FbLayout.

Let's move this patch earlier in the series, e.g. right after "new location for PCI config mirror".

This will keep all the architecture setup/non-messaging patches together, and keep the more complex message queue ones at the end, forming a more logical flow and letting us merge these ones first (hopefully reducing the series to just the FSP messaging patches soon).

Quoted 16 lines
---
 drivers/gpu/nova-core/fb.rs           | 14 +++++++---
 drivers/gpu/nova-core/fb/hal.rs       | 19 +++++++++-----
 drivers/gpu/nova-core/fb/hal/ga102.rs |  2 +-
 drivers/gpu/nova-core/fb/hal/gb100.rs | 38 +++++++++++++++++++++++++++
 drivers/gpu/nova-core/fb/hal/gh100.rs | 38 +++++++++++++++++++++++++++
 5 files changed, 101 insertions(+), 10 deletions(-)
 create mode 100644 drivers/gpu/nova-core/fb/hal/gb100.rs
 create mode 100644 drivers/gpu/nova-core/fb/hal/gh100.rs
drivers/gpu/nova-core/fb.rs +0 -0
index c2005e4b4177..756ff283a908 100644
@@ -103,6 +103,15 @@ pub(crate) fn unregister(&self, bar: &Bar0) {
     }

drivers/gpu/nova-core/fb.rs pub(crate) fn unregister(&self, bar: &Bar0) { · line 113

Quoted 10 lines
drivers/gpu/nova-core/fb.rs +8 -0
 }
 
+/// Calculate non-WPR heap size based on chipset architecture.
+/// This matches the logic used in FSP for consistency.
+pub(crate) fn calc_non_wpr_heap_size(chipset: Chipset) -> u64 {
+    hal::fb_hal(chipset)
+        .non_wpr_heap_size()
+        .map(u64::from)
+        .unwrap_or(u64::SZ_1M)
+}

This method is only ever called in a single place (which already has the HAL at hand), let's just inline it. The name is misleading as it doesn't calculate anything, it just returns a fixed per-chipset value. The comment is also not particularly informative so we won't lose much by dropping it.

Quoted 30 lines
drivers/gpu/nova-core/fb.rs +3 -3
+
 pub(crate) struct FbRange(Range<u64>);
 
 impl FbRange {
@@ -262,9 +271,8 @@ pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result<
         };
 
         let heap = {
-            const HEAP_SIZE: u64 = u64::SZ_1M;
-
-            FbRange(wpr2.start - HEAP_SIZE..wpr2.start)
+            let heap_size = calc_non_wpr_heap_size(chipset);
+            FbRange(wpr2.start - heap_size..wpr2.start)
         };
 
         Ok(Self {
drivers/gpu/nova-core/fb/hal.rs +2 -0
index 3b3bad0feed0..478f80d640c1 100644
@@ -12,6 +12,8 @@
 
 mod ga100;
 mod ga102;
+mod gb100;
+mod gh100;
 mod tu102;
 
 pub(crate) trait FbHal {

drivers/gpu/nova-core/fb/hal.rs pub(crate) trait FbHal { · line 39

Quoted 10 lines
drivers/gpu/nova-core/fb/hal.rs +7 -0
@@ -28,17 +30,22 @@ pub(crate) trait FbHal {
 
     /// Returns the VRAM size, in bytes.
     fn vidmem_size(&self, bar: &Bar0) -> u64;
+
+    /// Returns the non-WPR heap size for GPUs that need large reserved memory.
+    ///
+    /// Returns `None` for GPUs that don't need extra reserved memory.
+    fn non_wpr_heap_size(&self) -> Option<u32> {
+        None
+    }

This HAL method is bizarre.

Why return an Option when 0 expresses "I don't need extra memory" just as well?

Then there's the user of this HAL defaulting to SZ_1M if it returned None, which was the default value for heap. But if it returns something else than None, then we just use that value for heap, without adding SZ_1M... So what it appears to do is that it returns the total amount of heap, except when it returns None in which case the heap value should be SZ_1M?

If that's the case, then why not just have a heap_size that simply returns the amount of heap needed (without any Option), and just use that without further complications?

Please confirm whether the values returned in the HAL are actually total heap size, and if they are, let's generalize the HAL to all GPU generations.

drivers/gpu/nova-core/fb/hal.rs pub(crate) trait FbHal { · line 43

Quoted 5 lines
drivers/gpu/nova-core/fb/hal.rs +1 -1
 }
 
 /// Returns the HAL corresponding to `chipset`.
-pub(super) fn fb_hal(chipset: Chipset) -> &'static dyn FbHal {
+pub(crate) fn fb_hal(chipset: Chipset) -> &'static dyn FbHal {

The visibility of this method doesn't need to be changed.

Quoted 55 lines
drivers/gpu/nova-core/fb/hal.rs +3 -5
     match chipset.arch() {
         Architecture::Turing => tu102::TU102_HAL,
         Architecture::Ampere if chipset == Chipset::GA100 => ga100::GA100_HAL,
-        Architecture::Ampere => ga102::GA102_HAL,
-        Architecture::Ada
-        | Architecture::Hopper
-        | Architecture::BlackwellGB10x
-        | Architecture::BlackwellGB20x => ga102::GA102_HAL,
+        Architecture::Ampere | Architecture::Ada => ga102::GA102_HAL,
+        Architecture::Hopper => gh100::GH100_HAL,
+        Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => gb100::GB100_HAL,
     }
 }
drivers/gpu/nova-core/fb/hal/ga102.rs +1 -1
index 4b9f0f74d0e7..79c5a44f6a29 100644
@@ -11,7 +11,7 @@
     regs, //
 };
 
-fn vidmem_size_ga102(bar: &Bar0) -> u64 {
+pub(super) fn vidmem_size_ga102(bar: &Bar0) -> u64 {
     bar.read(regs::NV_USABLE_FB_SIZE_IN_MB).usable_fb_size()
 }
 
drivers/gpu/nova-core/fb/hal/gb100.rs new file +23 -0
new file mode 100644
index 000000000000..bead99a6ca76
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+
+use kernel::prelude::*;
+
+use crate::{
+    driver::Bar0,
+    fb::hal::FbHal, //
+};
+
+struct Gb100;
+
+impl FbHal for Gb100 {
+    fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64 {
+        super::ga100::read_sysmem_flush_page_ga100(bar)
+    }
+
+    fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
+        super::ga100::write_sysmem_flush_page_ga100(bar, addr);
+
+        Ok(())
+    }
+
+    fn supports_display(&self, bar: &Bar0) -> bool {

drivers/gpu/nova-core/fb/hal/gb100.rs line 33

Quoted 10 lines
drivers/gpu/nova-core/fb/hal/gb100.rs new file +10 -0
+        super::ga100::display_enabled_ga100(bar)
+    }
+
+    fn vidmem_size(&self, bar: &Bar0) -> u64 {
+        super::ga102::vidmem_size_ga102(bar)
+    }
+
+    fn non_wpr_heap_size(&self) -> Option<u32> {
+        // 2 MiB + 128 KiB non-WPR heap for Blackwell (see Open RM: kgspCalculateFbLayout_GB100).
+        Some(0x220000)

I could not find any function named kgspCalculateFbLayout_GB100 in OpenRM. There is one for GH100, but not for GB100. Also this method computes the whole layout, the relevant one would be kgspGetNonWprHeapSize.

Also I know this is a bit overkill, but let's make this a module-level constant so other HALs can refer to it if needed.

Quoted 33 lines
drivers/gpu/nova-core/fb/hal/gb100.rs new file +5 -0
+    }
+}
+
+const GB100: Gb100 = Gb100;
+pub(super) const GB100_HAL: &dyn FbHal = &GB100;
drivers/gpu/nova-core/fb/hal/gh100.rs new file +22 -0
new file mode 100644
index 000000000000..32d7414e6243
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+
+use kernel::prelude::*;
+
+use crate::{
+    driver::Bar0,
+    fb::hal::FbHal, //
+};
+
+struct Gh100;
+
+impl FbHal for Gh100 {
+    fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64 {
+        super::ga100::read_sysmem_flush_page_ga100(bar)
+    }
+
+    fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
+        super::ga100::write_sysmem_flush_page_ga100(bar, addr);
+
+        Ok(())
+    }
+

drivers/gpu/nova-core/fb/hal/gh100.rs line 32

Quoted 10 lines
drivers/gpu/nova-core/fb/hal/gh100.rs new file +10 -0
+    fn supports_display(&self, bar: &Bar0) -> bool {
+        super::ga100::display_enabled_ga100(bar)
+    }
+
+    fn vidmem_size(&self, bar: &Bar0) -> u64 {
+        super::ga102::vidmem_size_ga102(bar)
+    }
+
+    fn non_wpr_heap_size(&self) -> Option<u32> {
+        // 2 MiB non-WPR heap for Hopper (see Open RM: kgspCalculateFbLayout_GH100).

Here also let's remove the reference to kgspCalculateFbLayout_GH100 - it does exist as of 570.144, but has been removed in main. kgspGetNonWprHeapSize is a more accurate reference if we need one.

#46 lore raw

PATCH v10 25/28 gpu: nova-core: Hopper/Blackwell: add FSP Chain of Trust boot

In reply to John Hubbard

Add boot_fmc() which builds and sends the Chain of Trust message to FSP. FmcBootArgs bundles the DMA-coherent boot parameters that FSP reads at boot time.

---
 drivers/gpu/nova-core/fb.rs           |   1 -
 drivers/gpu/nova-core/firmware/fsp.rs |   1 -
 drivers/gpu/nova-core/fsp.rs          | 257 +++++++++++++++++++++++++-
 drivers/gpu/nova-core/gpu.rs          |   1 -
 drivers/gpu/nova-core/gsp/boot.rs     |  26 ++-
 drivers/gpu/nova-core/mctp.rs         |   2 -
 6 files changed, 275 insertions(+), 13 deletions(-)
drivers/gpu/nova-core/fb.rs +0 -1
index 756ff283a908..2b3a2bb2f1db 100644
@@ -294,7 +294,6 @@ pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result<
 }
 
 /// Returns the PMU reserved memory size for `chipset`.
-#[expect(dead_code)]
 pub(crate) fn calc_pmu_reserved_size(chipset: Chipset) -> u32 {
     match chipset.arch() {
         Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => PMU_RESERVED_SIZE,
drivers/gpu/nova-core/firmware/fsp.rs +0 -1
index 3968bacb7e61..301345aa491c 100644
@@ -14,7 +14,6 @@
     gpu::Chipset, //
 };
 
-#[expect(dead_code)]
 pub(crate) struct FspFirmware {
     /// FMC firmware image data (only the "image" ELF section).
     pub(crate) fmc_image: Coherent<[u8]>,
drivers/gpu/nova-core/fsp.rs +254 -3

296 lines not on this page · raw message

drivers/gpu/nova-core/gpu.rs +0 -1
index 5d7fd810687d..0a05d038ab76 100644
@@ -141,7 +141,6 @@ pub(crate) const fn needs_fwsec_bootloader(self) -> bool {
     ///
     /// Hopper (GH100) uses version 1, Blackwell uses version 2.
     /// Returns `None` for architectures that do not use FSP.
-    #[expect(dead_code)]
     pub(crate) const fn fsp_cot_version(&self) -> Option<FspCotVersion> {
         match self.arch() {
             Architecture::Hopper => Some(FspCotVersion::new(1)),
drivers/gpu/nova-core/gsp/boot.rs +21 -5
index 739624af1cef..703c9ee48363 100644
@@ -33,7 +33,10 @@
         gsp::GspFirmware,
         FIRMWARE_VERSION, //
     },
-    fsp::Fsp,
+    fsp::{
+        FmcBootArgs,
+        Fsp, //
+    },
     gpu::{
         Architecture,
         Chipset, //
@@ -203,16 +206,29 @@ fn boot_via_fsp(
         bar: &Bar0,
         chipset: Chipset,
         _gsp_falcon: &Falcon<Gsp>,
-        _wpr_meta: &Coherent<GspFwWprMeta>,
-        _libos: &Coherent<[LibosMemoryRegionInitArgument]>,
+        wpr_meta: &Coherent<GspFwWprMeta>,
+        libos: &Coherent<[LibosMemoryRegionInitArgument]>,
     ) -> Result {
-        let _fsp_falcon = Falcon::<FspEngine>::new(dev, chipset)?;
+        let fsp_falcon = Falcon::<FspEngine>::new(dev, chipset)?;
 
         let fsp_fw = FspFirmware::new(dev, chipset, FIRMWARE_VERSION)?;
-        let _signatures = Fsp::extract_fmc_signatures(dev, fsp_fw.fmc_elf.data())?;
+        let signatures = Fsp::extract_fmc_signatures(dev, fsp_fw.fmc_elf.data())?;
 
         Fsp::wait_secure_boot(dev, bar, chipset.arch())?;
 
+        let args = FmcBootArgs::new(
+            dev,
+            chipset,
+            &fsp_fw.fmc_image,
+            wpr_meta.dma_handle(),
+            core::mem::size_of::<GspFwWprMeta>() as u32,
+            libos.dma_handle(),
+            false,
+            &signatures,
+        )?;
+
+        Fsp::boot_fmc(dev, bar, &fsp_falcon, &args)?;
+
         Err(ENOTSUPP)
     }
 
drivers/gpu/nova-core/mctp.rs +0 -2
index 680ed19d196e..c23e8ec69636 100644
@@ -6,8 +6,6 @@
 //! Device Management) messages between the kernel driver and GPU firmware
 //! processors such as FSP and GSP.
 
-#![expect(dead_code)]
-
 /// NVDM message type identifiers carried over MCTP.
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
 #[repr(u8)]
Signature · 1 line
2.53.0
#47 lore raw

PATCH v10 26/28 gpu: nova-core: Blackwell: use correct sysmem flush registers

In reply to John Hubbard

Blackwell GPUs moved the sysmem flush page registers away from the legacy NV_PFB_NISO_FLUSH_SYSMEM_ADDR used by Ampere/Ada.

GB10x uses HSHUB0 registers, with both a primary and EG (egress) pair that must be programmed to the same address. GB20x uses FBHUB0 registers.

Add separate GB100 and GB202 fb HALs, and split the Blackwell HAL dispatch so that each uses its respective registers.

---
 drivers/gpu/nova-core/fb/hal.rs       |  8 ++-
 drivers/gpu/nova-core/fb/hal/gb100.rs | 54 ++++++++++++++++---
 drivers/gpu/nova-core/fb/hal/gb202.rs | 77 +++++++++++++++++++++++++++
 drivers/gpu/nova-core/regs.rs         | 36 +++++++++++++
 4 files changed, 168 insertions(+), 7 deletions(-)
 create mode 100644 drivers/gpu/nova-core/fb/hal/gb202.rs
drivers/gpu/nova-core/fb/hal.rs +7 -1
index 478f80d640c1..65edf07c3222 100644
@@ -13,9 +13,14 @@
 mod ga100;
 mod ga102;
 mod gb100;
+mod gb202;
 mod gh100;
 mod tu102;
 
+/// Non-WPR heap size for Blackwell (2 MiB + 128 KiB).
+/// See Open RM: kgspCalculateFbLayout_GB100.
+const BLACKWELL_NON_WPR_HEAP_SIZE: u32 = 0x220000;
+
 pub(crate) trait FbHal {
     /// Returns the address of the currently-registered sysmem flush page.
     fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64;
@@ -46,6 +51,7 @@ pub(crate) fn fb_hal(chipset: Chipset) -> &'static dyn FbHal {
         Architecture::Ampere if chipset == Chipset::GA100 => ga100::GA100_HAL,
         Architecture::Ampere | Architecture::Ada => ga102::GA102_HAL,
         Architecture::Hopper => gh100::GH100_HAL,
-        Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => gb100::GB100_HAL,
+        Architecture::BlackwellGB10x => gb100::GB100_HAL,
+        Architecture::BlackwellGB20x => gb202::GB202_HAL,
     }
 }
drivers/gpu/nova-core/fb/hal/gb100.rs +48 -6

77 lines not on this page · raw message

drivers/gpu/nova-core/fb/hal/gb202.rs new file +77 -0

77 lines not on this page · raw message

drivers/gpu/nova-core/regs.rs +36 -0
index c3ccae0c235f..77b11c7de3f8 100644
@@ -145,6 +145,42 @@ fn fmt(&self, f: &mut kernel::fmt::Formatter<'_>) -> kernel::fmt::Result {
         /// Bits 12..40 of the higher (exclusive) bound of the WPR2 region.
         31:4    hi_val;
     }
+
+    // Blackwell GB10x sysmem flush registers (HSHUB0).
+    //
+    // GB10x GPUs use two pairs of HSHUB registers for sysmembar: a primary pair and an EG
+    // (egress) pair. Both must be programmed to the same address. Hardware ignores bits 7:0
+    // of each LO register. HSHUB0 base is 0x00891000.
+
+    pub(crate) NV_PFB_HSHUB0_PCIE_FLUSH_SYSMEM_ADDR_LO(u32) @ 0x00891e50 {
+        31:0    adr => u32;
+    }
+
+    pub(crate) NV_PFB_HSHUB0_PCIE_FLUSH_SYSMEM_ADDR_HI(u32) @ 0x00891e54 {
+        19:0    adr;
+    }
+
+    pub(crate) NV_PFB_HSHUB0_EG_PCIE_FLUSH_SYSMEM_ADDR_LO(u32) @ 0x008916c0 {
+        31:0    adr => u32;
+    }
+
+    pub(crate) NV_PFB_HSHUB0_EG_PCIE_FLUSH_SYSMEM_ADDR_HI(u32) @ 0x008916c4 {
+        19:0    adr;
+    }
+
+    // Blackwell GB20x sysmem flush registers (FBHUB0).
+    //
+    // Unlike the older NV_PFB_NISO_FLUSH_SYSMEM_ADDR registers which encode the address with an
+    // 8-bit right-shift, these registers take the raw address split into lower/upper 32-bit halves.
+    // The hardware ignores bits 7:0 of the LO register.
+
+    pub(crate) NV_PFB_FBHUB0_PCIE_FLUSH_SYSMEM_ADDR_LO(u32) @ 0x008a1d58 {
+        31:0    adr => u32;
+    }
+
+    pub(crate) NV_PFB_FBHUB0_PCIE_FLUSH_SYSMEM_ADDR_HI(u32) @ 0x008a1d5c {
+        19:0    adr;
+    }
 }
 
 impl NV_PFB_PRI_MMU_LOCAL_MEMORY_RANGE {
Signature · 1 line
2.53.0
#48 lore raw

Re: [PATCH v10 26/28] gpu: nova-core: Blackwell: use correct sysmem flush registers

Quoted 11 lines · John Hubbard

Blackwell GPUs moved the sysmem flush page registers away from the legacy NV_PFB_NISO_FLUSH_SYSMEM_ADDR used by Ampere/Ada.

GB10x uses HSHUB0 registers, with both a primary and EG (egress) pair that must be programmed to the same address. GB20x uses FBHUB0 registers.

Add separate GB100 and GB202 fb HALs, and split the Blackwell HAL dispatch so that each uses its respective registers.

This is another one that can be moved to the beginning of the series. That way we have a nice progression of addressing the hardware differences -> fork the boot path -> build and use FMC messaging.

Quoted 13 lines
---
 drivers/gpu/nova-core/fb/hal.rs       |  8 ++-
 drivers/gpu/nova-core/fb/hal/gb100.rs | 54 ++++++++++++++++---
 drivers/gpu/nova-core/fb/hal/gb202.rs | 77 +++++++++++++++++++++++++++
 drivers/gpu/nova-core/regs.rs         | 36 +++++++++++++
 4 files changed, 168 insertions(+), 7 deletions(-)
 create mode 100644 drivers/gpu/nova-core/fb/hal/gb202.rs
drivers/gpu/nova-core/fb/hal.rs +0 -0
index 478f80d640c1..65edf07c3222 100644

drivers/gpu/nova-core/fb/hal.rs line 22

Quoted 10 lines
drivers/gpu/nova-core/fb/hal.rs +4 -0
@@ -13,9 +13,14 @@
 mod ga100;
 mod ga102;
 mod gb100;
+mod gb202;
 mod gh100;
 mod tu102;
 
+/// Non-WPR heap size for Blackwell (2 MiB + 128 KiB).
+/// See Open RM: kgspCalculateFbLayout_GB100.
+const BLACKWELL_NON_WPR_HEAP_SIZE: u32 = 0x220000;

What this const? If we want to share a value between different HALs the way of doing is putting it into a pub(super) method of the lowest HAL module and making higher ones call into it.

Quoted 18 lines
drivers/gpu/nova-core/fb/hal.rs +3 -1
+
 pub(crate) trait FbHal {
     /// Returns the address of the currently-registered sysmem flush page.
     fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64;
@@ -46,6 +51,7 @@ pub(crate) fn fb_hal(chipset: Chipset) -> &'static dyn FbHal {
         Architecture::Ampere if chipset == Chipset::GA100 => ga100::GA100_HAL,
         Architecture::Ampere | Architecture::Ada => ga102::GA102_HAL,
         Architecture::Hopper => gh100::GH100_HAL,
-        Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => gb100::GB100_HAL,
+        Architecture::BlackwellGB10x => gb100::GB100_HAL,
+        Architecture::BlackwellGB20x => gb202::GB202_HAL,
     }
 }
drivers/gpu/nova-core/fb/hal/gb100.rs +0 -0
index bead99a6ca76..c6e2a505e6ae 100644

drivers/gpu/nova-core/fb/hal/gb100.rs line 3

Quoted 4 lines
drivers/gpu/nova-core/fb/hal/gb100.rs +1 -1
@@ -1,21 +1,64 @@
 // SPDX-License-Identifier: GPL-2.0
 
-use kernel::prelude::*;
+//! Blackwell GB10x framebuffer HAL.

Let's add the module-level doccomments in the commit that introduced the module in the first place.

drivers/gpu/nova-core/fb/hal/gb100.rs line 6

Quoted 3 lines
drivers/gpu/nova-core/fb/hal/gb100.rs +3 -0
+//!
+//! GB10x GPUs use HSHUB0 registers for the sysmem flush page. Both the primary and EG (egress)
+//! register pairs must be programmed to the same address, as required by hardware.

This should be a method doccomment rather than a module one imho.

<snip>

Quoted 20 lines
drivers/gpu/nova-core/regs.rs +12 -0
index c3ccae0c235f..77b11c7de3f8 100644
@@ -145,6 +145,42 @@ fn fmt(&self, f: &mut kernel::fmt::Formatter<'_>) -> kernel::fmt::Result {
         /// Bits 12..40 of the higher (exclusive) bound of the WPR2 region.
         31:4    hi_val;
     }
+
+    // Blackwell GB10x sysmem flush registers (HSHUB0).
+    //
+    // GB10x GPUs use two pairs of HSHUB registers for sysmembar: a primary pair and an EG
+    // (egress) pair. Both must be programmed to the same address. Hardware ignores bits 7:0
+    // of each LO register. HSHUB0 base is 0x00891000.
+
+    pub(crate) NV_PFB_HSHUB0_PCIE_FLUSH_SYSMEM_ADDR_LO(u32) @ 0x00891e50 {
+        31:0    adr => u32;
+    }
+
+    pub(crate) NV_PFB_HSHUB0_PCIE_FLUSH_SYSMEM_ADDR_HI(u32) @ 0x00891e54 {

drivers/gpu/nova-core/regs.rs fn fmt(&self, f: &mut kernel::fmt::Formatter<'_>) -> kernel::fmt::Result { · line 169

Quoted 10 lines
drivers/gpu/nova-core/regs.rs +10 -0
+        19:0    adr;
+    }
+
+    pub(crate) NV_PFB_HSHUB0_EG_PCIE_FLUSH_SYSMEM_ADDR_LO(u32) @ 0x008916c0 {
+        31:0    adr => u32;
+    }
+
+    pub(crate) NV_PFB_HSHUB0_EG_PCIE_FLUSH_SYSMEM_ADDR_HI(u32) @ 0x008916c4 {
+        19:0    adr;
+    }

I had trouble finding these registers in OpenRM because they are not defined under the same name, given that they are relative registers and there are multiple HSHUBs (a detail that will likely become significant in the future).

So we should get this right from the get-go and use relative registers, and a (for now) unique Hshub0 base. That will also make it easier to match the registers against OpenRM when needed.

... but then, when I looked for the 0x00891000 base in OpenRM, I also couldn't find it. All I found was this in _kmemsysInitHshub0Aperture_GB100:

    #define NV_PFB_HSHUB0      0x00870fff:0x00870000

... which is different from the base in the comment above, for a reason I ignore.

And it looks like even that value isn't absolutely correct, because looking further in OpenRM is seems like it is getting the bases for the HSHUBs using NV_PTOP_DEVICE_INFO2 - runtime, per SKU values! We might need to update registers to support this, and I think it is fine to go with a workaround and a hardcoded value in a first time, but we should:

- Make sure we understand all the implications of this (I only looked superficially),
- Add a big TODO item detailing what needs to be done if this cannot be addressed in this series.

Quoted 4 lines
drivers/gpu/nova-core/regs.rs +4 -0
+
+    // Blackwell GB20x sysmem flush registers (FBHUB0).
+    //
+    // Unlike the older NV_PFB_NISO_FLUSH_SYSMEM_ADDR registers which encode the address with an

drivers/gpu/nova-core/regs.rs fn fmt(&self, f: &mut kernel::fmt::Formatter<'_>) -> kernel::fmt::Result { · line 183

Quoted 10 lines
drivers/gpu/nova-core/regs.rs +10 -0
+    // 8-bit right-shift, these registers take the raw address split into lower/upper 32-bit halves.
+    // The hardware ignores bits 7:0 of the LO register.
+
+    pub(crate) NV_PFB_FBHUB0_PCIE_FLUSH_SYSMEM_ADDR_LO(u32) @ 0x008a1d58 {
+        31:0    adr => u32;
+    }
+
+    pub(crate) NV_PFB_FBHUB0_PCIE_FLUSH_SYSMEM_ADDR_HI(u32) @ 0x008a1d5c {
+        19:0    adr;
+    }

Interestingly these registers are defined globally in OpenRM (and under the same name), so these seem to be much less concerning than HSHUB0. Still I suspect we will want to make them relative to future-proof the code, if we can figure out what the base is.

#49 lore raw

PATCH v10 27/28 gpu: nova-core: Hopper/Blackwell: larger WPR2 (GSP) heap

In reply to John Hubbard

Hopper, Blackwell and later GPUs require a larger heap for WPR2.

---
 drivers/gpu/nova-core/gsp/fw.rs | 61 +++++++++++++++++++++++++--------
 1 file changed, 47 insertions(+), 14 deletions(-)
drivers/gpu/nova-core/gsp/fw.rs +47 -14
index 5d36604ea1a3..7352952e4ef1 100644
@@ -103,21 +103,40 @@ enum GspFwHeapParams {}
 /// Minimum required alignment for the GSP heap.
 const GSP_HEAP_ALIGNMENT: Alignment = Alignment::new::<{ 1 << 20 }>();
 
+// These constants override the generated bindings for architecture-specific heap sizing.
+//
+// 14MB for Hopper/Blackwell+.
+const GSP_FW_HEAP_PARAM_BASE_RM_SIZE_GH100: u64 = 14 * u64::SZ_1M;
+// 142MB client alloc for ~188MB total.
+const GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE_GH100: u64 = 142 * u64::SZ_1M;
+// Hopper/Blackwell+ minimum heap size: 170MB (88 + 12 + 70).
+// See Open RM: GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MIN_MB for the base 88MB,
+// plus Hopper+ additions in kgspCalculateGspFwHeapSize_GH100.
+const GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MIN_MB_HOPPER: u64 = 170;
+
 impl GspFwHeapParams {
     /// Returns the amount of GSP-RM heap memory used during GSP-RM boot and initialization (up to
     /// and including the first client subdevice allocation).
-    fn base_rm_size(_chipset: Chipset) -> u64 {
-        // TODO: this needs to be updated to return the correct value for Hopper+ once support for
-        // them is added:
-        // u64::from(bindings::GSP_FW_HEAP_PARAM_BASE_RM_SIZE_GH100)
-        u64::from(bindings::GSP_FW_HEAP_PARAM_BASE_RM_SIZE_TU10X)
+    fn base_rm_size(chipset: Chipset) -> u64 {
+        use crate::gpu::Architecture;
+        match chipset.arch() {
+            Architecture::Hopper | Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => {
+                GSP_FW_HEAP_PARAM_BASE_RM_SIZE_GH100
+            }
+            _ => u64::from(bindings::GSP_FW_HEAP_PARAM_BASE_RM_SIZE_TU10X),
+        }
     }
 
     /// Returns the amount of heap memory required to support a single channel allocation.
-    fn client_alloc_size() -> u64 {
-        u64::from(bindings::GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE)
-            .align_up(GSP_HEAP_ALIGNMENT)
-            .unwrap_or(u64::MAX)
+    fn client_alloc_size(chipset: Chipset) -> Result<u64> {
+        use crate::gpu::Architecture;
+        let size = match chipset.arch() {
+            Architecture::Hopper | Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => {
+                GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE_GH100
+            }
+            _ => u64::from(bindings::GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE),
+        };
+        size.align_up(GSP_HEAP_ALIGNMENT).ok_or(EINVAL)
     }
 
     /// Returns the amount of memory to reserve for management purposes for a framebuffer of size
@@ -160,12 +179,26 @@ impl LibosParams {
                 * u64::SZ_1M,
     };
 
+    /// Hopper/Blackwell+ GPUs need a larger minimum heap size than the bindings specify.
+    /// The r570 bindings set LIBOS3_BAREMETAL_MIN_MB to 88MB, but Hopper/Blackwell+ actually
+    /// requires 170MB (88 + 12 + 70).
+    const LIBOS_HOPPER: LibosParams = LibosParams {
+        carveout_size: num::u32_as_u64(bindings::GSP_FW_HEAP_PARAM_OS_SIZE_LIBOS3_BAREMETAL),
+        allowed_heap_size: GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MIN_MB_HOPPER * u64::SZ_1M
+            ..num::u32_as_u64(bindings::GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MAX_MB)
+                * u64::SZ_1M,
+    };
+
     /// Returns the libos parameters corresponding to `chipset`.
     pub(crate) fn from_chipset(chipset: Chipset) -> &'static LibosParams {
-        if chipset < Chipset::GA102 {
-            &Self::LIBOS2
-        } else {
-            &Self::LIBOS3
+        use crate::gpu::Architecture;
+        match chipset.arch() {
+            Architecture::Turing => &Self::LIBOS2,
+            Architecture::Ampere if chipset == Chipset::GA100 => &Self::LIBOS2,
+            Architecture::Ampere | Architecture::Ada => &Self::LIBOS3,
+            Architecture::Hopper | Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => {
+                &Self::LIBOS_HOPPER
+            }
         }
     }
 
@@ -179,7 +212,7 @@ pub(crate) fn wpr_heap_size(&self, chipset: Chipset, fb_size: u64) -> Result<u64
             // RM boot working memory,
             .saturating_add(GspFwHeapParams::base_rm_size(chipset))
             // One RM client,
-            .saturating_add(GspFwHeapParams::client_alloc_size())
+            .saturating_add(GspFwHeapParams::client_alloc_size(chipset)?)
             // Overhead for memory management.
             .saturating_add(GspFwHeapParams::management_overhead(fb_size)?)
             // Clamp to the supported heap sizes.
Signature · 1 line
2.53.0
#50 lore raw

Re: [PATCH v10 27/28] gpu: nova-core: Hopper/Blackwell: larger WPR2 (GSP) heap

Quoted 3 lines · John Hubbard

Hopper, Blackwell and later GPUs require a larger heap for WPR2.

Let's also move this one to the beginning of the series (right after the new location of "larger non-WPR heap" sounds adequate).

drivers/gpu/nova-core/gsp/fw.rs enum GspFwHeapParams {} · line 106

Quoted 13 lines
---
 drivers/gpu/nova-core/gsp/fw.rs | 61 +++++++++++++++++++++++++--------
 1 file changed, 47 insertions(+), 14 deletions(-)
drivers/gpu/nova-core/gsp/fw.rs +1 -0
index 5d36604ea1a3..7352952e4ef1 100644
@@ -103,21 +103,40 @@ enum GspFwHeapParams {}
 /// Minimum required alignment for the GSP heap.
 const GSP_HEAP_ALIGNMENT: Alignment = Alignment::new::<{ 1 << 20 }>();
 
+// These constants override the generated bindings for architecture-specific heap sizing.

Err nope, we can and should update the bindings to also include these new values, as they exist in OpenRM and can change with firmware updates.

drivers/gpu/nova-core/gsp/fw.rs enum GspFwHeapParams {} · line 109

Quoted 3 lines
drivers/gpu/nova-core/gsp/fw.rs +3 -0
+//
+// 14MB for Hopper/Blackwell+.
+const GSP_FW_HEAP_PARAM_BASE_RM_SIZE_GH100: u64 = 14 * u64::SZ_1M;

This constant for instance exists as-is in OpenRM, so that's an easy one.

drivers/gpu/nova-core/gsp/fw.rs enum GspFwHeapParams {} · line 111

Quoted 2 lines
drivers/gpu/nova-core/gsp/fw.rs +2 -0
+// 142MB client alloc for ~188MB total.
+const GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE_GH100: u64 = 142 * u64::SZ_1M;

This one though... I could not find the origin for this value in OpenRM
- it seems to use the same value for all chipsets, without any particular expection for GH100+. And if I follow this behavior in nova-core my GB203 probes just fine.

drivers/gpu/nova-core/gsp/fw.rs enum GspFwHeapParams {} · line 114

Quoted 3 lines
drivers/gpu/nova-core/gsp/fw.rs +3 -0
+// Hopper/Blackwell+ minimum heap size: 170MB (88 + 12 + 70).
+// See Open RM: GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MIN_MB for the base 88MB,
+// plus Hopper+ additions in kgspCalculateGspFwHeapSize_GH100.

I also could not find kgspCalculateGspFwHeapSize_GH100 in both the 570.144 tag and the main branch of OpenRM, can you elaborate on the origin of this value?

From what I can infer, this 12 + 70 corresponds to OpenRM's BULLSEYE_ROOT_HEAP_ALLOC_RM_DATA_SECTION_SIZE_DELTA and BULLSEYE_ROOT_HEAP_ALLOC_BAREMETAL_LIBOS_HEAP_SIZE_DELTA. These values have also changed in main, so if we use them we should import them through the bindings.

But first let me question whether we need this at all, as these BULLSEYE* value are only used if some build feature of OpenRM is enabled.

Again, with the original value for this my GB203 probes without any issue, so it would be nice to confirm if and why we are diverging from what OpenRM seems to be doing.

Quoted 8 lines
drivers/gpu/nova-core/gsp/fw.rs +2 -2
+const GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MIN_MB_HOPPER: u64 = 170;
 
+
 impl GspFwHeapParams {
     /// Returns the amount of GSP-RM heap memory used during GSP-RM boot and initialization (up to
     /// and including the first client subdevice allocation).
-    fn base_rm_size(_chipset: Chipset) -> u64 {
-        // TODO: this needs to be updated to return the correct value for Hopper+ once support for

drivers/gpu/nova-core/gsp/fw.rs enum GspFwHeapParams {} · line 126

Quoted 10 lines
drivers/gpu/nova-core/gsp/fw.rs +7 -3
-        // them is added:
-        // u64::from(bindings::GSP_FW_HEAP_PARAM_BASE_RM_SIZE_GH100)
-        u64::from(bindings::GSP_FW_HEAP_PARAM_BASE_RM_SIZE_TU10X)
+    fn base_rm_size(chipset: Chipset) -> u64 {
+        use crate::gpu::Architecture;
+        match chipset.arch() {
+            Architecture::Hopper | Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => {
+                GSP_FW_HEAP_PARAM_BASE_RM_SIZE_GH100
+            }
+            _ => u64::from(bindings::GSP_FW_HEAP_PARAM_BASE_RM_SIZE_TU10X),

Let's do an exhaustive match, we will want to check the correct value for newly-added architectures.

#51 lore raw

PATCH v10 28/28 gpu: nova-core: Hopper/Blackwell: add GSP lockdown release polling

In reply to John Hubbard

On Hopper and Blackwell, FSP boots GSP with hardware lockdown enabled. After FSP Chain of Trust completes, the driver must poll for lockdown release before proceeding with GSP initialization. Add the register bit and helper functions needed for this polling.

---
 drivers/gpu/nova-core/fsp.rs      |  1 -
 drivers/gpu/nova-core/gsp/boot.rs | 90 +++++++++++++++++++++++++++++--
 drivers/gpu/nova-core/regs.rs     |  2 +
 3 files changed, 88 insertions(+), 5 deletions(-)
drivers/gpu/nova-core/fsp.rs +0 -1
index 75e06b2d5f06..db23a1995327 100644
@@ -278,7 +278,6 @@ pub(crate) fn new(
 
     /// DMA address of the FMC boot parameters, needed after boot for lockdown
     /// release polling.
-    #[expect(dead_code)]
     pub(crate) fn boot_params_dma_handle(&self) -> u64 {
         self.fmc_boot_params.dma_handle()
     }
drivers/gpu/nova-core/gsp/boot.rs +86 -4

120 lines not on this page · raw message

drivers/gpu/nova-core/regs.rs +2 -0
index 77b11c7de3f8..c7935abde2aa 100644
@@ -349,6 +349,8 @@ pub(crate) fn vga_workspace_addr(self) -> Option<u64> {
     pub(crate) NV_PFALCON_FALCON_HWCFG2(u32) @ PFalconBase + 0x000000f4 {
         /// Signal indicating that reset is completed (GA102+).
         31:31   reset_ready => bool;
+        /// RISC-V branch privilege lockdown bit.
+        13:13   riscv_br_priv_lockdown => bool;
         /// Set to 0 after memory scrubbing is completed.
         12:12   mem_scrubbing => bool;
         10:10   riscv => bool;
Signature · 1 line
2.53.0
#52 lore raw
In reply to John Hubbard

On Sat Apr 11, 2026 at 11:49 AM JST, John Hubbard wrote:
<snip>

Quoted 9 lines

John Hubbard (28):
gpu: nova-core: factor .fwsignature* selection into a new
find_gsp_sigs_section()
gpu: nova-core: use GPU Architecture to simplify HAL selections
gpu: nova-core: Hopper/Blackwell: basic GPU identification
gpu: nova-core: add Copy/Clone to Spec and Revision
gpu: nova-core: set DMA mask width based on GPU architecture
gpu: nova-core: move GFW boot wait into a GPU HAL
gpu: nova-core: Hopper/Blackwell: skip GFW boot waiting

As these are acked by Danilo [1], and looking good, I am pushing them into drm-rust-next-staging - feel free to drop them from your next revision.

[1] https://lore.kernel.org/all/[email protected]/

I'm still halfway through my review, but posted the comments I have so far - will come back for a second round on the upper half of the series. :)

#53 lore raw
In reply to John Hubbard
Quoted 7 lines · John Hubbard

gpu: nova-core: factor .fwsignature* selection into a new
find_gsp_sigs_section()
gpu: nova-core: use GPU Architecture to simplify HAL selections
gpu: nova-core: Hopper/Blackwell: basic GPU identification
gpu: nova-core: add Copy/Clone to Spec and Revision
gpu: nova-core: move GFW boot wait into a GPU HAL
gpu: nova-core: Hopper/Blackwell: skip GFW boot waiting

do not conflict with the Device HRT series [1], thus I have pushed them into drm-rust-next, thanks!

[1] https://lore.kernel.org/all/[email protected]/