gpu: nova-core: boot on the r000 GSP firmware
Subsystems (4)
cover gpu: nova-core: boot on the r000 GSP firmware
Nova-core boots the 570.144 GSP firmware today. This series moves the driver to the r000 firmware ABI, which is stable across releases, so firmware file names no longer carry a version number.
The actual firmware is not yet publicly available, so this series is for early review, and should not be merged until the corresponding firmware shows up.
Beyond drm-rust-next, the series sits on these patchsets:
* The GIN interrupt controller series, which needs Danilo Krummrich's PCI and irq rework and Joel Fernandes' wait_for_completion_timeout().
* Eliot Courtney's NVKV encoder and decoder, which GSP_INIT is built on, and his Vec::push_init.
I've created a branch that has everything, for reviewer convenience, here:
https://github.com/johnhubbard/linux/tree/nova-core-run-on-r615-or-later-v1
Patch 25 makes the big switch from r570 to r000 in one commit. Before that commit, everything works on r570. After that commit, only r000 is supported. Patches 1 to 24 add the pieces the switch needs, and patches 26 and 27 delete and clean up after it.
Tested on TU117 (Turing, T400), GA104 (Ampere, RTX A4000) and GB202 (Blackwell, RTX PRO 6000), covering PCIe probe, chipset and GPU name readback, the interrupt delivery self-test, and the KUnit suites.
Also, the vGPU team has tested an earlier, nearly identical version of this patchset (minus the cleanups at the end), and it works there too.
John Hubbard (27):
gpu: nova-core: firmware: add r000 bindings
gpu: nova-core: extract radix3 page table into its own module
gpu: nova-core: set MCTP transport header version to 1
gpu: nova-core: add Falcon helpers for r000 LOAD_EXEC events
gpu: nova-core: zero-pad radix3 page table levels to page boundary
gpu: nova-core: distinguish async GSP RPC traffic in debug logs
gpu: nova-core: add optional ucodes firmware loading
gpu: nova-core: add LIBOS3 log buffers and state monitor buffer
gpu: nova-core: add build ID headers to debugfs log buffer dumps
gpu: nova-core: rename the FbRanges elf field to fw_image
gpu: nova-core: regs: add msgq v2 BAR0 register declarations
gpu: nova-core: gsp: add msgq v2 internals
gpu: nova-core: generalize allocate_command() for variable headers
gpu: nova-core: add GMC API message types
gpu: nova-core: add GMC send path
gpu: nova-core: add GMC transport receive path
gpu: nova-core: gsp: add GMC dispatch on receive
gpu: nova-core: separate the generic falcon bootloader from FWSEC
gpu: nova-core: handle the r000 load-and-execute HS binary event
gpu: nova-core: handle the r000 load-and-execute bootloader event
gpu: nova-core: gsp: add the GMC boot event dispatcher
gpu: nova-core: gsp: add the GSP_INIT request builder
gpu: nova-core: gsp: send GSP_INIT and decode its reply
gpu: nova-core: gsp: pass the remaining log buffers to GSP-RM
gpu: nova-core: switch to the r000 GSP firmware
gpu: nova-core: gsp: remove the retired system-info and static-info
RPCs
gpu: nova-core: firmware: delete the r570 bindings
drivers/gpu/nova-core/driver.rs | 2 +-
drivers/gpu/nova-core/falcon.rs | 152 +++-
drivers/gpu/nova-core/fb.rs | 18 +-
drivers/gpu/nova-core/fb/hal/gb100.rs | 25 +-
drivers/gpu/nova-core/fb/hal/gb202.rs | 5 +-
drivers/gpu/nova-core/firmware.rs | 44 +-
drivers/gpu/nova-core/firmware/bindata.rs | 37 +
.../nova-core/firmware/fwsec/bootloader.rs | 112 +--
.../gpu/nova-core/firmware/gen_bootloader.rs | 215 +++++
drivers/gpu/nova-core/firmware/gsp.rs | 124 +--
drivers/gpu/nova-core/firmware/radix3.rs | 145 ++++
drivers/gpu/nova-core/firmware/tlv.rs | 56 ++
drivers/gpu/nova-core/fsp.rs | 3 +-
drivers/gpu/nova-core/gpu.rs | 23 +-
drivers/gpu/nova-core/gsp.rs | 284 ++++++-
drivers/gpu/nova-core/gsp/boot.rs | 549 +++++++++++-
drivers/gpu/nova-core/gsp/cmdq.rs | 792 ++++++++++++------
.../gpu/nova-core/gsp/cmdq/continuation.rs | 1 +
drivers/gpu/nova-core/gsp/commands.rs | 293 +++++--
drivers/gpu/nova-core/gsp/fw.rs | 740 ++++++++--------
drivers/gpu/nova-core/gsp/fw/commands.rs | 200 ++---
.../gsp/fw/{r570_144.rs => r000_00.rs} | 2 +-
.../gsp/fw/{r570_144 => r000_00}/bindings.rs | 548 ++++++++----
drivers/gpu/nova-core/gsp/hal.rs | 22 +-
drivers/gpu/nova-core/gsp/hal/tu102.rs | 18 +-
drivers/gpu/nova-core/gsp/regs.rs | 30 +
drivers/gpu/nova-core/gsp/sequencer.rs | 379 ---------
drivers/gpu/nova-core/irq/gsp.rs | 2 +-
drivers/gpu/nova-core/mctp.rs | 18 +-
drivers/gpu/nova-core/regs.rs | 8 +-
30 files changed, 3131 insertions(+), 1716 deletions(-)
create mode 100644 drivers/gpu/nova-core/firmware/bindata.rs
create mode 100644 drivers/gpu/nova-core/firmware/gen_bootloader.rs
create mode 100644 drivers/gpu/nova-core/firmware/radix3.rs
rename drivers/gpu/nova-core/gsp/fw/{r570_144.rs => r000_00.rs} (95%)
rename drivers/gpu/nova-core/gsp/fw/{r570_144 => r000_00}/bindings.rs (73%)
delete mode 100644 drivers/gpu/nova-core/gsp/sequencer.rsSignature · 1 line
2.55.0
PATCH 3/27 gpu: nova-core: set MCTP transport header version to 1
FSP requires MCTP transport header version 1. Nova-core leaves version bits 3:0 at zero, so every CoT and PRC request carries an invalid transport header.
Define the version and destination endpoint ID fields. Set the version to 1 for single-packet requests, and leave the unused destination endpoint ID at zero.
--- drivers/gpu/nova-core/mctp.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/nova-core/mctp.rs +12 -2
@@ -42,13 +42,23 @@ pub(crate) struct MctpHeader(u32) { 29:28 seq;/// Source endpoint ID. 23:16 seid; +/// Destination endpoint ID. + 15:8 deid; +/// MCTP header version. + 3:0 version; } }impl MctpHeader { -/// Builds a single-packet MCTP header (`SOM=1`, `EOM=1`, `SEQ=0`, `SEID=0`). +/// MCTP specification version 1.0. +const VERSION :u32 =1 ; + +/// Builds a single-packet MCTP header (`SOM=1`, `EOM=1`, `SEQ=0`, `SEID=0`, `VERSION=1`). pub (crate )fn single_packet () ->Self { -Self ::zeroed ().with_som (true ).with_eom (true ) +Self ::zeroed () + .with_const_version ::<{Self ::VERSION }>() + .with_som (true ) + .with_eom (true ) }/// Returns whether this is a complete single-packet message (`SOM=1` and `EOM=1`).
Signature · 1 line
2.55.0
PATCH 2/27 gpu: nova-core: extract radix3 page table into its own module
In reply to John HubbardMove the 3-level radix page table construction out of GspFirmware into a standalone Radix3 type in firmware/radix3.rs. The ucodes (bindata) firmware that GSP-RM loads at runtime also needs a radix3 page table, so the logic needs to be reusable.
Refactor GspFirmware to use the new Radix3 type and expose firmware size through a size() method instead of a public field.
--- drivers/gpu/nova-core/fb.rs | 2 +- drivers/gpu/nova-core/firmware.rs | 1 + drivers/gpu/nova-core/firmware/gsp.rs | 116 ++++---------------- drivers/gpu/nova-core/firmware/radix3.rs | 133 +++++++++++++++++++++++ drivers/gpu/nova-core/gsp/fw.rs | 4 +- 5 files changed, 159 insertions(+), 97 deletions(-) create mode 100644 drivers/gpu/nova-core/firmware/radix3.rs
drivers/gpu/nova-core/fb.rs +1 -1
@@ -236,7 +236,7 @@ pub(crate) fn new(let elf = {const ELF_DOWN_ALIGN :Alignment =Alignment ::new ::<SZ_64K >(); -let elf_size = u64::from_safe_cast (gsp_fw.size); +let elf_size = u64::from_safe_cast (gsp_fw.size ());let elf_addr = (boot.start - elf_size).align_down (ELF_DOWN_ALIGN );FbRange (elf_addr..elf_addr + elf_size)
drivers/gpu/nova-core/firmware.rs +1 -0
@@ -26,6 +26,7 @@pub (crate )mod fsp;pub (crate )mod fwsec;pub (crate )mod gsp; +pub (crate )mod radix3;pub (crate )mod riscv;pub (crate )mod tlv;
drivers/gpu/nova-core/firmware/gsp.rs +22 -94
165 lines not on this page · raw message
drivers/gpu/nova-core/firmware/radix3.rs new file +133 -0
133 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw.rs +2 -2
@@ -188,7 +188,7 @@ pub(crate) fn from_ranges<'a>( magic: bindings::GSP_FW_WPR_META_MAGIC as u64, revision: u64::from(bindings::GSP_FW_WPR_META_REVISION), sysmemAddrOfRadix3Elf: gsp_firmware.radix3_dma_address(), - sizeOfRadix3Elf: u64::from_safe_cast(gsp_firmware.size), + sizeOfRadix3Elf: u64::from_safe_cast(gsp_firmware.size()), sysmemAddrOfBootloader: gsp_firmware.bootloader.ucode.dma_address(), sizeOfBootloader: u64::from_safe_cast(gsp_firmware.bootloader.ucode.size()), bootloaderCodeOffset: u64::from(gsp_firmware.bootloader.code_offset),
@@ -243,7 +243,7 @@ pub(crate) fn from_sizes<'a>( magic: bindings::GSP_FW_WPR_META_MAGIC as u64, revision: u64::from(bindings::GSP_FW_WPR_META_REVISION), sysmemAddrOfRadix3Elf: gsp_firmware.radix3_dma_address(), - sizeOfRadix3Elf: u64::from_safe_cast(gsp_firmware.size), + sizeOfRadix3Elf: u64::from_safe_cast(gsp_firmware.size()), sysmemAddrOfBootloader: gsp_firmware.bootloader.ucode.dma_address(), sizeOfBootloader: u64::from_safe_cast(gsp_firmware.bootloader.ucode.size()), bootloaderCodeOffset: u64::from(gsp_firmware.bootloader.code_offset),
Signature · 1 line
2.55.0
PATCH 1/27 gpu: nova-core: firmware: add r000 bindings
In reply to John Hubbard"r000" means "latest firmware", without getting bogged down into naming actual versions, because those will vary. The story is: nova uses r570 at this point, but will transition soon to some later version, and that version will have a stable ABI, which in turn means that the firmware file names will stop including version numbers in the file name itself. Version information will still be recorded inside each firmware image, though.
The *_SI_* items are for key-value access to "System Info" items that nova will received from an early GSP-RM RPC call.
Add generated firmware bindings from the r000 Open RM headers. The module is registered but not yet wired as the active binding set.
--- drivers/gpu/nova-core/gsp/fw.rs | 1 + drivers/gpu/nova-core/gsp/fw/r000_00.rs | 31 + .../gpu/nova-core/gsp/fw/r000_00/bindings.rs | 1288 +++++++++++++++++ 3 files changed, 1320 insertions(+) create mode 100644 drivers/gpu/nova-core/gsp/fw/r000_00.rs create mode 100644 drivers/gpu/nova-core/gsp/fw/r000_00/bindings.rs
drivers/gpu/nova-core/gsp/fw.rs +1 -0
@@ -2,6 +2,7 @@// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. pub (crate )mod commands; +mod r000_00;mod r570_144;// Alias to avoid repeating the version number with every use.
drivers/gpu/nova-core/gsp/fw/r000_00.rs new file +31 -0
@@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 + +//! Firmware bindings. +//! +//! Imports the generated bindings by `bindgen`. +//! +//! This module may not be directly used. Please abstract or re-export the needed symbols in the +//! parent module instead. + +#![allow( +dead_code, +clippy::all, +clippy::undocumented_unsafe_blocks, +clippy::ptr_as_ptr, +clippy::ref_as_ptr, +missing_docs, +non_camel_case_types, +non_upper_case_globals, +non_snake_case, +improper_ctypes, +unreachable_pub, +unsafe_op_in_unsafe_fn +)] +use kernel::ffi; +use pin_init::MaybeZeroable ; + +include! ("r000_00/bindings.rs" ); + +// SAFETY: This type has a size of zero, so its inclusion into another type should not affect their +// ability to implement `Zeroable`. +unsafe impl <T > kernel::prelude::Zeroable for __IncompleteArrayField <T > {}
drivers/gpu/nova-core/gsp/fw/r000_00/bindings.rs new file +1288 -0
1,288 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH 4/27 gpu: nova-core: add Falcon helpers for r000 LOAD_EXEC events
In reply to John HubbardThe r000 LOAD_EXEC events provide addresses for images that the driver must copy into GSP Falcon IMEM and DMEM. The existing Falcon DMA path creates its source buffer from a FalconFirmware object, so it cannot use those addresses. The protocol also reports GSP RISC-V suspension through MAILBOX0 bit 31 rather than CPUCTL.halted.
Add Falcon operations for DMA from event-provided addresses and for the RISC-V suspend indication.
--- drivers/gpu/nova-core/falcon.rs | 136 +++++++++++++++++++++++++++++++- drivers/gpu/nova-core/regs.rs | 2 +- 2 files changed, 136 insertions(+), 2 deletions(-)
drivers/gpu/nova-core/falcon.rs +135 -1
@@ -133,12 +133,25 @@ pub(crate) enum FalconMem {/// Secure Instruction Memory. ImemSecure,/// Non-Secure Instruction Memory. -#[expect(unused)] +#[expect(dead_code)] ImemNonSecure,/// Data Memory. Dmem, } +/// Source offset of a raw falcon DMA transfer, added to the DMA base address. +#[expect(dead_code)] +#[derive( Copy , Clone )] +pub (crate )enum FalconDmaSrcOffset { +/// Byte offset from the DMA base address. +Offset (u32 ), +/// DMEM virtual address. The DMA engine also tags each loaded block with this value, so the +/// falcon reaches the data through its DMEM VA. The caller must bias the DMA base address so +/// that base plus this value addresses the first byte of the image. Only valid with +/// [`FalconMem::Dmem`]. +DmemVa (u32 ), +} +bounded_enum! {/// Defines the Framebuffer Interface (FBIF) aperture type. /// This determines the memory type for external memory access during a DMA transfer, which is
@@ -592,6 +605,109 @@ fn dma_wr(Ok (()) } +/// Perform a raw DMA transfer from a physical address to falcon IMEM or DMEM. +/// +/// Used by the GSP boot event handlers where the firmware provides the source +/// address directly (in GPU physical address space, routed through the FBIF +/// aperture). The caller must configure the FBIF TRANSCFG register +/// corresponding to `ctx_dma` before calling this method. +/// +/// A [`FalconDmaSrcOffset::DmemVa`] source offset also sets `DMATRFCMD.SET_DMTAG`, and +/// requires `target_mem` to be [`FalconMem::Dmem`]. +/// +/// # Errors +/// +/// - `EINVAL` if `ctx_dma` is not a valid context DMA slot, if `src_addr` is not aligned to +/// 256 bytes, or if a [`FalconDmaSrcOffset::DmemVa`] source offset is paired with an IMEM +/// target. +/// - `ERANGE` if `src_addr` does not fit the `DMATRFBASE` register pair. +#[expect(dead_code)] +pub (crate )fn raw_dma_transfer ( + &self, + ctx_dma:u8 , + src_addr:u64 , + target_mem:FalconMem , + src:FalconDmaSrcOffset , + dst_offset:u32 , + len:u32 , + ) ->Result { +const DMA_LEN :u32 = num::usize_into_u32 ::<{MEM_BLOCK_ALIGNMENT }>(); +const NUM_CTXDMA_SLOTS :u8 =8 ; + +if ctx_dma >=NUM_CTXDMA_SLOTS { +dev_err! (self.dev,"raw DMA: ctx_dma {} out of range\n" , ctx_dma); +return Err (EINVAL ); + } + +if src_addr % u64::from (DMA_LEN ) >0 { +dev_err! ( + self.dev, +"raw DMA: source address {:#x} not 256B-aligned\n" , + src_addr + ); +return Err (EINVAL ); + } + +if src_addr >>40 > u64::from (regs::NV_PFALCON_FALCON_DMATRFBASE1 ::BASE_MASK ) { +dev_err! ( + self.dev, +"raw DMA: source address {:#x} does not fit DMATRFBASE\n" , + src_addr + ); +return Err (ERANGE ); + } + +let (src_offset, set_dmtag) =match src { +FalconDmaSrcOffset ::Offset (offset) => (offset,false ), +// `SET_DMTAG` applies to DMEM only. +FalconDmaSrcOffset ::DmemVa (_)if target_mem !=FalconMem ::Dmem =>return Err (EINVAL ), +FalconDmaSrcOffset ::DmemVa (va) => (va,true ), + }; + +let num_transfers = len.div_ceil (DMA_LEN ); + + self.bar.write ( +WithBase ::of ::<E >(), + regs::NV_PFALCON_FALCON_DMATRFBASE ::zeroed ().with_base ( +// CAST: `as u32` is used on purpose since we do want to strip the upper bits, +// which will be written to `NV_PFALCON_FALCON_DMATRFBASE1`. + (src_addr >>8 )as u32 , + ), + ); + self.bar.write ( +WithBase ::of ::<E >(), + regs::NV_PFALCON_FALCON_DMATRFBASE1 ::zeroed ().try_with_base (src_addr >>40 )?, + ); + +let cmd = regs::NV_PFALCON_FALCON_DMATRFCMD ::zeroed () + .with_size (DmaTrfCmdSize ::Size256B ) + .try_with_ctxdma (u32::from (ctx_dma))? + .with_falcon_mem (target_mem) + .with_set_dmtag (set_dmtag); + +for posin (0 ..num_transfers).map (|i| i *DMA_LEN ) { + self.bar.write ( +WithBase ::of ::<E >(), + regs::NV_PFALCON_FALCON_DMATRFMOFFS ::zeroed ().try_with_offs (dst_offset + pos)?, + ); + self.bar.write ( +WithBase ::of ::<E >(), + regs::NV_PFALCON_FALCON_DMATRFFBOFFS ::zeroed ().with_offs (src_offset + pos), + ); + + self.bar.write (WithBase ::of ::<E >(), cmd); + +read_poll_timeout ( + ||Ok (self.bar.read (regs::NV_PFALCON_FALCON_DMATRFCMD ::of ::<E >())), + |r| r.idle (), +Delta ::ZERO , +Delta ::from_secs (2 ), + )?; + } + +Ok (()) + } +/// Perform a DMA load into `IMEM` and `DMEM` of `fw`, and prepare the falcon to run it. fn dma_load <F :FalconFirmware <Target =E > +FalconDmaLoadable >(&self, fw: &F ) ->Result {// DMA object with firmware content as the source of the DMA engine.
@@ -647,6 +763,24 @@ pub(crate) fn wait_till_halted(&self) -> Result<()> {Ok (()) } +/// Wait until the GSP processor has suspended. +/// +/// The RISC-V GSP signals suspension by setting bit 31 (`0x8000_0000`) in `MAILBOX0`, rather +/// than through `CPUCTL.halted`. +#[expect(dead_code)] +pub (crate )fn wait_for_processor_suspend (&self) ->Result <()> { +const INTERRUPT_PROCESSOR_SUSPENDED :u32 =0x8000_0000 ; + +read_poll_timeout ( + ||Ok (self.read_mailbox0 ()), + |val| (*val &INTERRUPT_PROCESSOR_SUSPENDED ) !=0 , +Delta ::ZERO , +Delta ::from_secs (2 ), + )?; + +Ok (()) + } +/// Start the falcon CPU. pub (crate )fn start (&self) ->Result <()> { match self
drivers/gpu/nova-core/regs.rs +1 -1
@@ -264,7 +264,7 @@ pub(crate) fn usable_fb_size(self) -> u64 { } pub(crate) NV_PFALCON_FALCON_DMATRFCMD(u32) @ PFalconBase + 0x00000118 { - 16:16 set_dmtag; + 16:16 set_dmtag => bool; 14:12 ctxdma; 10:8 size ?=> DmaTrfCmdSize; 5:5 is_write => bool;
Signature · 1 line
2.55.0
PATCH 5/27 gpu: nova-core: zero-pad radix3 page table levels to page boundary
In reply to John HubbardGSP-RM allocates the whole radix3 page table region in one block and zeroes it before writing entries. The booter reads each level a full page at a time when it walks the table, so every byte of a level page is firmware-visible whether or not it holds a valid entry.
The driver allocates each level separately and writes only the valid entries, so the last page of each level is only partly written. The booter reads the whole page regardless, and a non-zero word in the unwritten remainder is indistinguishable from an entry.
Zero-pad each level to the next GSP_PAGE_SIZE boundary after writing entries, and size each level buffer to that padded length so the pad does not force a reallocation.
--- drivers/gpu/nova-core/firmware/radix3.rs | 40 +++++++++++++++--------- 1 file changed, 26 insertions(+), 14 deletions(-)
drivers/gpu/nova-core/firmware/radix3.rs +26 -14
@@ -67,22 +67,18 @@ pub(crate) fn new<'a>( Ok(try_pin_init!(Self { data <- SGTable::new(dev, data, DataDirection::ToDevice, GFP_KERNEL), level2 <- { - VVec::<u8>::with_capacity( - data.iter().count() * core::mem::size_of::<u64>(), - GFP_KERNEL, - ) - .map_err(|_| ENOMEM) - .and_then(|level2| map_into_lvl(&data, level2)) - .map(|level2| SGTable::new(dev, level2, DataDirection::ToDevice, GFP_KERNEL))? + let level2 = VVec::<u8>::with_capacity(lvl_size(&data), GFP_KERNEL) + .map_err(|_| ENOMEM) + .and_then(|level2| map_into_lvl(&data, level2))?; + + SGTable::new(dev, level2, DataDirection::ToDevice, GFP_KERNEL) }, level1 <- { - VVec::<u8>::with_capacity( - level2.iter().count() * core::mem::size_of::<u64>(), - GFP_KERNEL, - ) - .map_err(|_| ENOMEM) - .and_then(|level1| map_into_lvl(&level2, level1)) - .map(|level1| SGTable::new(dev, level1, DataDirection::ToDevice, GFP_KERNEL))? + let level1 = VVec::<u8>::with_capacity(lvl_size(&level2), GFP_KERNEL) + .map_err(|_| ENOMEM) + .and_then(|level1| map_into_lvl(&level2, level1))?; + + SGTable::new(dev, level1, DataDirection::ToDevice, GFP_KERNEL) }, level0: { let level1_entry = level1.iter().next().ok_or(EINVAL)?;
@@ -113,6 +109,17 @@ pub(crate) fn size(&self) -> usize { } } +/// Returns the size, in bytes, of the page table level that maps `sg_table`: one `u64` entry per +/// 4KB page it spans, rounded up to the page boundary that [`map_into_lvl`] pads to. +fn lvl_size (sg_table: &SGTable <Owned <VVec <u8 >>>) ->usize { +let entries:usize = sg_table + .iter () + .map (|sg_entry| usize::from_safe_cast (sg_entry.dma_len ()).div_ceil (GSP_PAGE_SIZE )) + .sum (); + + (entries *size_of ::<u64 >()).next_multiple_of (GSP_PAGE_SIZE ) +} +/// Build a page table from a scatter-gather list. /// /// Takes each DMA-mapped region from `sg_table` and writes page table entries
@@ -129,5 +136,10 @@ fn map_into_lvl(sg_table: &SGTable<Owned<VVec<u8>>>, mut dst: VVec<u8>) -> Resul } } +// The last page of a level is only partly filled, and the booter DMAs each level a +// whole page at a time, so no entry past the last valid one may hold a stale address. +let padded = dst.len ().next_multiple_of (GSP_PAGE_SIZE ); + dst.resize (padded,0 ,GFP_KERNEL )?; +Ok (dst) }
Signature · 1 line
2.55.0
PATCH 6/27 gpu: nova-core: distinguish async GSP RPC traffic in debug logs
In reply to John HubbardThe receive path logged every message at the transport layer and did not distinguish events from command replies. Async sends shared the RPC sequence with waited-for commands, and GSP-initiated events arrived with that field unset.
Print a distinct debug line for async send, sync send, event, and command reply. Number async sends and events with driver-local counters.
IS_ASYNC selects only the send log line. Every command still carries the next RPC sequence on the wire.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 111 ++++++++++++++---- .../gpu/nova-core/gsp/cmdq/continuation.rs | 1 + drivers/gpu/nova-core/gsp/commands.rs | 2 + drivers/gpu/nova-core/gsp/fw.rs | 19 +++ 4 files changed, 107 insertions(+), 26 deletions(-)
drivers/gpu/nova-core/gsp/cmdq.rs +85 -26
@@ -87,6 +87,12 @@ pub(crate) trait CommandToGsp {/// Function identifying this command to the GSP. const FUNCTION :MsgFunction ; +/// Classifies the send-side debug log as an async send. +/// +/// Default is `false`. Set this only on commands that are sent without waiting for a reply. A +/// [`NoReply`] continuation of a waited-for command stays `false`. +const IS_ASYNC :bool =false ; +/// Type generated by [`CommandToGsp::init`], to be written into the command queue buffer. type Command :FromBytes +AsBytes ;
@@ -528,6 +534,8 @@ pub(crate) fn new(dev: &device::Device<device::Bound>) -> impl PinInit<Self, Err gsp_mem, elem_seq: 0, rpc_seq: 0, + tx_async_seq: 0, + rx_event_seq: 0, poisoned: Cell::new(false), }), }))
@@ -672,6 +680,12 @@ struct CmdqInner {/// [`CmdqInner::receive_msg`] match that reply to the awaiting command. Advances once per /// logical command. rpc_seq: u32, +/// Debug-log sequence for async sends. Those commands do not wait for a reply, so this +/// counter is the number printed in the send log. + tx_async_seq: u32, +/// Debug-log sequence for GSP-initiated events. The GSP leaves the RPC sequence unset on +/// those messages, so the driver numbers them itself. + rx_event_seq: u32,/// Set once a message with corrupt framing or a bad checksum is seen. Such a message has an /// untrusted length, so the queue cannot be advanced past it, and every later receive fails /// until the queue is torn down and reset.
@@ -738,13 +752,24 @@ fn send_single_command<M>(&mut self, bar: Bar0<'_>, command: M, rpc_seq: u32) -> dst.contents.1, ]))); -dev_dbg! ( - &self.dev, -"GSP RPC: send: seq# {}, function={:?}, length=0x{:x}\n" , - rpc_seq, -M ::FUNCTION , - dst.header.length (), - ); +if M ::IS_ASYNC { +dev_dbg! ( + &self.dev, +"GSP RPC: async send: seq# {}, function={:?}, length=0x{:x}\n" , + self.tx_async_seq, +M ::FUNCTION , + dst.header.length (), + ); + self.tx_async_seq +=1 ; + }else { +dev_dbg! ( + &self.dev, +"GSP RPC: send: seq# {}, function={:?}, length=0x{:x}\n" , + rpc_seq, +M ::FUNCTION , + dst.header.length (), + ); + }// All set - update the write pointer and inform the GSP of the new command. let elem_count = dst.header.element_count ();
@@ -826,14 +851,6 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {return Err (EIO ); }; -dev_dbg! ( - &self.dev, -"GSP RPC: receive: seq# {}, function={:?}, length=0x{:x}\n" , - header.sequence (), - header.function (), - header.length (), - ); -let payload_length = header.payload_length ();// Check that the driver read area is large enough for the message.
@@ -877,6 +894,41 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> { }) } +/// Writes the classified receive debug line for a decoded GSP message. +/// +/// Events print [`Self::rx_event_seq`]. Command replies print `seq`. An unrecognized function +/// code prints nothing here. +fn log_received (&self, function:Result <MsgFunction ,u32 >, seq:u32 , length:usize ) { +match function { +Ok (f)if f.is_event () => { +dev_dbg! ( + &self.dev, +"GSP RPC: async received: seq# {}, function={:?}, length=0x{:x}\n" , + self.rx_event_seq, + f, + length, + ); + } +Ok (f) => { +dev_dbg! ( + &self.dev, +"GSP RPC: response received: seq# {}, function={:?}, length=0x{:x}\n" , + seq, + f, + length, + ); + } +Err (_) => {} + } + } + +/// Advances [`Self::rx_event_seq`] after a GSP-initiated event has been consumed. +fn advance_rx_event_seq (&mut self, function:Result <MsgFunction ,u32 >) { +if matches! (function,Ok (f)if f.is_event ()) { + self.rx_event_seq +=1 ; + } + } +/// Receive a message from the GSP. /// /// The expected message type is given by the `M` generic parameter. With `expected_seq` set,
@@ -910,9 +962,12 @@ fn receive_msg<M: MessageFromGsp>(let message = self.wait_for_msg (timeout)?;let function = message.header.function ();let seq = message.header.sequence (); +let length = message.header.length ();let func_matches =matches! (function,Ok (f)if f ==M ::FUNCTION );let matched = func_matches && expected_seq.is_none_or (|expected| seq == expected); + self.log_received (function, seq, length); +// Every path must advance the read pointer past this message, including a failed decode. let result =if matched {match M ::Message ::from_bytes_prefix (message.contents.0 ) {
@@ -938,9 +993,10 @@ fn receive_msg<M: MessageFromGsp>( };// Advance the read pointer past this message. - self.gsp_mem.advance_cpu_read_ptr (u32::try_from ( - message.header.length ().div_ceil (GSP_PAGE_SIZE ), - )?); + self.gsp_mem + .advance_cpu_read_ptr (u32::try_from (length.div_ceil (GSP_PAGE_SIZE ))?); + + self.advance_rx_event_seq (function);if !matched {if func_matches {
@@ -962,8 +1018,8 @@ fn receive_msg<M: MessageFromGsp>(/// Routes a GSP message that is not the reply a caller is waiting for. /// /// GSP-reported errors are logged at error level and unrecognized function codes at warning -/// level. Every other known function code is consumed without a log line, because the RPC -/// receive trace in [`Self::wait_for_msg`] already records its arrival. +/// level. Every other known function code is consumed without a log line, because +/// [`Self::log_received`] already records its arrival. fn dispatch_event (&self, function:Result <MsgFunction ,u32 >, seq:u32 ) {match function {Ok (MsgFunction ::OsErrorLog ) => {
@@ -1004,16 +1060,19 @@ fn drain(&mut self) -> Result {while !self.gsp_mem.driver_read_area ().0 .is_empty () {// A message is available, so this returns without waiting. let msg = self.wait_for_msg (Delta ::ZERO )?; - -let pages = - u32::try_from (msg.header.length ().div_ceil (GSP_PAGE_SIZE )).map_err (|_| { -dev_err! (&self.dev,"GSP drain: message length overflow\n" ); -EIO - })?;let function = msg.header.function ();let seq = msg.header.sequence (); +let length = msg.header.length (); + + self.log_received (function, seq, length); + +let pages = u32::try_from (length.div_ceil (GSP_PAGE_SIZE )).map_err (|_| { +dev_err! (&self.dev,"GSP drain: message length overflow\n" ); +EIO + })?; self.gsp_mem.advance_cpu_read_ptr (pages); + self.advance_rx_event_seq (function); self.dispatch_event (function, seq); }
drivers/gpu/nova-core/gsp/cmdq/continuation.rs +1 -0
@@ -147,6 +147,7 @@ fn new(command: C, payload: KVVec<u8>) -> Self {impl <C :CommandToGsp >CommandToGsp for SplitCommand <C > {const FUNCTION :MsgFunction =C ::FUNCTION ; +const IS_ASYNC :bool =C ::IS_ASYNC ;type Command =C ::Command ;type Reply =C ::Reply ;type InitError =C ::InitError ;
drivers/gpu/nova-core/gsp/commands.rs +2 -0
@@ -52,6 +52,7 @@ pub(crate) fn new(pdev: &'a pci::Device<device::Bound>, chipset: Chipset) -> Selimpl <'a>CommandToGsp for SetSystemInfo <'a> {const FUNCTION :MsgFunction =MsgFunction ::GspSetSystemInfo ; +const IS_ASYNC :bool =true ;type Command = fw::commands::GspSetSystemInfo ;type Reply =NoReply ;type InitError =Error ;
@@ -122,6 +123,7 @@ pub(crate) fn new(vgpu_state: VgpuState) -> Result<Self> {impl CommandToGsp for SetRegistry {const FUNCTION :MsgFunction =MsgFunction ::SetRegistry ; +const IS_ASYNC :bool =true ;type Command = fw::commands::PackedRegistryTable ;type Reply =NoReply ;type InitError =Infallible ;
drivers/gpu/nova-core/gsp/fw.rs +19 -0
@@ -359,6 +359,25 @@ fn try_from(value: u32) -> Result<MsgFunction> { } } +impl MsgFunction { +/// Returns true if this is a GSP-initiated async event (`NV_VGPU_MSG_EVENT_*`), as opposed to +/// a command response (`NV_VGPU_MSG_FUNCTION_*`). +pub (crate )fn is_event (&self) ->bool { +matches! ( + self, +Self ::GspInitDone + |Self ::GspRunCpuSequencer + |Self ::PostEvent + |Self ::RcTriggered + |Self ::MmuFaultQueued + |Self ::OsErrorLog + |Self ::GspPostNoCat + |Self ::GspLockdownNotice + |Self ::UcodeLibOsPrint // + ) + } +} +impl From <MsgFunction >for u32 {fn from (value:MsgFunction ) ->Self {// CAST: `MsgFunction` is `repr(u32)` and can thus be cast losslessly.
Signature · 1 line
2.55.0
PATCH 7/27 gpu: nova-core: add optional ucodes firmware loading
In reply to John HubbardThe new GSP firmware takes an optional ucodes image, a bindata blob of microcode that GSP-RM loads at runtime. Open RM fetches it for every chip family except GB10Y and fails firmware load without it, so the driver will require it too once it boots the new firmware. The helper added here reports a missing metadata file rather than failing, and leaves that policy to its caller.
Load the ucodes metadata with the existing TLV request helper, and add support for the generic TLV payload convention it uses: either an inline BLOB, or a FILE basename with its SIZE. A FILE tag may only name a basename in the metadata file's own directory, so one carrying a path separator, a special directory name, or a control byte is rejected. Nothing calls this until the driver switches to the new firmware.
--- drivers/gpu/nova-core/firmware.rs | 8 +++- drivers/gpu/nova-core/firmware/bindata.rs | 38 +++++++++++++++ drivers/gpu/nova-core/firmware/tlv.rs | 56 +++++++++++++++++++++++ 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/nova-core/firmware/bindata.rs
drivers/gpu/nova-core/firmware.rs +7 -1
@@ -22,6 +22,7 @@ num::IntoSafeCast, // }; +pub (crate )mod bindata;pub (crate )mod booter;pub (crate )mod fsp;pub (crate )mod fwsec;
@@ -348,7 +349,12 @@ const fn make_entry_chipset(self, chipset: gpu::Chipset) -> Self {let mut this = self .make_entry_file (name,"gsp_bootloader.tlv" ) .make_entry_file (name,"gsp.tlv" ) - .make_entry_file (name,"gsp.bin" ); + .make_entry_file (name,"gsp.bin" ) + .make_entry_file (name,"ucodes.tlv" ) +// `ucodes.tlv` may name another safe basename in its FILE tag, but module firmware +// metadata cannot describe a runtime-selected filename. Advertise the conventional +// filename used by the distributed metadata. + .make_entry_file (name,"ucodes.bin" );// Add the firmware files specific to the GSP boot method of `chipset`. let boot_files =boot_firmware_files (chipset);
drivers/gpu/nova-core/firmware/bindata.rs new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +//! GSP bindata firmware loading. + +use kernel::{ + device, + prelude::*,// +}; + +use crate ::{ + firmware::tlv::{ + request_tlv, +Tlv ,// + }, + gpu::Chipset , +}; + +/// Requests the optional `ucodes` bindata metadata and loads its payload. +/// +/// A missing metadata file is reported as [`None`] so that the eventual caller can decide whether +/// ucodes are optional for its boot path. Once the metadata has been found, all parse and payload +/// loading errors, including a missing referenced file, are returned as errors. +#[expect(dead_code)] +pub (crate )fn request_ucodes_firmware ( + dev: &device::Device , + chipset:Chipset , +) ->Result <Option <VVec <u8 >>> { +let firmware =match request_tlv (dev, chipset,"ucodes" ) { +Ok (firmware) => firmware, +Err (e)if e ==ENOENT =>return Ok (None ), +Err (e) =>return Err (e), + }; + +let tlv =Tlv ::new (firmware.data ())?; + +Ok (Some (tlv.load_blob_or_file (dev, chipset)?)) +}
drivers/gpu/nova-core/firmware/tlv.rs +56 -0
62 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH 8/27 gpu: nova-core: add LIBOS3 log buffers and state monitor buffer
In reply to John HubbardGSP-RM on the new firmware logs from six LIBOS3 tasks on GA102 and later, where r570 logs from three, and it maps a small buffer during init to report RM state for diagnostics. Turing and GA100 run LIBOS2, where only the init and RM task logs exist. Two of the six task logs are a single page, where the rest are 64KB.
Allocate the three missing log buffers and the state monitor buffer, give LogBuffer const parameters for its size and page count so the single-page buffers can exist, and expose the new log buffers through the debugfs directory that already carries the others.
Nothing passes these to GSP-RM yet. The libos init arguments gain them when the driver switches to the new firmware.
--- drivers/gpu/nova-core/gsp.rs | 71 ++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 16 deletions(-)
drivers/gpu/nova-core/gsp.rs +55 -16
@@ -118,33 +118,63 @@ fn init(view: CoherentView<'_, Self>, start: DmaAddress) -> Result<()> {/// then pp points to index into the buffer where the next logging entry will /// be written. Therefore, the logging data is valid if: /// 1 <= pp < sizeof(buffer)/sizeof(u64) -struct LogBuffer (Coherent <[u8 ;LOG_BUFFER_SIZE ]>); +/// +/// `SIZE` is the buffer size in bytes and `NUM_PAGES` is the same size in GSP pages, checked +/// against each other at build time. Computing one from the other in a type position is not +/// stable Rust, so both are parameters. +struct LogBuffer <const SIZE :usize ,const NUM_PAGES :usize >(Coherent <[u8 ;SIZE ]>); + +/// Log buffer for a task that GSP-RM logs to at its default size. +/// +/// Matches the registry defaults for the init, interrupt, RM, and MNOC tasks +/// (`NV_REG_STR_RM_GSP_LOG_BUFFER_SIZE_TASK_*_DEFAULT`). +type TaskLogBuffer =LogBuffer <LOG_BUFFER_SIZE ,RM_LOG_BUFFER_NUM_PAGES >; + +/// Log buffer for a task that GSP-RM gives a single page. +/// +/// Matches the size GSP-RM hardcodes for the root and RM state monitor tasks. +type SmallLogBuffer =LogBuffer <GSP_PAGE_SIZE ,1 >; -impl LogBuffer { +impl <const SIZE :usize ,const NUM_PAGES :usize >LogBuffer <SIZE ,NUM_PAGES > {/// Creates a new `LogBuffer` mapped on `dev`. fn new (dev: &device::Device <device::Bound >) ->Result <Self > { +build_assert! (SIZE ==NUM_PAGES *GSP_PAGE_SIZE ); +let obj =Self (Coherent ::zeroed (dev,GFP_KERNEL )?);let start_addr = obj.0 .dma_address ();let pte_view =io_project! ( obj.0 , - [build:size_of ::<u64 >()..][build: ..RM_LOG_BUFFER_NUM_PAGES *size_of ::<u64 >()] + [build:size_of ::<u64 >()..][build: ..NUM_PAGES *size_of ::<u64 >()] ) - .try_cast ::<PteArray <RM_LOG_BUFFER_NUM_PAGES >>()?; + .try_cast ::<PteArray <NUM_PAGES >>()?;PteArray ::init (pte_view, start_addr)?;Ok (obj) } } +/// Log buffers used by GSP-RM for debug logging. +/// +/// r000+ firmware expects log buffers for all LIBOS3 tasks. Each buffer is +/// registered as a libos memory region entry, identified by its id8 name. +/// +/// The Open RM equivalents are `_kgspInitLibosLoggingStructures`, which allocates the buffers, +/// and `kgspSetupLibosInitArgs_IMPL`, which builds the `pLibosInitArgs[]` array. struct LogBuffers { -/// Init log buffer. - loginit:LogBuffer , -/// Interrupts log buffer. - logintr:LogBuffer , -/// RM log buffer. - logrm:LogBuffer , +/// Init task log buffer (LOGINIT). + loginit:TaskLogBuffer , +/// Interrupt task log buffer (LOGINTR). + logintr:TaskLogBuffer , +/// RM task log buffer (LOGRM). + logrm:TaskLogBuffer , +/// MNOC task log buffer (LOGMNOC). + logmnoc:TaskLogBuffer , +/// Root task log buffer (LOGROOT). + logroot:SmallLogBuffer , +/// RM state monitor task log buffer (LOGRMON). + logrmon:SmallLogBuffer , }/// GSP runtime data.
@@ -159,6 +189,8 @@ pub(crate) struct Gsp { pub(crate) cmdq: Arc<Cmdq>,/// RM arguments. rmargs: Coherent<GspArgumentsPadded>, +/// RM state monitor buffer (required by r000+ GSP-RM for diagnostics). + rm_state_monitor: Coherent<[u8; GSP_PAGE_SIZE]>, }impl Gsp {
@@ -167,16 +199,17 @@ pub(crate) fn new(pdev: &pci::Device<device::Bound>) -> impl PinInit<Self, Error pin_init::pin_init_scope(move || { let dev = pdev.as_ref(); - let loginit = LogBuffer::new(dev)?; - let logintr = LogBuffer::new(dev)?; - let logrm = LogBuffer::new(dev)?; + let loginit = TaskLogBuffer::new(dev)?; + let logintr = TaskLogBuffer::new(dev)?; + let logrm = TaskLogBuffer::new(dev)?; + let logmnoc = TaskLogBuffer::new(dev)?; + let logroot = SmallLogBuffer::new(dev)?; + let logrmon = SmallLogBuffer::new(dev)?; - // Initialise the logging structures. The OpenRM equivalents are in: - // _kgspInitLibosLoggingStructures (allocates memory for buffers) - // kgspSetupLibosInitArgs_IMPL (creates pLibosInitArgs[] array) Ok(try_pin_init!(Self { cmdq: Arc::pin_init(Cmdq::new(dev), GFP_KERNEL)?, rmargs: Coherent::init(dev, GFP_KERNEL, GspArgumentsPadded::new(cmdq.as_ref()))?, + rm_state_monitor: Coherent::zeroed(dev, GFP_KERNEL)?, libos: { let mut libos = CoherentBox::zeroed_slice( dev,
@@ -196,6 +229,9 @@ pub(crate) fn new(pdev: &pci::Device<device::Bound>) -> impl PinInit<Self, Error loginit, logintr, logrm, + logmnoc, + logroot, + logrmon, };#[allow(static_mut_refs)]
@@ -212,6 +248,9 @@ pub(crate) fn new(pdev: &pci::Device<device::Bound>) -> impl PinInit<Self, Error dir.read_binary_file (c"loginit" , &logs.loginit.0 ); dir.read_binary_file (c"logintr" , &logs.logintr.0 ); dir.read_binary_file (c"logrm" , &logs.logrm.0 ); + dir.read_binary_file (c"logmnoc" , &logs.logmnoc.0 ); + dir.read_binary_file (c"logroot" , &logs.logroot.0 ); + dir.read_binary_file (c"logrmon" , &logs.logrmon.0 ); }) }, }))
Signature · 1 line
2.55.0
PATCH 9/27 gpu: nova-core: add build ID headers to debugfs log buffer dumps
In reply to John HubbardA raw log buffer dump cannot be decoded without knowing which firmware build produced it, and which GPU and metadata format it belongs to. GSP-RM's own decoder takes that from a header ahead of the data, in the LIBOS_LOG_NVLOG_BUFFER_V2 layout.
Prepend that header to each debugfs dump. The build ID comes from the BLID tag of gsp.tlv, so request the metadata once when the GSP manager is created and hand it to the firmware loader rather than requesting it again during boot. A buffer whose build ID is missing serves its contents with no header.
--- drivers/gpu/nova-core/firmware.rs | 34 +++++ drivers/gpu/nova-core/firmware/gsp.rs | 8 +- drivers/gpu/nova-core/gpu.rs | 2 +- drivers/gpu/nova-core/gsp.rs | 185 ++++++++++++++++++++++---- drivers/gpu/nova-core/gsp/boot.rs | 2 +- 5 files changed, 200 insertions(+), 31 deletions(-)
drivers/gpu/nova-core/firmware.rs +34 -0
@@ -31,6 +31,40 @@pub (crate )mod riscv;pub (crate )mod tlv; +/// Maximum length of a build ID, matching Open RM's `BUILD_ID_MAX_LENGTH`. +const BUILD_ID_MAX_LENGTH :usize =32 ; + +/// Build ID extracted from firmware, used to correlate debugfs log buffer dumps +/// with the correct firmware symbols. +pub (crate )struct BuildId { + bytes: [u8 ;BUILD_ID_MAX_LENGTH ], + len:u8 , +} + +impl BuildId { +/// Constructs a [`BuildId`] from raw descriptor bytes. +/// +/// Returns `None` if `data` is empty or exceeds [`BUILD_ID_MAX_LENGTH`]. +pub (crate )fn from_raw (data: &[u8 ]) ->Option <Self > { +if data.is_empty () || data.len () >BUILD_ID_MAX_LENGTH { +return None ; + } + +let mut bytes = [0u8 ;BUILD_ID_MAX_LENGTH ]; + bytes[..data.len ()].copy_from_slice (data); + +Some (Self { + bytes, + len: data.len ()as u8 , + }) + } + +/// Returns the build ID bytes. +pub (crate )fn as_bytes (&self) -> &[u8 ] { + &self.bytes[..usize::from (self.len)] + } +} +/// Structure used to describe some firmwares, notably FWSEC-FRTS. #[repr( C )] #[derive( Debug , Clone , FromBytes )]
drivers/gpu/nova-core/firmware/gsp.rs +4 -4
@@ -16,8 +16,8 @@ radix3::Radix3, riscv::RiscvFirmware, // tlv::{ - request_tlv,// -Tlv , + request_tlv, +Tlv ,// }, }, gpu::Chipset,
@@ -48,10 +48,10 @@ impl GspFirmware { pub(crate) fn new<'a>( dev: &'a device::Device<device::Bound>, chipset: Chipset, + gsp_tlv: &'a firmware::Firmware, ) -> impl PinInit<Self, Error> + 'a { pin_init::pin_init_scope(move || { - let firmware = request_tlv(dev, chipset, "gsp")?; - let tlv = Tlv::new(firmware.data())?; + let tlv = Tlv::new(gsp_tlv.data())?; let fw_version = CString::try_from_fmt(fmt!("{}", tlv.get_string(b"VERS")?))?; dev_dbg!( dev,
drivers/gpu/nova-core/gpu.rs +1 -1
@@ -396,7 +396,7 @@ pub(crate) fn new( vgpu: VgpuManager::new(pdev, spec.chipset, fsp.as_mut()), - gsp <- Gsp::new(pdev), + gsp <- Gsp::new(pdev, spec.chipset),// This member must be initialized last, so the `UnloadBundle` can never be dropped // from outside of the constructed `GspResources`, ensuring that the unload sequence
drivers/gpu/nova-core/gsp.rs +160 -25
261 lines not on this page · raw message
drivers/gpu/nova-core/gsp/boot.rs +1 -1
@@ -42,7 +42,7 @@ pub(crate) fn boot(let dev = pdev.as_ref ();let hal =super ::hal::gsp_hal (chipset); -let gsp_fw =KBox ::pin_init (GspFirmware ::new (dev, chipset),GFP_KERNEL )?; +let gsp_fw =KBox ::pin_init (GspFirmware ::new (dev, chipset, &self.gsp_tlv),GFP_KERNEL )?;// Perform the chipset-specific boot sequence, and retrieve the unload bundle. let unload_bundle = hal.boot(&self, &mut ctx, &gsp_fw)?.or_else(|| {
Signature · 1 line
2.55.0
PATCH 10/27 gpu: nova-core: rename the FbRanges elf field to fw_image
In reply to John HubbardThe framebuffer region this field describes holds the GSP firmware image. It is an ELF under 570.144 and is not one under the firmware this series moves to, so name the field for what it holds rather than for its current format.
No functional change.
--- drivers/gpu/nova-core/fb.rs | 18 +++++++++--------- drivers/gpu/nova-core/gsp/fw.rs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/nova-core/fb.rs +9 -9
@@ -159,7 +159,7 @@ pub(crate) struct FbRanges {/// Memory area containing the GSP bootloader image. pub(crate) boot: FbRange,/// Memory area containing the GSP firmware image. - pub(crate) elf: FbRange, + pub(crate) fw_image: FbRange,/// WPR2 heap. pub(crate) wpr2_heap: FbRange,/// WPR2 region range, starting with an instance of `GspFwWprMeta`.
@@ -234,25 +234,25 @@ pub(crate) fn new(FbRange (bootloader_base..bootloader_base + bootloader_size) }; -let elf = { -const ELF_DOWN_ALIGN :Alignment =Alignment ::new ::<SZ_64K >(); -let elf_size = u64::from_safe_cast (gsp_fw.size ()); -let elf_addr = (boot.start - elf_size).align_down (ELF_DOWN_ALIGN ); +let fw_image = { +const FW_IMAGE_DOWN_ALIGN :Alignment =Alignment ::new ::<SZ_64K >(); +let fw_image_size = u64::from_safe_cast (gsp_fw.size ()); +let fw_image_addr = (boot.start - fw_image_size).align_down (FW_IMAGE_DOWN_ALIGN ); -FbRange (elf_addr..elf_addr + elf_size) +FbRange (fw_image_addr..fw_image_addr + fw_image_size) };let (vf_partition_count, wpr2_heap_size) =wpr2_heap_params (chipset, vgpu_state, fb.end)?;let wpr2_heap = {const WPR2_HEAP_DOWN_ALIGN :Alignment =Alignment ::new ::<SZ_1M >(); -let wpr2_heap_addr = elf +let wpr2_heap_addr = fw_image .start .checked_sub (wpr2_heap_size) .ok_or (EOVERFLOW )? .align_down (WPR2_HEAP_DOWN_ALIGN ); -FbRange (wpr2_heap_addr..(elf.start).align_down (WPR2_HEAP_DOWN_ALIGN )) +FbRange (wpr2_heap_addr..(fw_image.start).align_down (WPR2_HEAP_DOWN_ALIGN )) };let wpr2 = {
@@ -273,7 +273,7 @@ pub(crate) fn new( vga_workspace, frts, boot, - elf, + fw_image, wpr2_heap, wpr2, non_wpr_heap,
drivers/gpu/nova-core/gsp/fw.rs +1 -1
@@ -206,7 +206,7 @@ pub(crate) fn from_ranges<'a>( gspFwWprStart: ranges.wpr2.start, gspFwHeapOffset: ranges.wpr2_heap.start, gspFwHeapSize: ranges.wpr2_heap.len(), - gspFwOffset: ranges.elf.start, + gspFwOffset: ranges.fw_image.start, bootBinOffset: ranges.boot.start, frtsOffset: ranges.frts.start, frtsSize: ranges.frts.len(),
Signature · 1 line
2.55.0
PATCH 11/27 gpu: nova-core: regs: add msgq v2 BAR0 register declarations
In reply to John HubbardMsgq v2 moves the four ring pointers out of the in-memory headers and into BAR0. NV_PGSP_QUEUE_HEAD already exists as the v0 doorbell, so add NV_PGSP_QUEUE_TAIL, NV_PGSP_MSGQ_HEAD, and NV_PGSP_MSGQ_TAIL at the queue-0 offsets.
Nova only uses queue 0, so the registers are scalars rather than 8-element arrays. A comment records the full hardware layout for future multi-queue work.
--- drivers/gpu/nova-core/gsp/regs.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/gpu/nova-core/gsp/regs.rs +30 -0
@@ -5,6 +5,18 @@use crate ::regs::NV_PBUS_SW_SCRATCH ;// PGSP +// +// The msgq v2 wire protocol replaces the in-memory ring pointers with four +// BAR0 registers per queue: +// +// NV_PGSP_QUEUE_HEAD[i] @ 0x00110c00 + i*8 (CPU TX write, doorbell) +// NV_PGSP_QUEUE_TAIL[i] @ 0x00110c04 + i*8 (GSP TX read) +// NV_PGSP_MSGQ_HEAD[i] @ 0x00110c80 + i*8 (GSP RX write) +// NV_PGSP_MSGQ_TAIL[i] @ 0x00110c84 + i*8 (CPU RX read) +// +// Nova only uses queue 0, so the four registers are declared as single +// scalars at the i=0 offsets. NV_PGSP_QUEUE_HEAD is also used as the v0 +// doorbell, which is why it predates the others. register! {pub (super )NV_PGSP_QUEUE_HEAD (u32 ) @0x00110c00 {
@@ -12,6 +24,24 @@ } } +register! { +pub (super )NV_PGSP_QUEUE_TAIL (u32 ) @0x00110c04 { +31 :0 address; + } +} + +register! { +pub (super )NV_PGSP_MSGQ_HEAD (u32 ) @0x00110c80 { +31 :0 address; + } +} + +register! { +pub (super )NV_PGSP_MSGQ_TAIL (u32 ) @0x00110c84 { +31 :0 address; + } +} +// PBUS register! {
Signature · 1 line
2.55.0
PATCH 12/27 gpu: nova-core: gsp: add msgq v2 internals
In reply to John HubbardMsgq v2 moves the four ring pointers out of shared memory into BAR0 registers and treats them as monotonic counters, so head == tail distinguishes empty from full and the ring uses every slot. The pointers can also be out of step, because a GSP reset zeroes them while the ring keeps its contents.
Add the v2 TX header and the v2 ring helpers in parallel to the v0 ones, so the flip commit can swap call sites without writing new logic. Read the queue as empty while the read pointer is ahead of the write pointer, rather than taking the difference as a page count.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 140 ++++++++++++++++++++++++++++++ drivers/gpu/nova-core/gsp/fw.rs | 36 ++++++++ 2 files changed, 176 insertions(+)
drivers/gpu/nova-core/gsp/cmdq.rs +140 -0
@@ -467,6 +467,146 @@ fn advance_cpu_write_ptr(&mut self, elem_count: u32) { } } +// Msgq v2 internals. +// +// Msgq v2 keeps the four ring pointers in BAR0 registers as monotonic `u32` +// counters that wrap on overflow. The slot index is `ptr % MSGQ_NUM_PAGES` +// only at the point of use, and the ring uses every slot (no "leave one +// empty" rule, since `head == tail` distinguishes empty from full). +// +// Register-to-role mapping for queue 0: +// +// CPU TX write/doorbell: NV_PGSP_QUEUE_HEAD +// GSP TX read: NV_PGSP_QUEUE_TAIL +// GSP RX write: NV_PGSP_MSGQ_HEAD +// CPU RX read: NV_PGSP_MSGQ_TAIL +// +// A GSP reset zeroes all four counters while the in-memory ring keeps its +// contents, so the two ends can be out of step. Between the reset and +// GSP-RM writing its counter back the read pointer is ahead of the write +// pointer, which `driver_read_area_v2` reports as an empty ring. +// +// TODO: suspend/resume reset-recovery is not implemented. A power cycle +// loses the driver-side counters as well, so both ends have to be +// re-established. +#[expect(dead_code)] +impl DmaGspMem { +fn gsp_write_ptr_v2 (bar:Bar0 <'_>) ->u32 { + *bar.read (regs::NV_PGSP_MSGQ_HEAD ).address () + } + +fn gsp_read_ptr_v2 (bar:Bar0 <'_>) ->u32 { + *bar.read (regs::NV_PGSP_QUEUE_TAIL ).address () + } + +fn cpu_read_ptr_v2 (bar:Bar0 <'_>) ->u32 { + *bar.read (regs::NV_PGSP_MSGQ_TAIL ).address () + } + +fn cpu_write_ptr_v2 (bar:Bar0 <'_>) ->u32 { + *bar.read (regs::NV_PGSP_QUEUE_HEAD ).address () + } + +fn advance_cpu_read_ptr_v2 (bar:Bar0 <'_>, count:u32 ) { +let new_rptr =Self ::cpu_read_ptr_v2 (bar).wrapping_add (count); + +// Order all reads from the message data ahead of the read-pointer +// update so the GSP cannot recycle the slots while we are still +// looking at them. +fence (Ordering ::SeqCst ); + + bar.write_reg (regs::NV_PGSP_MSGQ_TAIL ::zeroed ().with_address (new_rptr)); + } + +fn advance_cpu_write_ptr_v2 (bar:Bar0 <'_>, count:u32 ) { +let new_wptr =Self ::cpu_write_ptr_v2 (bar).wrapping_add (count); + +// Order all writes to the message data ahead of the write-pointer +// update. Writing the head register doubles as the GSP doorbell. +fence (Ordering ::SeqCst ); + + bar.write_reg (regs::NV_PGSP_QUEUE_HEAD ::zeroed ().with_address (new_wptr)); + } + +/// Returns the region of the CPU message queue that the driver is currently allowed to write +/// to. +/// +/// As the message queue is a circular buffer, the region may be discontiguous in memory. In +/// that case the second slice will have a non-zero length. +fn driver_write_area_v2 ( + &mut self, + bar:Bar0 <'_>, + ) -> (&mut [[u8 ;GSP_PAGE_SIZE ]], &mut [[u8 ;GSP_PAGE_SIZE ]]) { +let raw_w =Self ::cpu_write_ptr_v2 (bar); +let raw_r =Self ::gsp_read_ptr_v2 (bar); + +let used = raw_w.wrapping_sub (raw_r); +let avail = num::u32_as_usize (MSGQ_NUM_PAGES .saturating_sub (used)); +let w_slot = num::u32_as_usize (raw_w %MSGQ_NUM_PAGES ); + +// Pointer to the first entry of the CPU message queue. +let data = ptr::project!(mut self.0 .as_mut_ptr (), .cpuq.msgq.data[build:0 ]); + +// SAFETY: +// - `data` points to `MSGQ_NUM_PAGES` valid message queue entries. +// - We will only access the driver-owned part of the shared memory. +// - Per the safety statement of the function, no concurrent access will be performed. +let data = +unsafe { core::slice::from_raw_parts_mut (data, num::u32_as_usize (MSGQ_NUM_PAGES )) }; +let (before_w, after_w) = data.split_at_mut (w_slot); + +let in_after = avail.min (after_w.len ()); +let in_before = avail - in_after; + (&mut after_w[..in_after], &mut before_w[..in_before]) + } + +/// Returns the size, in bytes, of the region of the CPU message queue that the driver is +/// currently allowed to write to. +fn driver_write_area_size_v2 (bar:Bar0 <'_>) ->usize { +let used =Self ::cpu_write_ptr_v2 (bar).wrapping_sub (Self ::gsp_read_ptr_v2 (bar)); +let slots =MSGQ_NUM_PAGES .saturating_sub (used); + num::u32_as_usize (slots) *GSP_PAGE_SIZE + } + +/// Returns the region of the GSP message queue that the driver is currently allowed to read +/// from. +/// +/// As the message queue is a circular buffer, the region may be discontiguous in memory. In +/// that case the second slice will have a non-zero length. +fn driver_read_area_v2 ( + &self, + bar:Bar0 <'_>, + ) -> (&[[u8 ;GSP_PAGE_SIZE ]], &[[u8 ;GSP_PAGE_SIZE ]]) { +let raw_w =Self ::gsp_write_ptr_v2 (bar); +let raw_r =Self ::cpu_read_ptr_v2 (bar); + +// A difference wider than the ring means the GSP has been reset and has not yet written +// its own counter back, so the read pointer is momentarily ahead of it. Report nothing +// readable, which holds the callers in their poll until GSP-RM restores the real value. +let pending = raw_w.wrapping_sub (raw_r); +let avail =if pending >MSGQ_NUM_PAGES { +0 + }else { + num::u32_as_usize (pending) + }; +let r_slot = num::u32_as_usize (raw_r %MSGQ_NUM_PAGES ); + +// Pointer to the first entry of the GSP message queue. +let data = ptr::project!(self.0 .as_ptr (), .gspq.msgq.data[build:0 ]); + +// SAFETY: +// - `data` points to `MSGQ_NUM_PAGES` valid message queue entries. +// - We will only access the driver-owned part of the shared memory. +// - Per the safety statement of the function, no concurrent access will be performed. +let data =unsafe { core::slice::from_raw_parts (data, num::u32_as_usize (MSGQ_NUM_PAGES )) }; +let (before_r, after_r) = data.split_at (r_slot); + +let in_after = avail.min (after_r.len ()); +let in_before = avail - in_after; + (&after_r[..in_after], &before_r[..in_before]) + } +} +/// A command ready to be sent on the command queue. /// /// This is the type returned by [`DmaGspMem::allocate_command`].
drivers/gpu/nova-core/gsp/fw.rs +36 -0
@@ -758,6 +758,42 @@ pub(crate) fn set_write_ptr(this: CoherentView<'_, Self>, val: u32) {// SAFETY: Padding is explicit and does not contain uninitialized data. unsafe impl AsBytes for MsgqTxHeader {} +/// TX header for setting up a message queue with the GSP, msgq v2 layout. +/// +/// Same wire size as [`MsgqTxHeader`] (32 bytes) with a different field +/// layout: the v0 `writePtr`, `flags`, and `rxHdrOff` fields are gone, the +/// `version` `u32` becomes split `versionMajor`/`versionMinor` `u16`s, and +/// the trailing space holds three reserved `u32`s. +#[repr(transparent)] +pub (crate )struct MsgqTxHeaderV2 (r000_00::msgqTxHeader ); + +#[expect(dead_code)] +impl MsgqTxHeaderV2 { +/// Creates a new v2 TX queue header. +/// +/// # Arguments +/// +/// * `msgq_size` - Total size of the message queue structure, in bytes. +/// * `msg_size` - Size of each message slot, in bytes. +/// * `msg_count` - Number of message slots in the ring. +/// * `entry_off` - Byte offset from the start of the queue at which the +/// message data array begins. +pub (crate )fn new (msgq_size:u32 , msg_size:u32 , msg_count:u32 , entry_off:u32 ) ->Self { +Self (r000_00::msgqTxHeader { + versionMajor:2 , + versionMinor:0 , + size: msgq_size, + msgSize: msg_size, + msgCount: msg_count, + entryOff: entry_off, + reserved: [0 ;3 ], + }) + } +} + +// SAFETY: Padding is explicit and does not contain uninitialized data. +unsafe impl AsBytes for MsgqTxHeaderV2 {} +/// RX header for setting up a message queue with the GSP. #[repr(transparent)] pub (crate )struct MsgqRxHeader (bindings::msgqRxHeader );
Signature · 1 line
2.55.0
PATCH 20/27 gpu: nova-core: handle the r000 load-and-execute bootloader event
In reply to John HubbardThe r000 GSP boot protocol asks the driver to run an image on the GSP falcon, and passes a bootloader descriptor naming where the image lives. Open RM does not copy the image itself. It runs the generic falcon bootloader, which reads that descriptor from DMEM and does the copy.
Nova-core has no handler for that event, and keeps its copy of the descriptor in the FWSEC module that first needed one.
Move the descriptor next to the bootloader that reads it, and add the handler. It points the requested FBIF aperture at the image, loads the descriptor and the bootloader, runs it, and restores the aperture.
--- .../nova-core/firmware/fwsec/bootloader.rs | 52 +----- .../gpu/nova-core/firmware/gen_bootloader.rs | 115 ++++++++++++- drivers/gpu/nova-core/gsp/boot.rs | 161 +++++++++++++++++- 3 files changed, 278 insertions(+), 50 deletions(-)
drivers/gpu/nova-core/firmware/fwsec/bootloader.rs +4 -48
@@ -33,60 +33,16 @@ }, firmware::{ fwsec::FwsecFirmware, - gen_bootloader::GenericBootloader, // + gen_bootloader::{ +BootloaderDmemDescV2 , +GenericBootloader ,// + }, }, gpu::Chipset, num::FromSafeCast, // regs, }; -/// Structure used by the boot-loader to load the rest of the code. -/// -/// This has to be filled by the GPU driver and copied into DMEM at offset -/// [`BootloaderDesc.dmem_load_off`]. -#[repr( C , packed)] -#[derive( Debug , Clone )] -struct BootloaderDmemDescV2 { -/// Reserved, should always be first element. - reserved: [u32 ;4 ], -/// 16B signature for secure code, 0s if no secure code. - signature: [u32 ;4 ], -/// DMA context used by the bootloader while loading code/data. - ctx_dma:u32 , -/// 256B-aligned physical FB address where code is located. - code_dma_base:u64 , -/// Offset from `code_dma_base` where the non-secure code is located. -/// -/// Also used as destination IMEM offset of non-secure code as the DMA firmware object is -/// expected to be a mirror image of its loaded state. -/// -/// Must be multiple of 256. - non_sec_code_off:u32 , -/// Size of the non-secure code part. - non_sec_code_size:u32 , -/// Offset from `code_dma_base` where the secure code is located (must be multiple of 256). -/// -/// Also used as destination IMEM offset of secure code as the DMA firmware object is expected -/// to be a mirror image of its loaded state. -/// -/// Must be multiple of 256. - sec_code_off:u32 , -/// Size of the secure code part. - sec_code_size:u32 , -/// Code entry point invoked by the bootloader after code is loaded. - code_entry_point:u32 , -/// 256B-aligned physical FB address where data is located. - data_dma_base:u64 , -/// Size of data block (should be multiple of 256B). - data_size:u32 , -/// Number of arguments to be passed to the target firmware being loaded. - argc:u32 , -/// Arguments to be passed to the target firmware being loaded. - argv:u32 , -} -// SAFETY: This struct doesn't contain uninitialized bytes and doesn't have interior mutability. -unsafe impl AsBytes for BootloaderDmemDescV2 {} -/// Wrapper for [`FwsecFirmware`] that includes the bootloader performing the actual load /// operation. pub (crate )struct FwsecFirmwareWithBl {
drivers/gpu/nova-core/firmware/gen_bootloader.rs +114 -1
138 lines not on this page · raw message
drivers/gpu/nova-core/gsp/boot.rs +160 -1
179 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH 13/27 gpu: nova-core: generalize allocate_command() for variable headers
In reply to John HubbardThe GMC command path uses a different message element header from the VGPU-style RPC path, but the two share the queue, the space accounting, and the wrapping rules. Make allocate_command() and GspCommand generic over the header type, defaulting to GspMsgElement so the existing RPC callers are unchanged.
No functional changes.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
drivers/gpu/nova-core/gsp/cmdq.rs +15 -7
@@ -365,6 +365,8 @@ fn driver_write_area_size(&self) -> usize {/// Allocates a region on the command queue that is large enough to send a command of `size` /// bytes, waiting for space to become available based on the provided timeout. /// +/// The type parameter `H` selects the message element header, [`GspMsgElement`] for RM RPC. +/// /// This returns a [`GspCommand`] ready to be written to by the caller. /// /// # Errors
@@ -372,13 +374,17 @@ fn driver_write_area_size(&self) -> usize {/// - `EMSGSIZE` if the command is larger than [`GSP_MSG_QUEUE_ELEMENT_SIZE_MAX`]. /// - `ETIMEDOUT` if space does not become available within the timeout. /// - `EIO` if the command header is not properly aligned. -fn allocate_command (&mut self, size:usize , timeout:Delta ) ->Result <GspCommand <'_>> { -if size_of ::<GspMsgElement >() + size >GSP_MSG_QUEUE_ELEMENT_SIZE_MAX { +fn allocate_command <H :FromBytes +AsBytes >( + &mut self, + size:usize , + timeout:Delta , + ) ->Result <GspCommand <'_,H >> { +if size_of ::<H >() + size >GSP_MSG_QUEUE_ELEMENT_SIZE_MAX {return Err (EMSGSIZE ); }read_poll_timeout ( ||Ok (self.driver_write_area_size ()), - |available_bytes| *available_bytes >=size_of ::<GspMsgElement >() + size, + |available_bytes| *available_bytes >=size_of ::<H >() + size,Delta ::from_micros (1 ), timeout, )?;
@@ -390,8 +396,8 @@ fn allocate_command(&mut self, size: usize, timeout: Delta) -> Result<GspCommand (slice_1.as_flattened_mut (), slice_2.as_flattened_mut ()) }; -// Extract area for the `GspMsgElement`. -let (header, slice_1) =GspMsgElement ::from_bytes_mut_prefix (slice_1).ok_or (EIO )?; +// Extract area for the message element header. +let (header, slice_1) =H ::from_bytes_mut_prefix (slice_1).ok_or (EIO )?;// Create the contents area. let (slice_1, slice_2) =if slice_1.len () > size {
@@ -609,10 +615,12 @@ fn driver_read_area_v2(/// A command ready to be sent on the command queue. /// +/// The type parameter `H` is the message element header type, [`GspMsgElement`] for RM RPC. +/// /// This is the type returned by [`DmaGspMem::allocate_command`]. -struct GspCommand <'a> { +struct GspCommand <'a,H =GspMsgElement > {// Writable reference to the header of the command. - header: &'amut GspMsgElement , + header: &'amut H ,// Writable slices to the contents of the command. The second slice is zero unless the command // loops over the command queue. contents: (&'amut [u8 ], &'amut [u8 ]),
Signature · 1 line
2.55.0
PATCH 14/27 gpu: nova-core: add GMC API message types
In reply to John HubbardThe new firmware carries GMC commands over the same MCTP/NVDM transport as the RPC path, under NVDM type 0x26 and with its own fixed header in place of rpc_message_header_v. Add that header as GmcApiHeader, matching Open RM's GMCAPI_HEADER, and the queue element that wraps it.
--- drivers/gpu/nova-core/gsp/fw.rs | 127 ++++++++++++++++++++++++++++++++ drivers/gpu/nova-core/mctp.rs | 2 + 2 files changed, 129 insertions(+)
drivers/gpu/nova-core/gsp/fw.rs +127 -0
@@ -50,6 +50,11 @@ cmdq::Cmdq, // GSP_PAGE_SIZE, }, + mctp::{ + MctpHeader, + NvdmHeader, + NvdmType, // + }, num::{ self,FromSafeCast ,//
@@ -947,6 +952,128 @@ unsafe impl AsBytes for GspMsgElement {}// are valid. unsafe impl FromBytes for GspMsgElement {} +/// Magic value that opens every MCTP-framed queue element: `"MCTP"` in ASCII. +const MCTP_MAGIC :u32 =0x4D43_5450 ; + +/// GMC API message header. +/// +/// Matches the `GMCAPI_HEADER` struct from Open RM. The `command` field carries +/// flags in the high byte and a 24-bit command ID in the low bits. `size` is the +/// payload size for both requests and responses, while the union at offset 16 +/// carries the maximum response size for requests and the status for responses. +#[repr( C )] +#[derive( Zeroable )] +pub (crate )struct GmcApiHeader { +/// GMC command identifier with flags in the high byte. +pub (crate ) command:u32 , +/// Payload size in bytes. +pub (crate ) size:u32 , +/// Sequence number for matching requests to responses. +pub (crate ) sequence:u64 , +/// Request: maximum response size. Response: `NV_STATUS` code. +pub (crate ) max_resp_or_status:u32 , + reserved: [u32 ;5 ], +} + +static_assert! (size_of ::<GmcApiHeader >() ==40 ); + +// SAFETY: All fields are integer types with no uninitialized padding bytes. +unsafe impl AsBytes for GmcApiHeader {} + +// SAFETY: All fields are integer types for which all bit patterns are valid. +unsafe impl FromBytes for GmcApiHeader {} + +/// Header for an unencrypted GMC API message in the GSP command queue. +/// +/// The fields before `gmc` match `GSP_MSG_QUEUE_ELEMENT` through its +/// `noEncryption` union member. `gmc` occupies the start of that member's +/// flexible payload array, and the GMC command payload follows this structure. +#[repr( C )] +pub (crate )struct GspGmcMsgElement { + mctp_magic:u32 , + mctp_payload_size:u32 , + mctp_header:MctpHeader , + nvdm_header:NvdmHeader , + nvdm_payload_size:u32 , + reserved:u32 , +pub (crate ) gmc:GmcApiHeader , +} + +static_assert! ( + core::mem::offset_of!(GspGmcMsgElement , mctp_magic) + == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT , mctpMagic) +); +static_assert! ( + core::mem::offset_of!(GspGmcMsgElement , mctp_payload_size) + == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT , mctpPayloadSize) +); +static_assert! ( + core::mem::offset_of!(GspGmcMsgElement , mctp_header) + == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT , mctpHeader) +); +static_assert! ( + core::mem::offset_of!(GspGmcMsgElement , nvdm_header) + == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT , nvdmHeader) +); + +#[expect(dead_code)] +impl GspGmcMsgElement { +/// Creates a new GMC message element. +/// +/// `payload_size` is the size of the command payload following this header. +/// `command_id` is the GMC command identifier. +/// `sequence` is the sequence number for request/response matching. +/// `max_response_size` is the maximum expected response payload size. +pub (crate )fn init ( + command_id:u32 , + sequence:u64 , + payload_size:usize , + max_response_size:u32 , + ) ->impl Init <Self ,Error > { +try_init! (GspGmcMsgElement { + mctp_magic:MCTP_MAGIC , +// Despite the name, this counts the element header as well as the payload. + mctp_payload_size:size_of ::<Self >() + .checked_add (payload_size) + .ok_or (EOVERFLOW )? + .try_into () + .map_err (|_|EOVERFLOW )?, + mctp_header:MctpHeader ::single_packet (), + nvdm_header:NvdmHeader ::new (NvdmType ::GmcApi ), + nvdm_payload_size:size_of ::<GmcApiHeader >() + .checked_add (payload_size) + .ok_or (EOVERFLOW )? + .try_into () + .map_err (|_|EOVERFLOW )?, + reserved:0u32 , + gmc:GmcApiHeader { + command: command_id, + size: payload_size.try_into ().map_err (|_|EOVERFLOW )?, + sequence, + max_resp_or_status: max_response_size, + reserved: [0 ;5 ], + }, + }) + } + +/// Returns the total length of the message, transport and GMC headers included. +pub (crate )fn length (&self) ->usize { + num::u32_as_usize (self.mctp_payload_size) + } + +/// Returns the number of elements (i.e. memory pages) used by this message. +pub (crate )fn element_count (&self) ->u32 { + self.mctp_payload_size + .div_ceil (num::usize_into_u32 ::<GSP_PAGE_SIZE >()) + } +} + +// SAFETY: All fields are integer types with no uninitialized padding bytes. +unsafe impl AsBytes for GspGmcMsgElement {} + +// SAFETY: All fields are integer types for which all bit patterns are valid. +unsafe impl FromBytes for GspGmcMsgElement {} +/// Arguments for GSP startup. #[repr(transparent)] #[derive( Zeroable )]
drivers/gpu/nova-core/mctp.rs +2 -0
@@ -28,6 +28,8 @@ pub(crate) enum NvdmType with TryFrom<Bounded<u32, 8>> { Cot = 0x14,/// FSP command response. FspResponse = 0x15, +/// GMC API message (GSP command queue). + GmcApi = 0x26, } }
Signature · 1 line
2.55.0
PATCH 15/27 gpu: nova-core: add GMC send path
In reply to John HubbardThe r000 GSP-RM boot protocol requires the driver to send GSP_INIT as a GMC command. GMC and RPC commands share the command queue and sequence counter. GMC queue elements carry a GMC API header and no checksum.
Add the GMC send path needed for GSP_INIT.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 59 +++++++++++++++++++++++++++++++ drivers/gpu/nova-core/gsp/fw.rs | 1 - 2 files changed, 59 insertions(+), 1 deletion(-)
drivers/gpu/nova-core/gsp/cmdq.rs +59 -0
@@ -52,6 +52,7 @@ driver::Bar0, gsp::{ fw::{ +GspGmcMsgElement ,GspMsgElement ,MsgFunction ,MsgqRxHeader ,
@@ -963,6 +964,64 @@ fn send_command<M>(&mut self, bar: Bar0<'_>, command: M) -> Result<u32>Ok (rpc_seq) } +/// Sends a GMC API command to the GSP. +/// +/// `command_id` is the GMC command identifier (from `GMCAPI_COMMANDS`). +/// `payload` is the command-specific data following the [`super::fw::GmcApiHeader`]. +/// `max_response_size` is the maximum expected response payload size. +/// +/// The command carries the next RPC sequence number, which the GSP echoes in its response. +/// The number is consumed whether or not the send succeeds. +/// +/// # Errors +/// +/// - `EMSGSIZE` if the command exceeds the maximum queue element size. +/// - `ETIMEDOUT` if space does not become available within the timeout. +/// - `EIO` if the command header is not properly aligned. +#[expect(dead_code)] +fn send_gmc ( + &mut self, + bar:Bar0 <'_>, + command_id:u32 , + payload: &[u8 ], + max_response_size:u32 , + ) ->Result { +let rpc_seq = self.rpc_seq; + self.rpc_seq = self.rpc_seq.wrapping_add (1 ); + +let dst = self + .gsp_mem + .allocate_command ::<GspGmcMsgElement >(payload.len (),Self ::ALLOCATE_TIMEOUT )?; + +let msg_element =GspGmcMsgElement ::init ( + command_id, + u64::from (rpc_seq), + payload.len (), + max_response_size, + ); +// SAFETY: `dst.header` points to a valid, writable `GspGmcMsgElement` region. +unsafe { + msg_element.__init (core::ptr::from_mut (dst.header))?; + } + +SBufferIter ::new_writer ([&mut dst.contents.0 [..], &mut dst.contents.1 [..]]) + .write_all (payload)?; + +dev_dbg! ( + &self.dev, +"GSP GMC: send: seq# {}, command_id=0x{:x}, length=0x{:x}\n" , + rpc_seq, + command_id, + dst.header.length (), + ); + +let elem_count = dst.header.element_count (); + self.gsp_mem.advance_cpu_write_ptr (elem_count); +Cmdq ::notify_gsp (bar); + +Ok (()) + } +/// Wait for a message to become available on the message queue. /// /// This works purely at the transport layer and does not interpret or validate the message
drivers/gpu/nova-core/gsp/fw.rs +0 -1
@@ -1016,7 +1016,6 @@ pub(crate) struct GspGmcMsgElement { == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, nvdmHeader) ); -#[expect(dead_code)] impl GspGmcMsgElement {/// Creates a new GMC message element. ///
Signature · 1 line
2.55.0
PATCH 21/27 gpu: nova-core: gsp: add the GMC boot event dispatcher
In reply to John HubbardThe r000 GSP boot protocol sends its two load-and-execute events as GMC commands, each identified by a command id.
Nova-core has a handler for each of the two events, but nothing that reads a command id and selects between them.
Add the dispatcher, keyed on the two command ids from the r000 bindings.
--- drivers/gpu/nova-core/gsp/boot.rs | 62 +++++++++++++++++++++++++++++-- drivers/gpu/nova-core/gsp/fw.rs | 10 +++++ 2 files changed, 69 insertions(+), 3 deletions(-)
drivers/gpu/nova-core/gsp/boot.rs +59 -3
@@ -36,7 +36,11 @@ }, gsp::{ cmdq::Cmdq, - commands, // + commands, + fw::{ +GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER , +GMCAPI_CMD_EXEC_HS_BINARY ,// + }, // }, regs, // };
@@ -162,6 +166,60 @@ fn core_resume(Ok (()) } +/// Dispatch one GMC boot event to its load-and-execute handler. +/// +/// LIBOS2 chipsets send `GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER` and LIBOS3 chipsets send +/// `GMCAPI_CMD_EXEC_HS_BINARY`, so a given GPU only ever reaches one of the two handlers. +/// +/// # Errors +/// +/// - `EINVAL` if `command_id` is not a load-and-execute command. +/// +/// Errors from the handlers are propagated as-is. +#[expect(dead_code)] +#[allow(clippy::too_many_arguments)] +fn dispatch_gmc_boot_event ( + command_id:u32 , + payload: &[u8 ], + bootloader: &GenericBootloader , + gsp_falcon: &Falcon <'_,Gsp >, + sec2_falcon: &Falcon <'_,Sec2 >, + bar:Bar0 <'_>, + dev: &device::Device , + bootloader_app_version:u32 , + libos_dma_handle:u64 , + ) ->Result { +match command_id { +GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER =>Self ::handle_load_exec_bootloader ( + payload, + bootloader, + gsp_falcon, + sec2_falcon, + bar, + dev, + bootloader_app_version, + libos_dma_handle, + ), +GMCAPI_CMD_EXEC_HS_BINARY =>Self ::handle_load_exec_hs_binary ( + payload, + gsp_falcon, + sec2_falcon, + bar, + dev, + bootloader_app_version, + libos_dma_handle, + ), + _ => { +dev_err! ( + dev, +"Unexpected GMC boot event: command_id={:#010x}\n" , + command_id + ); +Err (EINVAL ) + } + } + } +/// Handle a `GSP_LOAD_EXEC_GENERIC_BOOTLOADER` event. /// /// The driver does not copy the image the GSP asks for. It writes the descriptor the event
@@ -175,7 +233,6 @@ fn core_resume(/// size this driver mirrors, or the event names a context DMA slot or an aperture that does /// not exist. /// - `ETIMEDOUT` if the GSP does not suspend, or the image does not halt, in time. -#[expect(dead_code)] #[allow(clippy::too_many_arguments)] fn handle_load_exec_bootloader ( payload: &[u8],
@@ -268,7 +325,6 @@ fn handle_load_exec_bootloader(/// - `EINVAL` if the payload is shorter than the parameter block, or the ucode id does not /// fit the BROM register field. /// - `ETIMEDOUT` if the GSP does not suspend, or the binary does not halt, in time. -#[expect(dead_code)] #[allow(clippy::too_many_arguments)] fn handle_load_exec_hs_binary ( payload: &[u8],
drivers/gpu/nova-core/gsp/fw.rs +10 -0
@@ -979,6 +979,16 @@ pub(crate) struct GmcApiHeader {/// `GMCAPI_HEADER_COMMAND_ID_MASK`. The remaining byte carries flags. const GMCAPI_COMMAND_ID_MASK :u32 =0x00ff_ffff ; +/// GMC command asking the driver to run the generic falcon bootloader against a descriptor the +/// GSP supplies. +pub (crate )const GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER :u32 = + r000_00::GMCAPI_COMMANDS_GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER ; + +/// GMC command asking the driver to run a high-security binary the GSP has placed in the +/// framebuffer. +pub (crate )const GMCAPI_CMD_EXEC_HS_BINARY :u32 = + r000_00::GMCAPI_COMMANDS_GMCAPI_CMD_EXEC_HS_BINARY ; +static_assert! (size_of ::<GmcApiHeader >() ==40 );impl GmcApiHeader {
Signature · 1 line
2.55.0
PATCH 16/27 gpu: nova-core: add GMC transport receive path
In reply to John HubbardGSP-RM posts GMC and RPC messages on the same message queue. Both use the same MCTP and NVDM transport headers, but RPC messages continue with rpc_message_header_v and GMC messages continue with GmcApiHeader. Existing RPC receive code cannot parse the GMC layout.
Add a GMC receive path that validates the MCTP magic and rejects payloads whose advertised length exceeds the available queue contents. On a framing or length failure, poison the queue because the driver cannot safely advance the read pointer without a trusted length.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 83 ++++++++++++++++++++++++++++++- drivers/gpu/nova-core/gsp/fw.rs | 10 ++++ 2 files changed, 92 insertions(+), 1 deletion(-)
drivers/gpu/nova-core/gsp/cmdq.rs +82 -1
@@ -629,7 +629,7 @@ struct GspCommand<'a, H = GspMsgElement> {/// A message ready to be processed from the message queue. /// -/// This is the type returned by [`Cmdq::wait_for_msg`]. +/// This is the type returned by [`CmdqInner::wait_for_msg`]. struct GspMessage <'a> {// Reference to the header of the message. header: &'aGspMsgElement ,
@@ -638,6 +638,18 @@ struct GspMessage<'a> { contents: (&'a [u8], &'a [u8]), } +/// A GMC message ready to be processed from the message queue. +/// +/// This is the type returned by [`CmdqInner::wait_for_gmc_msg`]. +#[expect(dead_code)] +struct GmcMessage <'a> { +// Reference to the header of the message. + header: &'aGspGmcMsgElement , +// Slices of the payload following the `GmcApiHeader`. The second slice is empty unless the +// payload wraps around the end of the message queue. + contents: (&'a [u8 ], &'a [u8 ]), +} +/// GSP command queue. /// /// Provides the ability to send commands and receive messages from the GSP using a shared memory
@@ -1285,4 +1297,73 @@ fn drain(&mut self) -> Result {Ok (()) } + +/// Wait for a GMC message to become available on the message queue. +/// +/// This is the GMC counterpart to [`Self::wait_for_msg`] and reads the same queue. Like that +/// method it works purely at the transport layer, validating the MCTP framing and the +/// advertised length and nothing else. +/// +/// A [`GspGmcMsgElement`] and a [`GspMsgElement`] share every field through `nvdm_header`, +/// so a caller that may see either must check the NVDM type before reading `gmc`. Both +/// layouts put the element length in the same place, so the caller can advance the read +/// pointer past a returned message either way. +/// +/// # Errors +/// +/// - `ETIMEDOUT` if `timeout` has elapsed before any message becomes available. +/// - `EIO` if the framing is invalid, or the queue was already poisoned by an earlier such +/// failure. Either failure poisons the queue, so recovery requires a reset. +#[expect(dead_code)] +fn wait_for_gmc_msg (&self, timeout:Delta ) ->Result <GmcMessage <'_>> { +if self.poisoned.get () { +return Err (EIO ); + } + +let (slice_1, slice_2) =read_poll_timeout ( + ||Ok (self.gsp_mem.driver_read_area ()), + |driver_area| !driver_area.0 .is_empty (), +Delta ::from_millis (1 ), + timeout, + ) + .map (|(slice_1, slice_2)| (slice_1.as_flattened (), slice_2.as_flattened ()))?; + +let Some ((header, slice_1)) =GspGmcMsgElement ::from_bytes_prefix (slice_1)else { + self.poisoned.set (true ); +return Err (EIO ); + }; + +// Checked before any length field is read, since a bad magic leaves them untrusted. +if !header.has_valid_magic () { +dev_err! (&self.dev,"GSP GMC: receive: bad MCTP magic\n" ); + self.poisoned.set (true ); +return Err (EIO ); + } + +let payload_length = header.payload_length (); + +// Check that the driver read area is large enough for the message. +if slice_1.len () + slice_2.len () < payload_length { + self.poisoned.set (true ); +return Err (EIO ); + } + +// Cut the message slices down to the actual length of the message. +let (slice_1, slice_2) =if slice_1.len () > payload_length { +// PANIC: we checked above that `slice_1` is at least as long as `payload_length`. + (slice_1.split_at (payload_length).0 , &slice_2[0 ..0 ]) + }else { + ( + slice_1, +// PANIC: we checked above that `slice_1.len() + slice_2.len()` is at least as +// large as `payload_length`. + slice_2.split_at (payload_length - slice_1.len ()).0 , + ) + }; + +Ok (GmcMessage { + header, + contents: (slice_1, slice_2), + }) + } }
drivers/gpu/nova-core/gsp/fw.rs +10 -0
@@ -1055,11 +1055,21 @@ pub(crate) fn init( }) } +/// Returns the length of the response payload (data after the [`GmcApiHeader`]). +pub (crate )fn payload_length (&self) ->usize { + num::u32_as_usize (self.nvdm_payload_size).saturating_sub (size_of ::<GmcApiHeader >()) + } +/// Returns the total length of the message, transport and GMC headers included. pub (crate )fn length (&self) ->usize { num::u32_as_usize (self.mctp_payload_size) } +/// Returns `true` if the MCTP magic field contains the expected value. +pub (crate )fn has_valid_magic (&self) ->bool { + self.mctp_magic ==MCTP_MAGIC + } +/// Returns the number of elements (i.e. memory pages) used by this message. pub (crate )fn element_count (&self) ->u32 { self.mctp_payload_size
Signature · 1 line
2.55.0
PATCH 17/27 gpu: nova-core: gsp: add GMC dispatch on receive
In reply to John HubbardThe r000 boot path delivers the load-and-execute steps as GMC events keyed by command id, where the RPC path keys on a function code, so the boot loop needs its own dispatch.
Add a GMC receive that dispatches on the command id. A GMC element and an RPC element share every field through the NVDM header, so this checks the NVDM type before reading the GMC header and drops an element of the other kind rather than handing the handler a command id decoded from an RPC header. An element nobody claims yields Ok(None), and the read pointer advances on every path.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 69 ++++++++++++++++++++++++++++++- drivers/gpu/nova-core/gsp/fw.rs | 20 +++++++++ 2 files changed, 87 insertions(+), 2 deletions(-)
drivers/gpu/nova-core/gsp/cmdq.rs +67 -2
@@ -641,7 +641,6 @@ struct GspMessage<'a> {/// A GMC message ready to be processed from the message queue. /// /// This is the type returned by [`CmdqInner::wait_for_gmc_msg`]. -#[expect(dead_code)] struct GmcMessage <'a> {// Reference to the header of the message. header: &'aGspGmcMsgElement ,
@@ -791,6 +790,22 @@ fn receive_msg<M: MessageFromGsp>(&self, timeout: Delta) -> Result<M> self.inner.lock ().receive_msg (timeout,None ) } +/// Receives one GMC event from the GSP and passes its command id and raw payload slices to +/// `handler`. +/// +/// This method may sleep while waiting. The [`CmdqInner`] mutex stays locked across the wait +/// and across the `handler` call, so `handler` must not call back into this [`Cmdq`]. +/// +/// See [`CmdqInner::receive_gmc_and_dispatch`] for return values, queue state, and errors. +#[expect(dead_code)] +pub (crate )fn receive_gmc_and_dispatch <R >( + &self, + timeout:Delta , + handler:impl FnOnce (u32 , &[u8 ], &[u8 ]) ->Option <R >, + ) ->Result <Option <R >> { + self.inner.lock ().receive_gmc_and_dispatch (timeout, handler) + } +/// Waits for an unsolicited GSP event of type `M`, dispatching any other event that arrives /// first. ///
@@ -1314,7 +1329,6 @@ fn drain(&mut self) -> Result {/// - `ETIMEDOUT` if `timeout` has elapsed before any message becomes available. /// - `EIO` if the framing is invalid, or the queue was already poisoned by an earlier such /// failure. Either failure poisons the queue, so recovery requires a reset. -#[expect(dead_code)] fn wait_for_gmc_msg (&self, timeout:Delta ) ->Result <GmcMessage <'_>> {if self.poisoned.get () {return Err (EIO );
@@ -1366,4 +1380,55 @@ fn wait_for_gmc_msg(&self, timeout: Delta) -> Result<GmcMessage<'_>> { contents: (slice_1, slice_2), }) } + +/// Receive the next GMC event from the GSP and dispatch it through a handler. +/// +/// The handler receives the GMC command id and the raw payload slices that follow the +/// [`super::fw::GmcApiHeader`] (two slices because the circular buffer may wrap). It returns +/// `None` for an event it does not handle. +/// +/// Where [`Self::receive_msg`] keys on [`MsgFunction`], this keys on the GMC command id, +/// which is the form the r000 firmware uses for boot events. +/// +/// Returns `Ok(None)` when nothing claimed the element, either because it is not a GMC +/// element or because the handler declined it. The read pointer is advanced on every path. +/// +/// # Errors +/// +/// - `ETIMEDOUT` if `timeout` has elapsed before any message becomes available. +/// - `EIO` if the queue is poisoned or the element fails framing validation (see +/// [`Self::wait_for_gmc_msg`]). +fn receive_gmc_and_dispatch <R >( + &mut self, + timeout:Delta , + handler:impl FnOnce (u32 , &[u8 ], &[u8 ]) ->Option <R >, + ) ->Result <Option <R >> { +let message = self.wait_for_gmc_msg (timeout)?; +let header = message.header; +let length = header.length (); + +// The RPC and GMC elements share every field through `nvdm_header`, so `gmc` holds an +// RPC header rather than a GMC one unless the NVDM type says otherwise. +let result =if header.is_gmc_api () { +let command_id = header.gmc.command_id (); + +dev_dbg! ( + &self.dev, +"GSP GMC: event: seq# {}, command_id=0x{:x}, length=0x{:x}\n" , + header.gmc.sequence, + command_id, + length, + ); + +handler (command_id, message.contents.0 , message.contents.1 ) + }else { +dev_warn! (&self.dev,"GSP GMC: dropping non-GMC queue element\n" ); +None + }; + + self.gsp_mem + .advance_cpu_read_ptr (u32::try_from (length.div_ceil (GSP_PAGE_SIZE ))?); + +Ok (result) + } }
drivers/gpu/nova-core/gsp/fw.rs +20 -0
@@ -975,8 +975,19 @@ pub(crate) struct GmcApiHeader { reserved: [u32; 5], } +/// Command identifier bits of [`GmcApiHeader::command`], matching Open RM's +/// `GMCAPI_HEADER_COMMAND_ID_MASK`. The remaining byte carries flags. +const GMCAPI_COMMAND_ID_MASK :u32 =0x00ff_ffff ; +static_assert! (size_of ::<GmcApiHeader >() ==40 ); +impl GmcApiHeader { +/// Returns the command identifier, without the flag byte. +pub (crate )fn command_id (&self) ->u32 { + self.command &GMCAPI_COMMAND_ID_MASK + } +} +// SAFETY: All fields are integer types with no uninitialized padding bytes. unsafe impl AsBytes for GmcApiHeader {}
@@ -1070,6 +1081,15 @@ pub(crate) fn has_valid_magic(&self) -> bool { self.mctp_magic ==MCTP_MAGIC } +/// Returns `true` if the NVDM header routes this element to the GSP's GMC dispatch. +/// +/// A [`GspMsgElement`] and a [`GspGmcMsgElement`] share every field through `nvdm_header`, +/// so the NVDM type is what distinguishes the two on the queue, and `gmc` holds an RPC +/// header rather than a GMC one when this returns `false`. +pub (crate )fn is_gmc_api (&self) ->bool { + self.nvdm_header.validate (NvdmType ::GmcApi ) + } +/// Returns the number of elements (i.e. memory pages) used by this message. pub (crate )fn element_count (&self) ->u32 { self.mctp_payload_size
Signature · 1 line
2.55.0
PATCH 18/27 gpu: nova-core: separate the generic falcon bootloader from FWSEC
In reply to John HubbardThe r000 GSP boot protocol sends a load-and-execute event for the generic falcon bootloader.
Nova-core stored the image and its load parameters in the FWSEC firmware wrapper, which kept the r000 boot path from loading it independently.
Separate the bootloader image and load parameters from the FWSEC wrapper. Place the bootloader at the end of the target falcon's HWCFG-reported IMEM rather than below a fixed 64 KiB ceiling, so its placement remains within bounds on falcons with less IMEM.
--- drivers/gpu/nova-core/falcon.rs | 15 +++ drivers/gpu/nova-core/firmware.rs | 1 + .../nova-core/firmware/fwsec/bootloader.rs | 64 ++--------- .../gpu/nova-core/firmware/gen_bootloader.rs | 102 ++++++++++++++++++ drivers/gpu/nova-core/gsp/hal/tu102.rs | 6 +- drivers/gpu/nova-core/regs.rs | 5 + 6 files changed, 135 insertions(+), 58 deletions(-) create mode 100644 drivers/gpu/nova-core/firmware/gen_bootloader.rs
drivers/gpu/nova-core/falcon.rs +15 -0
@@ -387,6 +387,21 @@ pub(crate) fn new( }) } +/// Returns the size of this falcon's IMEM, in bytes. +/// +/// `NV_PFALCON_FALCON_IMEMC` addresses IMEM with a 16-bit byte offset, so the result never +/// exceeds 64KiB. +pub (crate )fn imem_size (&self) ->usize { +let blocks = usize::from_safe_cast ( + *self + .bar + .read (regs::NV_PFALCON_FALCON_HWCFG ::of ::<E >()) + .imem_size (), + ); + + blocks *MEM_BLOCK_ALIGNMENT + } +/// Resets DMA-related registers. pub (crate )fn dma_reset (&self) { self.bar.update (regs::NV_PFALCON_FBIF_CTL ::of ::<E >(), |v| {
drivers/gpu/nova-core/firmware.rs +1 -0
@@ -26,6 +26,7 @@pub (crate )mod booter;pub (crate )mod fsp;pub (crate )mod fwsec; +pub (crate )mod gen_bootloader;pub (crate )mod gsp;pub (crate )mod radix3;pub (crate )mod riscv;
drivers/gpu/nova-core/firmware/fwsec/bootloader.rs +8 -56
121 lines not on this page · raw message
drivers/gpu/nova-core/firmware/gen_bootloader.rs new file +102 -0
102 lines not on this page · raw message
drivers/gpu/nova-core/gsp/hal/tu102.rs +4 -2
@@ -166,7 +166,7 @@ fn run_fwsec_frts( )?;if self.needs_fwsec_bootloader { -let fwsec_frts_bl =FwsecFirmwareWithBl ::new (fwsec_frts, dev, chipset)?; +let fwsec_frts_bl =FwsecFirmwareWithBl ::new (fwsec_frts, dev, chipset, falcon)?;// Load and run the bootloader, which will load FWSEC-FRTS and run it. fwsec_frts_bl.run (dev, falcon, bar)?; }else {
@@ -224,7 +224,9 @@ fn build_unload_bundle(// Load the FWSEC SB firmware, as well as its bootloader if required. let fwsec_sb =FwsecFirmware ::new (dev, gsp_falcon, bios,FwsecCommand ::Sb )?;let fwsec_sb =if self.needs_fwsec_bootloader { -FwsecUnloadFirmware ::WithBl (FwsecFirmwareWithBl ::new (fwsec_sb, dev, chipset)?) +FwsecUnloadFirmware ::WithBl (FwsecFirmwareWithBl ::new ( + fwsec_sb, dev, chipset, gsp_falcon, + )?) }else {FwsecUnloadFirmware ::WithoutBl (fwsec_sb) };
drivers/gpu/nova-core/regs.rs +5 -0
@@ -247,6 +247,11 @@ pub(crate) fn usable_fb_size(self) -> u64 { 31:0 value => u32; } + pub(crate) NV_PFALCON_FALCON_HWCFG(u32) @ PFalconBase + 0x00000108 { +/// Size of this falcon's IMEM, in blocks of [`crate::falcon::MEM_BLOCK_ALIGNMENT`] bytes. + 8:0 imem_size; + } + pub(crate) NV_PFALCON_FALCON_DMACTL(u32) @ PFalconBase + 0x0000010c { 7:7 secure_stat => bool; 6:3 dmaq_num;
Signature · 1 line
2.55.0
PATCH 22/27 gpu: nova-core: gsp: add the GSP_INIT request builder
In reply to John HubbardThe r000 GSP boot protocol replaces the separate system-info, registry and static-info commands with one GSP_INIT request, whose payload is an NVKV key-value blob rather than a packed struct.
Nova-core has the NVKV codec and the GSP_INIT schema, but nothing that fills the schema in from a PCI device.
Add the builder. It encodes the PCI identifiers and config mirror range the RPC path already sends, and the registry entries, whose names carry the NULL that GSP-RM counts in the encoded length.
--- drivers/gpu/nova-core/gsp/commands.rs | 52 +++++++++++++++++++++ drivers/gpu/nova-core/gsp/fw/commands.rs | 58 +++++++++++++++++++++++- 2 files changed, 108 insertions(+), 2 deletions(-)
drivers/gpu/nova-core/gsp/commands.rs +52 -0
@@ -30,8 +30,16 @@ }, fw::{ self, + commands::{ + GspInitRequest, + RegKey, // + }, MsgFunction, // }, + nvkv::{ +Encodeable , +Encoder ,// + }, }, sbuffer::SBufferIter, vgpu::VgpuState, //
@@ -259,6 +267,50 @@ pub(crate) fn gpu_name(&self) -> core::result::Result<&str, GpuNameError> { } } +/// Registry entries the driver sends to GSP-RM on every boot, each with the NULL terminator that +/// Open RM counts in the encoded name length. +/// +/// `RMSecBusResetEnable` enables PCI secondary bus reset. `RMForcePcieConfigSave` makes GSP-RM +/// preserve PCI configuration registers across any PCI reset. `RMDevidCheckIgnore` lets GSP-RM +/// boot when the PCI device id is absent from its product name database. +/// +/// [`SetRegistry::new`] carries the same entries for the RPC path, where the names have no +/// terminator because that encoding appends one. +const REGISTRY_ENTRIES : &[(&[u8 ],u32 )] = &[ + (b"RMSecBusResetEnable\0" ,1 ), + (b"RMForcePcieConfigSave\0" ,1 ), + (b"RMDevidCheckIgnore\0" ,1 ), +]; + +/// Builds the NVKV-encoded payload of a `GSP_INIT` request. +/// +/// The payload carries the system information GSP-RM reads before it starts, and +/// [`REGISTRY_ENTRIES`] as `REGKEY_NAME` and `REGKEY_VALUE_U32` pairs. GSP-RM requires each name +/// to be followed by its value, which is the order [`RegKey`] declares them in. +/// +/// # Errors +/// +/// - `ENOMEM` if the registry list or the encoder buffer cannot be allocated. +#[expect(dead_code)] +pub (crate )fn build_gsp_init_payload ( + pdev: &pci::Device <device::Bound >, + chipset:Chipset , + vgpu_state:VgpuState , +) ->Result <KVVec <u64 >> { +let mut regkeys =KVVec ::new (); +for &(name, value)in REGISTRY_ENTRIES { + regkeys.push (RegKey ::new (name, value),GFP_KERNEL )?; + } +if matches! (vgpu_state,VgpuState ::Enabled { .. }) { + regkeys.push (RegKey ::new (b"RMSetSriovMode\0" ,1 ),GFP_KERNEL )?; + } + +let mut encoder =Encoder ::new (); +GspInitRequest ::new (pdev, chipset, regkeys).encode (&mut encoder)?; + +Ok (encoder.finish ()) +} +pub (crate )use fw::commands::PowerStateLevel ;/// The `UnloadingGuestDriver` command, used to shut down the GSP.
drivers/gpu/nova-core/gsp/fw/commands.rs +56 -2
88 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH 19/27 gpu: nova-core: handle the r000 load-and-execute HS binary event
In reply to John HubbardThe r000 GSP boot protocol asks the driver to run a high-security binary on the GSP falcon, and sends the framebuffer addresses of its code and data in the event payload.
Nova-core has no handler for that event. It also has no way to restart GSP-RM afterwards, which every load-and-execute event needs.
Add the handler. It DMAs the image into falcon memory, programs the BROM registers that make the falcon verify the PKC signature, runs the binary, and resumes GSP-RM. Write FLCN_ERR_BINARY_NOT_STARTED to MAILBOX0 before starting, which Open RM does so a binary that never runs is distinguishable from one that succeeded, and which also clears the suspend bit the next event polls.
--- drivers/gpu/nova-core/falcon.rs | 7 +- drivers/gpu/nova-core/gsp/boot.rs | 229 +++++++++++++++++++++++++++++- drivers/gpu/nova-core/regs.rs | 1 + 3 files changed, 232 insertions(+), 5 deletions(-)
drivers/gpu/nova-core/falcon.rs +4 -3
@@ -140,7 +140,6 @@ pub(crate) enum FalconMem { }/// Source offset of a raw falcon DMA transfer, added to the DMA base address. -#[expect(dead_code)] #[derive( Copy , Clone )] pub (crate )enum FalconDmaSrcOffset {/// Byte offset from the DMA base address.
@@ -636,7 +635,6 @@ fn dma_wr(/// 256 bytes, or if a [`FalconDmaSrcOffset::DmemVa`] source offset is paired with an IMEM /// target. /// - `ERANGE` if `src_addr` does not fit the `DMATRFBASE` register pair. -#[expect(dead_code)] pub (crate )fn raw_dma_transfer ( &self, ctx_dma: u8,
@@ -782,7 +780,10 @@ pub(crate) fn wait_till_halted(&self) -> Result<()> {/// /// The RISC-V GSP signals suspension by setting bit 31 (`0x8000_0000`) in `MAILBOX0`, rather /// than through `CPUCTL.halted`. -#[expect(dead_code)] +/// +/// Nothing else clears that bit, so the caller must write `MAILBOX0` before starting the +/// falcon CPU. A caller that runs this twice without an intervening write sees the first +/// suspension both times. pub (crate )fn wait_for_processor_suspend (&self) ->Result <()> {const INTERRUPT_PROCESSOR_SUSPENDED :u32 =0x8000_0000 ;
drivers/gpu/nova-core/gsp/boot.rs +227 -2
258 lines not on this page · raw message
drivers/gpu/nova-core/regs.rs +1 -0
@@ -353,6 +353,7 @@ pub(crate) fn usable_fb_size(self) -> u64 { } pub(crate) NV_PFALCON_FBIF_TRANSCFG(u32)[8] @ PFalconBase + 0x00000600 { + 3:3 engine_id_flag => bool; 2:2 mem_type => FalconFbifMemType; 1:0 target ?=> FalconFbifTarget; }
Signature · 1 line
2.55.0
PATCH 24/27 gpu: nova-core: gsp: pass the remaining log buffers to GSP-RM
In reply to John HubbardThe libos loader finds each log buffer by looking up its eight-byte name in the init argument array, so a buffer the array does not name is never written to.
Nova-core allocates six log buffers and gives all six a debugfs file, but names only three, so the other three can never read back anything but zeros.
Name all six. RMARGS moves to the end of the array, which does not matter to a loader that searches by name.
--- drivers/gpu/nova-core/gsp.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/nova-core/gsp.rs +13 -1
@@ -355,7 +355,19 @@ pub(crate) fn new( 2, LibosMemoryRegionInitArgument::new("LOGRM", &logrm.buffer), )?; - libos.init_at (3 ,LibosMemoryRegionInitArgument ::new ("RMARGS" , rmargs))?; + libos.init_at ( +3 , +LibosMemoryRegionInitArgument ::new ("LOGMNOC" , &logmnoc.buffer), + )?; + libos.init_at ( +4 , +LibosMemoryRegionInitArgument ::new ("LOGROOT" , &logroot.buffer), + )?; + libos.init_at ( +5 , +LibosMemoryRegionInitArgument ::new ("LOGRMON" , &logrmon.buffer), + )?; + libos.init_at (6 ,LibosMemoryRegionInitArgument ::new ("RMARGS" , rmargs))?; libos.into () },
Signature · 1 line
2.55.0
PATCH 23/27 gpu: nova-core: gsp: send GSP_INIT and decode its reply
In reply to John HubbardGSP-RM answers a GSP_INIT request with the static GPU configuration, and that reply is also what signals it has finished starting. It raises load-and-execute events in the meantime, so a caller must handle them rather than wait through them.
Nova-core can build the request but cannot send it: the GMC sender is private, and the receive path drops the field carrying the reply status.
Add the sender and the receive-side status field it needs, and decode the reply into the static-info type the RPC path already produces.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 49 ++++++-- drivers/gpu/nova-core/gsp/commands.rs | 140 ++++++++++++++++++++++- drivers/gpu/nova-core/gsp/fw.rs | 4 + drivers/gpu/nova-core/gsp/fw/commands.rs | 35 +++++- 4 files changed, 213 insertions(+), 15 deletions(-)
drivers/gpu/nova-core/gsp/cmdq.rs +39 -10
@@ -790,22 +790,43 @@ fn receive_msg<M: MessageFromGsp>(&self, timeout: Delta) -> Result<M> self.inner.lock ().receive_msg (timeout,None ) } -/// Receives one GMC event from the GSP and passes its command id and raw payload slices to -/// `handler`. +/// Receives one GMC element from the GSP and passes its command id, the `max_resp_or_status` +/// field, and the raw payload slices to `handler`. /// /// This method may sleep while waiting. The [`CmdqInner`] mutex stays locked across the wait /// and across the `handler` call, so `handler` must not call back into this [`Cmdq`]. /// /// See [`CmdqInner::receive_gmc_and_dispatch`] for return values, queue state, and errors. -#[expect(dead_code)] pub (crate )fn receive_gmc_and_dispatch <R >( &self, timeout:Delta , - handler:impl FnOnce (u32 , &[u8 ], &[u8 ]) ->Option <R >, + handler:impl FnOnce (u32 ,u32 , &[u8 ], &[u8 ]) ->Option <R >, ) ->Result <Option <R >> { self.inner.lock ().receive_gmc_and_dispatch (timeout, handler) } +/// Sends a GMC API command to the GSP without waiting for its response. +/// +/// A caller that expects a response reads it with [`Self::receive_gmc_and_dispatch`], which +/// lets it handle the events GSP-RM interleaves before the response arrives. +/// +/// # Errors +/// +/// - `EMSGSIZE` if the command exceeds the maximum queue element size. +/// - `ETIMEDOUT` if space does not become available within the timeout. +/// - `EIO` if the command header is not properly aligned. +pub (crate )fn send_gmc_no_wait ( + &self, + bar:Bar0 <'_>, + command_id:u32 , + payload: &[u8 ], + max_response_size:u32 , + ) ->Result { + self.inner + .lock () + .send_gmc (bar, command_id, payload, max_response_size) + } +/// Waits for an unsolicited GSP event of type `M`, dispatching any other event that arrives /// first. ///
@@ -1005,7 +1026,6 @@ fn send_command<M>(&mut self, bar: Bar0<'_>, command: M) -> Result<u32>/// - `EMSGSIZE` if the command exceeds the maximum queue element size. /// - `ETIMEDOUT` if space does not become available within the timeout. /// - `EIO` if the command header is not properly aligned. -#[expect(dead_code)] fn send_gmc ( &mut self, bar: Bar0<'_>,
@@ -1383,9 +1403,13 @@ fn wait_for_gmc_msg(&self, timeout: Delta) -> Result<GmcMessage<'_>> {/// Receive the next GMC event from the GSP and dispatch it through a handler. /// -/// The handler receives the GMC command id and the raw payload slices that follow the -/// [`super::fw::GmcApiHeader`] (two slices because the circular buffer may wrap). It returns -/// `None` for an event it does not handle. +/// The handler receives the GMC command id, the header's `max_resp_or_status` field, and the +/// raw payload slices that follow the [`super::fw::GmcApiHeader`] (two slices because the +/// circular buffer may wrap). It returns `None` for an element it does not handle. +/// +/// `max_resp_or_status` is a union: GSP-RM writes an `NV_STATUS` there when the element is a +/// response, and the maximum response size when it is a request. Only a handler that knows +/// which one it asked for can read it. /// /// Where [`Self::receive_msg`] keys on [`MsgFunction`], this keys on the GMC command id, /// which is the form the r000 firmware uses for boot events.
@@ -1401,7 +1425,7 @@ fn wait_for_gmc_msg(&self, timeout: Delta) -> Result<GmcMessage<'_>> {fn receive_gmc_and_dispatch <R >( &mut self, timeout:Delta , - handler:impl FnOnce (u32 , &[u8 ], &[u8 ]) ->Option <R >, + handler:impl FnOnce (u32 ,u32 , &[u8 ], &[u8 ]) ->Option <R >, ) ->Result <Option <R >> {let message = self.wait_for_gmc_msg (timeout)?;let header = message.header;
@@ -1420,7 +1444,12 @@ fn receive_gmc_and_dispatch<R>( length, ); -handler (command_id, message.contents.0 , message.contents.1 ) +handler ( + command_id, + header.gmc.max_resp_or_status, + message.contents.0 , + message.contents.1 , + ) }else {dev_warn! (&self.dev,"GSP GMC: dropping non-GMC queue element\n" );None
drivers/gpu/nova-core/gsp/commands.rs +138 -2
163 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw.rs +4 -0
@@ -979,6 +979,10 @@ pub(crate) struct GmcApiHeader {/// `GMCAPI_HEADER_COMMAND_ID_MASK`. The remaining byte carries flags. const GMCAPI_COMMAND_ID_MASK :u32 =0x00ff_ffff ; +/// GMC command that hands GSP-RM its system information and registry keys and returns the static +/// GPU configuration. Its reply is also what signals that GSP-RM has finished starting. +pub (crate )const GMCAPI_CMD_GSP_INIT :u32 = r000_00::GMCAPI_COMMANDS_GMCAPI_CMD_GSP_INIT ; +/// GMC command asking the driver to run the generic falcon bootloader against a descriptor the /// GSP supplies. pub(crate) const GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER: u32 =
drivers/gpu/nova-core/gsp/fw/commands.rs +32 -3
@@ -402,7 +402,7 @@ pub(crate) fn new(/// Schema for the `GSP_INIT` response. #[cfg_attr(not( CONFIG_KUNIT ), allow(dead_code))] #[derive( Default )] - struct GspInitResponseSchema => GspInitResponse { + pub(crate) struct GspInitResponseSchema => GspInitResponse { gpu_name:Array <u8 , {GspInitResponse ::MAX_GPU_NAME_LEN }, {Self ::GPU_NAME_STRING_KEY }>, fb_regions:Accumulated <FbRegionSchema >,
@@ -420,7 +420,7 @@ impl GspInitResponseSchema {/// Payload of the `GSP_INIT` response. #[cfg_attr(not( CONFIG_KUNIT ), allow(dead_code))] -struct GspInitResponse { +pub (crate )struct GspInitResponse { gpu_name:ArrayVec <u8 , {Self ::MAX_GPU_NAME_LEN }>, fb_regions:KVVec <FbRegion >, bar1_pde_base:u64 ,
@@ -428,7 +428,36 @@ struct GspInitResponse { }impl GspInitResponse { -const MAX_GPU_NAME_LEN :usize =64 ; +pub (crate )const MAX_GPU_NAME_LEN :usize =64 ; + +/// A region with no tag is general-purpose memory. A tagged region is reserved for a +/// firmware-internal use that the tag identifies. +const FB_REGION_TAG_NONE :u32 =0 ; + +/// Returns the GPU name, which GSP-RM sends with its NULL terminator. +pub (crate )fn gpu_name (&self) -> &[u8 ] { + self.gpu_name.as_slice () + } + +/// Iterates over the FB regions the driver may allocate from. +/// +/// A region qualifies when it is untagged, unprotected, and supports both compression and +/// isochronous access, which is the same set the RPC path selects from +/// [`GspStaticConfigInfo::usable_fb_regions`]. +pub (crate )fn usable_fb_regions (&self) ->impl Iterator <Item =Range <u64 >> + '_ { + self.fb_regions.iter ().filter_map (|region| { +if region.limit >= region.base + && region.tag ==Self ::FB_REGION_TAG_NONE + && !region.flags.protected () + && region.flags.support_compressed () + && region.flags.support_iso () + { + region.limit.checked_add (1 ).map (|end| region.base..end) + }else { +None + } + }) + } }nvkv_decode! {
Signature · 1 line
2.55.0
PATCH 26/27 gpu: nova-core: gsp: remove the retired system-info and static-info RPCs
In reply to John HubbardThe r000 boot path folds the system information and the static GPU configuration into the GSP_INIT request, whose reply carries that configuration back to the driver.
The set-system-info and get-static-info commands stayed behind after the switch, unreachable and marked dead, along with the two payload structures that encoded them.
Remove both commands and their payloads, and keep the decoded static configuration that the GSP_INIT reply fills in. The two message-function entries stay, because that table catalogs the wire protocol rather than what the driver implements, and already names many functions nova-core never sends.
--- drivers/gpu/nova-core/gsp.rs | 8 -- drivers/gpu/nova-core/gsp/commands.rs | 65 +------------ drivers/gpu/nova-core/gsp/fw/commands.rs | 115 +---------------------- 3 files changed, 3 insertions(+), 185 deletions(-)
drivers/gpu/nova-core/gsp.rs +0 -8
@@ -407,14 +407,6 @@ pub(crate) fn new( }) } -/// Query the GSP for the static GPU information. -/// -/// The r000 boot path gets the same information from the `GSP_INIT` reply instead. -#[expect(dead_code)] -pub (crate )fn get_static_info (&self, bar:Bar0 <'_>) ->Result <commands::GetGspStaticInfoReply > { - self.cmdq.send_command (bar, commands::GetGspStaticInfo ) - } -/// Returns a shared handle to the GSP command queue. pub (crate )fn cmdq (&self) ->Arc <Cmdq > { self.cmdq.clone ()
drivers/gpu/nova-core/gsp/commands.rs +1 -64
83 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw/commands.rs +2 -113
145 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH 25/27 gpu: nova-core: switch to the r000 GSP firmware
In reply to John HubbardThe r000 firmware changes four things about how it talks to the driver. Queue elements carry MCTP and NVDM headers and no checksum. Msgq version 2 keeps all four ring pointers in BAR0, and its head-register write doubles as the doorbell. Load-and-execute steps arrive as GMC commands rather than as RPC events. And a single GSP_INIT request replaces the system-info, registry and static-info commands, with its reply standing in for the init-done event.
None of the four can change on its own, because only one firmware version is present at a time, so a commit that changed only some of them would not boot at all.
Switch all four together. The startup arguments gain the ucodes image and the state-monitor buffer, and the FMC boot parameters gain the magic and size header that r000 expects. A missing ucodes image is now fatal, which is what Open RM requires everywhere except GB10Y. Only Turing and GA100 raise the generic-bootloader event, so the bootloader image is requested only on those chipsets.
Each load-and-execute event ends in a GSP falcon reset, which zeroes all four msgq counters. GSP-RM writes back the two counters it owns and carries on counting from where it stopped. Write the driver's two counters back the same way, counting the element just handled as consumed.
Name the r000 module in the bindings alias, so that every constant comes from the r000 headers rather than the r570 ones. The r570 headers size the GSP heap at 14 MiB of RM boot working memory on Hopper and later, and the r000 headers size it at 18 MiB.
Msgq version 2 holds the read pointer in BAR0, so the r000 headers define no RX header. Remove the driver's copy and the space it occupied. No offset changes, because the message data is page-aligned and already sits at 4096.
The r000 firmware also sizes two framebuffer carveouts differently, and the driver reserves them. Its PMU region above FRTS covers the backing store, the communication surfaces and the misc memory, which come to 25 MiB + 384 KiB, and GB20x asks for a flat 3 MiB of non-WPR heap. Both are larger than the r570 amounts, so carrying those forward under-reserves memory the firmware expects to own.
The boot events and the GSP_INIT reply replace the CPU sequencer and the wait for init-done, so neither has a caller left. Remove both, and the run-CPU-sequencer entry in the message-function table with them, so that code arriving on the queue is reported as unknown rather than decoded into types nothing acts on.
--- drivers/gpu/nova-core/driver.rs | 2 +- drivers/gpu/nova-core/fb/hal/gb100.rs | 25 +- drivers/gpu/nova-core/fb/hal/gb202.rs | 5 +- drivers/gpu/nova-core/firmware/bindata.rs | 1 - drivers/gpu/nova-core/gpu.rs | 21 +- drivers/gpu/nova-core/gsp.rs | 34 +- drivers/gpu/nova-core/gsp/boot.rs | 139 ++++-- drivers/gpu/nova-core/gsp/cmdq.rs | 365 +++++--------- drivers/gpu/nova-core/gsp/commands.rs | 68 +-- drivers/gpu/nova-core/gsp/fw.rs | 564 ++++++---------------- drivers/gpu/nova-core/gsp/hal.rs | 22 +- drivers/gpu/nova-core/gsp/hal/tu102.rs | 12 - drivers/gpu/nova-core/gsp/sequencer.rs | 379 --------------- drivers/gpu/nova-core/irq/gsp.rs | 2 +- drivers/gpu/nova-core/mctp.rs | 2 + 15 files changed, 456 insertions(+), 1185 deletions(-) delete mode 100644 drivers/gpu/nova-core/gsp/sequencer.rs
drivers/gpu/nova-core/driver.rs +1 -1
@@ -135,7 +135,7 @@ fn probe<'bound>(// SAFETY: as for the `bar` borrow above. let bar =unsafe { &*core::ptr::from_ref (bar) };crate ::irq::gsp::enable (bar, gpu.chipset (), vectors_ref.irq_type ()); - gpu.cmdq ().drain ()?; + gpu.cmdq ().drain (bar)?; }, _reg: auxiliary::Registration::new( pdev.as_ref(),
drivers/gpu/nova-core/fb/hal/gb100.rs +21 -4
@@ -80,10 +80,27 @@ fn write_sysmem_flush_page_gb100(bar: Bar0<'_>, addr: Bounded<u64, 52>) { ); } -// This PMU reservation size is r570-specific. +/// PMU backing store (see Open RM: `kpmuReservedMemoryBackingStoreSizeGet`). +const PMU_BACKING_STORE_SIZE :usize =9 *SZ_1M ; + +/// PMU communication surfaces (see Open RM: `gpuGetPmuReservedMemorySurfacesSize`). +const PMU_SURFACES_SIZE :usize =SZ_16M +SZ_256K ; + +/// Miscellaneous PMU memory (see Open RM: `kpmuReservedMemoryMiscSizeGet`). +const PMU_MISC_SIZE :usize =SZ_4K ; + +// Open RM reserves the backing store, the surfaces and the misc memory as one region above +// FRTS, aligned to KPMU_RESERVED_MEMORY_ALIGNMENT (see kpmuReservedMemorySizeGet). pub (super )const fn pmu_reserved_size_gb100 () ->u32 { -usize_into_u32 ::<{const_align_up (SZ_8M +SZ_16M +SZ_4K ,Alignment ::new ::<SZ_128K >()).unwrap () }>( - ) +usize_into_u32 ::< + { +const_align_up ( +PMU_BACKING_STORE_SIZE +PMU_SURFACES_SIZE +PMU_MISC_SIZE , +Alignment ::new ::<SZ_128K >(), + ) + .unwrap () + }, + >() }impl FbHal for Gb100 {
@@ -112,7 +129,7 @@ fn pmu_reserved_size(&self) -> u32 { }fn non_wpr_heap_size (&self) ->u64 { -// Non-WPR heap for GB10x (see Open RM: kgspGetNonWprHeapSize, GB100/GB102). +// Open RM's kgspGetNonWprHeapSize returns a flat 2 MiB for GB10x. u64::SZ_2M }
drivers/gpu/nova-core/fb/hal/gb202.rs +2 -3
@@ -72,9 +72,8 @@ fn pmu_reserved_size(&self) -> u32 { }fn non_wpr_heap_size (&self) ->u64 { -// Non-WPR heap for GB20x (see Open RM: kgspGetNonWprHeapSize, GB202+). -// This size is r570-specific. - u64::SZ_2M + u64::SZ_128K +// Open RM's kgspGetNonWprHeapSize returns a flat 3 MiB for GB20x. +3 * u64::SZ_1M }fn frts_size (&self) ->u64 {
drivers/gpu/nova-core/firmware/bindata.rs +0 -1
@@ -21,7 +21,6 @@/// A missing metadata file is reported as [`None`] so that the eventual caller can decide whether /// ucodes are optional for its boot path. Once the metadata has been found, all parse and payload /// loading errors, including a missing referenced file, are returned as errors. -#[expect(dead_code)] pub (crate )fn request_ucodes_firmware ( dev: &device::Device , chipset: Chipset,
drivers/gpu/nova-core/gpu.rs +8 -13
@@ -27,7 +27,6 @@ gsp::{ self, cmdq::Cmdq, - commands::GetGspStaticInfoReply,Gsp ,GspBootContext ,// },
@@ -276,16 +275,14 @@ struct GspResources<'gpu> {/// GSP runtime data. #[pin] gsp: Gsp, -/// GSP unload firmware bundle, if any. - unload_bundle: Option<gsp::UnloadBundle>, +/// What the GSP boot sequence produced, including the unload bundle. + boot_result: gsp::BootResult, }/// Structure holding the resources required to operate the GPU. #[pin_data] pub (crate )struct Gpu <'gpu> { spec:Spec , -/// Static GPU information as provided by the GSP. - gsp_static_info:GetGspStaticInfoReply ,/// GSP and its resources. #[pin] gsp_resources:GspResources <'gpu>,
@@ -303,7 +300,7 @@ fn drop(self: Pin<&mut Self>) {let this = self.project ();let device = *this.device;let bar = *this.bar; -let bundle = this.unload_bundle.take (); +let bundle = this.boot_result.take_unload_bundle ();let _ = this .gsp
@@ -398,10 +395,10 @@ pub(crate) fn new( gsp <- Gsp::new(pdev, spec.chipset), -// This member must be initialized last, so the `UnloadBundle` can never be dropped +// This member must be initialized last, so the unload bundle can never be dropped // from outside of the constructed `GspResources`, ensuring that the unload sequence // is properly run in case of failure. - unload_bundle: gsp.boot(GspBootContext { + boot_result: gsp.boot(GspBootContext { pdev, bar, chipset: spec.chipset,
@@ -412,9 +409,9 @@ pub(crate) fn new( })?, }), - gsp_static_info: { - // Obtain and display basic GPU information. - let info = gsp_resources.gsp.get_static_info(bar)?; + _: { +// The `GSP_INIT` reply already carried this. +let info = &gsp_resources.boot_result.static_info;match info.gpu_name () {Ok (name) =>dev_info! (dev,"GPU name: {}\n" , name),Err (e) =>dev_warn! (dev,"GPU name unavailable: {:?}\n" , e),
@@ -434,8 +431,6 @@ pub(crate) fn new( / u64::SZ_1M ); } - - info } }) }
drivers/gpu/nova-core/gsp.rs +32 -2
@@ -30,7 +30,6 @@#[cfg_attr(not( CONFIG_KUNIT ), allow(dead_code))] mod nvkv;mod regs; -mod sequencer;pub (crate )use fw::{GspFmcBootParams ,
@@ -334,8 +333,12 @@ pub(crate) fn new( Ok(try_pin_init!(Self { gsp_tlv, cmdq: Arc::pin_init(Cmdq::new(dev), GFP_KERNEL)?, - rmargs: Coherent::init(dev, GFP_KERNEL, GspArgumentsPadded::new(cmdq.as_ref()))?, rm_state_monitor: Coherent::zeroed(dev, GFP_KERNEL)?, + rmargs: Coherent::init( + dev, + GFP_KERNEL, + GspArgumentsPadded::new(cmdq.as_ref(), None, rm_state_monitor), + )?, libos: { let mut libos = CoherentBox::zeroed_slice( dev,
@@ -405,6 +408,9 @@ pub(crate) fn new( }/// Query the GSP for the static GPU information. +/// +/// The r000 boot path gets the same information from the `GSP_INIT` reply instead. +#[expect(dead_code)] pub (crate )fn get_static_info (&self, bar:Bar0 <'_>) ->Result <commands::GetGspStaticInfoReply > { self.cmdq.send_command (bar, commands::GetGspStaticInfo ) }
@@ -417,3 +423,27 @@ pub(crate) fn cmdq(&self) -> Arc<Cmdq> {/// Opaque bundle required to unload the GSP. Created by [`Gsp::boot`], consumed by [`Gsp::unload`]. pub (crate )struct UnloadBundle (KBox <dyn hal::UnloadBundle >); + +/// What a successful [`Gsp::boot`] leaves the caller. +pub (crate )struct BootResult { + unload_bundle:Option <UnloadBundle >, +/// Static GPU configuration, as reported in the `GSP_INIT` reply. +pub (crate ) static_info: commands::GetGspStaticInfoReply , +} + +impl BootResult { +pub (super )fn new ( + unload_bundle:Option <UnloadBundle >, + static_info: commands::GetGspStaticInfoReply , + ) ->Self { +Self { + unload_bundle, + static_info, + } + } + +/// Takes the unload bundle out, leaving none behind, for the teardown path. +pub (crate )fn take_unload_bundle (&mut self) ->Option <UnloadBundle > { + self.unload_bundle.take () + } +}
drivers/gpu/nova-core/gsp/boot.rs +107 -32
243 lines not on this page · raw message
drivers/gpu/nova-core/gsp/cmdq.rs +109 -256
643 lines not on this page · raw message
drivers/gpu/nova-core/gsp/commands.rs +26 -42
141 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw.rs +138 -426
782 lines not on this page · raw message
drivers/gpu/nova-core/gsp/hal.rs +9 -13
@@ -41,19 +41,6 @@ fn boot( ctx: &mut GspBootContext<'_, '_>, gsp_fw: &GspFirmware, ) -> Result<Option<crate::gsp::UnloadBundle>>; - -/// Performs HAL-specific post-GSP boot tasks. -/// -/// This method is called by the GSP boot code after the GSP is confirmed to be running, and -/// after the initialization commands have been pushed onto its queue. -fn post_boot ( - &self, - _gsp: &Gsp , - _ctx: &mut GspBootContext <'_, '_>, - _gsp_fw: &GspFirmware , - ) ->Result { -Ok (()) - } }/// Returns the names of the firmware files required to boot the GSP of `chipset`, in addition to
@@ -75,6 +62,15 @@ pub(crate) const fn boot_firmware_files(chipset: Chipset) -> &'static [&'static } } +/// Returns `true` if GSP-RM on `chipset` loads its images through the generic falcon bootloader. +/// +/// Turing and GA100 raise `GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER` during boot and need the +/// `gen_bootloader.tlv` image to service it. GA102 and later raise `GMCAPI_CMD_EXEC_HS_BINARY` +/// instead, and [`boot_firmware_files`] ships them no such image. +pub (super )const fn uses_generic_bootloader (chipset:Chipset ) ->bool { +matches! (chipset.arch (),Architecture ::Turing ) ||matches! (chipset,Chipset ::GA100 ) +} +/// Returns the GSP HAL to be used for `chipset`. pub (super )fn gsp_hal (chipset:Chipset ) -> &'staticdyn GspHal {match chipset.arch () {
drivers/gpu/nova-core/gsp/hal/tu102.rs +0 -12
@@ -40,7 +40,6 @@ UnloadBundle, // }, regs, - sequencer::GspSequencer, Gsp, GspBootContext, GspFwWprMeta, //
@@ -316,17 +315,6 @@ fn boot(Ok (unload_guard.dismiss ()) } - -fn post_boot ( - &self, - gsp: &Gsp , - ctx: &mut GspBootContext <'_, '_>, - gsp_fw: &GspFirmware , - ) ->Result { -GspSequencer ::run (&gsp.cmdq, ctx, &gsp.libos, gsp_fw.bootloader.app_version)?; - -Ok (()) - } }/// The TU102 HAL requires the use of the FWSEC bootloader.
drivers/gpu/nova-core/gsp/sequencer.rs deleted +0 -379
379 lines not on this page · raw message
drivers/gpu/nova-core/irq/gsp.rs +1 -1
@@ -178,7 +178,7 @@ fn handle(&self) -> irq::ThreadedIrqReturn {/// IRQ thread: drains and dispatches the GSP-to-CPU message queue. fn handle_threaded (&self) -> irq::IrqReturn { -if let Err (e) = self.cmdq.drain () { +if let Err (e) = self.cmdq.drain (self.bar) {// A queue that fails to drain cannot advance past the message that failed, so every // later notification would repeat this failure. Disable the source instead. self.tree
drivers/gpu/nova-core/mctp.rs +2 -0
@@ -28,6 +28,8 @@ pub(crate) enum NvdmType with TryFrom<Bounded<u32, 8>> { Cot = 0x14,/// FSP command response. FspResponse = 0x15, +/// GSP-RM RPC message. + RmRpc = 0x25,/// GMC API message (GSP command queue). GmcApi = 0x26, }
Signature · 1 line
2.55.0
PATCH 27/27 gpu: nova-core: firmware: delete the r570 bindings
In reply to John HubbardNothing referenced the r570 firmware bindings once the driver started compiling against the r000 headers, but the module stayed declared and its generated definitions kept being built.
Delete the module and its bindings, along with the last two comments that named r570.
--- drivers/gpu/nova-core/fsp.rs | 3 +- drivers/gpu/nova-core/gsp/fw.rs | 4 +- drivers/gpu/nova-core/gsp/fw/r570_144.rs | 31 - .../gpu/nova-core/gsp/fw/r570_144/bindings.rs | 1060 ----------------- 4 files changed, 3 insertions(+), 1095 deletions(-) delete mode 100644 drivers/gpu/nova-core/gsp/fw/r570_144.rs delete mode 100644 drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs
drivers/gpu/nova-core/fsp.rs +2 -1
@@ -256,7 +256,8 @@ fn frts_vidmem_offset(hal: &dyn hal::FspHal, fb_info: &FbSizes) -> Result<u64> {// As per OpenRM's `kfspPrepareBootCommands_GH100`. if fb_info.pmu_reserved_size !=0 { offset = (offset + u64::from (fb_info.pmu_reserved_size)) -// The 2 MiB alignment is r570-specific. +// Open RM aligns this to WPR granularity, which is 128 KiB. 2 MiB is a +// multiple of that and reserves at least as much. .align_up (Alignment ::new ::<SZ_2M >()) .ok_or (EINVAL )?; }
drivers/gpu/nova-core/gsp/fw.rs +1 -3
@@ -3,7 +3,6 @@pub (crate )mod commands;mod r000_00; -mod r570_144;// Alias to avoid repeating the version number with every use. use r000_00as bindings;
@@ -512,10 +511,9 @@ fn init(sequence: u32, cmd_size: usize, function: MsgFunction) -> impl Init<Self } } -/// GSP Message Element (r000 MCTP/NVDM format). +/// GSP Message Element, in the MCTP/NVDM format. /// /// This is the transport-layer header for messages exchanged with GSP-RM. -/// r000 firmware uses MCTP/NVDM framing instead of the r570 `GSP_MSG_QUEUE_ELEMENT`. #[repr( C )] pub (crate )struct GspMsgElement { mctp_magic:u32 ,
drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0 -31
@@ -1,31 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -//! Firmware bindings. -//! -//! Imports the generated bindings by `bindgen`. -//! -//! This module may not be directly used. Please abstract or re-export the needed symbols in the -//! parent module instead. - -#![allow( -dead_code, -clippy::all, -clippy::undocumented_unsafe_blocks, -clippy::ptr_as_ptr, -clippy::ref_as_ptr, -missing_docs, -non_camel_case_types, -non_upper_case_globals, -non_snake_case, -improper_ctypes, -unreachable_pub, -unsafe_op_in_unsafe_fn -)] -use kernel::ffi; -use pin_init::MaybeZeroable ; - -include! ("r570_144/bindings.rs" ); - -// SAFETY: This type has a size of zero, so its inclusion into another type should not affect their -// ability to implement `Zeroable`. -unsafe impl <T > kernel::prelude::Zeroable for __IncompleteArrayField <T > {}
drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs deleted +0 -1060
1,060 lines not on this page · raw message
Signature · 1 line
2.55.0
Re: [PATCH 02/27] gpu: nova-core: extract radix3 page table into its own module
In reply to John HubbardQuoted 6 lines · John Hubbard
let elf = {
constELF_DOWN_ALIGN: Alignment = Alignment::new::<SZ_64K>(); - letelf_size=u64::from_safe_cast(gsp_fw.size);
+ letelf_size= u64::from_safe_cast(gsp_fw.size()); letelf_addr= (boot.start - elf_size).align_down(ELF_DOWN_ALIGN);
Just FYI, the GSP images are no longer ELFs. With the transition to TLV, the actual GSP image section is extracted from the original ELF, and that image is not an ELF on GA102+.
$ file /lib/firmware/nvidia/ga102/gsp/gsp.bin /lib/firmware/nvidia/ga102/gsp/gsp.bin: OpenPGP Secret Key
It's not a PGP key either. This is just file being confused.
I probably should have changed this when I removed all the ELF code in my TLV patchset, but I didn't notice it.
Re: [PATCH 05/27] gpu: nova-core: zero-pad radix3 page table levels to page boundary
In reply to John HubbardQuoted 16 lines · John Hubbard
drivers/gpu/nova- renamed from drivers/gpu/nova-core/firmware/radix3.rs +0
-0
core/firmware/radix3.rs
indexb60611c7bea0..f14ad4e82d3d100644drivers/gpu/nova-core/firmware/radix3.rs +0
-7@@ -67,22 +67,18 @@ pub(crate) fn new<'a>( Ok(try_pin_init!(Self { data <- SGTable::new(dev, data, DataDirection::ToDevice, GFP_KERNEL), level2 <- { - VVec::<u8>::with_capacity( - data.iter().count() * core::mem::size_of::<u64>(), - GFP_KERNEL, - ) - .map_err(|_| ENOMEM) - .and_then(|level2| map_into_lvl(&data, level2)) - .map(|level2| SGTable::new(dev, level2, DataDirection::ToDevice,
Quoted 6 lines
GFP_KERNEL))?
+ let level2 = VVec::<u8>::with_capacity(lvl_size(&data),GFP_KERNEL) + .map_err(|_| ENOMEM)
+ .and_then(|level2|map_into_lvl(&data, level2))?; +
+SGTable::new(dev, level2, DataDirection::ToDevice, GFP_KERNEL)
Could you use the new Vec::zeroed() to get a buffer that's already all zeroed-out?
Re: [PATCH 07/27] gpu: nova-core: add optional ucodes firmware loading
In reply to John HubbardQuoted 8 lines · John Hubbard
+ if
file.is_empty()+ || matches!(file, "." | "..") + || file+ .bytes()
+ .any(|b| b == b'/' || b == b'\\' ||b.is_ascii_control()) + {
+ return Err(EINVAL);
+ }
I'm not sure if this is needed because request_into_buf() will reject any crazy filename that would result from an invalid FILE tag.
Quoted 5 lines
+
+ let size = usize::from_safe_cast(self.get_u32(b"SIZE")?); + if size == 0 {
+ return Err(EINVAL); // TODO: Use ENODATA once available. + }
FYI, ENODATA is already in linux-next.
Re: [PATCH 08/27] gpu: nova-core: add LIBOS3 log buffers and state monitor buffer
In reply to John HubbardQuoted 11 lines · John Hubbard
drivers/gpu/nova-core/gsp.rs +8
-0+/// Matches the registry defaults for the init, interrupt, RM, and MNOC tasks +/// (`NV_REG_STR_RM_GSP_LOG_BUFFER_SIZE_TASK_*_DEFAULT`). +type TaskLogBuffer =LogBuffer <LOG_BUFFER_SIZE ,RM_LOG_BUFFER_NUM_PAGES >; + +/// Log buffer for a task that GSP-RM gives a single page. +/// +/// Matches the size GSP-RM hardcodes for the root and RM state monitor tasks. +type SmallLogBuffer =LogBuffer <GSP_PAGE_SIZE ,1 >;drivers/gpu/nova-core/gsp.rs +1
-1-impl LogBuffer { +impl <const SIZE :usize ,const NUM_PAGES :usize >LogBuffer <SIZE ,NUM_PAGES > {
Quoted 3 lines
/// Creates a new
LogBuffermapped ondev.
fnnew(dev: &device::Device<device::Bound>)-> Result<Self> { + build_assert!(SIZE ==NUM_PAGES*GSP_PAGE_SIZE);
Why do we need to specify both NUM_PAGES and SIZE? We can always derive one from the other.
Re: [PATCH 09/27] gpu: nova-core: add build ID headers to debugfs log buffer dumps
In reply to John Hubbarddrivers/gpu/nova-core/firmware.rs line 35
Quoted 10 lines · John Hubbard
drivers/gpu/nova-core/firmware.rs +0
-0@@ -31,6 +31,40 @@ pub(crate) mod riscv; pub(crate) mod tlv;drivers/gpu/nova-core/firmware.rs +2
-0+/// Maximum length of a build ID, matching Open RM's `BUILD_ID_MAX_LENGTH`. +const BUILD_ID_MAX_LENGTH :usize =32 ;
Um, I recently made a change to the script that expands the build ID from a 32-byte hex
[3] tag="BLID" length=20
00000000 b5 9b b5 6c 76 7e 1e 34 ef 86 45 c6 73 31 f6 a6 |...lv~.4..E.s1..| 00000010 5b 8a 5c 3e |[.\>|
to a 64-byte string:
[7] tag="BLID" length=40
00000000 39 65 37 64 39 35 66 35 32 62 63 30 36 66 37 63 |9e7d95f52bc06f7c| 00000010 66 31 61 34 36 37 37 35 61 64 34 35 30 63 63 63 |f1a46775ad450ccc| 00000020 65 66 66 34 35 35 65 34 |eff455e4|
I'm assuming you want me to change that back? I didn't realize the build ID was actually going to be used by the driver.
Re: [PATCH 10/27] gpu: nova-core: rename the FbRanges elf field to fw_image
In reply to John HubbardQuoted 4 lines · John Hubbard
The framebuffer region this field describes holds the GSP firmware image. It is an ELF under 570.144 and is not one under the firmware this series moves to, so name the field for what it holds rather than for its current format.
It's not an ELF under the 570 either. It's only an ELF with non-TLV.
Re: [PATCH 07/27] gpu: nova-core: add optional ucodes firmware loading
In reply to John HubbardQuoted 8 lines · John Hubbard
+ /// Loads the payload described by this TLV into owned memory.
+ ///
+ /// The generic firmware TLV representation is either an inlineBLOB, or aFILEbasename
+ /// together with itsSIZE. Mixing the representations or specifying only half of the file
+ /// representation is invalid. Referenced files are constrained to the metadata file's + /// directory.
Quoted 8 lines
+ pub(crate) fn load_blob_or_file(
+ &self,
+ dev:&device::Device,
+ chipset:gpu::Chipset,
+ ) -> Result<VVec<u8>> {
+ lethas_blob=self.contains(b"BLOB");
+ lethas_file=self.contains(b"FILE");
+ lethas_size=self.contains(b"SIZE");
The problem with this approach is that it allocates a buffer for the BLOB and memcpys the data, even though that's not necessary if you expect the TLV to have a BLOB tag. It's highly unlikely that the driver will ever not know in advance whether a given TLV has a BLOB or a FILE tag.
We should not encourage the driver to use this function for all images. Instead, I would like to see a comment that stipulates that this function should be used in only two cases:
1) We will want to keep the image data after the TLV goes out of scope, so we want the BLOB copied into a VVec anyway.
2) We expect the TLV to have a FILE tag, but obviously it shouldn't fail if it doesn't.
Re: [PATCH 25/27] gpu: nova-core: switch to the r000 GSP firmware
In reply to John HubbardQuoted 5 lines · John Hubbard
// Perform the chipset-specific boot sequence, and retrieve the unload bundle. let
unload_bundle=hal.boot(&self, &mut ctx, &gsp_fw)?.or_else(|| { dev_warn!(dev, "The GSP won't be able to unload properly on unbind.\n");(quoted diff) +0
-0@@ -96,17 +122,41 @@ pub(crate) fn boot(
Quoted 8 lines
dev_dbg!(pdev, "RISC-V active? {}\n",
gsp_falcon.is_riscv_active(),);
- self.cmdq
- .send_command_no_wait(bar,commands::SetSystemInfo::new(pdev, chipset))?; - self.cmdq
- .send_command_no_wait(bar, commands::SetRegistry::new(ctx.vgpu.state())?)?; -
-hal.post_boot(&self, ctx, &gsp_fw)?;
FYI, my Turing fix moves the send_command_no_wait() calls to above the hal.boot() line, where it belongs, so you'll need to rebase on top of it.
Quoted 7 lines · John Hubbard
Nova-core boots the 570.144 GSP firmware today. This series moves the driver to the r000 firmware ABI, which is stable across releases, so firmware file names no longer carry a version number.
The actual firmware is not yet publicly available, so this series is for early review, and should not be merged until the corresponding firmware shows up.
I'm not familiar with the new boot process for "r000", so FWIW:
Re: [PATCH 09/27] gpu: nova-core: add build ID headers to debugfs log buffer dumps
In reply to Timur TabiQuoted 22 lines · Timur Tabi
drivers/gpu/nova-core/firmware.rs line 35
Quoted 10 lines · John Hubbard
drivers/gpu/nova-core/firmware.rs +0
-0@@ -31,6 +31,40 @@ pub(crate) mod riscv; pub(crate) mod tlv;drivers/gpu/nova-core/firmware.rs +2
-0+/// Maximum length of a build ID, matching Open RM's `BUILD_ID_MAX_LENGTH`. +const BUILD_ID_MAX_LENGTH :usize =32 ;Um, I recently made a change to the script that expands the build ID from a 32-byte hex
[3] tag="BLID" length=20
00000000 b5 9b b5 6c 76 7e 1e 34 ef 86 45 c6 73 31 f6 a6 |...lv~.4..E.s1..| 00000010 5b 8a 5c 3e |[.\>|to a 64-byte string:
Quoted 7 lines
[7] tag="BLID" length=40
00000000 39 65 37 64 39 35 66 35 32 62 63 30 36 66 37 63 |9e7d95f52bc06f7c| 00000010 66 31 61 34 36 37 37 35 61 64 34 35 30 63 63 63 |f1a46775ad450ccc| 00000020 65 66 66 34 35 35 65 34 |eff455e4|I'm assuming you want me to change that back? I didn't realize the build ID was actually going to be used by the driver.
Well, let's do whatever is best. If you really want/need BLID to be 64 bytes then I can update this series to match.
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH 10/27] gpu: nova-core: rename the FbRanges elf field to fw_image
In reply to Timur TabiQuoted 7 lines · Timur Tabi
Quoted 4 lines · John Hubbard
The framebuffer region this field describes holds the GSP firmware image. It is an ELF under 570.144 and is not one under the firmware this series moves to, so name the field for what it holds rather than for its current format.
It's not an ELF under the 570 either. It's only an ELF with non-TLV.
Yes. I'll fix that to reflect that.
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH 25/27] gpu: nova-core: switch to the r000 GSP firmware
In reply to Timur TabiQuoted 1 line · Timur Tabi
On Tue, 2026-08-18 at 20:52 -0700, John Hubbard wrote:
...>> @@ -96,17 +122,41 @@ pub(crate) fn boot(
Quoted 10 lines
Quoted 9 lines
dev_dbg!(pdev, "RISC-V active? {}\n",gsp_falcon.is_riscv_active(),);
- self.cmdq
- .send_command_no_wait(bar,commands::SetSystemInfo::new(pdev, chipset))?; - self.cmdq
- .send_command_no_wait(bar, commands::SetRegistry::new(ctx.vgpu.state())?)?; -
-hal.post_boot(&self, ctx, &gsp_fw)?;
Quoted 3 lines
FYI, my Turing fix moves the
send_command_no_wait()calls to above thehal.boot()line, where it belongs, so you'll need to rebase on top of it.
Thanks for the heads up on that!
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH 02/27] gpu: nova-core: extract radix3 page table into its own module
In reply to Timur TabiQuoted 11 lines · Timur Tabi
Quoted 6 lines · John Hubbard
let elf = {
constELF_DOWN_ALIGN: Alignment = Alignment::new::<SZ_64K>(); - letelf_size=u64::from_safe_cast(gsp_fw.size);
+ letelf_size= u64::from_safe_cast(gsp_fw.size()); letelf_addr= (boot.start - elf_size).align_down(ELF_DOWN_ALIGN);Just FYI, the GSP images are no longer ELFs. With the transition to TLV, the actual GSP image section is extracted from the original ELF, and that image is not an ELF on GA102+.
Yes. In fact I removed all mention of ELF and elf, by the end of this series.
Quoted 4 lines
$ file /lib/firmware/nvidia/ga102/gsp/gsp.bin /lib/firmware/nvidia/ga102/gsp/gsp.bin: OpenPGP Secret KeyIt's not a PGP key either. This is just
filebeing confused.
lol
Quoted 3 lines
I probably should have changed this when I removed all the ELF code in my TLV patchset, but I didn't notice it.
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH 09/27] gpu: nova-core: add build ID headers to debugfs log buffer dumps
In reply to John HubbardQuoted 6 lines · John Hubbard
Quoted 3 lines
I'm assuming you want me to change that back? I didn't realize the build ID was actually going
to be used by the driver.Well, let's do whatever is best. If you really want/need BLID to be 64 bytes then I can update this series to match.
You would need to run some ascii_to_hex command on the string to turn it back to 32 bytes, which is silly. I made it 64 bytes because I thought the only use case for it was to display it.
Re: [PATCH 09/27] gpu: nova-core: add build ID headers to debugfs log buffer dumps
Quoted 10 lines · Timur Tabi
Quoted 6 lines · John Hubbard
Quoted 3 lines
I'm assuming you want me to change that back? I didn't realize the build ID was actually going
to be used by the driver.Well, let's do whatever is best. If you really want/need BLID to be 64 bytes then I can update this series to match.
You would need to run some
ascii_to_hexcommand on the string to turn it back to 32 bytes, which is silly. I made it 64 bytes because I thought the only use case for it was to display it.
OK, yes, please change it back, then. Having BLID here is of course incredibly convenient, because we can avoid all kinds of difficulty in decoding the logs. The decoder really prefers having this, and then it does the right thing.
I've tested log decoding with this series and it is working nicely, btw.
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH 05/27] gpu: nova-core: zero-pad radix3 page table levels to page boundary
In reply to Timur TabiQuoted 17 lines · Timur Tabi
Quoted 16 lines · John Hubbard
drivers/gpu/nova- renamed from drivers/gpu/nova-core/firmware/radix3.rs +0
-0
core/firmware/radix3.rs
indexb60611c7bea0..f14ad4e82d3d100644drivers/gpu/nova-core/firmware/radix3.rs +0
-7@@ -67,22 +67,18 @@ pub(crate) fn new<'a>( Ok(try_pin_init!(Self { data <- SGTable::new(dev, data, DataDirection::ToDevice, GFP_KERNEL), level2 <- { - VVec::<u8>::with_capacity( - data.iter().count() * core::mem::size_of::<u64>(), - GFP_KERNEL, - ) - .map_err(|_| ENOMEM) - .and_then(|level2| map_into_lvl(&data, level2)) - .map(|level2| SGTable::new(dev, level2, DataDirection::ToDevice,
Quoted 8 lines
Quoted 6 lines
GFP_KERNEL))?
+ let level2 = VVec::<u8>::with_capacity(lvl_size(&data),GFP_KERNEL) + .map_err(|_| ENOMEM)
+ .and_then(|level2|map_into_lvl(&data, level2))?; +
+SGTable::new(dev, level2, DataDirection::ToDevice, GFP_KERNEL)Could you use the new
Vec::zeroed()to get a buffer that's already all zeroed-out?
Yes. The incremental diff below does that, and is passing my runtime tests:
<blueforge> linux-github (nova-core-run-on-r615-or-later-v2)$ git d -- drivers/gpu/nova-core/firmware/radix3.rs
drivers/gpu/nova-core/firmware/radix3.rs +19 -15
@@ -67,16 +67,12 @@ pub(crate) fn new<'a>( Ok(try_pin_init!(Self { data <- SGTable::new(dev, data, DataDirection::ToDevice, GFP_KERNEL), level2 <- { - let level2 = VVec::<u8>::with_capacity(lvl_size(&data), GFP_KERNEL) - .map_err(|_| ENOMEM) - .and_then(|level2| map_into_lvl(&data, level2))?; + let level2 = build_lvl(&data)?; SGTable::new(dev, level2, DataDirection::ToDevice, GFP_KERNEL) }, level1 <- { - let level1 = VVec::<u8>::with_capacity(lvl_size(&level2), GFP_KERNEL) - .map_err(|_| ENOMEM) - .and_then(|level1| map_into_lvl(&level2, level1))?; + let level1 = build_lvl(&level2)?; SGTable::new(dev, level1, DataDirection::ToDevice, GFP_KERNEL) },
@@ -110,7 +106,7 @@ pub(crate) fn size(&self) -> usize { }/// Returns the size, in bytes, of the page table level that maps `sg_table`: one `u64` entry per -/// 4KB page it spans, rounded up to the page boundary that [`map_into_lvl`] pads to. +/// 4KB page it spans, rounded up to a whole number of `GSP_PAGE_SIZE` pages. fn lvl_size (sg_table: &SGTable <Owned <VVec <u8 >>>) ->usize {let entries:usize = sg_table .iter ()
@@ -120,26 +116,34 @@ fn lvl_size(sg_table: &SGTable<Owned<VVec<u8>>>) -> usize { (entries *size_of ::<u64 >()).next_multiple_of (GSP_PAGE_SIZE ) } -/// Build a page table from a scatter-gather list. +/// Builds a page table level from a scatter-gather list. /// /// Takes each DMA-mapped region from `sg_table` and writes page table entries /// for all 4KB pages within that region. For example, a 16KB SG entry becomes /// 4 consecutive page table entries. -fn map_into_lvl (sg_table: &SGTable <Owned <VVec <u8 >>>,mut dst:VVec <u8 >) ->Result <VVec <u8 >> { +/// +/// The returned buffer spans a whole number of `GSP_PAGE_SIZE` pages, and every byte past the +/// last entry is zero. The booter DMAs each level a whole page at a time. +/// +/// Returns `ENOMEM` if the level cannot be allocated, and `EINVAL` if `sg_table` spans more +/// pages than [`lvl_size`] accounted for. +fn build_lvl (sg_table: &SGTable <Owned <VVec <u8 >>>) ->Result <VVec <u8 >> { +let mut dst =VVec ::<u8 >::zeroed (lvl_size (sg_table),GFP_KERNEL ).map_err (|_|ENOMEM )?; +let mut entries = dst.chunks_exact_mut (size_of ::<u64 >()); +for sg_entryin sg_table.iter () {let num_pages = usize::from_safe_cast (sg_entry.dma_len ()).div_ceil (GSP_PAGE_SIZE );for iin 0 ..num_pages {let entry = sg_entry.dma_address () + (u64::from_safe_cast (i) * u64::from_safe_cast (GSP_PAGE_SIZE )); - dst.extend_from_slice (&entry.to_le_bytes (),GFP_KERNEL )?; + + entries + .next () + .ok_or (EINVAL )? + .copy_from_slice (&entry.to_le_bytes ()); } } -// The last page of a level is only partly filled, and the booter DMAs each level a -// whole page at a time, so no entry past the last valid one may hold a stale address. -let padded = dst.len ().next_multiple_of (GSP_PAGE_SIZE ); - dst.resize (padded,0 ,GFP_KERNEL )?; -Ok (dst) }
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH 07/27] gpu: nova-core: add optional ucodes firmware loading
In reply to Timur TabiQuoted 10 lines · Timur Tabi
Quoted 8 lines · John Hubbard
+ if
file.is_empty()+ || matches!(file, "." | "..") + || file+ .bytes()
+ .any(|b| b == b'/' || b == b'\\' ||b.is_ascii_control()) + {
+ return Err(EINVAL);
+ }
Quoted 2 lines
I'm not sure if this is needed because
request_into_buf()will reject any crazy filename that would result from an invalid FILE tag.
OK, mostly yes. I'll simplify the checks down to just looking for empty, ".", "..", or "/".
Quoted 9 lines
Quoted 6 lines
+
+ let size = usize::from_safe_cast(self.get_u32(b"SIZE")?); + if size == 0 {
+ return Err(EINVAL); // TODO: Use ENODATA once available. + }FYI, ENODATA is already in linux-next.
OK, I'll just cherry pick it into my branch as a prerequisite, for v2, and use ENODATA here and get rid of that TODO.
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH 08/27] gpu: nova-core: add LIBOS3 log buffers and state monitor buffer
In reply to Timur TabiQuoted 17 lines · Timur Tabi
Quoted 11 lines · John Hubbard
drivers/gpu/nova-core/gsp.rs +8
-0+/// Matches the registry defaults for the init, interrupt, RM, and MNOC tasks +/// (`NV_REG_STR_RM_GSP_LOG_BUFFER_SIZE_TASK_*_DEFAULT`). +type TaskLogBuffer =LogBuffer <LOG_BUFFER_SIZE ,RM_LOG_BUFFER_NUM_PAGES >; + +/// Log buffer for a task that GSP-RM gives a single page. +/// +/// Matches the size GSP-RM hardcodes for the root and RM state monitor tasks. +type SmallLogBuffer =LogBuffer <GSP_PAGE_SIZE ,1 >;drivers/gpu/nova-core/gsp.rs +1
-1-impl LogBuffer { +impl <const SIZE :usize ,const NUM_PAGES :usize >LogBuffer <SIZE ,NUM_PAGES > {Quoted 3 lines
/// Creates a new
LogBuffermapped ondev.
fnnew(dev: &device::Device<device::Bound>)-> Result<Self> { + build_assert!(SIZE ==NUM_PAGES*GSP_PAGE_SIZE);Why do we need to specify both
NUM_PAGESand SIZE? We can always derive one from the other.
OK yes. As long as we use NUM_PAGES, it works. I'll do that.
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH 07/27] gpu: nova-core: add optional ucodes firmware loading
In reply to Timur TabiQuoted 22 lines · Timur Tabi
Quoted 8 lines · John Hubbard
+ /// Loads the payload described by this TLV into owned memory.
+ ///
+ /// The generic firmware TLV representation is either an inlineBLOB, or aFILEbasename
+ /// together with itsSIZE. Mixing the representations or specifying only half of the file
+ /// representation is invalid. Referenced files are constrained to the metadata file's + /// directory.Quoted 8 lines
+ pub(crate) fn load_blob_or_file(
+ &self,
+ dev:&device::Device,
+ chipset:gpu::Chipset,
+ ) -> Result<VVec<u8>> {
+ lethas_blob=self.contains(b"BLOB");
+ lethas_file=self.contains(b"FILE");
+ lethas_size=self.contains(b"SIZE");The problem with this approach is that it allocates a buffer for the BLOB and memcpys the data, even though that's not necessary if you expect the TLV to have a BLOB tag. It's highly unlikely that the driver will ever not know in advance whether a given TLV has a BLOB or a FILE tag.
Quoted 8 lines
We should not encourage the driver to use this function for all images. Instead, I would like to see a comment that stipulates that this function should be used in only two cases:
1) We will want to keep the image data after the TLV goes out of scope, so we want the BLOB copied into a VVec anyway.
2) We expect the TLV to have a FILE tag, but obviously it shouldn't fail if it doesn't.
OK, let me go tighten this up accordingly, yes.
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH 03/27] gpu: nova-core: set MCTP transport header version to 1
In reply to John HubbardOn Tue, 18 Aug 2026 20:51:56 -0700
John Hubbard <[email protected]> wrote:
One nit: might be better to update the doc as well.
(quoted diff) +0 -0
b/Documentation/gpu/nova/core/fsp.rst index 52d618d22bb8..60c647181da0 100644 --- a/Documentation/gpu/nova/core/fsp.rst
+++ b/Documentation/gpu/nova/core/fsp.rst
@@ -106,6 +106,8 @@ All FSP messages share a common header format consisting of two 32-bit words:
- Bit 30: EOM (End of Message)
- Bits 29:28: Packet sequence number
- Bits 23:16: Source Endpoint ID
+- Bits 15:8: Destination Endpoint ID +- Bits 3:0: MCTP header version (1)
**NVDM header** (NVIDIA Vendor Defined Message):
Quoted 47 lines
FSP requires MCTP transport header version 1. Nova-core leaves version bits 3:0 at zero, so every CoT and PRC request carries an invalid transport header.
Define the version and destination endpoint ID fields. Set the version to 1 for single-packet requests, and leave the unused destination endpoint ID at zero.
Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/mctp.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/nova-core/mctp.rsindex90c642c91a72..03546213da28100644 ---a/drivers/gpu/nova-core/mctp.rs
+++b/drivers/gpu/nova-core/mctp.rs(quoted diff) +4
-1@@ -42,13 +42,23 @@ pub(crate) struct MctpHeader(u32) { 29:28 seq; /// Source endpoint ID. 23:16 seid; + /// Destination endpoint ID. + 15:8 deid; + /// MCTP header version. + 3:0 version; } } impl MctpHeader { - /// Builds a single-packet MCTP header (`SOM=1`, `EOM=1`,
SEQ=0,SEID=0).(quoted diff) +4
-0+ /// MCTP specification version 1.0. + const VERSION: u32 = 1; + + /// Builds a single-packet MCTP header (`SOM=1`, `EOM=1`,
SEQ=0,SEID=0,VERSION=1). pub(crate) fnsingle_packet()-> Self {(quoted diff) +4
-1- Self::zeroed().with_som(true).with_eom(true) + Self::zeroed() + .with_const_version::<{ Self::VERSION }>() + .with_som(true) + .with_eom(true) } /// Returns whether this is a complete single-packet message(
SOM=1andEOM=1).
Re: [PATCH 04/27] gpu: nova-core: add Falcon helpers for r000 LOAD_EXEC events
In reply to John HubbardOn Tue, 18 Aug 2026 20:51:57 -0700
John Hubbard <[email protected]> wrote:
Looking good to me (double checking the flows aligned with r000 firmware) with one nit below.
Quoted 9 lines
The r000
LOAD_EXECevents provide addresses for images that the driver must copy into GSP Falcon IMEM and DMEM. The existing Falcon DMA path creates its source buffer from a FalconFirmware object, so it cannot use those addresses. The protocol also reports GSP RISC-V suspension through MAILBOX0 bit 31 rather than CPUCTL.halted.Add Falcon operations for DMA from event-provided addresses and for the RISC-V suspend indication.
snip
Review
Quoted 11 lines
+ regs::NV_PFALCON_FALCON_DMATRFMOFFS::zeroed().try_with_offs(dst_offset
+ pos)?,drivers/gpu/nova-core/falcon.rs +4
-0+ ); + self.bar.write ( + WithBase::of::<E>(), +regs::NV_PFALCON_FALCON_DMATRFFBOFFS::zeroed().with_offs(src_offset + pos),
(quoted diff) +2
-0+ ); +
Should we think of using check_add() here?
Z.
Quoted 58 lines
drivers/gpu/nova-core/falcon.rs +4
-0+ self.bar.write (WithBase ::of ::<E >(), cmd); + + read_poll_timeout( + ||Ok(self.bar.read(regs::NV_PFALCON_FALCON_DMATRFCMD::of::<E>())),
drivers/gpu/nova-core/falcon.rs +9
-0+ |r| r.idle(), + Delta::ZERO, + Delta::from_secs(2), + )?; + } + +Ok (()) + } +/// Perform a DMA load into `IMEM` and `DMEM` of `fw`, and prepare the falcon to run it. fn dma_load<F: FalconFirmware<Target = E> + FalconDmaLoadable>(&self, fw: &F) -> Result { // DMA object with E> firmware content as the source of the DMA engine.
drivers/gpu/nova-core/falcon.rs +3
-0@@ -647,6 +763,24 @@ pub(crate) fn wait_till_halted(&self) ->Result <()> {Ok (()) } +/// Wait until the GSP processor has suspended. +/// +/// The RISC-V GSP signals suspension by setting bit 31 (
0x8000_0000) inMAILBOX0, ratherdrivers/gpu/nova-core/falcon.rs +15
-0+/// than through `CPUCTL.halted`. +#[expect(dead_code)] +pub (crate )fn wait_for_processor_suspend (&self) ->Result <()> { +const INTERRUPT_PROCESSOR_SUSPENDED :u32 =0x8000_0000 ; + +read_poll_timeout ( + ||Ok (self.read_mailbox0 ()), + |val| (*val &INTERRUPT_PROCESSOR_SUSPENDED ) !=0 , +Delta ::ZERO , +Delta ::from_secs (2 ), + )?; + +Ok (()) + } +/// Start the falcon CPU. pub (crate )fn start (&self) ->Result <()> { match self(quoted diff) +0
-0
b/drivers/gpu/nova-core/regs.rsindex01fde2c5e5a6..5d265b5788e3100644 ---a/drivers/gpu/nova-core/regs.rs
+++b/drivers/gpu/nova-core/regs.rsdrivers/gpu/nova-core/regs.rs +1
-1@@ -264,7 +264,7 @@ pub(crate) fn usable_fb_size(self) -> u64 { } pub(crate) NV_PFALCON_FALCON_DMATRFCMD(u32) @ PFalconBase + 0x00000118 { - 16:16 set_dmtag; + 16:16 set_dmtag => bool; 14:12 ctxdma; 10:8 size ?=> DmaTrfCmdSize;5:5 is_write => bool;
Re: [PATCH 06/27] gpu: nova-core: distinguish async GSP RPC traffic in debug logs
In reply to John HubbardOn Tue, 18 Aug 2026 20:51:59 -0700
John Hubbard <[email protected]> wrote:
Looks good to me with one nit: should we use wrapping_add(1) for tx_async_seq/rx_event_seq?
Z.
Quoted 301 lines
The receive path logged every message at the transport layer and did not distinguish events from command replies. Async sends shared the RPC sequence with waited-for commands, and GSP-initiated events arrived with that field unset.
Print a distinct debug line for async send, sync send, event, and command reply. Number async sends and events with driver-local counters.
IS_ASYNCselects only the send log line. Every command still carries the next RPC sequence on the wire.Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/gsp/cmdq.rs | 111 ++++++++++++++---- .../gpu/nova-core/gsp/cmdq/continuation.rs | 1 + drivers/gpu/nova-core/gsp/commands.rs | 2 + drivers/gpu/nova-core/gsp/fw.rs | 19 +++ 4 files changed, 107 insertions(+), 26 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/cmdq.rsindexac3e6642031a..d3afe3f9bb37100644 ---a/drivers/gpu/nova-core/gsp/cmdq.rs
+++b/drivers/gpu/nova-core/gsp/cmdq.rsdrivers/gpu/nova-core/gsp/cmdq.rs +3
-0@@ -87,6 +87,12 @@ pub(crate) trait CommandToGsp {/// Function identifying this command to the GSP. const FUNCTION :MsgFunction ; +/// Classifies the send-side debug log as an async send. +/// +/// Default is `false`. Set this only on commands that are sent without waiting for a reply. A
+ /// [NoReply] continuation of a waited-for command staysfalse.drivers/gpu/nova-core/gsp/cmdq.rs +2
-0+const IS_ASYNC :bool =false ; +/// Type generated by [`CommandToGsp::init`], to be written into the command queue buffer. type Command: FromBytes + AsBytes;
drivers/gpu/nova-core/gsp/cmdq.rs +2
-0@@ -528,6 +534,8 @@ pub(crate) fn new(dev: &device::Device<device::Bound>) -> impl PinInit<Self, Err gsp_mem, elem_seq: 0, rpc_seq: 0, + tx_async_seq: 0, + rx_event_seq: 0, poisoned: Cell::new(false), }), }))@@ -672,6 +680,12 @@ struct CmdqInner {/// [`CmdqInner::receive_msg`] match that reply to the awaiting command. Advances once per /// logical command.
rpc_seq: u32,+ /// Debug-log sequence for async sends. Those commands do not
wait for a reply, so thisdrivers/gpu/nova-core/gsp/cmdq.rs +3
-0+/// counter is the number printed in the send log. + tx_async_seq: u32, +/// Debug-log sequence for GSP-initiated events. The GSP leaves the RPC sequence unset on
drivers/gpu/nova-core/gsp/cmdq.rs +2
-0+/// those messages, so the driver numbers them itself. + rx_event_seq: u32,/// Set once a message with corrupt framing or a bad checksum is seen. Such a message has an /// untrusted length, so the queue cannot be advanced past it, and every later receive fails /// until the queue is torn down and reset. @@ -738,13 +752,24 @@ fn send_single_command<M>(&mut self, bar: Bar0<'_>, command: M,
rpc_seq:
u32) -> dst.contents.1, ])));drivers/gpu/nova-core/gsp/cmdq.rs +4
-7-dev_dbg! ( - &self.dev, -"GSP RPC: send: seq# {}, function={:?}, length=0x{:x}\n" , - rpc_seq, -M ::FUNCTION , - dst.header.length (), - ); +if M ::IS_ASYNC { +dev_dbg! ( + &self.dev, + "GSP RPC: async send: seq# {}, function={:?},length=0x{:x}\n",
drivers/gpu/nova-core/gsp/cmdq.rs +9
-0+ self.tx_async_seq, + M::FUNCTION, + dst.header.length(), + ); + self.tx_async_seq +=1 ; + }else { +dev_dbg! ( + &self.dev, + "GSP RPC: send: seq# {}, function={:?},length=0x{:x}\n",
drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+ rpc_seq, + M::FUNCTION, + dst.header.length(), + ); + }// All set - update the write pointer and inform the GSP of the new command. let
elem_count=dst.header.element_count();drivers/gpu/nova-core/gsp/cmdq.rs +0
-8@@ -826,14 +851,6 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> { return Err(EIO); }; -dev_dbg! ( - &self.dev, -"GSP RPC: receive: seq# {}, function={:?}, length=0x{:x}\n", - header.sequence (), - header.function (), - header.length (), - ); - let payload_length = header.payload_length();// Check that the driver read area is large enough for the message. @@ -877,6 +894,41 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> { }) }+ /// Writes the classified receive debug line for a decoded GSP
message.(quoted diff) +2
-0+ /// + /// Events print [`Self::rx_event_seq`]. Command replies print
seq. An unrecognized function(quoted diff) +2
-0+ /// code prints nothing here. + fn log_received(&self, function: Result<MsgFunction, u32>, seq:u32, length: usize) {
drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+match function { +Ok (f)if f.is_event () => { +dev_dbg! ( + &self.dev, + "GSP RPC: async received: seq# {},function={:?}, length=0x{:x}\n",
drivers/gpu/nova-core/gsp/cmdq.rs +9
-0+ self.rx_event_seq, + f, + length, + ); + } + Ok(f) => { +dev_dbg! ( + &self.dev, + "GSP RPC: response received: seq# {},function={:?}, length=0x{:x}\n",
drivers/gpu/nova-core/gsp/cmdq.rs +10
-0+ seq, + f, + length, + ); + } + Err(_) => {} + } + } + +/// Advances [`Self::rx_event_seq`] after a GSP-initiated event has been consumed.
+ fn advance_rx_event_seq(&mut self, function: Result<MsgFunction,
u32>) {drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+if matches! (function,Ok (f)if f.is_event ()) { + self.rx_event_seq +=1 ; + } + } +/// Receive a message from the GSP. /// /// The expected message type is given by the `M` generic parameter. With
expected_seqset, @@ -910,9 +962,12 @@ fn receive_msg<M: MessageFromGsp>( let message =self.wait_for_msg(timeout)?; let function = message.header.function(); let seq = message.header.sequence(); + let length = message.header.length(); let func_matches = matches!(function, Ok(f) if f ==
M::FUNCTION); let matched =func_matches&&expected_seq.is_none_or(|expected| seq == expected);drivers/gpu/nova-core/gsp/cmdq.rs +2
-0+ self.log_received (function, seq, length); +// Every path must advance the read pointer past this message, including a failed decode. let result = if matched {
match M::Message::from_bytes_prefix(message.contents.0) {drivers/gpu/nova-core/gsp/cmdq.rs +4
-3@@ -938,9 +993,10 @@ fn receive_msg<M: MessageFromGsp>( };// Advance the read pointer past this message. - self.gsp_mem.advance_cpu_read_ptr (u32::try_from ( - message.header.length ().div_ceil (GSP_PAGE_SIZE ), - )?); + self.gsp_mem + .advance_cpu_read_ptr (u32::try_from (length.div_ceil (GSP_PAGE_SIZE ))?); + + self.advance_rx_event_seq (function);if !matched {if func_matches {(quoted diff) +0
-0@@ -962,8 +1018,8 @@ fn receive_msg<M: MessageFromGsp>( /// Routes a GSP message that is not the reply a caller iswaiting for. ///
/// GSP-reported errors are logged at error level andunrecognized function codes at warning
- /// level. Every other known function code is consumed without a
log line, because the RPC
- /// receive trace in [Self::wait_for_msg] already records its
arrival.
+ /// level. Every other known function code is consumed without a
log line, because
+ /// [Self::log_received] already records its arrival.
fn dispatch_event(&self, function: Result<MsgFunction, u32>,seq: u32) { match function { Ok(MsgFunction::OsErrorLog) => {drivers/gpu/nova-core/gsp/cmdq.rs +0
-3@@ -1004,16 +1060,19 @@ fn drain(&mut self) -> Result {while !self.gsp_mem.driver_read_area ().0 .is_empty () {// A message is available, so this returns without waiting. let msg = self.wait_for_msg(Delta::ZERO)?; - - let pages = -u32::try_from(msg.header.length().div_ceil(GSP_PAGE_SIZE)).map_err(|_| {
- dev_err!(&self.dev, "GSP drain: message length
overflow\n");drivers/gpu/nova-core/gsp/cmdq.rs +5
-2-EIO - })?;let function = msg.header.function ();let seq = msg.header.sequence (); +let length = msg.header.length (); + + self.log_received (function, seq, length); + + let pages =u32::try_from(length.div_ceil(GSP_PAGE_SIZE)).map_err(|_| {
+ dev_err!(&self.dev, "GSP drain: message length
overflow\n");drivers/gpu/nova-core/gsp/cmdq.rs +3
-0+EIO + })?; self.gsp_mem.advance_cpu_read_ptr (pages); + self.advance_rx_event_seq (function); self.dispatch_event (function, seq); }(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/cmdq/continuation.rsindex05e904f18097..a606c7be52a7100644 ---a/drivers/gpu/nova-core/gsp/cmdq/continuation.rs+++b/drivers/gpu/nova-core/gsp/cmdq/continuation.rs@@ -147,6 +147,7 @@ fnnew(command: C, payload: KVVec<u8>)-> Self {impl<C: CommandToGsp> CommandToGsp for SplitCommand<C> { const FUNCTION: MsgFunction = C::FUNCTION;drivers/gpu/nova-core/gsp/cmdq/continuation.rs +1
-0+const IS_ASYNC :bool =C ::IS_ASYNC ;type Command =C ::Command ;type Reply =C ::Reply ;type InitError =C ::InitError ;(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/commands.rsindex61fe93db9e7e..d5575c036eb9100644 ---a/drivers/gpu/nova-core/gsp/commands.rs+++b/drivers/gpu/nova-core/gsp/commands.rs@@ -52,6 +52,7 @@ pub(crate) fnnew(pdev: &'a pci::Device<device::Bound>, chipset: Chipset)-> Selimpl<'a> CommandToGsp for SetSystemInfo<'a> { const FUNCTION: MsgFunction = MsgFunction::GspSetSystemInfo;drivers/gpu/nova-core/gsp/commands.rs +2
-0+const IS_ASYNC :bool =true ;type Command = fw::commands::GspSetSystemInfo ;type Reply =NoReply ;type InitError =Error ;@@ -122,6 +123,7 @@ pub(crate) fn new(vgpu_state: VgpuState) ->Result <Self > {impl CommandToGsp for SetRegistry {const FUNCTION :MsgFunction =MsgFunction ::SetRegistry ; +const IS_ASYNC :bool =true ;type Command = fw::commands::PackedRegistryTable ;type Reply =NoReply ;type InitError =Infallible ;(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/fw.rsindexd3678f16750a..857d53c77297100644 ---a/drivers/gpu/nova-core/gsp/fw.rs
+++b/drivers/gpu/nova-core/gsp/fw.rsdrivers/gpu/nova-core/gsp/fw.rs +2
-0@@ -359,6 +359,25 @@ fn try_from(value: u32) -> Result<MsgFunction> { } } +impl MsgFunction { +/// Returns true if this is a GSP-initiated async event (
NV_VGPU_MSG_EVENT_*), as opposed todrivers/gpu/nova-core/gsp/fw.rs +17
-0+/// a command response (`NV_VGPU_MSG_FUNCTION_*`). +pub (crate )fn is_event (&self) ->bool { +matches! ( + self, +Self ::GspInitDone + |Self ::GspRunCpuSequencer + |Self ::PostEvent + |Self ::RcTriggered + |Self ::MmuFaultQueued + |Self ::OsErrorLog + |Self ::GspPostNoCat + |Self ::GspLockdownNotice + |Self ::UcodeLibOsPrint // + ) + } +} +impl From <MsgFunction >for u32 {fn from (value:MsgFunction ) ->Self {// CAST: `MsgFunction` is `repr(u32)` and can thus be cast losslessly.
Re: [PATCH 11/27] gpu: nova-core: regs: add msgq v2 BAR0 register declarations
In reply to John HubbardOn Tue, 18 Aug 2026 20:52:04 -0700
John Hubbard <[email protected]> wrote:
Looking good to me.
Z.
Quoted 63 lines
Msgq v2 moves the four ring pointers out of the in-memory headers and into BAR0.
NV_PGSP_QUEUE_HEADalready exists as the v0 doorbell, so addNV_PGSP_QUEUE_TAIL,NV_PGSP_MSGQ_HEAD, andNV_PGSP_MSGQ_TAILat the queue-0 offsets.Nova only uses queue 0, so the registers are scalars rather than 8-element arrays. A comment records the full hardware layout for future multi-queue work.
Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/gsp/regs.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/regs.rsindex9a48aa87e7fb..d2e40ed13123100644 ---a/drivers/gpu/nova-core/gsp/regs.rs
+++b/drivers/gpu/nova-core/gsp/regs.rsdrivers/gpu/nova-core/gsp/regs.rs +2
-0@@ -5,6 +5,18 @@use crate ::regs::NV_PBUS_SW_SCRATCH ;// PGSP +// +// The msgq v2 wire protocol replaces the in-memory ring pointers with four +// BAR0 registers per queue:
(quoted diff) +2
-0+// +// NV_PGSP_QUEUE_HEAD[i] @ 0x00110c00 + i*8 (CPU TX write,doorbell) +// NV_PGSP_QUEUE_TAIL[i] @
0x00110c04+ i*8 (GSP TX
read) +// NV_PGSP_MSGQ_HEAD[i] @0x00110c80+ i*8 (GSP RX write)drivers/gpu/nova-core/gsp/regs.rs +3
-0+// NV_PGSP_MSGQ_TAIL[i] @ 0x00110c84 + i*8 (CPU RX read) +// +// Nova only uses queue 0, so the four registers are declared as single +// scalars at the i=0 offsets.
NV_PGSP_QUEUE_HEADis also used as the v0 +// doorbell, which is why it predates the others.register! { pub(super) NV_PGSP_QUEUE_HEAD(u32) @ 0x00110c00 {drivers/gpu/nova-core/gsp/regs.rs +18
-0@@ -12,6 +24,24 @@ } } +register! { +pub (super )NV_PGSP_QUEUE_TAIL (u32 ) @0x00110c04 { +31 :0 address; + } +} + +register! { +pub (super )NV_PGSP_MSGQ_HEAD (u32 ) @0x00110c80 { +31 :0 address; + } +} + +register! { +pub (super )NV_PGSP_MSGQ_TAIL (u32 ) @0x00110c84 { +31 :0 address; + } +} +// PBUS register! {
Re: [PATCH 14/27] gpu: nova-core: add GMC API message types
In reply to John HubbardOn Tue, 18 Aug 2026 20:52:07 -0700
John Hubbard <[email protected]> wrote:
snip
Quoted 12 lines
drivers/gpu/nova-core/gsp/fw.rs +3
-0+/// GMC API message header. +/// +/// Matches the `GMCAPI_HEADER` struct from Open RM. The `command` field carries +/// flags in the high byte and a 24-bit command ID in the low bits.
sizeis the +/// payload size for both requests and responses, while the union at offset 16 +/// carries the maximum response size for requests and the status for responses. +#[repr(C)]drivers/gpu/nova-core/gsp/fw.rs +5
-0+#[derive( Zeroable )] +pub (crate )struct GmcApiHeader { +/// GMC command identifier with flags in the high byte. +pub (crate ) command:u32 , +/// Payload size in bytes.
drivers/gpu/nova-core/gsp/fw.rs unsafe impl AsBytes for GspMsgElement {} · line 979
Quoted 10 lines
drivers/gpu/nova-core/gsp/fw.rs +10
-0+ pub(crate) size: u32, +/// Sequence number for matching requests to responses. + pub(crate) sequence: u64, +/// Request: maximum response size. Response: `NV_STATUS` code. + pub(crate) max_resp_or_status: u32, + reserved: [u32; 5], +} + +static_assert! (size_of ::<GmcApiHeader >() ==40 ); +
Should we use the GMCAPI_HEADER in the r000 bindings?
Z.
Quoted 120 lines
+// SAFETY: All fields are integer types with no uninitialized padding bytes. +unsafe impl AsBytes for GmcApiHeader {}
(quoted diff) +2
-0+ +// SAFETY: All fields are integer types for which all bit patternsare valid. +unsafe impl FromBytes for GmcApiHeader {}
(quoted diff) +2
-0+ +/// Header for an unencrypted GMC API message in the GSP commandqueue. +///
(quoted diff) +2
-0+/// The fields before `gmc` match `GSP_MSG_QUEUE_ELEMENT` through its +/// `noEncryption` union member. `gmc` occupies the start of thatmember's +/// flexible payload array, and the GMC command payload follows this structure. +#[repr(C)]
drivers/gpu/nova-core/gsp/fw.rs +13
-0+pub (crate )struct GspGmcMsgElement { + mctp_magic:u32 , + mctp_payload_size:u32 , + mctp_header:MctpHeader , + nvdm_header:NvdmHeader , + nvdm_payload_size:u32 , + reserved:u32 , +pub (crate ) gmc:GmcApiHeader , +} + +static_assert!( + core::mem::offset_of!(GspGmcMsgElement, mctp_magic) + == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT,mctpMagic) +);
drivers/gpu/nova-core/gsp/fw.rs +3
-0+static_assert!( + core::mem::offset_of!(GspGmcMsgElement, mctp_payload_size) + == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT,mctpPayloadSize) +);
drivers/gpu/nova-core/gsp/fw.rs +3
-0+static_assert!( + core::mem::offset_of!(GspGmcMsgElement, mctp_header) + == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT,mctpHeader) +);
drivers/gpu/nova-core/gsp/fw.rs +3
-0+static_assert!( + core::mem::offset_of!(GspGmcMsgElement, nvdm_header) + == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT,nvdmHeader) +);
drivers/gpu/nova-core/gsp/fw.rs +6
-0+ +#[expect(dead_code)] +impl GspGmcMsgElement { +/// Creates a new GMC message element. +/// +/// `payload_size` is the size of the command payload following this header.
(quoted diff) +2
-0+ /// `command_id` is the GMC command identifier. + /// `sequence` is the sequence number for request/responsematching.
+ ///max_response_sizeis the maximum expected response payload
size.drivers/gpu/nova-core/gsp/fw.rs +9
-0+pub (crate )fn init ( + command_id:u32 , + sequence:u64 , + payload_size:usize , + max_response_size:u32 , + ) ->impl Init <Self ,Error > { +try_init! (GspGmcMsgElement { + mctp_magic:MCTP_MAGIC , +// Despite the name, this counts the element header as well as the payload.
drivers/gpu/nova-core/gsp/fw.rs +16
-0+ mctp_payload_size: size_of::<Self>() + .checked_add(payload_size) + .ok_or(EOVERFLOW)? + .try_into() + .map_err(|_| EOVERFLOW)?, + mctp_header: MctpHeader::single_packet(), + nvdm_header: NvdmHeader::new(NvdmType::GmcApi), + nvdm_payload_size: size_of::<GmcApiHeader>() + .checked_add(payload_size) + .ok_or(EOVERFLOW)? + .try_into() + .map_err(|_| EOVERFLOW)?, + reserved: 0u32, + gmc: GmcApiHeader { + command: command_id, + size: payload_size.try_into().map_err(|_|EOVERFLOW)?,
drivers/gpu/nova-core/gsp/fw.rs +8
-0+ sequence, + max_resp_or_status: max_response_size, + reserved: [0; 5], + }, + }) + } + +/// Returns the total length of the message, transport and GMC headers included.
drivers/gpu/nova-core/gsp/fw.rs +5
-0+pub (crate )fn length (&self) ->usize { + num::u32_as_usize (self.mctp_payload_size) + } + +/// Returns the number of elements (i.e. memory pages) used by this message.
drivers/gpu/nova-core/gsp/fw.rs +7
-0+pub (crate )fn element_count (&self) ->u32 { + self.mctp_payload_size + .div_ceil (num::usize_into_u32 ::<GSP_PAGE_SIZE >()) + } +} + +// SAFETY: All fields are integer types with no uninitialized padding bytes. +unsafe impl AsBytes for GspGmcMsgElement {}
(quoted diff) +2
-0+ +// SAFETY: All fields are integer types for which all bit patternsare valid. +unsafe impl FromBytes for GspGmcMsgElement {}
drivers/gpu/nova-core/gsp/fw.rs +1
-0+/// Arguments for GSP startup. #[repr(transparent)] #[derive( Zeroable )] (quoted diff) +0
-0
b/drivers/gpu/nova-core/mctp.rsindex03546213da28..0ae88bef2a05100644 ---a/drivers/gpu/nova-core/mctp.rs
+++b/drivers/gpu/nova-core/mctp.rsdrivers/gpu/nova-core/mctp.rs +2
-0@@ -28,6 +28,8 @@ pub(crate) enum NvdmType with TryFrom<Bounded<u32, 8>> { Cot = 0x14,/// FSP command response. FspResponse = 0x15, +/// GMC API message (GSP command queue). + GmcApi = 0x26, } }
Re: [PATCH 15/27] gpu: nova-core: add GMC send path
In reply to John HubbardOn Tue, 18 Aug 2026 20:52:08 -0700
John Hubbard <[email protected]> wrote:
Looking good to me.
Quoted 112 lines
The r000 GSP-RM boot protocol requires the driver to send
GSP_INITas a GMC command. GMC and RPC commands share the command queue and sequence counter. GMC queue elements carry a GMC API header and no checksum.Add the GMC send path needed for
GSP_INIT.Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/gsp/cmdq.rs | 59+++++++++++++++++++++++++++++++
drivers/gpu/nova-core/gsp/fw.rs|
1 - 2 files changed, 59 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/cmdq.rsindex0dab3d279426..88b143c6a7b7100644 ---a/drivers/gpu/nova-core/gsp/cmdq.rs
+++b/drivers/gpu/nova-core/gsp/cmdq.rsdrivers/gpu/nova-core/gsp/cmdq.rs +4
-0@@ -52,6 +52,7 @@ driver::Bar0, gsp::{ fw::{ +GspGmcMsgElement ,GspMsgElement ,MsgFunction ,MsgqRxHeader ,@@ -963,6 +964,64 @@ fn send_command<M>(&mut self, bar: Bar0<'_>, command: M) -> Result<u32> Ok(rpc_seq) } +/// Sends a GMC API command to the GSP. +/// +/// `command_id` is the GMC command identifier (from
GMCAPI_COMMANDS).
+ ///payloadis the command-specific data following the
[super::fw::GmcApiHeader].
+ ///max_response_sizeis the maximum expected response payload
size.(quoted diff) +2
-0+ /// + /// The command carries the next RPC sequence number, which theGSP echoes in its response.
drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+/// The number is consumed whether or not the send succeeds. +/// +/// # Errors +/// +/// - `EMSGSIZE` if the command exceeds the maximum queue element size.
+ /// -ETIMEDOUTif space does not become available within the
timeout.drivers/gpu/nova-core/gsp/cmdq.rs +15
-0+/// - `EIO` if the command header is not properly aligned. +#[expect(dead_code)] +fn send_gmc ( + &mut self, + bar:Bar0 <'_>, + command_id:u32 , + payload: &[u8 ], + max_response_size:u32 , + ) ->Result { +let rpc_seq = self.rpc_seq; + self.rpc_seq = self.rpc_seq.wrapping_add (1 ); + +let dst = self + .gsp_mem + .allocate_command::<GspGmcMsgElement>(payload.len(),
Self::ALLOCATE_TIMEOUT)?; +drivers/gpu/nova-core/gsp/cmdq.rs +7
-0+let msg_element =GspGmcMsgElement ::init ( + command_id, + u64::from (rpc_seq), + payload.len (), + max_response_size, + ); +// SAFETY: `dst.header` points to a valid, writable
GspGmcMsgElementregion.drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+unsafe { + msg_element.__init (core::ptr::from_mut (dst.header))?; + } + + SBufferIter::new_writer([&mut dst.contents.0[..], &mutdst.contents.1[..]])
drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+ .write_all(payload)?; + +dev_dbg! ( + &self.dev, + "GSP GMC: send: seq# {}, command_id=0x{:x},length=0x{:x}\n",
drivers/gpu/nova-core/gsp/cmdq.rs +12
-0+ rpc_seq, + command_id, + dst.header.length(), + ); + +let elem_count = dst.header.element_count (); + self.gsp_mem.advance_cpu_write_ptr (elem_count); +Cmdq ::notify_gsp (bar); + +Ok (()) + } +/// Wait for a message to become available on the message queue. /// /// This works purely at the transport layer and does not interpret or validate the message diff --git
a/drivers/gpu/nova-core/gsp/fw.rsb/drivers/gpu/nova-core/gsp/fw.rsindex050a6af8c0c7..56f255a3d49c100644 ---a/drivers/gpu/nova-core/gsp/fw.rs+++b/drivers/gpu/nova-core/gsp/fw.rs@@ -1016,7 +1016,6 @@ pub(crate) struct GspGmcMsgElement { == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, nvdmHeader) );-#[expect(dead_code)]
impl GspGmcMsgElement { /// Creates a new GMC message element. ///
Re: [PATCH 16/27] gpu: nova-core: add GMC transport receive path
In reply to John HubbardQuoted 5 lines · On Tue, 18 Aug 2026 20:52:09 -0700 John Hubbard <[email protected]> wrote:
GSP-RM posts GMC and RPC messages on the same message queue. Both use the same MCTP and NVDM transport headers, but RPC messages continue with
rpc_message_header_vand GMC messages continue with GmcApiHeader. Existing RPC receive code cannot parse the GMC layout.
snip
Quoted 25 lines
+ fn
wait_for_gmc_msg(&self, timeout: Delta)->
Result<GmcMessage<'_>> {drivers/gpu/nova-core/gsp/cmdq.rs +11
-0+if self.poisoned.get () { +return Err (EIO ); + } + +let (slice_1, slice_2) =read_poll_timeout ( + ||Ok (self.gsp_mem.driver_read_area ()), + |driver_area| !driver_area.0 .is_empty (), +Delta ::from_millis (1 ), + timeout, + ) + .map(|(slice_1, slice_2)| (slice_1.as_flattened(),
slice_2.as_flattened()))?; +
+ letSome((header, slice_1))=GspGmcMsgElement::from_bytes_prefix(slice_1)else {drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+ self.poisoned.set (true ); +return Err (EIO ); + }; + +// Checked before any length field is read, since a bad magic leaves them untrusted.
(quoted diff) +2
-0+ if !header.has_valid_magic() { + dev_err!(&self.dev, "GSP GMC: receive: bad MCTPmagic\n");
drivers/gpu/nova-core/gsp/cmdq.rs fn drain(&mut self) -> Result { · line 1342
Quoted 4 lines
drivers/gpu/nova-core/gsp/cmdq.rs +4
-0+ self.poisoned.set (true ); +return Err (EIO ); + } +
IMO, should we also check the MCTP version here?
drivers/gpu/nova-core/gsp/cmdq.rs fn drain(&mut self) -> Result { · line 1350
Quoted 9 lines
drivers/gpu/nova-core/gsp/cmdq.rs +3
-0+let payload_length = header.payload_length (); + +// Check that the driver read area is large enough for the message.
drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+if slice_1.len () + slice_2.len () < payload_length { + self.poisoned.set (true ); +return Err (EIO ); + } +
Do we need more checks here? Here we only checked the nvdm payload size, while in PATCH 17, the queue cursor is advanced by mctp payload size. It would be better we can confirm the frame correctness here in PATCH 16, e.g. check the mctp payload size with various constraints. (size > min size, size < QUEUE MAX SIZE, size < available space, etc...r000 firmware does check these)
Quoted 51 lines
+ // Cut the message slices down to the actual length of the
message.(quoted diff) +2
-0+ let (slice_1, slice_2) = if slice_1.len() > payload_length { + // PANIC: we checked above that `slice_1` is at least aslong as
payload_length.drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+ (slice_1.split_at (payload_length).0 , &slice_2[0 ..0 ]) + }else { + ( + slice_1, + // PANIC: we checked above that `slice_1.len() +slice_2.len()` is at least as
drivers/gpu/nova-core/gsp/cmdq.rs +10
-0+// large as `payload_length`. + slice_2.split_at(payload_length - slice_1.len()).0, + ) + }; + +Ok (GmcMessage { + header, + contents: (slice_1, slice_2), + }) + } }(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/fw.rsindex56f255a3d49c..9e6b5ec6aadb100644 ---a/drivers/gpu/nova-core/gsp/fw.rs
+++b/drivers/gpu/nova-core/gsp/fw.rs(quoted diff) +1
-0@@ -1055,11 +1055,21 @@ pub(crate) fn init( }) } + /// Returns the length of the response payload (data after the[
GmcApiHeader]).(quoted diff) +2
-0+ pub(crate) fn payload_length(&self) -> usize { +num::u32_as_usize(self.nvdm_payload_size).saturating_sub(size_of::<GmcApiHeader>())
drivers/gpu/nova-core/gsp/cmdq.rs +2
-0+ } +/// Returns the total length of the message, transport and GMC headers included. pub(crate) fn length(&self) -> usize { num::u32_as_usize(self.mctp_payload_size) }+ /// Returns
trueif the MCTP magic field contains the expected
value.drivers/gpu/nova-core/gsp/fw.rs +4
-0+pub (crate )fn has_valid_magic (&self) ->bool { + self.mctp_magic ==MCTP_MAGIC + } +/// Returns the number of elements (i.e. memory pages) used by this message. pub(crate) fn
element_count(&self)-> u32 {
self.mctp_payload_size
Re: [PATCH 17/27] gpu: nova-core: gsp: add GMC dispatch on receive
In reply to John HubbardQuoted 3 lines · On Tue, 18 Aug 2026 20:52:10 -0700 John Hubbard <[email protected]> wrote:
The r000 boot path delivers the load-and-execute steps as GMC events keyed by command id, where the RPC path keys on a function code, so the boot loop needs its own dispatch.
snip
Quoted 13 lines
drivers/gpu/nova-core/gsp/cmdq.rs +10
-0+fn receive_gmc_and_dispatch <R >( + &mut self, + timeout:Delta , + handler:impl FnOnce (u32 , &[u8 ], &[u8 ]) ->Option <R >, + ) ->Result <Option <R >> { +let message = self.wait_for_gmc_msg (timeout)?; +let header = message.header; +let length = header.length (); + +// The RPC and GMC elements share every field through
nvdm_header, sogmcholds an
+ // RPC header rather than a GMC one unless the NVDM type
says otherwise.
drivers/gpu/nova-core/gsp/cmdq.rs fn wait_for_gmc_msg(&self, timeout: Delta) -> Result<GmcMessage<'_>> { · line 1414
Quoted 3 lines
drivers/gpu/nova-core/gsp/cmdq.rs +3
-0+let result =if header.is_gmc_api () { +let command_id = header.gmc.command_id (); +
IMO, should we check header.gmc.size == payload_length()? as now we know it is a GMC message now. Not sure if gmc.size < payload_length() is a valid use case.
Quoted 67 lines
drivers/gpu/nova-core/gsp/cmdq.rs +3
-0+dev_dbg! ( + &self.dev, + "GSP GMC: event: seq# {}, command_id=0x{:x},length=0x{:x}\n",
drivers/gpu/nova-core/gsp/cmdq.rs +6
-0+ header.gmc.sequence, + command_id, + length, + ); + + handler(command_id, message.contents.0,message.contents.1)
(quoted diff) +2
-0+ } else { + dev_warn!(&self.dev, "GSP GMC: dropping non-GMC queueelement\n");
drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+None + }; + + self.gsp_mem +.advance_cpu_read_ptr(u32::try_from(length.div_ceil(GSP_PAGE_SIZE))?);
drivers/gpu/nova-core/gsp/cmdq.rs +3
-0+ +Ok (result) + } }(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/fw.rsindex9e6b5ec6aadb..83f7d2042aa1100644 ---a/drivers/gpu/nova-core/gsp/fw.rs
+++b/drivers/gpu/nova-core/gsp/fw.rsdrivers/gpu/nova-core/gsp/fw.rs +1
-0@@ -975,8 +975,19 @@ pub(crate) struct GmcApiHeader { reserved: [u32; 5], } +/// Command identifier bits of [`GmcApiHeader::command`], matching Open RM's +///
GMCAPI_HEADER_COMMAND_ID_MASK. The remaining byte carries flags. +constGMCAPI_COMMAND_ID_MASK: u32 = 0x00ff_ffff;drivers/gpu/nova-core/gsp/fw.rs +8
-0+static_assert! (size_of ::<GmcApiHeader >() ==40 ); +impl GmcApiHeader { +/// Returns the command identifier, without the flag byte. +pub (crate )fn command_id (&self) ->u32 { + self.command &GMCAPI_COMMAND_ID_MASK + } +} +// SAFETY: All fields are integer types with no uninitialized padding bytes. unsafe impl AsBytes for GmcApiHeader {}
drivers/gpu/nova-core/gsp/fw.rs +1
-0@@ -1070,6 +1081,15 @@ pub(crate) fn has_valid_magic(&self) -> bool { self.mctp_magic ==MCTP_MAGIC } +/// Returns `true` if the NVDM header routes this element to the GSP's GMC dispatch.
(quoted diff) +2
-0+ /// + /// A [`GspMsgElement`] and a [`GspGmcMsgElement`] share everyfield through
nvdm_header,
+ /// so the NVDM type is what distinguishes the two on the queue,
andgmcholds an RPCdrivers/gpu/nova-core/gsp/fw.rs +5
-0+/// header rather than a GMC one when this returns `false`. +pub (crate )fn is_gmc_api (&self) ->bool { + self.nvdm_header.validate (NvdmType ::GmcApi ) + } +/// Returns the number of elements (i.e. memory pages) used by this message. pub(crate) fn
element_count(&self)-> u32 {
self.mctp_payload_size
Re: [PATCH 13/27] gpu: nova-core: generalize allocate_command() for variable headers
In reply to John HubbardOn Tue, 18 Aug 2026 20:52:06 -0700
John Hubbard <[email protected]> wrote:
Looking good to me.
Quoted 80 lines
The GMC command path uses a different message element header from the VGPU-style RPC path, but the two share the queue, the space accounting, and the wrapping rules. Make
allocate_command()and GspCommand generic over the header type, defaulting to GspMsgElement so the existing RPC callers are unchanged.No functional changes.
Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/gsp/cmdq.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/cmdq.rsindex1d86d2927a94..0dab3d279426100644 ---a/drivers/gpu/nova-core/gsp/cmdq.rs
+++b/drivers/gpu/nova-core/gsp/cmdq.rs(quoted diff) +0
-0@@ -365,6 +365,8 @@ fn driver_write_area_size(&self) -> usize { /// Allocates a region on the command queue that is large enoughto send a command of
size/// bytes, waiting for space to become available based on the provided timeout. ///
+ /// The type parameterHselects the message element header,
[GspMsgElement] for RM RPC.
+ ////// This returns a [`GspCommand`] ready to be written to by the caller. /// /// # Errors(quoted diff) +0
-0@@ -372,13 +374,17 @@ fn driver_write_area_size(&self) -> usize { /// - `EMSGSIZE` if the command is larger than[
GSP_MSG_QUEUE_ELEMENT_SIZE_MAX]. /// -ETIMEDOUTif space does not become available within the timeout. /// -EIOif the command header is not properly aligned.
- fnallocate_command(&mut self, size: usize, timeout: Delta)->
Result<GspCommand<'_>> {
- if size_of::<GspMsgElement>() + size >GSP_MSG_QUEUE_ELEMENT_SIZE_MAX{drivers/gpu/nova-core/gsp/cmdq.rs +6
-1+fn allocate_command <H :FromBytes +AsBytes >( + &mut self, + size:usize , + timeout:Delta , + ) ->Result <GspCommand <'_,H >> { +if size_of ::<H >() + size >GSP_MSG_QUEUE_ELEMENT_SIZE_MAX {return Err (EMSGSIZE ); }read_poll_timeout ( || Ok(self.driver_write_area_size()), - |available_bytes| *available_bytes >=size_of::<GspMsgElement>() + size,
+ |available_bytes|*available_bytes>= size_of::<H>() +
size,Delta::from_micros(1),timeout, )?;(quoted diff) +2
-2@@ -390,8 +396,8 @@ fn allocate_command(&mut self, size: usize, timeout: Delta) -> Result<GspCommand (slice_1.as_flattened_mut(), slice_2.as_flattened_mut()) }; - // Extract area for the `GspMsgElement`. - let (header, slice_1) = GspMsgElement::from_bytes_mut_prefix(slice_1).ok_or(EIO)?; + // Extract area for the message element header. + let (header, slice_1) = H::from_bytes_mut_prefix(slice_1).ok_or(EIO)?; // Create the contents area.let (slice_1, slice_2) = if slice_1.len() > size {drivers/gpu/nova-core/gsp/cmdq.rs +1
-0@@ -609,10 +615,12 @@ fn driver_read_area_v2(/// A command ready to be sent on the command queue. /// +/// The type parameter `H` is the message element header type, [
GspMsgElement] for RM RPC. +///
/// This is the type returned by [DmaGspMem::allocate_command].drivers/gpu/nova-core/gsp/cmdq.rs +2
-2-struct GspCommand <'a> { +struct GspCommand <'a,H =GspMsgElement > {// Writable reference to the header of the command. - header: &'amut GspMsgElement , + header: &'amut H ,// Writable slices to the contents of the command. The second slice is zero unless the command // loops over the command queue.
contents: (&'a mut [u8], &'a mut [u8]),
Re: [PATCH 18/27] gpu: nova-core: separate the generic falcon bootloader from FWSEC
In reply to John HubbardOn Tue, 18 Aug 2026 20:52:11 -0700
John Hubbard <[email protected]> wrote:
Looking good to me.
Quoted 364 lines
The r000 GSP boot protocol sends a load-and-execute event for the generic falcon bootloader.
Nova-core stored the image and its load parameters in the FWSEC firmware wrapper, which kept the r000 boot path from loading it independently.
Separate the bootloader image and load parameters from the FWSEC wrapper. Place the bootloader at the end of the target falcon's HWCFG-reported IMEM rather than below a fixed 64 KiB ceiling, so its placement remains within bounds on falcons with less IMEM.
Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/falcon.rs | 15 +++ drivers/gpu/nova-core/firmware.rs | 1 + .../nova-core/firmware/fwsec/bootloader.rs | 64 ++--------- .../gpu/nova-core/firmware/gen_bootloader.rs | 102 ++++++++++++++++++ drivers/gpu/nova-core/gsp/hal/tu102.rs | 6 +- drivers/gpu/nova-core/regs.rs | 5 + 6 files changed, 135 insertions(+), 58 deletions(-) create mode 100644 drivers/gpu/nova-core/firmware/gen_bootloader.rs(quoted diff) +0
-0
b/drivers/gpu/nova-core/falcon.rsindex20a288050c37..b8013d2eb582100644 ---a/drivers/gpu/nova-core/falcon.rs
+++b/drivers/gpu/nova-core/falcon.rsdrivers/gpu/nova-core/falcon.rs +3
-0@@ -387,6 +387,21 @@ pub(crate) fn new( }) } +/// Returns the size of this falcon's IMEM, in bytes. +/// +/// `NV_PFALCON_FALCON_IMEMC` addresses IMEM with a 16-bit byte offset, so the result never
drivers/gpu/nova-core/falcon.rs +12
-0+/// exceeds 64KiB. +pub (crate )fn imem_size (&self) ->usize { +let blocks = usize::from_safe_cast ( + *self + .bar + .read (regs::NV_PFALCON_FALCON_HWCFG ::of ::<E >()) + .imem_size (), + ); + + blocks *MEM_BLOCK_ALIGNMENT + } +/// Resets DMA-related registers. pub (crate )fn dma_reset (&self) { self.bar.update (regs::NV_PFALCON_FBIF_CTL ::of ::<E >(), |v| {(quoted diff) +0
-0
b/drivers/gpu/nova-core/firmware.rsindexe0befe84aa3e..9ff764930bcd100644 ---a/drivers/gpu/nova-core/firmware.rs
+++b/drivers/gpu/nova-core/firmware.rsdrivers/gpu/nova-core/firmware.rs +1
-0@@ -26,6 +26,7 @@pub (crate )mod booter;pub (crate )mod fsp;pub (crate )mod fwsec; +pub (crate )mod gen_bootloader;pub (crate )mod gsp;pub (crate )mod radix3;pub (crate )mod riscv;(quoted diff) +0
-0
b/drivers/gpu/nova-core/firmware/fwsec/bootloader.rsindexec4d92317a93..6670d17b4eeb100644 ---a/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs+++b/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs@@ -14,18 +14,12 @@dma::Coherent,io::{register::WithBase, Io}, prelude::*,drivers/gpu/nova-core/firmware/fwsec/bootloader.rs +5
-38- ptr::{ - Alignable, - Alignment, // - }, - sizes, transmute::AsBytes, };use crate ::{ driver::Bar0 , falcon::{ - self, gsp::Gsp ,Falcon ,FalconBromParams ,@@ -39,10 +33,7 @@ }, firmware::{ fwsec::FwsecFirmware, - tlv::{ - request_tlv,// -Tlv , - }, + gen_bootloader::GenericBootloader, // }, gpu::Chipset, num::FromSafeCast, //@@ -101,16 +92,12 @@ unsafe impl AsBytes for BootloaderDmemDescV2 {}pub (crate )struct FwsecFirmwareWithBl {/// DMA object the bootloader will copy the firmware from. _firmware_dma:Coherent <[u8 ]>, -/// Code of the bootloader to be loaded into non-secure IMEM. - ucode:KVec <u8 >, +/// Bootloader that performs the load. + bootloader:GenericBootloader ,/// Descriptor to be loaded into DMEM for the bootloader to read. dmem_desc:BootloaderDmemDescV2 , -/// Range-validated start offset of the firmware code in IMEM. - imem_dst_start:u16 ,/// BROM parameters of the loaded firmware. brom_params:FalconBromParams , -/// Range-validated `desc.start_tag`. - start_tag:u16 , }impl FwsecFirmwareWithBl {@@ -120,29 +107,9 @@ pub(crate) fn new( firmware: FwsecFirmware, dev: &Device<device::Bound>, chipset: Chipset, + falcon: &Falcon<'_, Gsp>, ) -> Result<Self> { -let fw =request_tlv (dev, chipset,"gen_bootloader" )?; -let tlv =Tlv ::new (fw.data ())?; -dev_dbg! ( - dev, -"loaded generic bootloader firmware v{}\n" , - tlv.get_string (b"VERS" )? - ); - -let ucode = { -let blob = tlv.get_bytes (b"BLOB" )?; -let code_size = usize::from_safe_cast(tlv.get_u32(b"CDSZ")?); -let code = blob.get (..code_size).ok_or (EINVAL )?; -let aligned_code_size = code_size - .align_up (Alignment ::new ::<{ falcon::MEM_BLOCK_ALIGNMENT }>()) - .ok_or (EINVAL )?; - -let mut ucode =KVec ::with_capacity (aligned_code_size, GFP_KERNEL)?; - ucode.extend_from_slice (code,GFP_KERNEL )?; - ucode.resize (aligned_code_size,0 ,GFP_KERNEL )?; - - ucode - }; + let bootloader = GenericBootloader::new(dev, chipset,falcon)?; // `BootloaderDmemDescV2` expects the source to be a mirror image of the destination and // uses the same offset parameter for both. @@ -213,21 +180,11 @@ pub(crate) fn new( } };- // The bootloader's code must be loaded in the area right
below the first 64K of IMEM.drivers/gpu/nova-core/firmware/fwsec/bootloader.rs +1
-10-const BOOTLOADER_LOAD_CEILING :usize = sizes::SZ_64K ; -let imem_dst_start =BOOTLOADER_LOAD_CEILING - .checked_sub (ucode.len ()) - .ok_or (EOVERFLOW )?; - -let start_tag = u16::try_from (tlv.get_u32 (b"STRT" )?)?; -Ok (Self { _firmware_dma: firmware_dma, - ucode, + bootloader, dmem_desc, brom_params: firmware.brom_params (), - imem_dst_start: u16::try_from (imem_dst_start)?, - start_tag, }) }@@ -282,7 +239,7 @@ fn brom_params(&self) -> FalconBromParams {fn boot_addr (&self) ->u32 {// On V2 platforms, the boot address is extracted from the generic bootloader, because the // gbl is what actually copies FWSEC into memory, so that is what needs to be booted.
drivers/gpu/nova-core/firmware/fwsec/bootloader.rs +2
-7- u32::from (self.start_tag) <<8 + self.bootloader.boot_addr () } }@@ -292,12 +249,7 @@ fn imem_sec_load_params(&self) -> Option<FalconPioImemLoadTarget<'_>> { } fn imem_ns_load_params(&self) -> Option<FalconPioImemLoadTarget<'_>> { - Some(FalconPioImemLoadTarget { - data: self.ucode.as_ref(), - dst_start: self.imem_dst_start, - secure: false, - start_tag: self.start_tag, - }) + Some(self.bootloader.imem_load_params()) }fn dmem_load_params(&self) -> FalconPioDmemLoadTarget<'_> {(quoted diff) +0
-0
b/drivers/gpu/nova-core/firmware/gen_bootloader.rsnew file mode 100644 index 000000000000..f949223af2d0drivers/gpu/nova-core/firmware/gen_bootloader.rs new file +5
-0@@ -0,0 +1,102 @@ +// SPDX-License-Identifier: GPL-2.0 + +//! The generic falcon bootloader. +//! +//! A small program loaded into falcon IMEM using PIO, which then DMAs a larger image into IMEM and +//! DMEM from a descriptor the driver leaves in DMEM at offset 0. Open RM's +//!
ksec2GetGenericBlUcodesupplies the same image for both SEC2 and GSP. + +use kernel::{drivers/gpu/nova-core/firmware/gen_bootloader.rs new file +24
-0+ device, + prelude::*, + ptr::{ +Alignable , +Alignment ,// + }, +}; + +use crate ::{ + falcon::{ + self, +Falcon , +FalconEngine , +FalconPioImemLoadTarget ,// + }, + firmware::tlv::{ + request_tlv,// +Tlv , + }, + gpu::Chipset , + num::FromSafeCast ,// +}; + +/// The generic falcon bootloader image and the IMEM placement it was loaded for. +pub(crate) struct GenericBootloader {
+ /// Bootloader code, zero-padded to a whole number of falcon
memory blocks.drivers/gpu/nova-core/firmware/gen_bootloader.rs new file +9
-0+ ucode: KVec<u8>, +/// Byte offset in IMEM the code is loaded at. + imem_dst_start: u16, +/// Tag the first code block is loaded under. + start_tag: u16, +} + +impl GenericBootloader { +/// Loads the generic bootloader image for `chipset`, placed in the last blocks of
falcon'sdrivers/gpu/nova-core/firmware/gen_bootloader.rs new file +5
-0+/// IMEM so the image it goes on to load has the rest to itself. +/// +/// # Errors +/// +/// - `EINVAL` if a required TLV field is absent or the image does not fit in IMEM.
+ /// -ENOMEMif the padded copy of the code cannot be
allocated.drivers/gpu/nova-core/firmware/gen_bootloader.rs new file +16
-0+pub (crate )fn new <E :FalconEngine + 'static>( + dev: &device::Device <device::Bound >, + chipset:Chipset , + falcon: &Falcon <'_,E >, + ) ->Result <Self > { +let fw =request_tlv (dev, chipset,"gen_bootloader" )?; +let tlv =Tlv ::new (fw.data ())?; +dev_dbg! ( + dev, +"loaded generic bootloader firmware v{}\n" , + tlv.get_string (b"VERS" )? + ); + +let ucode = { +let blob = tlv.get_bytes (b"BLOB" )?; + let code_size =usize::from_safe_cast(tlv.get_u32(b"CDSZ")?);
drivers/gpu/nova-core/firmware/gen_bootloader.rs new file +3
-0+let code = blob.get (..code_size).ok_or (EINVAL )?; +let aligned_code_size = code_size + .align_up(Alignment::new::<{
falcon::MEM_BLOCK_ALIGNMENT}>())drivers/gpu/nova-core/firmware/gen_bootloader.rs new file +3
-0+ .ok_or(EINVAL)?; + + let mut ucode = KVec::with_capacity(aligned_code_size,
GFP_KERNEL)?;drivers/gpu/nova-core/firmware/gen_bootloader.rs new file +7
-0+ ucode.extend_from_slice (code,GFP_KERNEL )?; + ucode.resize (aligned_code_size,0 ,GFP_KERNEL )?; + + ucode + }; + + let imem_dst_start =falcon.imem_size().checked_sub(ucode.len()).ok_or(EINVAL)?; +
drivers/gpu/nova-core/firmware/gen_bootloader.rs new file +8
-0+Ok (Self { + ucode, + imem_dst_start: u16::try_from (imem_dst_start)?, + start_tag: u16::try_from (tlv.get_u32 (b"STRT" )?)?, + }) + } + +/// Returns the address the falcon must boot from to run this bootloader.
drivers/gpu/nova-core/firmware/gen_bootloader.rs new file +5
-0+pub (crate )fn boot_addr (&self) ->u32 { + u32::from (self.start_tag) <<8 + } + +/// Returns the PIO parameters that place this bootloader in non-secure IMEM.
+ pub(crate) fnimem_load_params(&self)->
FalconPioImemLoadTarget<'_> {drivers/gpu/nova-core/firmware/gen_bootloader.rs new file +8
-0+FalconPioImemLoadTarget { + data: self.ucode.as_ref (), + dst_start: self.imem_dst_start, + secure:false , + start_tag: self.start_tag, + } + } +}(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/hal/tu102.rsindexa5c0ca355493..68a48c882c0f100644 ---a/drivers/gpu/nova-core/gsp/hal/tu102.rs+++b/drivers/gpu/nova-core/gsp/hal/tu102.rs@@ -166,7 +166,7 @@ fnrun_fwsec_frts( )?;if self.needs_fwsec_bootloader {- let
fwsec_frts_bl= FwsecFirmwareWithBl::new(fwsec_frts,
dev, chipset)?;
+ letfwsec_frts_bl= FwsecFirmwareWithBl::new(fwsec_frts,
dev, chipset, falcon)?; // Load and run the bootloader, which will load FWSEC-FRTS and run it.fwsec_frts_bl.run(dev, falcon, bar)?;} else {(quoted diff) +3
-1@@ -224,7 +224,9 @@ fn build_unload_bundle( // Load the FWSEC SB firmware, as well as its bootloader if required. let fwsec_sb = FwsecFirmware::new(dev, gsp_falcon, bios, FwsecCommand::Sb)?; let fwsec_sb = if self.needs_fwsec_bootloader { - FwsecUnloadFirmware::WithBl(FwsecFirmwareWithBl::new(fwsec_sb, dev, chipset)?) + FwsecUnloadFirmware::WithBl(FwsecFirmwareWithBl::new( + fwsec_sb, dev, chipset, gsp_falcon, + )?) } else {FwsecUnloadFirmware::WithoutBl(fwsec_sb) };(quoted diff) +0
-0
b/drivers/gpu/nova-core/regs.rsindex5d265b5788e3..5501c36a56af100644 ---a/drivers/gpu/nova-core/regs.rs
+++b/drivers/gpu/nova-core/regs.rsdrivers/gpu/nova-core/regs.rs +2
-0@@ -247,6 +247,11 @@ pub(crate) fn usable_fb_size(self) -> u64 { 31:0 value => u32; } + pub(crate) NV_PFALCON_FALCON_HWCFG(u32) @ PFalconBase + 0x00000108 { +/// Size of this falcon's IMEM, in blocks of [
crate::falcon::MEM_BLOCK_ALIGNMENT] bytes.drivers/gpu/nova-core/regs.rs +3
-0+ 8:0 imem_size; + } + pub(crate) NV_PFALCON_FALCON_DMACTL(u32) @ PFalconBase +0x0000010c { 7:7 secure_stat => bool; 6:3 dmaq_num;
Re: [PATCH 20/27] gpu: nova-core: handle the r000 load-and-execute bootloader event
In reply to John HubbardOn Tue, 18 Aug 2026 20:52:13 -0700
John Hubbard <[email protected]> wrote:
snip
Quoted 92 lines
drivers/gpu/nova-core/gsp/boot.rs +3
-0+/// Handle a `GSP_LOAD_EXEC_GENERIC_BOOTLOADER` event. +/// +/// The driver does not copy the image the GSP asks for. It writes the descriptor the event
+ /// carries to DMEM offset 0, places the generic bootloader in
IMEM, points the requested FBIF
+ /// aperture at wherever the image lives, and runs the
bootloader, which does the copy from
+ /// the descriptor and jumps to the image. The aperture is
restored afterwards.drivers/gpu/nova-core/gsp/boot.rs +4
-0+/// +/// # Errors +/// +/// - `EINVAL` if the payload is shorter than the parameter block, the descriptor is not the
+ /// size this driver mirrors, or the event names a context DMA
slot or an aperture that does(quoted diff) +2
-0+ /// not exist. + /// - `ETIMEDOUT` if the GSP does not suspend, or the image doesnot halt, in time.
drivers/gpu/nova-core/gsp/boot.rs +13
-0+#[expect(dead_code)] +#[allow(clippy::too_many_arguments)] +fn handle_load_exec_bootloader ( + payload: &[u8 ], + bootloader: &GenericBootloader , + gsp_falcon: &Falcon <'_,Gsp >, + sec2_falcon: &Falcon <'_,Sec2 >, + bar:Bar0 <'_>, + dev: &device::Device , + bootloader_app_version:u32 , + libos_dma_handle:u64 , + ) ->Result { + let params =
LoadExecGenericBootloaderParams::from_bytes_prefix(payload)drivers/gpu/nova-core/gsp/boot.rs +5
-0+ .ok_or(EINVAL)? + .0 ; + + let desc_size = +u32::try_from(core::mem::size_of::<BootloaderDmemDescV2>()).map_err(|_| EOVERFLOW)?;
drivers/gpu/nova-core/gsp/boot.rs +37
-0+if params.dmem_desc_size != desc_size { +dev_err! ( + dev, +"Load-exec descriptor is {} bytes, expected {}\n" , + params.dmem_desc_size, + desc_size + ); +return Err (EINVAL ); + } + +let ctx_dma = params.ctx_dma ()?; +let fbif_target = params.fbif_target ()?; +let transcfg = || { + regs::NV_PFALCON_FBIF_TRANSCFG ::of ::<Gsp >() + .try_at (usize::from (ctx_dma)) + .ok_or (EINVAL ) + }; + + gsp_falcon.wait_for_processor_suspend ().inspect_err (|_| { +dev_err! ( + dev, +"Timeout waiting for GSP suspend (mbox0={:#x})\n" , + gsp_falcon.read_mailbox0 () + ); + })?; + + gsp_falcon.reset ()?; + gsp_falcon.dma_reset (); + +let saved_transcfg = bar.read (transcfg ()?); + bar.update (transcfg ()?, |v| { + v.with_target (fbif_target) + .with_mem_type (FalconFbifMemType ::Physical ) + }); + + let run = (|| -> Result { +gsp_falcon.pio_load(&bootloader.with_descriptor(¶ms.dmem_desc))?;
(quoted diff) +2
-0+ + // Also clears the suspend bit that
wait_for_processor_suspendpolls, so the next
+ // load-and-execute event does not read this one's
suspension.
+gsp_falcon.write_mailboxes(Some(FLCN_ERR_BINARY_NOT_STARTED), None); +drivers/gpu/nova-core/gsp/boot.rs +5
-0+ gsp_falcon.start ()?; + gsp_falcon.wait_till_halted().inspect_err(|_| { + dev_err!( + dev, + "Timeout waiting for the loaded image to halt(mbox0={:#x})\n",
drivers/gpu/nova-core/gsp/boot.rs fn core_resume( · line 249
Quoted 7 lines
drivers/gpu/nova-core/gsp/boot.rs +7
-0+ gsp_falcon.read_mailbox0 () + ); + }) + })(); + + bar.update (transcfg ()?, |_| saved_transcfg); + run?;
TRANSCFG was restored only when the transfer is successful in OpenRM [1] (also r000 firmware), I think that is reasonable since if the HALT is not received, the controller is in stale and might still be active on memory read/write until it got reset.
I guess we should follow OpenRM's scheme, e.g.
run?;bar.update(xxxx);
Quoted 82 lines
drivers/gpu/nova-core/gsp/boot.rs +10
-0+ +Self ::core_resume ( + gsp_falcon, + sec2_falcon, + dev, + bootloader_app_version, + libos_dma_handle, + ) + } +/// Handle a `GSP_LOAD_EXEC_HS_BINARY` event. /// /// The GSP asks the driver to run a high-security binary that it has already placed in the @@ -347,6 +448,64 @@ pub(crate) fn unload( /// points it at local framebuffer.
constHS_BINARY_CTX_DMA: u8 = 0;drivers/gpu/nova-core/gsp/boot.rs +6
-0+/// Number of FBIF context DMA slots a falcon has. +const NUM_CTX_DMA :usize =8 ; + +/// Parameters for loading and executing the generic bootloader. +/// +/// Sent by GSP-RM as the payload of
GSP_LOAD_EXEC_GENERIC_BOOTLOADER. The descriptor carries +/// the code and data addresses, whileaddr_spaceandcpu_cache_attribsay which FBIF aperture +/// reaches them. +#[repr(C)]drivers/gpu/nova-core/gsp/boot.rs +15
-0+struct LoadExecGenericBootloaderParams { + dmem_desc:BootloaderDmemDescV2 , + dmem_desc_size:u32 , + addr_space:u32 , + cpu_cache_attrib:u32 , + _reserved: [u32 ;4 ], +} + +impl LoadExecGenericBootloaderParams { +const ADDR_SYSMEM :u32 =1 ; +const ADDR_FBMEM :u32 =2 ; +const NV_MEMORY_CACHED :u32 =0 ; +const NV_MEMORY_UNCACHED :u32 =1 ; + +/// Returns the context DMA slot the bootloader is to fetch the image through.
drivers/gpu/nova-core/gsp/boot.rs +18
-0+/// +/// # Errors +/// +/// - `EINVAL` if the slot is outside the FBIF `TRANSCFG` array. +fn ctx_dma (&self) ->Result <u8 > { +let ctx_dma = self.dmem_desc.ctx_dma; + + u8::try_from (ctx_dma) + .ok () + .filter (|slot| usize::from (*slot) <NUM_CTX_DMA ) + .ok_or (EINVAL ) + } + +/// Returns the FBIF aperture that reaches the image. +/// +/// # Errors +/// +/// - `EINVAL` if the address space and cache attribute pair is not one this driver maps.
drivers/gpu/nova-core/gsp/boot.rs +4
-0+fn fbif_target (&self) ->Result <FalconFbifTarget > { +match (self.addr_space, self.cpu_cache_attrib) { + (Self::ADDR_FBMEM, _) => Ok(FalconFbifTarget::LocalFb), + (Self::ADDR_SYSMEM, Self::NV_MEMORY_CACHED) =>Ok(FalconFbifTarget::CoherentSysmem),
drivers/gpu/nova-core/gsp/boot.rs +9
-0+ (Self::ADDR_SYSMEM, Self::NV_MEMORY_UNCACHED) => { +Ok (FalconFbifTarget ::NoncoherentSysmem ) + } + _ => Err(EINVAL), + } + } +} + +// SAFETY: The nested descriptor is `FromBytes`, and every other field is an integer type for +// which all bit patterns are valid.
drivers/gpu/nova-core/gsp/boot.rs +2
-0+unsafe impl FromBytes for LoadExecGenericBootloaderParams {} +/// Parameters for loading and executing an HS (High-Security) binary. ///
/// Sent by GSP-RM as the payload ofGSP_LOAD_EXEC_HS_BINARY. The
firmware
Re: [PATCH 21/27] gpu: nova-core: gsp: add the GMC boot event dispatcher
In reply to John HubbardOn Tue, 18 Aug 2026 20:52:14 -0700
John Hubbard <[email protected]> wrote:
Looks good to me besides a nit below.
Quoted 43 lines
The r000 GSP boot protocol sends its two load-and-execute events as GMC commands, each identified by a command id.
Nova-core has a handler for each of the two events, but nothing that reads a command id and selects between them.
Add the dispatcher, keyed on the two command ids from the r000 bindings.
Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/gsp/boot.rs | 62+++++++++++++++++++++++++++++--
drivers/gpu/nova-core/gsp/fw.rs|
10 +++++ 2 files changed, 69 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/boot.rsindexd62a5c834ccf..15933ecc061b100644 ---a/drivers/gpu/nova-core/gsp/boot.rs
+++b/drivers/gpu/nova-core/gsp/boot.rsdrivers/gpu/nova-core/gsp/boot.rs +8
-1@@ -36,7 +36,11 @@ }, gsp::{ cmdq::Cmdq, - commands, // + commands, + fw::{ +GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER , +GMCAPI_CMD_EXEC_HS_BINARY ,// + }, // }, regs, // };@@ -162,6 +166,60 @@ fn core_resume(Ok (()) } +/// Dispatch one GMC boot event to its load-and-execute handler. +/// +/// LIBOS2 chipsets send `GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER` and LIBOS3 chipsets send
+ ///GMCAPI_CMD_EXEC_HS_BINARY, so a given GPU only ever
reaches one of the two handlers.
drivers/gpu/nova-core/gsp/boot.rs fn core_resume( · line 180
Quoted 8 lines
drivers/gpu/nova-core/gsp/boot.rs +8
-0+/// +/// # Errors +/// +/// - `EINVAL` if `command_id` is not a load-and-execute command. +/// +/// Errors from the handlers are propagated as-is. +#[expect(dead_code)] +#[allow(clippy::too_many_arguments)]
Should this be expect? So that if we refactored this arugment list in future and it gets shorter then CLIPPY will tell us to remove the tag above.
Quoted 87 lines
drivers/gpu/nova-core/gsp/boot.rs +13
-0+fn dispatch_gmc_boot_event ( + command_id:u32 , + payload: &[u8 ], + bootloader: &GenericBootloader , + gsp_falcon: &Falcon <'_,Gsp >, + sec2_falcon: &Falcon <'_,Sec2 >, + bar:Bar0 <'_>, + dev: &device::Device , + bootloader_app_version:u32 , + libos_dma_handle:u64 , + ) ->Result { +match command_id { + GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER =>Self::handle_load_exec_bootloader(
drivers/gpu/nova-core/gsp/boot.rs +10
-0+ payload, + bootloader, + gsp_falcon, + sec2_falcon, + bar, + dev, + bootloader_app_version, + libos_dma_handle, + ), + GMCAPI_CMD_EXEC_HS_BINARY =>Self::handle_load_exec_hs_binary(
drivers/gpu/nova-core/gsp/boot.rs +12
-0+ payload, + gsp_falcon, + sec2_falcon, + bar, + dev, + bootloader_app_version, + libos_dma_handle, + ), + _ => { + dev_err!( + dev, + "Unexpected GMC boot event:command_id={:#010x}\n",
drivers/gpu/nova-core/gsp/boot.rs +7
-0+ command_id + ); +Err (EINVAL ) + } + } + } +/// Handle a `GSP_LOAD_EXEC_GENERIC_BOOTLOADER` event. /// /// The driver does not copy the image the GSP asks for. It writes the descriptor the event @@ -175,7 +233,6 @@ fn core_resume(
/// size this driver mirrors, or the event names a context DMA slot or an aperture that does /// not exist. /// - `ETIMEDOUT` if the GSP does not suspend, or the image doesnot halt, in time.
drivers/gpu/nova-core/gsp/boot.rs +0
-1-#[expect(dead_code)] #[allow(clippy::too_many_arguments)] fn handle_load_exec_bootloader ( payload: &[u8],@@ -268,7 +325,6 @@ fn handle_load_exec_bootloader(/// - `EINVAL` if the payload is shorter than the parameter block, or the ucode id does not /// fit the BROM register field.
/// - `ETIMEDOUT` if the GSP does not suspend, or the binarydoes not halt, in time.
drivers/gpu/nova-core/gsp/boot.rs +0
-1-#[expect(dead_code)] #[allow(clippy::too_many_arguments)] fn handle_load_exec_hs_binary ( payload: &[u8],(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/fw.rsindex83f7d2042aa1..4772af362117100644 ---a/drivers/gpu/nova-core/gsp/fw.rs
+++b/drivers/gpu/nova-core/gsp/fw.rs(quoted diff) +1
-0@@ -979,6 +979,16 @@ pub(crate) struct GmcApiHeader { /// `GMCAPI_HEADER_COMMAND_ID_MASK`. The remaining byte carries flags. const GMCAPI_COMMAND_ID_MASK: u32 = 0x00ff_ffff; +/// GMC command asking the driver to run the generic falconbootloader against a descriptor the +/// GSP supplies.
drivers/gpu/nova-core/gsp/fw.rs +4
-0+pub (crate )const GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER :u32 = + r000_00::GMCAPI_COMMANDS_GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER ; + +/// GMC command asking the driver to run a high-security binary the GSP has placed in the +/// framebuffer.
drivers/gpu/nova-core/gsp/fw.rs +3
-0+pub (crate )const GMCAPI_CMD_EXEC_HS_BINARY :u32 = + r000_00::GMCAPI_COMMANDS_GMCAPI_CMD_EXEC_HS_BINARY ; +static_assert! (size_of ::<GmcApiHeader >() ==40 );impl GmcApiHeader {
Re: [PATCH 22/27] gpu: nova-core: gsp: add the GSP_INIT request builder
In reply to John HubbardQuoted 13 lines · On Tue, 18 Aug 2026 20:52:15 -0700 John Hubbard <[email protected]> wrote:
The r000 GSP boot protocol replaces the separate system-info, registry and static-info commands with one
GSP_INITrequest, whose payload is an NVKV key-value blob rather than a packed struct.Nova-core has the NVKV codec and the
GSP_INITschema, but nothing that fills the schema in from a PCI device.Add the builder. It encodes the PCI identifiers and config mirror range the RPC path already sends, and the registry entries, whose names carry the NULL that GSP-RM counts in the encoded length.
Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>
snip
Quoted 19 lines
[
GspSetSystemInfo::init] on the RPC path.drivers/gpu/nova-core/gsp/fw/commands.rs +7
-0+pub (crate )fn new ( + dev: &pci::Device <device::Bound >, + chipset:Chipset , + regkeys:KVVec <RegKey >, + ) ->Self { +let mirror = chipset.pci_config_mirror_range (); + let device_id = (u32::from(dev.device_id()) << 16) |u32::from(dev.vendor_id().as_raw());
(quoted diff) +2
-0+ let sub_device_id = + (u32::from(dev.subsystem_device_id()) << 16) |u32::from(dev.subsystem_vendor_id()); +
drivers/gpu/nova-core/gsp/fw/commands.rs +6
-0+Self { + pci_device_id: device_id.into (), + pci_sub_device_id: sub_device_id.into (), + pci_revision_id: u32::from (dev.revision_id ()).into (), + pci_config_mirror_base: mirror.start.into (), + pci_config_mirror_size: (mirror.end -mirror.start).into(),
drivers/gpu/nova-core/gsp/fw/commands.rs impl GspInitRequest { · line 391
Quoted 2 lines
drivers/gpu/nova-core/gsp/fw/commands.rs +2
-0+ oor_arch: OorArch::host().into(), + bus_device_func: u64::from(dev.dev_id()).into(),
This looks not correct (though the name looks really really confusing):
https://github.com/NVIDIA/open-gpu-kernel-modules/blob/main/src/nvidia/generated/g_gpu_nvoc.h#L439
// DRF macros for GPUBUSINFO::nvDomainBusDeviceFunc
#define NVGPU_BUSDEVICE_DOMAIN 63:32
#define NVGPU_BUSDEVICE_BUS 15:8
#define NVGPU_BUSDEVICE_DEVICE 7:0
static NV_INLINE NvU64 gpuEncodeDomainBusDevice(NvU32 domain, NvU8 bus,
NvU8 device) {
return DRF_NUM64(GPU, _BUSDEVICE, _DOMAIN, domain) |
DRF_NUM64(GPU, _BUSDEVICE, _BUS, bus) |
DRF_NUM64(GPU, _BUSDEVICE, _DEVICE, device);
}The output should be ((domain << 32) | (bus << 8) | slot) - DBD
While in our code, dev.dev_id() returns from PCI_DEVID(), which is (bus << 8) | (slot << 3) | function - BDF.
Z.
Quoted 7 lines
drivers/gpu/nova-core/gsp/fw/commands.rs +4
-0+ regkeys, + vf_info: None, + } + } }// Decode:
Re: [PATCH 23/27] gpu: nova-core: gsp: send GSP_INIT and decode its reply
In reply to John HubbardOn Tue, 18 Aug 2026 20:52:16 -0700
John Hubbard <[email protected]> wrote:
Looks good to me.
Quoted 395 lines
GSP-RM answers a
GSP_INITrequest with the static GPU configuration, and that reply is also what signals it has finished starting. It raises load-and-execute events in the meantime, so a caller must handle them rather than wait through them.Nova-core can build the request but cannot send it: the GMC sender is private, and the receive path drops the field carrying the reply status.
Add the sender and the receive-side status field it needs, and decode the reply into the static-info type the RPC path already produces.
Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/gsp/cmdq.rs | 49 ++++++-- drivers/gpu/nova-core/gsp/commands.rs | 140 ++++++++++++++++++++++- drivers/gpu/nova-core/gsp/fw.rs | 4 + drivers/gpu/nova-core/gsp/fw/commands.rs | 35 +++++- 4 files changed, 213 insertions(+), 15 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/cmdq.rsindex7da61bc9ad92..82ff46620911100644 ---a/drivers/gpu/nova-core/gsp/cmdq.rs
+++b/drivers/gpu/nova-core/gsp/cmdq.rs(quoted diff) +0
-1@@ -790,22 +790,43 @@ fn receive_msg<M: MessageFromGsp>(&self, timeout: Delta) -> Result<M> self.inner.lock().receive_msg(timeout, None) } - /// Receives one GMC event from the GSP and passes its commandid and raw payload slices to
(quoted diff) +1
-1- /// `handler`. + /// Receives one GMC element from the GSP and passes its commandid, the
max_resp_or_status
+ /// field, and the raw payload slices tohandler./// /// This method may sleep while waiting. The [`CmdqInner`] mutex stays locked across the wait /// and across the `handler` call, so `handler` must not call back into this [`Cmdq`]. /// /// See [`CmdqInner::receive_gmc_and_dispatch`] for returnvalues, queue state, and errors.
drivers/gpu/nova-core/gsp/cmdq.rs +2
-2-#[expect(dead_code)] pub (crate )fn receive_gmc_and_dispatch <R >( &self, timeout:Delta , - handler:impl FnOnce (u32 , &[u8 ], &[u8 ]) ->Option <R >, + handler:impl FnOnce (u32 ,u32 , &[u8 ], &[u8 ]) ->Option <R >, ) ->Result <Option <R >> { self.inner.lock ().receive_gmc_and_dispatch (timeout, handler) } +/// Sends a GMC API command to the GSP without waiting for its response.
(quoted diff) +2
-0+ /// + /// A caller that expects a response reads it with[
Self::receive_gmc_and_dispatch], which
+ /// lets it handle the events GSP-RM interleaves before the
response arrives.drivers/gpu/nova-core/gsp/cmdq.rs +4
-0+/// +/// # Errors +/// +/// - `EMSGSIZE` if the command exceeds the maximum queue element size.
+ /// -ETIMEDOUTif space does not become available within the
timeout.drivers/gpu/nova-core/gsp/cmdq.rs +13
-0+/// - `EIO` if the command header is not properly aligned. +pub (crate )fn send_gmc_no_wait ( + &self, + bar:Bar0 <'_>, + command_id:u32 , + payload: &[u8 ], + max_response_size:u32 , + ) ->Result { + self.inner + .lock () + .send_gmc (bar, command_id, payload, max_response_size) + } +/// Waits for an unsolicited GSP event of type `M`, dispatching any other event that arrives /// first.
///(quoted diff) +0
-0@@ -1005,7 +1026,6 @@ fn send_command<M>(&mut self, bar: Bar0<'_>,command: M) -> Result<u32> /// -
EMSGSIZEif the command exceeds the maximum queue element size. /// -ETIMEDOUTif space does not become available within the timeout. /// -EIOif the command header is not properly aligned.drivers/gpu/nova-core/gsp/cmdq.rs +0
-1-#[expect(dead_code)] fn send_gmc ( &mut self, bar: Bar0<'_>,@@ -1383,9 +1403,13 @@ fn wait_for_gmc_msg(&self, timeout: Delta) -> Result<GmcMessage<'_>> {/// Receive the next GMC event from the GSP and dispatch it through a handler. ///
- /// The handler receives the GMC command id and the raw payload
slices that follow the
- /// [super::fw::GmcApiHeader] (two slices because the circular
buffer may wrap). It returns(quoted diff) +1
-1- /// `None` for an event it does not handle. + /// The handler receives the GMC command id, the header's
max_resp_or_statusfield, and the
+ /// raw payload slices that follow the
[super::fw::GmcApiHeader] (two slices because the
+ /// circular buffer may wrap). It returnsNonefor an element
it does not handle.(quoted diff) +2
-0+ /// + /// `max_resp_or_status` is a union: GSP-RM writes an
NV_STATUSthere when the element is a
+ /// response, and the maximum response size when it is a
request. Only a handler that knows
+ /// which one it asked for can read it./// /// Where [`Self::receive_msg`] keys on [`MsgFunction`], thiskeys on the GMC command id, /// which is the form the r000 firmware uses for boot events. @@ -1401,7 +1425,7 @@ fn
wait_for_gmc_msg(&self, timeout: Delta)-> Result<GmcMessage<'_>> { fn receive_gmc_and_dispatch<R>( &mut self,
timeout: Delta,drivers/gpu/nova-core/gsp/cmdq.rs +7
-2- handler: impl FnOnce(u32, &[u8], &[u8]) -> Option<R>, + handler: impl FnOnce(u32, u32, &[u8], &[u8]) -> Option<R>, ) -> Result<Option<R>> {let message = self.wait_for_gmc_msg (timeout)?;let header = message.header;@@ -1420,7 +1444,12 @@ fn receive_gmc_and_dispatch<R>( length, ); -handler (command_id, message.contents.0 , message.contents.1) +handler ( + command_id, + header.gmc.max_resp_or_status, + message.contents.0 , + message.contents.1 , + ) }else { dev_warn!(&self.dev, "GSP GMC: dropping non-GMC queueelement\n"); None
(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/commands.rsindex0c3832ccf726..d55faf1a4e04100644 ---a/drivers/gpu/nova-core/gsp/commands.rs+++b/drivers/gpu/nova-core/gsp/commands.rs@@ -20,6 +20,7 @@
};use crate::{
drivers/gpu/nova-core/gsp/commands.rs +9
-2+ driver::Bar0, gpu::Chipset, gsp::{ cmdq::{@@ -32,13 +33,18 @@ self, commands::{ GspInitRequest, + GspInitResponse, + GspInitResponseSchema, RegKey, // }, - MsgFunction, // + MsgFunction, + GMCAPI_CMD_GSP_INIT, // }, nvkv::{ +Decoder ,Encodeable , -Encoder ,// +Encoder , +UnknownKeyPolicy ,// }, }, sbuffer::SBufferIter,@@ -311,6 +317,136 @@ pub(crate) fn build_gsp_init_payload(Ok (encoder.finish ()) } +/// Size of the buffer GSP-RM may fill with static configuration, matching the allocation Open RM +/// makes in
kgspSendInitRpcs.drivers/gpu/nova-core/gsp/commands.rs +3
-0+const GSP_INIT_MAX_RESPONSE_SIZE :u32 =48 *1024 ; + +/// Sends `GSP_INIT` and returns the static configuration its reply carries. +///
+/// GSP-RM interleaves load-and-execute events between the request and the reply, and those events +/// drive the falcon loads that let it finish starting, so each one is passed toon_boot_event+/// rather than skipped. The reply arrives only once GSP-RM is up, which is what makes it the +/// signal that boot is complete. +///drivers/gpu/nova-core/gsp/commands.rs +5
-0+/// `payload` is the blob from [`build_gsp_init_payload`]. +/// +/// # Errors +/// +/// - `EIO` if GSP-RM reports a failure status, or if the reply is not a whole number of NVKV +/// words.
+/// -ETIMEDOUTif neither the reply nor another element arrives
within +/// [Cmdq::RECEIVE_TIMEOUT].(quoted diff) +2
-0+/// +/// Errors from `on_boot_event` and from decoding the reply arepropagated as-is. +#[expect(dead_code)]
drivers/gpu/nova-core/gsp/commands.rs +7
-0+pub (crate )fn gsp_init ( + cmdq: &Cmdq , + bar:Bar0 <'_>, + payload: &[u64 ], +mut on_boot_event:impl FnMut (u32 , &[u8 ]) ->Result , +) ->Result <GetGspStaticInfoReply > { +// Qualified because `zerocopy::IntoBytes` also gives `[T]` an
as_bytes.drivers/gpu/nova-core/gsp/commands.rs +21
-0+let payload =AsBytes ::as_bytes (payload); + + cmdq.send_gmc_no_wait ( + bar, +GMCAPI_CMD_GSP_INIT , + payload, +GSP_INIT_MAX_RESPONSE_SIZE , + )?; + +loop { + let reply = cmdq.receive_gmc_and_dispatch( + Cmdq::RECEIVE_TIMEOUT, + |command_id, max_resp_or_status, payload_0, payload_1| { + if command_id == GMCAPI_CMD_GSP_INIT { + Some(decode_gsp_init_reply( + max_resp_or_status, + payload_0, + payload_1, + )) + } else { + // A boot event. Keep waiting for the replyunless handling it failed.
drivers/gpu/nova-core/gsp/commands.rs +15
-0+match on_boot_event (command_id, payload_0) { +Ok (()) =>None , +Err (e) =>Some (Err (e)), + } + } + }, + )?; + +if let Some (reply) = reply { +return reply; + } + } +} + +/// Decodes the `GSP_INIT` reply, whose `max_resp_or_status` field carries an
NV_STATUS. +fn decode_gsp_init_reply(drivers/gpu/nova-core/gsp/commands.rs +12
-0+ status: u32, + payload_0: &[u8], + payload_1: &[u8], +) -> Result<GetGspStaticInfoReply> { +if status !=0 { +return Err (EIO ); + } + +decode_gsp_info (&nvkv_words (payload_0, payload_1)?) +} + +/// Joins the two halves of a wrapped payload into the `u64` words an NVKV stream is made of. +///
drivers/gpu/nova-core/gsp/commands.rs +5
-0+/// # Errors +/// +/// - `EIO` if the combined length is not a whole number of words. +/// - `ENOMEM` if the buffer cannot be allocated. +fn nvkv_words(payload_0: &[u8], payload_1: &[u8]) ->Result<KVVec<u64>> {
+ let bytes = SBufferIter::new_reader([payload_0,
payload_1]).flush_into_kvec(GFP_KERNEL)?;drivers/gpu/nova-core/gsp/commands.rs +6
-0+let words = bytes.chunks_exact (size_of ::<u64 >()); +if !words.remainder ().is_empty () { +return Err (EIO ); + } + + let mut out = KVVec::with_capacity(bytes.len() /size_of::<u64>(),
GFP_KERNEL)?;(quoted diff) +2
-0+ for word in words { + let word: [u8; size_of::<u64>()] =word.try_into().map_err(|_| EIO)?;
drivers/gpu/nova-core/gsp/commands.rs +37
-0+ out.push (u64::from_le_bytes (word),GFP_KERNEL )?; + } + +Ok (out) +} + +/// Decodes the static GPU configuration from an NVKV stream. +/// +/// # Errors +/// +/// - `EINVAL` if the stream is malformed or omits a required key. +/// - `ENOMEM` if the decoded regions cannot be allocated. +fn decode_gsp_info (words: &[u64 ]) ->Result <GetGspStaticInfoReply > { +let decoder =Decoder ::new (words,UnknownKeyPolicy ::Ignore ); +let decoded =KBox ::try_init ( + decoder.decode (GspInitResponseSchema ::default ())?, +GFP_KERNEL , + )?; + +let mut gpu_name = [0u8 ;GspInitResponse ::MAX_GPU_NAME_LEN ]; +let name = decoded.gpu_name (); + gpu_name + .get_mut (..name.len ()) + .ok_or (EINVAL )? + .copy_from_slice (name); + +let mut usable_fb_regions =KVec ::new (); +for regionin decoded.usable_fb_regions () { + usable_fb_regions.push (region,GFP_KERNEL )?; + } + +Ok (GetGspStaticInfoReply { + gpu_name, + usable_fb_regions, + }) +} +pub (crate )use fw::commands::PowerStateLevel ;/// The `UnloadingGuestDriver` command, used to shut down the GSP. (quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/fw.rsindex4772af362117..6958ee3a2e4e100644 ---a/drivers/gpu/nova-core/gsp/fw.rs
+++b/drivers/gpu/nova-core/gsp/fw.rs(quoted diff) +1
-0@@ -979,6 +979,10 @@ pub(crate) struct GmcApiHeader { /// `GMCAPI_HEADER_COMMAND_ID_MASK`. The remaining byte carries flags. const GMCAPI_COMMAND_ID_MASK: u32 = 0x00ff_ffff; +/// GMC command that hands GSP-RM its system information andregistry keys and returns the static +/// GPU configuration. Its reply is also what signals that GSP-RM has finished starting. +pub(crate) const
GMCAPI_CMD_GSP_INIT: u32 =r000_00::GMCAPI_COMMANDS_GMCAPI_CMD_GSP_INIT; + /// GMC command asking the driver to run the generic falcon bootloader against a descriptor the /// GSP supplies. pub(crate) constGMCAPI_CMD_EXEC_GENERIC_BOOTLOADER: u32 = diff --gita/drivers/gpu/nova-core/gsp/fw/commands.rsb/drivers/gpu/nova-core/gsp/fw/commands.rsindexbfd756813c64..00e40a435053100644 ---a/drivers/gpu/nova-core/gsp/fw/commands.rs+++b/drivers/gpu/nova-core/gsp/fw/commands.rs@@ -402,7 +402,7 @@ pub(crate) fn new( /// Schema for theGSP_INITresponse. #[cfg_attr(not(CONFIG_KUNIT),allow(dead_code))] #[derive(Default)]drivers/gpu/nova-core/gsp/fw/commands.rs +1
-1- struct GspInitResponseSchema => GspInitResponse { + pub(crate) struct GspInitResponseSchema => GspInitResponse { gpu_name:Array <u8 , {GspInitResponse ::MAX_GPU_NAME_LEN }, {
Self::GPU_NAME_STRING_KEY}>,fb_regions: Accumulated<FbRegionSchema>,drivers/gpu/nova-core/gsp/fw/commands.rs +4
-2@@ -420,7 +420,7 @@ impl GspInitResponseSchema {/// Payload of the `GSP_INIT` response. #[cfg_attr(not( CONFIG_KUNIT ), allow(dead_code))] -struct GspInitResponse { +pub (crate )struct GspInitResponse { gpu_name:ArrayVec <u8 , {Self ::MAX_GPU_NAME_LEN }>, fb_regions:KVVec <FbRegion >, bar1_pde_base:u64 ,@@ -428,7 +428,36 @@ struct GspInitResponse { }impl GspInitResponse { -const MAX_GPU_NAME_LEN :usize =64 ; +pub (crate )const MAX_GPU_NAME_LEN :usize =64 ; + +/// A region with no tag is general-purpose memory. A tagged region is reserved for a
drivers/gpu/nova-core/gsp/fw/commands.rs +4
-0+/// firmware-internal use that the tag identifies. +const FB_REGION_TAG_NONE :u32 =0 ; + +/// Returns the GPU name, which GSP-RM sends with its NULL terminator.
drivers/gpu/nova-core/gsp/fw/commands.rs +7
-0+pub (crate )fn gpu_name (&self) -> &[u8 ] { + self.gpu_name.as_slice () + } + +/// Iterates over the FB regions the driver may allocate from. +/// +/// A region qualifies when it is untagged, unprotected, and supports both compression and
+ /// isochronous access, which is the same set the RPC path
selects from(quoted diff) +2
-0+ /// [`GspStaticConfigInfo::usable_fb_regions`]. + pub(crate) fn usable_fb_regions(&self) -> impl Iterator<Item =Range<u64>> + '_ {
drivers/gpu/nova-core/gsp/fw/commands.rs +8
-0+ self.fb_regions.iter ().filter_map (|region| { +if region.limit >= region.base + && region.tag ==Self ::FB_REGION_TAG_NONE + && !region.flags.protected () + && region.flags.support_compressed () + && region.flags.support_iso () + { + region.limit.checked_add(1).map(|end|region.base..end)
drivers/gpu/nova-core/gsp/fw/commands.rs +5
-0+ }else { +None + } + }) + } }nvkv_decode! {
Re: [PATCH 24/27] gpu: nova-core: gsp: pass the remaining log buffers to GSP-RM
In reply to John HubbardOn Tue, 18 Aug 2026 20:52:17 -0700
John Hubbard <[email protected]> wrote:
Quoted 46 lines
The libos loader finds each log buffer by looking up its eight-byte name in the init argument array, so a buffer the array does not name is never written to.
Nova-core allocates six log buffers and gives all six a debugfs file, but names only three, so the other three can never read back anything but zeros.
Name all six. RMARGS moves to the end of the array, which does not matter to a loader that searches by name.
Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/gsp.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp.rsindex 232905638169..f1bd66024b72 100644drivers/gpu/nova-core/gsp.rs +11
-1@@ -355,7 +355,19 @@ pub(crate) fn new( 2,LibosMemoryRegionInitArgument ::new ("LOGRM" , &logrm.buffer), )?; - libos.init_at (3 , LibosMemoryRegionInitArgument::new("RMARGS", rmargs))?; + libos.init_at ( +3 , +LibosMemoryRegionInitArgument ::new ("LOGMNOC" , &logmnoc.buffer), + )?; + libos.init_at ( +4 , +LibosMemoryRegionInitArgument ::new ("LOGROOT" , &logroot.buffer), + )?; + libos.init_at ( + 5, +
LibosMemoryRegionInitArgument::new("LOGRMON", &logrmon.buffer),drivers/gpu/nova-core/gsp.rs +2
-0+ )?; + libos.init_at(6,LibosMemoryRegionInitArgument::new("RMARGS", rmargs))?; libos.into() },
Re: [PATCH 26/27] gpu: nova-core: gsp: remove the retired system-info and static-info RPCs
In reply to John HubbardOn Tue, 18 Aug 2026 20:52:19 -0700
John Hubbard <[email protected]> wrote:
We can remove SetRegistry in gsp/commands.rs and gsp/fw/commands.rs as well.
Quoted 306 lines
The r000 boot path folds the system information and the static GPU configuration into the
GSP_INITrequest, whose reply carries that configuration back to the driver.The set-system-info and get-static-info commands stayed behind after the switch, unreachable and marked dead, along with the two payload structures that encoded them.
Remove both commands and their payloads, and keep the decoded static configuration that the
GSP_INITreply fills in. The two message-function entries stay, because that table catalogs the wire protocol rather than what the driver implements, and already names many functions nova-core never sends.Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/gsp.rs | 8 -- drivers/gpu/nova-core/gsp/commands.rs | 65 +------------ drivers/gpu/nova-core/gsp/fw/commands.rs | 115+---------------------- 3 files changed, 3 insertions(+), 185 deletions(-)
(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp.rsindex8e912eaf8e2e..b128153fda86100644drivers/gpu/nova-core/gsp.rs +0
-3@@ -407,14 +407,6 @@ pub(crate) fn new( }) } -/// Query the GSP for the static GPU information. -/// -/// The r000 boot path gets the same information from the
GSP_INITreply instead.drivers/gpu/nova-core/gsp.rs +0
-2-#[expect(dead_code)] - pub(crate) fn get_static_info(&self, bar: Bar0<'_>) ->Result<commands::GetGspStaticInfoReply> {
drivers/gpu/nova-core/gsp.rs +0
-3- self.cmdq.send_command (bar, commands::GetGspStaticInfo ) - } -/// Returns a shared handle to the GSP command queue. pub (crate )fn cmdq (&self) ->Arc <Cmdq > { self.cmdq.clone ()(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/commands.rsindex26ea07dc4a28..9079393da0b3100644 ---a/drivers/gpu/nova-core/gsp/commands.rs+++b/drivers/gpu/nova-core/gsp/commands.rs@@ -49,34 +49,6 @@vgpu::VgpuState, //};
drivers/gpu/nova-core/gsp/commands.rs +0
-3-/// The `GspSetSystemInfo` command. -/// -/// The r000 boot path folds this into the `GSP_INIT` payload instead. -pub(crate) struct SetSystemInfo<'a> {
drivers/gpu/nova-core/gsp/commands.rs +0
-7- pdev: &'a pci::Device<device::Bound>, - chipset: Chipset, -} - -#[expect(dead_code)] -impl <'a>SetSystemInfo <'a> { -/// Creates a new `GspSetSystemInfo` command using the parameters of
pdev.
- pub(crate) fn new(pdev: &'a pci::Device<device::Bound>, chipset:
Chipset) -> Self {drivers/gpu/nova-core/gsp/commands.rs +1
-52-Self { pdev, chipset } - } -} - -impl <'a>CommandToGsp for SetSystemInfo <'a> { -const FUNCTION :MsgFunction =MsgFunction ::GspSetSystemInfo ; -const IS_ASYNC :bool =true ; -type Command = fw::commands::GspSetSystemInfo ; -type Reply =NoReply ; -type InitError =Error ; - -fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > { -Self ::Command ::init (self.pdev, self.chipset) - } -} -struct RegistryEntry { key: &'staticstr , value:u32 ,@@ -186,48 +158,13 @@ fn init_variable_payload( } } -/// The `GetGspStaticInfo` command. -pub(crate) struct GetGspStaticInfo; - -impl CommandToGsp for GetGspStaticInfo { - const FUNCTION: MsgFunction = MsgFunction::GetGspStaticInfo; - type Command = fw::commands::GspStaticConfigInfo; - type Reply = GetGspStaticInfoReply; - type InitError = Infallible; - - fn init(&self) -> impl Init<Self::Command, Self::InitError> { - Self::Command::init_zeroed() - } -} - -/// The reply from the GSP to the [`GetGspStaticInfo`] command. +/// The static GPU configuration, as decoded from the `GSP_INIT` reply. pub(crate) struct GetGspStaticInfoReply { gpu_name: [u8;64 ],/// Usable FB (VRAM) regions for driver memory allocation. pub(crate) usable_fb_regions: KVec<Range<u64>>, } -impl MessageFromGsp for GetGspStaticInfoReply { - const FUNCTION: MsgFunction = MsgFunction::GetGspStaticInfo; - type Message = fw::commands::GspStaticConfigInfo; - type InitError = Error; - - fn read( - msg: &Self::Message, - _sbuffer: &mut SBufferIter<array::IntoIter<&[u8], 2>>, - ) -> Result<Self, Self::InitError> { - let mut usable_fb_regions = KVec::new(); - for region in msg.usable_fb_regions() { - usable_fb_regions.push(region, GFP_KERNEL)?; - } - - Ok(GetGspStaticInfoReply { - gpu_name: msg.gpu_name_str(), - usable_fb_regions, - }) - } -} - /// Error type for [`GetGspStaticInfoReply::gpu_name`]. #[derive(Debug)] pub(crate) enum GpuNameError {(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/fw/commands.rsindex00e40a435053..e49234f35d0f100644 ---a/drivers/gpu/nova-core/gsp/fw/commands.rs+++b/drivers/gpu/nova-core/gsp/fw/commands.rs@@ -14,11 +14,7 @@}, //};
drivers/gpu/nova-core/gsp/fw/commands.rs +1
-14-use crate ::{ - gpu::Chipset , - gsp::GSP_PAGE_SIZE , - num::IntoSafeCast ,// -}; +use crate ::gpu::Chipset ;use crate ::gsp::nvkv::{ nvkv_decode,@@ -37,56 +33,6 @@use super ::bindings; -/// Payload of the `GspSetSystemInfo` command. -#[repr(transparent)] -pub (crate )struct GspSetSystemInfo { - inner: bindings::GspSystemInfo , -} -static_assert! (size_of ::<GspSetSystemInfo >() <GSP_PAGE_SIZE ); - -impl GspSetSystemInfo { -/// Returns an in-place initializer for the `GspSetSystemInfo` command.
drivers/gpu/nova-core/gsp/fw/commands.rs +0
-6-pub (crate )fn init <'a>( - dev: &'a pci::Device <device::Bound >, - chipset:Chipset , - ) ->impl Init <Self ,Error > + 'a { -type InnerGspSystemInfo = bindings::GspSystemInfo ; - let pci_config_mirror_range =
chipset.pci_config_mirror_range();drivers/gpu/nova-core/gsp/fw/commands.rs +0
-7- let init_inner = try_init!(InnerGspSystemInfo { - gpuPhysAddr: dev.resource_start(0)?, - gpuPhysFbAddr: dev.resource_start(1)?, - gpuPhysInstAddr: dev.resource_start(3)?, - nvDomainBusDeviceFunc: u64::from(dev.dev_id()), - - // Using TASK_SIZE in r535_gsp_rpc_set_system_info()seems wrong because
- //TASK_SIZEis per-task. That's probably a design issue
in GSP-RM though.drivers/gpu/nova-core/gsp/fw/commands.rs +0
-3- maxUserVa: (1 << 47) - 4096, - pciConfigMirrorBase: pci_config_mirror_range.start, - pciConfigMirrorSize: pci_config_mirror_range.end -pci_config_mirror_range.start, -
- PCIDeviceID: (u32::from(dev.device_id()) << 16) |
u32::from(dev.vendor_id().as_raw()),
- PCISubDeviceID: (u32::from(dev.subsystem_device_id()) <<
16)drivers/gpu/nova-core/gsp/fw/commands.rs +0
-14- | u32::from(dev.subsystem_vendor_id()), - PCIRevisionID: u32::from(dev.revision_id()), - bIsPrimary: 0, - bPreserveVideoMemoryAllocations: 0, - ..Zeroable::init_zeroed() - }); - -try_init! (GspSetSystemInfo { - inner <- init_inner, - }) - } -} - -// SAFETY: These structs don't meet the no-padding requirements of AsBytes but -// that is not a problem because they are not
used outside the kernel. -unsafe impl AsBytes for GspSetSystemInfo {}(quoted diff) +0
-2- -// SAFETY: These structs don't meet the no-padding requirements ofFromBytes but -// that is not a problem because they are not
used outside the kernel. -unsafe impl FromBytes for GspSetSystemInfo {} -
#[repr(transparent)]
pub(crate) structPackedRegistryEntry(bindings::PACKED_REGISTRY_ENTRY);drivers/gpu/nova-core/gsp/fw/commands.rs +0
-4@@ -136,60 +82,6 @@ unsafe impl AsBytes for PackedRegistryTable {}// are valid. unsafe impl FromBytes for PackedRegistryTable {} -/// Payload of the `GetGspStaticInfo` command and message. -#[repr(transparent)] -#[derive( Zeroable )] -pub(crate) struct
GspStaticConfigInfo(bindings::GspStaticConfigInfo_t); -(quoted diff) +0
-2-impl GspStaticConfigInfo { - /// Returns a bytes array containing the (hopefully)zero-terminated name of this GPU.
drivers/gpu/nova-core/gsp/fw/commands.rs +0
-5-pub (crate )fn gpu_name_str (&self) -> [u8 ;64 ] { - self.0 .gpuNameString - } - -/// Returns an iterator over valid FB regions from GSP firmware data.
drivers/gpu/nova-core/gsp/fw/commands.rs +0
-3-fn fb_regions ( - &self, - ) -> impl Iterator<Item =
&bindings::NV2080_CTRL_CMD_FB_GET_FB_REGION_FB_REGION_INFO> {drivers/gpu/nova-core/gsp/fw/commands.rs +0
-11-let fb_info = &self.0 .fbRegionInfoParams; - fb_info - .fbRegion - .iter () - .take (fb_info.numFBRegions.into_safe_cast ()) - .filter (|reg| reg.limit >= reg.base) - } - -/// Iterates over usable FB regions from GSP firmware data. -/// -/// Each yielded region is a [`Range<u64>`] suitable for driver memory allocation.
- /// Usable regions are those that satisfy all the following
properties:drivers/gpu/nova-core/gsp/fw/commands.rs +0
-3-/// - Are not reserved for firmware internal use. -/// - Are not protected (hardware-enforced access restrictions). -/// - Support compression (can use GPU memory compression for bandwidth).
- /// - Support ISO (isochronous memory for display requiring
guaranteed bandwidth).
- pub(crate) fnusable_fb_regions(&self)-> impl Iterator<Item =
Range<u64>> + '_ {(quoted diff) +0
-2- self.fb_regions().filter_map(|reg| { - // Filter: not reserved, not protected, supportscompression and ISO.
drivers/gpu/nova-core/gsp/fw/commands.rs +0
-14-if reg.reserved ==0 - && reg.bProtected ==0 - && reg.supportCompressed !=0 - && reg.supportISO !=0 - { - reg.limit.checked_add (1 ).map (|end| reg.base..end) - }else { -None - } - }) - } -} - -// SAFETY: Padding is explicit and will not contain uninitialized data. -unsafe impl AsBytes for GspStaticConfigInfo {}
(quoted diff) +0
-2- -// SAFETY: This struct only contains integer types for which all bitpatterns -// are valid.
drivers/gpu/nova-core/gsp/fw/commands.rs +0
-4-unsafe impl FromBytes for GspStaticConfigInfo {} -/// Power level requested to the [`UnloadingGuestDriver`] command. #[derive( Clone , Copy , Debug , PartialEq , Eq )] #[repr( u32 )] @@ -369,8 +261,6 @@ impl GspInitRequest {const NV_DOMAIN_BUS_DEVICE_FUNC_KEY :KeyId =0x1020 ;/// Describes `dev` to GSP-RM and asks it to apply `regkeys`. -/// -/// The same identifiers reach GSP-RM through [
GspSetSystemInfo::init] on the RPC path. pub(crate) fn new(dev: &pci::Device<device::Bound>, chipset: Chipset,drivers/gpu/nova-core/gsp/fw/commands.rs +0
-0@@ -442,8 +332,7 @@ pub(crate) fn gpu_name(&self) -> &[u8] {/// Iterates over the FB regions the driver may allocate from. /// /// A region qualifies when it is untagged, unprotected, and supports both compression and
- /// isochronous access, which is the same set the RPC path
selects fromdrivers/gpu/nova-core/gsp/fw/commands.rs +1
-1-/// [`GspStaticConfigInfo::usable_fb_regions`]. +/// isochronous access. pub(crate) fn usable_fb_regions(&self) -> impl Iterator<Item =Range<u64>> + '_ { self.fb_regions.iter().filter_map(|region| {
if region.limit >= region.base
Re: [PATCH 27/27] gpu: nova-core: firmware: delete the r570 bindings
In reply to John HubbardOn Tue, 18 Aug 2026 20:52:20 -0700
John Hubbard <[email protected]> wrote:
Quoted 1,265 lines
Nothing referenced the r570 firmware bindings once the driver started compiling against the r000 headers, but the module stayed declared and its generated definitions kept being built.
Delete the module and its bindings, along with the last two comments that named r570.
Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/fsp.rs | 3 +- drivers/gpu/nova-core/gsp/fw.rs | 4 +- drivers/gpu/nova-core/gsp/fw/r570_144.rs | 31 - .../gpu/nova-core/gsp/fw/r570_144/bindings.rs | 1060 ----------------- 4 files changed, 3 insertions(+), 1095 deletions(-) delete mode 100644 drivers/gpu/nova-core/gsp/fw/r570_144.rs delete mode 100644 drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs(quoted diff) +0
-0
b/drivers/gpu/nova-core/fsp.rsindexab685fb4168f..668d64e8c8db100644drivers/gpu/nova-core/fsp.rs +0
-0@@ -256,7 +256,8 @@ fn frts_vidmem_offset(hal: &dyn hal::FspHal,
fb_info: &FbSizes) -> Result<u64> { // As per OpenRM'skfspPrepareBootCommands_GH100. if fb_info.pmu_reserved_size != 0 {
offset = (offset +u64::from(fb_info.pmu_reserved_size))drivers/gpu/nova-core/fsp.rs +1
-1-// The 2 MiB alignment is r570-specific. +// Open RM aligns this to WPR granularity, which is 128 KiB. 2 MiB is a
drivers/gpu/nova-core/fsp.rs +1
-0+// multiple of that and reserves at least as much. .align_up(Alignment::new::<SZ_2M>()) .ok_or (EINVAL )?; }(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/fw.rsindexc24808e41941..55e032db649b100644 ---a/drivers/gpu/nova-core/gsp/fw.rs
+++b/drivers/gpu/nova-core/gsp/fw.rsdrivers/gpu/nova-core/gsp/fw.rs +1
-2@@ -3,7 +3,6 @@pub (crate )mod commands;mod r000_00; -mod r570_144;// Alias to avoid repeating the version number with every use. use r000_00as bindings;@@ -512,10 +511,9 @@ fn init(sequence: u32, cmd_size: usize, function: MsgFunction) -> impl Init<Self } } -/// GSP Message Element (r000 MCTP/NVDM format). +/// GSP Message Element, in the MCTP/NVDM format. /// /// This is the transport-layer header for messages exchanged with GSP-RM. -/// r000 firmware uses MCTP/NVDM framing instead of the r570
GSP_MSG_QUEUE_ELEMENT. #[repr(C)]pub(crate) struct GspMsgElement { mctp_magic: u32,(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/fw/r570_144.rsdeleted file mode 100644 index 2e6f0d298756..000000000000drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-7@@ -1,31 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -//! Firmware bindings. -//! -//! Imports the generated bindings by `bindgen`. -//! -//! This module may not be directly used. Please abstract or re-export the needed symbols in the -//! parent module instead.
drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-21- -#![allow( -dead_code, -clippy::all, -clippy::undocumented_unsafe_blocks, -clippy::ptr_as_ptr, -clippy::ref_as_ptr, -missing_docs, -non_camel_case_types, -non_upper_case_globals, -non_snake_case, -improper_ctypes, -unreachable_pub, -unsafe_op_in_unsafe_fn -)] -use kernel::ffi; -use pin_init::MaybeZeroable ; - -include! ("r570_144/bindings.rs" ); - -// SAFETY: This type has a size of zero, so its inclusion into another type should not affect their -// ability to implement
Zeroable. -unsafe impl<T>kernel::prelude::Zeroablefor __IncompleteArrayField<T> {} diff --gita/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rsb/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rsdeleted file mode 100644 index afe3e007f088..000000000000 ---a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs+++/dev/nulldrivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-5@@ -1,1060 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#[repr( C )] -#[derive( Default )] -pub struct __IncompleteArrayField<T>(::core::marker::PhantomData<T>,[T; 0]); -impl<T> __IncompleteArrayField<T> {
drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-23-#[inline] -pub const fn new () ->Self { -__IncompleteArrayField (::core::marker::PhantomData , []) - } -#[inline] -pub fn as_ptr (&self) -> *const T { - selfas *const _ as *const T - } -#[inline] -pub fn as_mut_ptr (&mut self) -> *mut T { - selfas *mut _ as *mut T - } -#[inline] -pub unsafe fn as_slice (&self, len:usize ) -> &[T ] { - ::core::slice::from_raw_parts (self.as_ptr (), len) - } -#[inline] -pub unsafe fn as_mut_slice (&mut self, len:usize ) -> &mut [T ] { - ::core::slice::from_raw_parts_mut (self.as_mut_ptr (), len) - } -} -impl <T > ::core::fmt::Debug for __IncompleteArrayField <T > { - fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) ->::core::fmt::Result {
drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-17- fmt.write_str ("__IncompleteArrayField" ) - } -} -pub const NV2080_CTRL_GPU_SET_POWER_STATE_GPU_LEVEL_0 :u32 =0 ; -pub const NV2080_CTRL_GPU_SET_POWER_STATE_GPU_LEVEL_3 :u32 =3 ; -pub const NV2080_CTRL_GPU_SET_POWER_STATE_GPU_LEVEL_7 :u32 =7 ; -pub const NV_VGPU_MSG_SIGNATURE_VALID :u32 =1129337430 ; -pub const GSP_FW_HEAP_PARAM_OS_SIZE_LIBOS2 :u32 =0 ; -pub const GSP_FW_HEAP_PARAM_OS_SIZE_LIBOS3_BAREMETAL :u32 =23068672 ; -pub const GSP_FW_HEAP_PARAM_BASE_RM_SIZE_TU10X :u32 =8388608 ; -pub const GSP_FW_HEAP_PARAM_BASE_RM_SIZE_GH100 :u32 =14680064 ; -pub const GSP_FW_HEAP_PARAM_SIZE_PER_GB_FB :u32 =98304 ; -pub const GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE :u32 =100663296 ; -pub const GSP_FW_HEAP_SIZE_VGPU_DEFAULT :u32 =609222656 ; -pub const GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS2_MIN_MB :u32 =64 ; -pub const GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS2_MAX_MB :u32 =256 ; -pub const GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MIN_MB: u32 =88; -pub const
GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MAX_MB: u32 = 280; -pub constGSP_FW_WPR_META_REVISION: u32 = 1;drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-13-pub const GSP_FW_WPR_META_MAGIC :i64 = -2577556379034558285 ; -pub const REGISTRY_TABLE_ENTRY_TYPE_DWORD :u32 =1 ; -pub const GSP_MSG_QUEUE_ELEMENT_SIZE_MAX :u32 =65536 ; -pub type __u8 = ffi::c_uchar ; -pub type __u16 = ffi::c_ushort ; -pub type __u32 = ffi::c_uint ; -pub type __u64 = ffi::c_ulonglong ; -pub type u8_ =__u8 ; -pub type u16_ =__u16 ; -pub type u32_ =__u32 ; -pub type u64_ =__u64 ; -pub const NV_VGPU_MSG_FUNCTION_NOP :_bindgen_ty_2 =0 ; -pub const NV_VGPU_MSG_FUNCTION_SET_GUEST_SYSTEM_INFO :_bindgen_ty_2 = 1; -pub const
NV_VGPU_MSG_FUNCTION_ALLOC_ROOT:_bindgen_ty_2= 2;drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-15-pub const NV_VGPU_MSG_FUNCTION_ALLOC_DEVICE :_bindgen_ty_2 =3 ; -pub const NV_VGPU_MSG_FUNCTION_ALLOC_MEMORY :_bindgen_ty_2 =4 ; -pub const NV_VGPU_MSG_FUNCTION_ALLOC_CTX_DMA :_bindgen_ty_2 =5 ; -pub const NV_VGPU_MSG_FUNCTION_ALLOC_CHANNEL_DMA :_bindgen_ty_2 =6 ; -pub const NV_VGPU_MSG_FUNCTION_MAP_MEMORY :_bindgen_ty_2 =7 ; -pub const NV_VGPU_MSG_FUNCTION_BIND_CTX_DMA :_bindgen_ty_2 =8 ; -pub const NV_VGPU_MSG_FUNCTION_ALLOC_OBJECT :_bindgen_ty_2 =9 ; -pub const NV_VGPU_MSG_FUNCTION_FREE :_bindgen_ty_2 =10 ; -pub const NV_VGPU_MSG_FUNCTION_LOG :_bindgen_ty_2 =11 ; -pub const NV_VGPU_MSG_FUNCTION_ALLOC_VIDMEM :_bindgen_ty_2 =12 ; -pub const NV_VGPU_MSG_FUNCTION_UNMAP_MEMORY :_bindgen_ty_2 =13 ; -pub const NV_VGPU_MSG_FUNCTION_MAP_MEMORY_DMA :_bindgen_ty_2 =14 ; -pub const NV_VGPU_MSG_FUNCTION_UNMAP_MEMORY_DMA :_bindgen_ty_2 =15 ; -pub const NV_VGPU_MSG_FUNCTION_GET_EDID :_bindgen_ty_2 =16 ; -pub const NV_VGPU_MSG_FUNCTION_ALLOC_DISP_CHANNEL: _bindgen_ty_2 =17; -pub const
NV_VGPU_MSG_FUNCTION_ALLOC_DISP_OBJECT:_bindgen_ty_2= 18; -pub constNV_VGPU_MSG_FUNCTION_ALLOC_SUBDEVICE:_bindgen_ty_2= 19; -pub constNV_VGPU_MSG_FUNCTION_ALLOC_DYNAMIC_MEMORY:_bindgen_ty_2= 20; -pub constNV_VGPU_MSG_FUNCTION_DUP_OBJECT:_bindgen_ty_2= 21; -pub constNV_VGPU_MSG_FUNCTION_IDLE_CHANNELS:_bindgen_ty_2= 22; -pub constNV_VGPU_MSG_FUNCTION_ALLOC_EVENT:_bindgen_ty_2= 23; -pub constNV_VGPU_MSG_FUNCTION_SEND_EVENT:_bindgen_ty_2= 24; -pub constNV_VGPU_MSG_FUNCTION_REMAPPER_CONTROL:_bindgen_ty_2= 25; -pub constNV_VGPU_MSG_FUNCTION_DMA_CONTROL:_bindgen_ty_2= 26; -pub constNV_VGPU_MSG_FUNCTION_DMA_FILL_PTE_MEM:_bindgen_ty_2= 27; -pub constNV_VGPU_MSG_FUNCTION_MANAGE_HW_RESOURCE:_bindgen_ty_2= 28; -pub constNV_VGPU_MSG_FUNCTION_BIND_ARBITRARY_CTX_DMA:_bindgen_ty_2= 29; -pub constNV_VGPU_MSG_FUNCTION_CREATE_FB_SEGMENT:_bindgen_ty_2= 30; -pub constNV_VGPU_MSG_FUNCTION_DESTROY_FB_SEGMENT:_bindgen_ty_2= 31; -pub constNV_VGPU_MSG_FUNCTION_ALLOC_SHARE_DEVICE:_bindgen_ty_2= 32; -pub constNV_VGPU_MSG_FUNCTION_DEFERRED_API_CONTROL:_bindgen_ty_2= 33; -pub constNV_VGPU_MSG_FUNCTION_REMOVE_DEFERRED_API:_bindgen_ty_2= 34; -pub constNV_VGPU_MSG_FUNCTION_SIM_ESCAPE_READ:_bindgen_ty_2= 35; -pub constNV_VGPU_MSG_FUNCTION_SIM_ESCAPE_WRITE:_bindgen_ty_2= 36; -pub constNV_VGPU_MSG_FUNCTION_SIM_MANAGE_DISPLAY_CONTEXT_DMA:_bindgen_ty_2= 37; -pub constNV_VGPU_MSG_FUNCTION_FREE_VIDMEM_VIRT:_bindgen_ty_2= 38; -pub constNV_VGPU_MSG_FUNCTION_PERF_GET_PSTATE_INFO:_bindgen_ty_2= 39; -pub constNV_VGPU_MSG_FUNCTION_PERF_GET_PERFMON_SAMPLE:_bindgen_ty_2= 40; -pub constNV_VGPU_MSG_FUNCTION_PERF_GET_VIRTUAL_PSTATE_INFO:_bindgen_ty_2= 41; -pub constNV_VGPU_MSG_FUNCTION_PERF_GET_LEVEL_INFO:_bindgen_ty_2= 42; -pub constNV_VGPU_MSG_FUNCTION_MAP_SEMA_MEMORY:_bindgen_ty_2= 43; -pub constNV_VGPU_MSG_FUNCTION_UNMAP_SEMA_MEMORY:_bindgen_ty_2= 44; -pub constNV_VGPU_MSG_FUNCTION_SET_SURFACE_PROPERTIES:_bindgen_ty_2= 45; -pub constNV_VGPU_MSG_FUNCTION_CLEANUP_SURFACE:_bindgen_ty_2= 46; -pub constNV_VGPU_MSG_FUNCTION_UNLOADING_GUEST_DRIVER:_bindgen_ty_2= 47; -pub constNV_VGPU_MSG_FUNCTION_TDR_SET_TIMEOUT_STATE:_bindgen_ty_2= 48; -pub constNV_VGPU_MSG_FUNCTION_SWITCH_TO_VGA:_bindgen_ty_2= 49; -pub constNV_VGPU_MSG_FUNCTION_GPU_EXEC_REG_OPS:_bindgen_ty_2= 50; -pub constNV_VGPU_MSG_FUNCTION_GET_STATIC_INFO:_bindgen_ty_2= 51; -pub constNV_VGPU_MSG_FUNCTION_ALLOC_VIRTMEM:_bindgen_ty_2= 52; -pub constNV_VGPU_MSG_FUNCTION_UPDATE_PDE_2:_bindgen_ty_2= 53; -pub constNV_VGPU_MSG_FUNCTION_SET_PAGE_DIRECTORY:_bindgen_ty_2= 54; -pub constNV_VGPU_MSG_FUNCTION_GET_STATIC_PSTATE_INFO:_bindgen_ty_2= 55; -pub constNV_VGPU_MSG_FUNCTION_TRANSLATE_GUEST_GPU_PTES:_bindgen_ty_2= 56; -pub constNV_VGPU_MSG_FUNCTION_RESERVED_57:_bindgen_ty_2= 57; -pub constNV_VGPU_MSG_FUNCTION_RESET_CURRENT_GR_CONTEXT:_bindgen_ty_2= 58; -pub constNV_VGPU_MSG_FUNCTION_SET_SEMA_MEM_VALIDATION_STATE:_bindgen_ty_2= 59; -pub constNV_VGPU_MSG_FUNCTION_GET_ENGINE_UTILIZATION:_bindgen_ty_2= 60; -pub constNV_VGPU_MSG_FUNCTION_UPDATE_GPU_PDES:_bindgen_ty_2= 61; -pub constNV_VGPU_MSG_FUNCTION_GET_ENCODER_CAPACITY:_bindgen_ty_2= 62; -pub constNV_VGPU_MSG_FUNCTION_VGPU_PF_REG_READ32:_bindgen_ty_2= 63; -pub constNV_VGPU_MSG_FUNCTION_SET_GUEST_SYSTEM_INFO_EXT:_bindgen_ty_2= 64; -pub constNV_VGPU_MSG_FUNCTION_GET_GSP_STATIC_INFO:_bindgen_ty_2= 65; -pub constNV_VGPU_MSG_FUNCTION_RMFS_INIT:_bindgen_ty_2= 66; -pub constNV_VGPU_MSG_FUNCTION_RMFS_CLOSE_QUEUE:_bindgen_ty_2= 67; -pub constNV_VGPU_MSG_FUNCTION_RMFS_CLEANUP:_bindgen_ty_2= 68; -pub constNV_VGPU_MSG_FUNCTION_RMFS_TEST:_bindgen_ty_2= 69; -pub constNV_VGPU_MSG_FUNCTION_UPDATE_BAR_PDE:_bindgen_ty_2= 70; -pub constNV_VGPU_MSG_FUNCTION_CONTINUATION_RECORD:_bindgen_ty_2= 71; -pub constNV_VGPU_MSG_FUNCTION_GSP_SET_SYSTEM_INFO:_bindgen_ty_2= 72;drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-2-pub const NV_VGPU_MSG_FUNCTION_SET_REGISTRY :_bindgen_ty_2 =73 ; -pub const NV_VGPU_MSG_FUNCTION_GSP_INIT_POST_OBJGPU: _bindgen_ty_2 =74; -pub const
NV_VGPU_MSG_FUNCTION_SUBDEV_EVENT_SET_NOTIFICATION:_bindgen_ty_2= 75; -pub constNV_VGPU_MSG_FUNCTION_GSP_RM_CONTROL:_bindgen_ty_2= 76; -pub constNV_VGPU_MSG_FUNCTION_GET_STATIC_INFO2:_bindgen_ty_2= 77; -pub constNV_VGPU_MSG_FUNCTION_DUMP_PROTOBUF_COMPONENT:_bindgen_ty_2= 78; -pub constNV_VGPU_MSG_FUNCTION_UNSET_PAGE_DIRECTORY:_bindgen_ty_2= 79; -pub constNV_VGPU_MSG_FUNCTION_GET_CONSOLIDATED_STATIC_INFO:_bindgen_ty_2= 80; -pub constNV_VGPU_MSG_FUNCTION_GMMU_REGISTER_FAULT_BUFFER:_bindgen_ty_2= 81; -pub constNV_VGPU_MSG_FUNCTION_GMMU_UNREGISTER_FAULT_BUFFER:_bindgen_ty_2= 82; -pub constNV_VGPU_MSG_FUNCTION_GMMU_REGISTER_CLIENT_SHADOW_FAULT_BUFFER:_bindgen_ty_2= 83; -pub constNV_VGPU_MSG_FUNCTION_GMMU_UNREGISTER_CLIENT_SHADOW_FAULT_BUFFER:_bindgen_ty_2= 84; -pub constNV_VGPU_MSG_FUNCTION_CTRL_SET_VGPU_FB_USAGE:_bindgen_ty_2= 85; -pub constNV_VGPU_MSG_FUNCTION_CTRL_NVFBC_SW_SESSION_UPDATE_INFO:_bindgen_ty_2= 86; -pub constNV_VGPU_MSG_FUNCTION_CTRL_NVENC_SW_SESSION_UPDATE_INFO:_bindgen_ty_2= 87; -pub constNV_VGPU_MSG_FUNCTION_CTRL_RESET_CHANNEL:_bindgen_ty_2= 88; -pub constNV_VGPU_MSG_FUNCTION_CTRL_RESET_ISOLATED_CHANNEL:_bindgen_ty_2= 89; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GPU_HANDLE_VF_PRI_FAULT:_bindgen_ty_2= 90; -pub constNV_VGPU_MSG_FUNCTION_CTRL_CLK_GET_EXTENDED_INFO:_bindgen_ty_2= 91;drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-2-pub const NV_VGPU_MSG_FUNCTION_CTRL_PERF_BOOST :_bindgen_ty_2 =92 ; -pub const NV_VGPU_MSG_FUNCTION_CTRL_PERF_VPSTATES_GET_CONTROL:
_bindgen_ty_2= 93; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GET_ZBC_CLEAR_TABLE:_bindgen_ty_2= 94; -pub constNV_VGPU_MSG_FUNCTION_CTRL_SET_ZBC_COLOR_CLEAR:_bindgen_ty_2= 95; -pub constNV_VGPU_MSG_FUNCTION_CTRL_SET_ZBC_DEPTH_CLEAR:_bindgen_ty_2= 96; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GPFIFO_SCHEDULE:_bindgen_ty_2= 97; -pub constNV_VGPU_MSG_FUNCTION_CTRL_SET_TIMESLICE:_bindgen_ty_2= 98; -pub constNV_VGPU_MSG_FUNCTION_CTRL_PREEMPT:_bindgen_ty_2= 99; -pub constNV_VGPU_MSG_FUNCTION_CTRL_FIFO_DISABLE_CHANNELS:_bindgen_ty_2= 100; -pub constNV_VGPU_MSG_FUNCTION_CTRL_SET_TSG_INTERLEAVE_LEVEL:_bindgen_ty_2= 101; -pub constNV_VGPU_MSG_FUNCTION_CTRL_SET_CHANNEL_INTERLEAVE_LEVEL:_bindgen_ty_2= 102; -pub constNV_VGPU_MSG_FUNCTION_GSP_RM_ALLOC:_bindgen_ty_2= 103; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GET_P2P_CAPS_V2:_bindgen_ty_2= 104; -pub constNV_VGPU_MSG_FUNCTION_CTRL_CIPHER_AES_ENCRYPT:_bindgen_ty_2= 105; -pub constNV_VGPU_MSG_FUNCTION_CTRL_CIPHER_SESSION_KEY:_bindgen_ty_2= 106; -pub constNV_VGPU_MSG_FUNCTION_CTRL_CIPHER_SESSION_KEY_STATUS:_bindgen_ty_2= 107; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_CLEAR_ALL_SM_ERROR_STATES:_bindgen_ty_2= 108; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_READ_ALL_SM_ERROR_STATES:_bindgen_ty_2= 109; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_SET_EXCEPTION_MASK:_bindgen_ty_2= 110; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GPU_PROMOTE_CTX:_bindgen_ty_2= 111; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GR_CTXSW_PREEMPTION_BIND:_bindgen_ty_2= 112; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GR_SET_CTXSW_PREEMPTION_MODE:_bindgen_ty_2= 113; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GR_CTXSW_ZCULL_BIND:_bindgen_ty_2= 114; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GPU_INITIALIZE_CTX:_bindgen_ty_2= 115; -pub constNV_VGPU_MSG_FUNCTION_CTRL_VASPACE_COPY_SERVER_RESERVED_PDES:_bindgen_ty_2= 116; -pub constNV_VGPU_MSG_FUNCTION_CTRL_FIFO_CLEAR_FAULTED_BIT:_bindgen_ty_2= 117; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GET_LATEST_ECC_ADDRESSES:_bindgen_ty_2= 118; -pub constNV_VGPU_MSG_FUNCTION_CTRL_MC_SERVICE_INTERRUPTS:_bindgen_ty_2= 119; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DMA_SET_DEFAULT_VASPACE:_bindgen_ty_2= 120; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GET_CE_PCE_MASK:_bindgen_ty_2= 121; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GET_ZBC_CLEAR_TABLE_ENTRY:_bindgen_ty_2= 122; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GET_NVLINK_PEER_ID_MASK:_bindgen_ty_2= 123; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GET_NVLINK_STATUS:_bindgen_ty_2= 124; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GET_P2P_CAPS:_bindgen_ty_2= 125; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GET_P2P_CAPS_MATRIX:_bindgen_ty_2= 126; -pub constNV_VGPU_MSG_FUNCTION_RESERVED_0:_bindgen_ty_2= 127; -pub constNV_VGPU_MSG_FUNCTION_CTRL_RESERVE_PM_AREA_SMPC:_bindgen_ty_2= 128; -pub constNV_VGPU_MSG_FUNCTION_CTRL_RESERVE_HWPM_LEGACY:_bindgen_ty_2= 129; -pub constNV_VGPU_MSG_FUNCTION_CTRL_B0CC_EXEC_REG_OPS:_bindgen_ty_2= 130; -pub constNV_VGPU_MSG_FUNCTION_CTRL_BIND_PM_RESOURCES:_bindgen_ty_2= 131; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_SUSPEND_CONTEXT:_bindgen_ty_2= 132; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_RESUME_CONTEXT:_bindgen_ty_2= 133; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_EXEC_REG_OPS:_bindgen_ty_2= 134; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_SET_MODE_MMU_DEBUG:_bindgen_ty_2= 135; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_READ_SINGLE_SM_ERROR_STATE:_bindgen_ty_2= 136; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_CLEAR_SINGLE_SM_ERROR_STATE:_bindgen_ty_2= 137; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_SET_MODE_ERRBAR_DEBUG:_bindgen_ty_2= 138; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_SET_NEXT_STOP_TRIGGER_TYPE:_bindgen_ty_2= 139; -pub constNV_VGPU_MSG_FUNCTION_CTRL_ALLOC_PMA_STREAM:_bindgen_ty_2= 140; -pub constNV_VGPU_MSG_FUNCTION_CTRL_PMA_STREAM_UPDATE_GET_PUT:_bindgen_ty_2= 141; -pub constNV_VGPU_MSG_FUNCTION_CTRL_FB_GET_INFO_V2:_bindgen_ty_2= 142; -pub constNV_VGPU_MSG_FUNCTION_CTRL_FIFO_SET_CHANNEL_PROPERTIES:_bindgen_ty_2= 143; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GR_GET_CTX_BUFFER_INFO:_bindgen_ty_2= 144; -pub constNV_VGPU_MSG_FUNCTION_CTRL_KGR_GET_CTX_BUFFER_PTES:_bindgen_ty_2= 145; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GPU_EVICT_CTX:_bindgen_ty_2= 146; -pub constNV_VGPU_MSG_FUNCTION_CTRL_FB_GET_FS_INFO:_bindgen_ty_2= 147; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GRMGR_GET_GR_FS_INFO:_bindgen_ty_2= 148; -pub constNV_VGPU_MSG_FUNCTION_CTRL_STOP_CHANNEL:_bindgen_ty_2= 149; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GR_PC_SAMPLING_MODE:_bindgen_ty_2= 150; -pub constNV_VGPU_MSG_FUNCTION_CTRL_PERF_RATED_TDP_GET_STATUS:_bindgen_ty_2= 151; -pub constNV_VGPU_MSG_FUNCTION_CTRL_PERF_RATED_TDP_SET_CONTROL:_bindgen_ty_2= 152; -pub constNV_VGPU_MSG_FUNCTION_CTRL_FREE_PMA_STREAM:_bindgen_ty_2= 153; -pub constNV_VGPU_MSG_FUNCTION_CTRL_TIMER_SET_GR_TICK_FREQ:_bindgen_ty_2= 154; -pub constNV_VGPU_MSG_FUNCTION_CTRL_FIFO_SETUP_VF_ZOMBIE_SUBCTX_PDB:_bindgen_ty_2= 155; -pub constNV_VGPU_MSG_FUNCTION_GET_CONSOLIDATED_GR_STATIC_INFO:_bindgen_ty_2= 156; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_SET_SINGLE_SM_SINGLE_STEP:_bindgen_ty_2= 157; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GR_GET_TPC_PARTITION_MODE:_bindgen_ty_2= 158; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GR_SET_TPC_PARTITION_MODE:_bindgen_ty_2= 159; -pub constNV_VGPU_MSG_FUNCTION_UVM_PAGING_CHANNEL_ALLOCATE:_bindgen_ty_2= 160; -pub constNV_VGPU_MSG_FUNCTION_UVM_PAGING_CHANNEL_DESTROY:_bindgen_ty_2= 161; -pub constNV_VGPU_MSG_FUNCTION_UVM_PAGING_CHANNEL_MAP:_bindgen_ty_2= 162; -pub constNV_VGPU_MSG_FUNCTION_UVM_PAGING_CHANNEL_UNMAP:_bindgen_ty_2= 163; -pub constNV_VGPU_MSG_FUNCTION_UVM_PAGING_CHANNEL_PUSH_STREAM:_bindgen_ty_2= 164; -pub constNV_VGPU_MSG_FUNCTION_UVM_PAGING_CHANNEL_SET_HANDLES:_bindgen_ty_2= 165; -pub constNV_VGPU_MSG_FUNCTION_UVM_METHOD_STREAM_GUEST_PAGES_OPERATION:_bindgen_ty_2= 166; -pub constNV_VGPU_MSG_FUNCTION_CTRL_INTERNAL_QUIESCE_PMA_CHANNEL:_bindgen_ty_2= 167; -pub constNV_VGPU_MSG_FUNCTION_DCE_RM_INIT:_bindgen_ty_2= 168; -pub constNV_VGPU_MSG_FUNCTION_REGISTER_VIRTUAL_EVENT_BUFFER:_bindgen_ty_2= 169; -pub constNV_VGPU_MSG_FUNCTION_CTRL_EVENT_BUFFER_UPDATE_GET:_bindgen_ty_2= 170; -pub constNV_VGPU_MSG_FUNCTION_GET_PLCABLE_ADDRESS_KIND:_bindgen_ty_2= 171; -pub constNV_VGPU_MSG_FUNCTION_CTRL_PERF_LIMITS_SET_STATUS_V2:_bindgen_ty_2= 172; -pub constNV_VGPU_MSG_FUNCTION_CTRL_INTERNAL_SRIOV_PROMOTE_PMA_STREAM:_bindgen_ty_2= 173; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GET_MMU_DEBUG_MODE:_bindgen_ty_2= 174; -pub constNV_VGPU_MSG_FUNCTION_CTRL_INTERNAL_PROMOTE_FAULT_METHOD_BUFFERS:_bindgen_ty_2= 175; -pub constNV_VGPU_MSG_FUNCTION_CTRL_FLCN_GET_CTX_BUFFER_SIZE:_bindgen_ty_2= 176; -pub constNV_VGPU_MSG_FUNCTION_CTRL_FLCN_GET_CTX_BUFFER_INFO:_bindgen_ty_2= 177; -pub constNV_VGPU_MSG_FUNCTION_DISABLE_CHANNELS:_bindgen_ty_2= 178; -pub constNV_VGPU_MSG_FUNCTION_CTRL_FABRIC_MEMORY_DESCRIBE:_bindgen_ty_2= 179; -pub constNV_VGPU_MSG_FUNCTION_CTRL_FABRIC_MEM_STATS:_bindgen_ty_2= 180; -pub constNV_VGPU_MSG_FUNCTION_SAVE_HIBERNATION_DATA:_bindgen_ty_2= 181; -pub constNV_VGPU_MSG_FUNCTION_RESTORE_HIBERNATION_DATA:_bindgen_ty_2= 182; -pub constNV_VGPU_MSG_FUNCTION_CTRL_INTERNAL_MEMSYS_SET_ZBC_REFERENCED:_bindgen_ty_2= 183; -pub constNV_VGPU_MSG_FUNCTION_CTRL_EXEC_PARTITIONS_CREATE:_bindgen_ty_2= 184; -pub constNV_VGPU_MSG_FUNCTION_CTRL_EXEC_PARTITIONS_DELETE:_bindgen_ty_2= 185; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GPFIFO_GET_WORK_SUBMIT_TOKEN:_bindgen_ty_2= 186; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GPFIFO_SET_WORK_SUBMIT_TOKEN_NOTIF_INDEX:_bindgen_ty_2= 187; -pub constNV_VGPU_MSG_FUNCTION_PMA_SCRUBBER_SHARED_BUFFER_GUEST_PAGES_OPERATION:_bindgen_ty_2=drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-2-188 ; -pub const
NV_VGPU_MSG_FUNCTION_CTRL_MASTER_GET_VIRTUAL_FUNCTION_ERROR_CONT_INTR_MASK:drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-2- _bindgen_ty_2 =189 ; -pub const
NV_VGPU_MSG_FUNCTION_SET_SYSMEM_DIRTY_PAGE_TRACKING_BUFFER:_bindgen_ty_2= 190; -pub constNV_VGPU_MSG_FUNCTION_CTRL_SUBDEVICE_GET_P2P_CAPS:_bindgen_ty_2= 191; -pub constNV_VGPU_MSG_FUNCTION_CTRL_BUS_SET_P2P_MAPPING:_bindgen_ty_2= 192; -pub constNV_VGPU_MSG_FUNCTION_CTRL_BUS_UNSET_P2P_MAPPING:_bindgen_ty_2= 193; -pub constNV_VGPU_MSG_FUNCTION_CTRL_FLA_SETUP_INSTANCE_MEM_BLOCK:_bindgen_ty_2= 194; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GPU_MIGRATABLE_OPS:_bindgen_ty_2= 195; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GET_TOTAL_HS_CREDITS:_bindgen_ty_2= 196; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GET_HS_CREDITS:_bindgen_ty_2= 197; -pub constNV_VGPU_MSG_FUNCTION_CTRL_SET_HS_CREDITS:_bindgen_ty_2= 198; -pub constNV_VGPU_MSG_FUNCTION_CTRL_PM_AREA_PC_SAMPLER:_bindgen_ty_2= 199; -pub constNV_VGPU_MSG_FUNCTION_INVALIDATE_TLB:_bindgen_ty_2= 200; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GPU_QUERY_ECC_STATUS:_bindgen_ty_2= 201; -pub constNV_VGPU_MSG_FUNCTION_ECC_NOTIFIER_WRITE_ACK:_bindgen_ty_2= 202; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_GET_MODE_MMU_DEBUG:_bindgen_ty_2= 203; -pub constNV_VGPU_MSG_FUNCTION_RM_API_CONTROL:_bindgen_ty_2= 204; -pub constNV_VGPU_MSG_FUNCTION_CTRL_CMD_INTERNAL_GPU_START_FABRIC_PROBE:_bindgen_ty_2= 205; -pub constNV_VGPU_MSG_FUNCTION_CTRL_NVLINK_GET_INBAND_RECEIVED_DATA:_bindgen_ty_2= 206; -pub constNV_VGPU_MSG_FUNCTION_GET_STATIC_DATA:_bindgen_ty_2= 207; -pub constNV_VGPU_MSG_FUNCTION_RESERVED_208:_bindgen_ty_2= 208; -pub constNV_VGPU_MSG_FUNCTION_CTRL_GPU_GET_INFO_V2:_bindgen_ty_2= 209; -pub constNV_VGPU_MSG_FUNCTION_GET_BRAND_CAPS:_bindgen_ty_2= 210; -pub constNV_VGPU_MSG_FUNCTION_CTRL_CMD_NVLINK_INBAND_SEND_DATA:_bindgen_ty_2= 211; -pub constNV_VGPU_MSG_FUNCTION_UPDATE_GPM_GUEST_BUFFER_INFO:_bindgen_ty_2= 212; -pub constNV_VGPU_MSG_FUNCTION_CTRL_CMD_INTERNAL_CONTROL_GSP_TRACE:_bindgen_ty_2= 213; -pub constNV_VGPU_MSG_FUNCTION_CTRL_SET_ZBC_STENCIL_CLEAR:_bindgen_ty_2= 214; -pub constNV_VGPU_MSG_FUNCTION_CTRL_SUBDEVICE_GET_VGPU_HEAP_STATS:_bindgen_ty_2= 215; -pub constNV_VGPU_MSG_FUNCTION_CTRL_SUBDEVICE_GET_LIBOS_HEAP_STATS:_bindgen_ty_2= 216; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_SET_MODE_MMU_GCC_DEBUG:_bindgen_ty_2= 217; -pub constNV_VGPU_MSG_FUNCTION_CTRL_DBG_GET_MODE_MMU_GCC_DEBUG:_bindgen_ty_2= 218; -pub constNV_VGPU_MSG_FUNCTION_CTRL_RESERVE_HES:_bindgen_ty_2= 219; -pub constNV_VGPU_MSG_FUNCTION_CTRL_RELEASE_HES:_bindgen_ty_2= 220; -pub constNV_VGPU_MSG_FUNCTION_CTRL_RESERVE_CCU_PROF:_bindgen_ty_2= 221; -pub constNV_VGPU_MSG_FUNCTION_CTRL_RELEASE_CCU_PROF:_bindgen_ty_2= 222; -pub constNV_VGPU_MSG_FUNCTION_RESERVED:_bindgen_ty_2= 223; -pub constNV_VGPU_MSG_FUNCTION_CTRL_CMD_GET_CHIPLET_HS_CREDIT_POOL:_bindgen_ty_2= 224; -pub constNV_VGPU_MSG_FUNCTION_CTRL_CMD_GET_HS_CREDITS_MAPPING:_bindgen_ty_2= 225; -pub constNV_VGPU_MSG_FUNCTION_CTRL_EXEC_PARTITIONS_EXPORT:_bindgen_ty_2= 226; -pub constNV_VGPU_MSG_FUNCTION_NUM_FUNCTIONS:_bindgen_ty_2= 227; -pub type_bindgen_ty_2=ffi::c_uint; -pub constNV_VGPU_MSG_EVENT_FIRST_EVENT:_bindgen_ty_3= 4096; -pub constNV_VGPU_MSG_EVENT_GSP_INIT_DONE:_bindgen_ty_3= 4097; -pub constNV_VGPU_MSG_EVENT_GSP_RUN_CPU_SEQUENCER:_bindgen_ty_3= 4098; -pub constNV_VGPU_MSG_EVENT_POST_EVENT:_bindgen_ty_3= 4099; -pub constNV_VGPU_MSG_EVENT_RC_TRIGGERED:_bindgen_ty_3= 4100; -pub constNV_VGPU_MSG_EVENT_MMU_FAULT_QUEUED:_bindgen_ty_3= 4101; -pub constNV_VGPU_MSG_EVENT_OS_ERROR_LOG:_bindgen_ty_3= 4102; -pub constNV_VGPU_MSG_EVENT_RG_LINE_INTR:_bindgen_ty_3= 4103; -pub constNV_VGPU_MSG_EVENT_GPUACCT_PERFMON_UTIL_SAMPLES:_bindgen_ty_3= 4104; -pub constNV_VGPU_MSG_EVENT_SIM_READ:_bindgen_ty_3= 4105; -pub constNV_VGPU_MSG_EVENT_SIM_WRITE:_bindgen_ty_3= 4106; -pub constNV_VGPU_MSG_EVENT_SEMAPHORE_SCHEDULE_CALLBACK:_bindgen_ty_3= 4107;drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-2-pub const NV_VGPU_MSG_EVENT_UCODE_LIBOS_PRINT :_bindgen_ty_3 =4108 ; -pub const NV_VGPU_MSG_EVENT_VGPU_GSP_PLUGIN_TRIGGERED :_bindgen_ty_3 = 4109; -pub const
NV_VGPU_MSG_EVENT_PERF_GPU_BOOST_SYNC_LIMITS_CALLBACK:_bindgen_ty_3= 4110; -pub constNV_VGPU_MSG_EVENT_PERF_BRIDGELESS_INFO_UPDATE:_bindgen_ty_3= 4111; -pub constNV_VGPU_MSG_EVENT_VGPU_CONFIG:_bindgen_ty_3= 4112; -pub constNV_VGPU_MSG_EVENT_DISPLAY_MODESET:_bindgen_ty_3= 4113; -pub constNV_VGPU_MSG_EVENT_EXTDEV_INTR_SERVICE:_bindgen_ty_3= 4114; -pub constNV_VGPU_MSG_EVENT_NVLINK_INBAND_RECEIVED_DATA_256:_bindgen_ty_3= 4115; -pub constNV_VGPU_MSG_EVENT_NVLINK_INBAND_RECEIVED_DATA_512:_bindgen_ty_3= 4116; -pub constNV_VGPU_MSG_EVENT_NVLINK_INBAND_RECEIVED_DATA_1024:_bindgen_ty_3= 4117; -pub constNV_VGPU_MSG_EVENT_NVLINK_INBAND_RECEIVED_DATA_2048:_bindgen_ty_3= 4118; -pub constNV_VGPU_MSG_EVENT_NVLINK_INBAND_RECEIVED_DATA_4096:_bindgen_ty_3= 4119; -pub constNV_VGPU_MSG_EVENT_TIMED_SEMAPHORE_RELEASE:_bindgen_ty_3= 4120; -pub constNV_VGPU_MSG_EVENT_NVLINK_IS_GPU_DEGRADED:_bindgen_ty_3= 4121; -pub constNV_VGPU_MSG_EVENT_PFM_REQ_HNDLR_STATE_SYNC_CALLBACK:_bindgen_ty_3= 4122; -pub constNV_VGPU_MSG_EVENT_NVLINK_FAULT_UP:_bindgen_ty_3= 4123; -pub constNV_VGPU_MSG_EVENT_GSP_LOCKDOWN_NOTICE:_bindgen_ty_3= 4124; -pub constNV_VGPU_MSG_EVENT_MIG_CI_CONFIG_UPDATE:_bindgen_ty_3= 4125;drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-2-pub const NV_VGPU_MSG_EVENT_UPDATE_GSP_TRACE :_bindgen_ty_3 =4126 ; -pub const NV_VGPU_MSG_EVENT_NVLINK_FATAL_ERROR_RECOVERY:
_bindgen_ty_3= 4127; -pub constNV_VGPU_MSG_EVENT_GSP_POST_NOCAT_RECORD:_bindgen_ty_3= 4128; -pub constNV_VGPU_MSG_EVENT_FECS_ERROR:_bindgen_ty_3= 4129; -pub constNV_VGPU_MSG_EVENT_RECOVERY_ACTION:_bindgen_ty_3= 4130; -pub constNV_VGPU_MSG_EVENT_NUM_EVENTS:_bindgen_ty_3= 4131; -pub type_bindgen_ty_3=ffi::c_uint; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, MaybeZeroable)] -pub structNV0080_CTRL_GPU_GET_SRIOV_CAPS_PARAMS{drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-37- pub totalVFs: u32_, - pub firstVfOffset: u32_, - pub vfFeatureMask: u32_, - pub __bindgen_padding_0: [u8; 4usize], - pub FirstVFBar0Address: u64_, - pub FirstVFBar1Address: u64_, - pub FirstVFBar2Address: u64_, - pub bar0Size: u64_, - pub bar1Size: u64_, - pub bar2Size: u64_, - pub b64bitBar0: u8_, - pub b64bitBar1: u8_, - pub b64bitBar2: u8_, - pub bSriovEnabled: u8_, - pub bSriovHeavyEnabled: u8_, - pub bEmulateVFBar0TlbInvalidationRegister: u8_, - pub bClientRmAllocatedCtxBuffer: u8_, - pub bNonPowerOf2ChannelCountSupported: u8_, - pub bVfResizableBAR1Supported: u8_, - pub __bindgen_padding_1: [u8; 7usize], -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct NV2080_CTRL_BIOS_GET_SKU_INFO_PARAMS { -pub BoardID:u32_ , -pub chipSKU: [ffi::c_char ;9usize ], -pub chipSKUMod: [ffi::c_char ;5usize ], -pub __bindgen_padding_0: [u8 ;2usize ], -pub skuConfigVersion:u32_ , -pub project: [ffi::c_char ;5usize ], -pub projectSKU: [ffi::c_char ;5usize ], -pub CDP: [ffi::c_char ;6usize ], -pub projectSKUMod: [ffi::c_char ;2usize ], -pub __bindgen_padding_1: [u8 ;2usize ], -pub businessCycle:u32_ , -} -pub type NV2080_CTRL_CMD_FB_GET_FB_REGION_SURFACE_MEM_TYPE_FLAG =[
u8_; 17usize]; -#[repr(C)]drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-10-#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct NV2080_CTRL_CMD_FB_GET_FB_REGION_FB_REGION_INFO { -pub base:u64_ , -pub limit:u64_ , -pub reserved:u64_ , -pub performance:u32_ , -pub supportCompressed:u8_ , -pub supportISO:u8_ , -pub bProtected:u8_ , - pub blackList:
NV2080_CTRL_CMD_FB_GET_FB_REGION_SURFACE_MEM_TYPE_FLAG, -}drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-6-#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct NV2080_CTRL_CMD_FB_GET_FB_REGION_INFO_PARAMS { -pub numFBRegions:u32_ , -pub __bindgen_padding_0: [u8 ;4usize ], - pub fbRegion: [NV2080_CTRL_CMD_FB_GET_FB_REGION_FB_REGION_INFO;16usize], -}
drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-127-#[repr( C )] -#[derive( Debug , Copy , Clone , MaybeZeroable )] -pub struct NV2080_CTRL_GPU_GET_GID_INFO_PARAMS { -pub index:u32_ , -pub flags:u32_ , -pub length:u32_ , -pub data: [u8_ ;256usize ], -} -impl Default for NV2080_CTRL_GPU_GET_GID_INFO_PARAMS { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct DOD_METHOD_DATA { -pub status:u32_ , -pub acpiIdListLen:u32_ , -pub acpiIdList: [u32_ ;16usize ], -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct JT_METHOD_DATA { -pub status:u32_ , -pub jtCaps:u32_ , -pub jtRevId:u16_ , -pub bSBIOSCaps:u8_ , -pub __bindgen_padding_0:u8 , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct MUX_METHOD_DATA_ELEMENT { -pub acpiId:u32_ , -pub mode:u32_ , -pub status:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct MUX_METHOD_DATA { -pub tableLen:u32_ , -pub acpiIdMuxModeTable: [MUX_METHOD_DATA_ELEMENT ;16usize ], -pub acpiIdMuxPartTable: [MUX_METHOD_DATA_ELEMENT ;16usize ], -pub acpiIdMuxStateTable: [MUX_METHOD_DATA_ELEMENT ;16usize ], -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct CAPS_METHOD_DATA { -pub status:u32_ , -pub optimusCaps:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct ACPI_METHOD_DATA { -pub bValid:u8_ , -pub __bindgen_padding_0: [u8 ;3usize ], -pub dodMethodData:DOD_METHOD_DATA , -pub jtMethodData:JT_METHOD_DATA , -pub muxMethodData:MUX_METHOD_DATA , -pub capsMethodData:CAPS_METHOD_DATA , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct VIRTUAL_DISPLAY_GET_MAX_RESOLUTION_PARAMS { -pub headIndex:u32_ , -pub maxHResolution:u32_ , -pub maxVResolution:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct VIRTUAL_DISPLAY_GET_NUM_HEADS_PARAMS { -pub numHeads:u32_ , -pub maxNumHeads:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct BUSINFO { -pub deviceID:u16_ , -pub vendorID:u16_ , -pub subdeviceID:u16_ , -pub subvendorID:u16_ , -pub revisionID:u8_ , -pub __bindgen_padding_0:u8 , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GSP_VF_INFO { -pub totalVFs:u32_ , -pub firstVFOffset:u32_ , -pub FirstVFBar0Address:u64_ , -pub FirstVFBar1Address:u64_ , -pub FirstVFBar2Address:u64_ , -pub b64bitBar0:u8_ , -pub b64bitBar1:u8_ , -pub b64bitBar2:u8_ , -pub __bindgen_padding_0: [u8 ;5usize ], -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GSP_PCIE_CONFIG_REG { -pub linkCap:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct EcidManufacturingInfo { -pub ecidLow:u32_ , -pub ecidHigh:u32_ , -pub ecidExtended:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct FW_WPR_LAYOUT_OFFSET { -pub nonWprHeapOffset:u64_ , -pub frtsOffset:u64_ , -} -#[repr( C )] -#[derive( Debug , Copy , Clone , MaybeZeroable )] -pub struct GspStaticConfigInfo_t { -pub grCapsBits: [u8_ ;23usize ], -pub __bindgen_padding_0:u8 , -pub gidInfo:NV2080_CTRL_GPU_GET_GID_INFO_PARAMS , -pub SKUInfo:NV2080_CTRL_BIOS_GET_SKU_INFO_PARAMS , -pub __bindgen_padding_1: [u8 ;4usize ], - pub fbRegionInfoParams:
NV2080_CTRL_CMD_FB_GET_FB_REGION_INFO_PARAMS,drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-43- pub sriovCaps: NV0080_CTRL_GPU_GET_SRIOV_CAPS_PARAMS, - pub sriovMaxGfid: u32_, - pub engineCaps: [u32_; 3usize], - pub poisonFuseEnabled: u8_, - pub __bindgen_padding_2: [u8; 7usize], - pub fb_length: u64_, - pub fbio_mask: u64_, - pub fb_bus_width: u32_, - pub fb_ram_type: u32_, - pub fbp_mask: u64_, - pub l2_cache_size: u32_, - pub gpuNameString: [u8_; 64usize], - pub gpuShortNameString: [u8_; 64usize], - pub gpuNameString_Unicode: [u16_; 64usize], - pub bGpuInternalSku: u8_, - pub bIsQuadroGeneric: u8_, - pub bIsQuadroAd: u8_, - pub bIsNvidiaNvs: u8_, - pub bIsVgx: u8_, - pub bGeforceSmb: u8_, - pub bIsTitan: u8_, - pub bIsTesla: u8_, - pub bIsMobile: u8_, - pub bIsGc6Rtd3Allowed: u8_, - pub bIsGc8Rtd3Allowed: u8_, - pub bIsGcOffRtd3Allowed: u8_, - pub bIsGcoffLegacyAllowed: u8_, - pub bIsMigSupported: u8_, - pub RTD3GC6TotalBoardPower: u16_, - pub RTD3GC6PerstDelay: u16_, - pub __bindgen_padding_3: [u8; 2usize], - pub bar1PdeBase: u64_, - pub bar2PdeBase: u64_, - pub bVbiosValid: u8_, - pub __bindgen_padding_4: [u8; 3usize], - pub vbiosSubVendor: u32_, - pub vbiosSubDevice: u32_, - pub bPageRetirementSupported: u8_, - pub bSplitVasBetweenServerClientRm: u8_, - pub bClRootportNeedsNosnoopWAR: u8_, - pub __bindgen_padding_5: u8, - pub displaylessMaxHeads: VIRTUAL_DISPLAY_GET_NUM_HEADS_PARAMS, - pub displaylessMaxResolution:
VIRTUAL_DISPLAY_GET_MAX_RESOLUTION_PARAMS,drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-127- pub __bindgen_padding_6: [u8; 4usize], - pub displaylessMaxPixels: u64_, - pub hInternalClient: u32_, - pub hInternalDevice: u32_, - pub hInternalSubdevice: u32_, - pub bSelfHostedMode: u8_, - pub bAtsSupported: u8_, - pub bIsGpuUefi: u8_, - pub bIsEfiInit: u8_, - pub ecidInfo: [EcidManufacturingInfo; 2usize], - pub fwWprLayoutOffset: FW_WPR_LAYOUT_OFFSET, -} -impl Default for GspStaticConfigInfo_t { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GspSystemInfo { -pub gpuPhysAddr:u64_ , -pub gpuPhysFbAddr:u64_ , -pub gpuPhysInstAddr:u64_ , -pub gpuPhysIoAddr:u64_ , -pub nvDomainBusDeviceFunc:u64_ , -pub simAccessBufPhysAddr:u64_ , -pub notifyOpSharedSurfacePhysAddr:u64_ , -pub pcieAtomicsOpMask:u64_ , -pub consoleMemSize:u64_ , -pub maxUserVa:u64_ , -pub pciConfigMirrorBase:u32_ , -pub pciConfigMirrorSize:u32_ , -pub PCIDeviceID:u32_ , -pub PCISubDeviceID:u32_ , -pub PCIRevisionID:u32_ , -pub pcieAtomicsCplDeviceCapMask:u32_ , -pub oorArch:u8_ , -pub __bindgen_padding_0: [u8 ;7usize ], -pub clPdbProperties:u64_ , -pub Chipset:u32_ , -pub bGpuBehindBridge:u8_ , -pub bFlrSupported:u8_ , -pub b64bBar0Supported:u8_ , -pub bMnocAvailable:u8_ , -pub chipsetL1ssEnable:u32_ , -pub bUpstreamL0sUnsupported:u8_ , -pub bUpstreamL1Unsupported:u8_ , -pub bUpstreamL1PorSupported:u8_ , -pub bUpstreamL1PorMobileOnly:u8_ , -pub bSystemHasMux:u8_ , -pub upstreamAddressValid:u8_ , -pub FHBBusInfo:BUSINFO , -pub chipsetIDInfo:BUSINFO , -pub __bindgen_padding_1: [u8 ;2usize ], -pub acpiMethodData:ACPI_METHOD_DATA , -pub hypervisorType:u32_ , -pub bIsPassthru:u8_ , -pub __bindgen_padding_2: [u8 ;7usize ], -pub sysTimerOffsetNs:u64_ , -pub gspVFInfo:GSP_VF_INFO , -pub bIsPrimary:u8_ , -pub isGridBuild:u8_ , -pub __bindgen_padding_3: [u8 ;2usize ], -pub pcieConfigReg:GSP_PCIE_CONFIG_REG , -pub gridBuildCsp:u32_ , -pub bPreserveVideoMemoryAllocations:u8_ , -pub bTdrEventSupported:u8_ , -pub bFeatureStretchVblankCapable:u8_ , -pub bEnableDynamicGranularityPageArrays:u8_ , -pub bClockBoostSupported:u8_ , -pub bRouteDispIntrsToCPU:u8_ , -pub __bindgen_padding_4: [u8 ;6usize ], -pub hostPageSize:u64_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct MESSAGE_QUEUE_INIT_ARGUMENTS { -pub sharedMemPhysAddr:u64_ , -pub pageTableEntryCount:u32_ , -pub __bindgen_padding_0: [u8 ;4usize ], -pub cmdQueueOffset:u64_ , -pub statQueueOffset:u64_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GSP_SR_INIT_ARGUMENTS { -pub oldLevel:u32_ , -pub flags:u32_ , -pub bInPMTransition:u8_ , -pub __bindgen_padding_0: [u8 ;3usize ], -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GSP_ARGUMENTS_CACHED { -pub messageQueueInitArguments:MESSAGE_QUEUE_INIT_ARGUMENTS , -pub srInitArguments:GSP_SR_INIT_ARGUMENTS , -pub gpuInstance:u32_ , -pub bDmemStack:u8_ , -pub __bindgen_padding_0: [u8 ;7usize ], -pub profilerArgs:GSP_ARGUMENTS_CACHED__bindgen_ty_1 , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GSP_ARGUMENTS_CACHED__bindgen_ty_1 { -pub pa:u64_ , -pub size:u64_ , -} -#[repr( C )] -#[derive( Copy , Clone , MaybeZeroable )] -pub union rpc_message_rpc_union_field_v03_00 { -pub spare:u32_ , -pub cpuRmGfid:u32_ , -} -impl Default for rpc_message_rpc_union_field_v03_00 { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -pub type rpc_message_rpc_union_field_v =
rpc_message_rpc_union_field_v03_00; -#[repr(C)]drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-131-#[derive( MaybeZeroable )] -pub struct rpc_message_header_v03_00 { -pub header_version:u32_ , -pub signature:u32_ , -pub length:u32_ , -pub function:u32_ , -pub rpc_result:u32_ , -pub rpc_result_private:u32_ , -pub sequence:u32_ , -pub u:rpc_message_rpc_union_field_v , -pub rpc_message_data:__IncompleteArrayField <u8_ >, -} -impl Default for rpc_message_header_v03_00 { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -pub type rpc_message_header_v =rpc_message_header_v03_00 ; -#[repr( C )] -#[derive( Copy , Clone , MaybeZeroable )] -pub struct GspFwWprMeta { -pub magic:u64_ , -pub revision:u64_ , -pub sysmemAddrOfRadix3Elf:u64_ , -pub sizeOfRadix3Elf:u64_ , -pub sysmemAddrOfBootloader:u64_ , -pub sizeOfBootloader:u64_ , -pub bootloaderCodeOffset:u64_ , -pub bootloaderDataOffset:u64_ , -pub bootloaderManifestOffset:u64_ , -pub __bindgen_anon_1:GspFwWprMeta__bindgen_ty_1 , -pub gspFwRsvdStart:u64_ , -pub nonWprHeapOffset:u64_ , -pub nonWprHeapSize:u64_ , -pub gspFwWprStart:u64_ , -pub gspFwHeapOffset:u64_ , -pub gspFwHeapSize:u64_ , -pub gspFwOffset:u64_ , -pub bootBinOffset:u64_ , -pub frtsOffset:u64_ , -pub frtsSize:u64_ , -pub gspFwWprEnd:u64_ , -pub fbSize:u64_ , -pub vgaWorkspaceOffset:u64_ , -pub vgaWorkspaceSize:u64_ , -pub bootCount:u64_ , -pub __bindgen_anon_2:GspFwWprMeta__bindgen_ty_2 , -pub gspFwHeapVfPartitionCount:u8_ , -pub flags:u8_ , -pub padding: [u8_ ;2usize ], -pub pmuReservedSize:u32_ , -pub verified:u64_ , -} -#[repr( C )] -#[derive( Copy , Clone , MaybeZeroable )] -pub union GspFwWprMeta__bindgen_ty_1 { -pub __bindgen_anon_1:GspFwWprMeta__bindgen_ty_1__bindgen_ty_1 , -pub __bindgen_anon_2:GspFwWprMeta__bindgen_ty_1__bindgen_ty_2 , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GspFwWprMeta__bindgen_ty_1__bindgen_ty_1 { -pub sysmemAddrOfSignature:u64_ , -pub sizeOfSignature:u64_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GspFwWprMeta__bindgen_ty_1__bindgen_ty_2 { -pub gspFwHeapFreeListWprOffset:u32_ , -pub unused0:u32_ , -pub unused1:u64_ , -} -impl Default for GspFwWprMeta__bindgen_ty_1 { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -#[repr( C )] -#[derive( Copy , Clone , MaybeZeroable )] -pub union GspFwWprMeta__bindgen_ty_2 { -pub __bindgen_anon_1:GspFwWprMeta__bindgen_ty_2__bindgen_ty_1 , -pub __bindgen_anon_2:GspFwWprMeta__bindgen_ty_2__bindgen_ty_2 , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GspFwWprMeta__bindgen_ty_2__bindgen_ty_1 { -pub partitionRpcAddr:u64_ , -pub partitionRpcRequestOffset:u16_ , -pub partitionRpcReplyOffset:u16_ , -pub elfCodeOffset:u32_ , -pub elfDataOffset:u32_ , -pub elfCodeSize:u32_ , -pub elfDataSize:u32_ , -pub lsUcodeVersion:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GspFwWprMeta__bindgen_ty_2__bindgen_ty_2 { -pub partitionRpcPadding: [u32_ ;4usize ], -pub sysmemAddrOfCrashReportQueue:u64_ , -pub sizeOfCrashReportQueue:u32_ , -pub lsUcodeVersionPadding: [u32_ ;1usize ], -} -impl Default for GspFwWprMeta__bindgen_ty_2 { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -impl Default for GspFwWprMeta { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -pub type LibosAddress =u64_ ; -pub const LibosMemoryRegionKind_LIBOS_MEMORY_REGION_NONE:LibosMemoryRegionKind = 0; -pub const
LibosMemoryRegionKind_LIBOS_MEMORY_REGION_CONTIGUOUS:
LibosMemoryRegionKind = 1; -pub constLibosMemoryRegionKind_LIBOS_MEMORY_REGION_RADIX3:
LibosMemoryRegionKind = 2; -pub type LibosMemoryRegionKind =ffi::c_uint; -pub constLibosMemoryRegionLoc_LIBOS_MEMORY_REGION_LOC_NONE:
LibosMemoryRegionLoc = 0; -pub constLibosMemoryRegionLoc_LIBOS_MEMORY_REGION_LOC_SYSMEM:
LibosMemoryRegionLoc = 1; -pub constLibosMemoryRegionLoc_LIBOS_MEMORY_REGION_LOC_FB: LibosMemoryRegionLoc = 2; -pub type LibosMemoryRegionLoc =ffi::c_uint; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, MaybeZeroable)] -pub struct LibosMemoryRegionInitArgument {drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-63- pub id8: LibosAddress, - pub pa: LibosAddress, - pub size: LibosAddress, - pub kind: u8_, - pub loc: u8_, - pub __bindgen_padding_0: [u8; 6usize], -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct PACKED_REGISTRY_ENTRY { -pub nameOffset:u32_ , -pub type_:u8_ , -pub __bindgen_padding_0: [u8 ;3usize ], -pub data:u32_ , -pub length:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , MaybeZeroable )] -pub struct PACKED_REGISTRY_TABLE { -pub size:u32_ , -pub numEntries:u32_ , -pub entries:__IncompleteArrayField <PACKED_REGISTRY_ENTRY >, -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct msgqTxHeader { -pub version:u32_ , -pub size:u32_ , -pub msgSize:u32_ , -pub msgCount:u32_ , -pub writePtr:u32_ , -pub flags:u32_ , -pub rxHdrOff:u32_ , -pub entryOff:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct msgqRxHeader { -pub readPtr:u32_ , -} -#[repr( C )] -#[repr(align( 8 ))] -#[derive( MaybeZeroable )] -pub struct GSP_MSG_QUEUE_ELEMENT { -pub authTagBuffer: [u8_ ;16usize ], -pub aadBuffer: [u8_ ;16usize ], -pub checkSum:u32_ , -pub seqNum:u32_ , -pub elemCount:u32_ , -pub __bindgen_padding_0: [u8 ;4usize ], -pub rpc:rpc_message_header_v , -} -impl Default for GSP_MSG_QUEUE_ELEMENT { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -pub const GSP_DMA_TARGET_GSP_DMA_TARGET_LOCAL_FB :GSP_DMA_TARGET =0 ; -pub const GSP_DMA_TARGET_GSP_DMA_TARGET_COHERENT_SYSTEM:
GSP_DMA_TARGET= 1; -pub constGSP_DMA_TARGET_GSP_DMA_TARGET_NONCOHERENT_SYSTEM:GSP_DMA_TARGET= 2;drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-95-pub const GSP_DMA_TARGET_GSP_DMA_TARGET_COUNT :GSP_DMA_TARGET =3 ; -pub type GSP_DMA_TARGET = ffi::c_uint; -#[repr(C)] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GSP_FMC_INIT_PARAMS { -pub regkeys:u32_ , -} -#[repr( C )] -#[derive( Debug , Copy , Clone , MaybeZeroable )] -pub struct GSP_ACR_BOOT_GSP_RM_PARAMS { -pub target:GSP_DMA_TARGET , -pub gspRmDescSize:u32_ , -pub gspRmDescOffset:u64_ , -pub wprCarveoutOffset:u64_ , -pub wprCarveoutSize:u32_ , -pub bIsGspRmBoot:u8_ , -pub __bindgen_padding_0: [u8 ;3usize ], -} -impl Default for GSP_ACR_BOOT_GSP_RM_PARAMS { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -#[repr( C )] -#[derive( Debug , Copy , Clone , MaybeZeroable )] -pub struct GSP_RM_PARAMS { -pub target:GSP_DMA_TARGET , -pub __bindgen_padding_0: [u8 ;4usize ], -pub bootArgsOffset:u64_ , -} -impl Default for GSP_RM_PARAMS { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -#[repr( C )] -#[derive( Debug , Copy , Clone , MaybeZeroable )] -pub struct GSP_SPDM_PARAMS { -pub target:GSP_DMA_TARGET , -pub __bindgen_padding_0: [u8 ;4usize ], -pub payloadBufferOffset:u64_ , -pub payloadBufferSize:u32_ , -pub __bindgen_padding_1: [u8 ;4usize ], -} -impl Default for GSP_SPDM_PARAMS { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -#[repr( C )] -#[derive( Debug , Copy , Clone , MaybeZeroable )] -pub struct GSP_FMC_BOOT_PARAMS { -pub initParams:GSP_FMC_INIT_PARAMS , -pub __bindgen_padding_0: [u8 ;4usize ], -pub bootGspRmParams:GSP_ACR_BOOT_GSP_RM_PARAMS , -pub gspRmParams:GSP_RM_PARAMS , -pub gspSpdmParams:GSP_SPDM_PARAMS , -} -impl Default for GSP_FMC_BOOT_PARAMS { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct rpc_unloading_guest_driver_v1F_07 { -pub bInPMTransition:u8_ , -pub bGc6Entering:u8_ , -pub __bindgen_padding_0: [u8 ;2usize ], -pub newLevel:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , MaybeZeroable )] -pub struct rpc_run_cpu_sequencer_v17_00 { -pub bufferSizeDWord:u32_ , -pub cmdIndex:u32_ , -pub regSaveArea: [u32_ ;8usize ], -pub commandBuffer:__IncompleteArrayField <u32_ >, -} -pub const GSP_SEQ_BUF_OPCODE_GSP_SEQ_BUF_OPCODE_REG_WRITE:
GSP_SEQ_BUF_OPCODE= 0; -pub constGSP_SEQ_BUF_OPCODE_GSP_SEQ_BUF_OPCODE_REG_MODIFY:GSP_SEQ_BUF_OPCODE= 1; -pub constGSP_SEQ_BUF_OPCODE_GSP_SEQ_BUF_OPCODE_REG_POLL:GSP_SEQ_BUF_OPCODE= 2; -pub constGSP_SEQ_BUF_OPCODE_GSP_SEQ_BUF_OPCODE_DELAY_US:GSP_SEQ_BUF_OPCODE= 3; -pub constGSP_SEQ_BUF_OPCODE_GSP_SEQ_BUF_OPCODE_REG_STORE:GSP_SEQ_BUF_OPCODE= 4; -pub constGSP_SEQ_BUF_OPCODE_GSP_SEQ_BUF_OPCODE_CORE_RESET:GSP_SEQ_BUF_OPCODE= 5; -pub constGSP_SEQ_BUF_OPCODE_GSP_SEQ_BUF_OPCODE_CORE_START:GSP_SEQ_BUF_OPCODE= 6; -pub constGSP_SEQ_BUF_OPCODE_GSP_SEQ_BUF_OPCODE_CORE_WAIT_FOR_HALT:GSP_SEQ_BUF_OPCODE= 7; -pub constGSP_SEQ_BUF_OPCODE_GSP_SEQ_BUF_OPCODE_CORE_RESUME:GSP_SEQ_BUF_OPCODE= 8; -pub typeGSP_SEQ_BUF_OPCODE=ffi::c_uint; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, MaybeZeroable)] -pub structGSP_SEQ_BUF_PAYLOAD_REG_WRITE{drivers/gpu/nova-core/gsp/fw/r570_144.rs deleted +0
-63- pub addr: u32_, - pub val: u32_, -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GSP_SEQ_BUF_PAYLOAD_REG_MODIFY { -pub addr:u32_ , -pub mask:u32_ , -pub val:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GSP_SEQ_BUF_PAYLOAD_REG_POLL { -pub addr:u32_ , -pub mask:u32_ , -pub val:u32_ , -pub timeout:u32_ , -pub error:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GSP_SEQ_BUF_PAYLOAD_DELAY_US { -pub val:u32_ , -} -#[repr( C )] -#[derive( Debug , Default , Copy , Clone , MaybeZeroable )] -pub struct GSP_SEQ_BUF_PAYLOAD_REG_STORE { -pub addr:u32_ , -pub index:u32_ , -} -#[repr( C )] -#[derive( Copy , Clone , MaybeZeroable )] -pub struct GSP_SEQUENCER_BUFFER_CMD { -pub opCode:GSP_SEQ_BUF_OPCODE , -pub payload:GSP_SEQUENCER_BUFFER_CMD__bindgen_ty_1 , -} -#[repr( C )] -#[derive( Copy , Clone , MaybeZeroable )] -pub union GSP_SEQUENCER_BUFFER_CMD__bindgen_ty_1 { -pub regWrite:GSP_SEQ_BUF_PAYLOAD_REG_WRITE , -pub regModify:GSP_SEQ_BUF_PAYLOAD_REG_MODIFY , -pub regPoll:GSP_SEQ_BUF_PAYLOAD_REG_POLL , -pub delayUs:GSP_SEQ_BUF_PAYLOAD_DELAY_US , -pub regStore:GSP_SEQ_BUF_PAYLOAD_REG_STORE , -} -impl Default for GSP_SEQUENCER_BUFFER_CMD__bindgen_ty_1 { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -} -impl Default for GSP_SEQUENCER_BUFFER_CMD { -fn default () ->Self { -let mut s = ::core::mem::MaybeUninit ::<Self >::uninit (); -unsafe { - ::core::ptr::write_bytes (s.as_mut_ptr (),0 ,1 ); - s.assume_init () - } - } -}
Quoted 5 lines · Timur Tabi
Quoted 4 lines · John Hubbard
Nova-core boots the 570.144 GSP firmware today. This series moves the driver to the r000 firmware ABI, which is stable across releases, so firmware file names no longer carry a version number.
Quoted 7 lines
Quoted 3 lines
The actual firmware is not yet publicly available, so this series is for early review, and should not be merged until the corresponding firmware shows up.
I'm not familiar with the new boot process for "r000", so FWIW:
Reviewed-by Timur Tabi <[email protected]>
Thanks for the review(s)!
thanks,
Signature · 1 line
John Hubbard
Re: [PATCH 03/27] gpu: nova-core: set MCTP transport header version to 1
In reply to Zhi WangQuoted 4 lines · Zhi Wang
On Tue, 18 Aug 2026 20:51:56 -0700
John Hubbard <[email protected]> wrote:One nit: might be better to update the doc as well.
Yes. Agreed. I'll send individual replies to the patch feedback as usual, but let me first mention that I've applied all of your and Timur's feedback, 100%, to a -v2 branch already.
It's passing tests cleanly, so as soon as I make a few more passes through it I'll post that. Likely tomorrow.
thanks,
John Hubbard
Quoted 67 lines
Reviewed-by Zhi Wang <[email protected]>(quoted diff) +0
-0
b/Documentation/gpu/nova/core/fsp.rstindex52d618d22bb8..60c647181da0100644 ---a/Documentation/gpu/nova/core/fsp.rst
+++b/Documentation/gpu/nova/core/fsp.rst(quoted diff) +0
-0@@ -106,6 +106,8 @@ All FSP messages share a common header formatconsisting of two 32-bit words:
- Bit 30: EOM (End of Message)
- Bits 29:28: Packet sequence number
- Bits 23:16: Source Endpoint ID+- Bits 15:8: Destination Endpoint ID +- Bits 3:0: MCTP header version (1)**NVDM header** (NVIDIA Vendor Defined Message):
Quoted 47 lines
FSP requires MCTP transport header version 1. Nova-core leaves version bits 3:0 at zero, so every CoT and PRC request carries an invalid transport header.
Define the version and destination endpoint ID fields. Set the version to 1 for single-packet requests, and leave the unused destination endpoint ID at zero.
Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/mctp.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/nova-core/mctp.rsindex90c642c91a72..03546213da28100644 ---a/drivers/gpu/nova-core/mctp.rs
+++b/drivers/gpu/nova-core/mctp.rs(quoted diff) +4
-1@@ -42,13 +42,23 @@ pub(crate) struct MctpHeader(u32) { 29:28 seq; /// Source endpoint ID. 23:16 seid; + /// Destination endpoint ID. + 15:8 deid; + /// MCTP header version. + 3:0 version; } } impl MctpHeader { - /// Builds a single-packet MCTP header (`SOM=1`, `EOM=1`,
SEQ=0,SEID=0).(quoted diff) +4
-0+ /// MCTP specification version 1.0. + const VERSION: u32 = 1; + + /// Builds a single-packet MCTP header (`SOM=1`, `EOM=1`,
SEQ=0,SEID=0,VERSION=1). pub(crate) fnsingle_packet()-> Self {(quoted diff) +4
-1- Self::zeroed().with_som(true).with_eom(true) + Self::zeroed() + .with_const_version::<{ Self::VERSION }>() + .with_som(true) + .with_eom(true) } /// Returns whether this is a complete single-packet message(
SOM=1andEOM=1).
Re: [PATCH 03/27] gpu: nova-core: set MCTP transport header version to 1
On Thu, 20 Aug 2026 19:31:33 -0700
John Hubbard <[email protected]> wrote:
No need to reply to each comment. :) Feel free to use whichever feedback you find helpful. I am just glad I could help a bit.
Z.
Quoted 87 lines · Zhi Wang
Quoted 4 lines
On Tue, 18 Aug 2026 20:51:56 -0700
John Hubbard <[email protected]> wrote:One nit: might be better to update the doc as well.
Yes. Agreed. I'll send individual replies to the patch feedback as usual, but let me first mention that I've applied all of your and Timur's feedback, 100%, to a -v2 branch already.
It's passing tests cleanly, so as soon as I make a few more passes through it I'll post that. Likely tomorrow.
thanks,
John HubbardQuoted 68 lines
Reviewed-by Zhi Wang <[email protected]>(quoted diff) +0
-0
b/Documentation/gpu/nova/core/fsp.rstindex52d618d22bb8..60c647181da0100644 ---a/Documentation/gpu/nova/core/fsp.rst+++b/Documentation/gpu/nova/core/fsp.rst@@ -106,6 +106,8 @@ All FSP messages share a common header format consisting of two 32-bit words:
- Bit 30: EOM (End of Message)
- Bits 29:28: Packet sequence number
- Bits 23:16: Source Endpoint ID+- Bits 15:8: Destination Endpoint ID +- Bits 3:0: MCTP header version (1)**NVDM header** (NVIDIA Vendor Defined Message):
Quoted 47 lines
FSP requires MCTP transport header version 1. Nova-core leaves version bits 3:0 at zero, so every CoT and PRC request carries an invalid transport header.
Define the version and destination endpoint ID fields. Set the version to 1 for single-packet requests, and leave the unused destination endpoint ID at zero.
Assisted-by Cursor:claude-opus-5Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/mctp.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/nova-core/mctp.rsindex90c642c91a72..03546213da28100644 ---a/drivers/gpu/nova-core/mctp.rs
+++b/drivers/gpu/nova-core/mctp.rs(quoted diff) +4
-1@@ -42,13 +42,23 @@ pub(crate) struct MctpHeader(u32) { 29:28 seq; /// Source endpoint ID. 23:16 seid; + /// Destination endpoint ID. + 15:8 deid; + /// MCTP header version. + 3:0 version; } } impl MctpHeader { - /// Builds a single-packet MCTP header (`SOM=1`, `EOM=1`,
SEQ=0,SEID=0).(quoted diff) +4
-0+ /// MCTP specification version 1.0. + const VERSION: u32 = 1; + + /// Builds a single-packet MCTP header (`SOM=1`, `EOM=1`,
SEQ=0,SEID=0,VERSION=1). pub(crate) fnsingle_packet()-> Self {(quoted diff) +4
-1- Self::zeroed().with_som(true).with_eom(true) + Self::zeroed() + .with_const_version::<{ Self::VERSION }>() + .with_som(true) + .with_eom(true) } /// Returns whether this is a complete single-packet message(
SOM=1andEOM=1).