gpu: nova-core: Boot GSP to RISC-V active
Subsystems (6)
Alexandre Courbot
maintainerv7 cover gpu: nova-core: Boot GSP to RISC-V active
Taking over this series while Alistair is on holidays.
This revision is mostly a polishing of v6, notably by removing the use of as thanks to the newly-introduced num module [1]. It also addresses some leftover feedback from v5.
I still need to do an extensive review of the top patches, but I think the command queue basics should be looking close to what we want. Caveat, they will evolve once we support interrupts.
One patch that needs particular attention is "rust: enable slice_flatten feature and abstract it through an extension trait", as it abstracts the slice flatten feature that has been stabilized in 1.80. I hope I captured Miguel's proposal correctly.
A branch including this series and its dependencies is available at [2].
[1] https://lore.kernel.org/rust-for-linux/[email protected]/T/#t
[2] https://github.com/Gnurou/linux/tree/b4/gsp_boot
Changes in v7:
- Remove as conversions by using the features of the num module.
- Add build-time conversion of constant integer values to smaller types.
- Thanks to the two items above, make more functions infallible.
- Remove unneeded nr_ptes member of the Cmdq.
- Use repr(u32) for MsgFunction to simplify it.
- Use from_ref instead of casting references into pointers with as.
- Add message header version type to remove use of magic number.
- Switch some parameters to usize to limit type conversions.
- Add comments for undocumented functions.
- Remove function_number method of GspMsgElement and return invalid function numbers as the error value of function instead.
- Work around the renaming of slice::flatten to slice::as_flattened in Rust 1.80 (thanks Miguel!).
- Fix clippy warning with Rust 1.78.
- Link to v6: https://lore.kernel.org/r/[email protected]/
---
Alexandre Courbot (3):
gpu: nova-core: compute layout of more framebuffer regions required for GSP
gpu: nova-core: num: add functions to safely convert a const value to a smaller type
rust: enable slice_flatten feature and abstract it through an extension trait
Alistair Popple (8):
gpu: nova-core: Set correct DMA mask
gpu: nova-core: Create initial Gsp
gpu: nova-core: gsp: Create wpr metadata
gpu: nova-core: Add zeroable trait to bindings
gpu: nova-core: gsp: Add GSP command queue bindings and handling
gpu: nova-core: gsp: Create rmargs
gpu: nova-core: gsp: Add RM registry and sysinfo bindings and commands
nova-core: gsp: Boot GSP
Joel Fernandes (3):
gpu: nova-core: Add a slice-buffer (sbuffer) datastructure
nova-core: falcon: Add support to check if RISC-V is active
nova-core: falcon: Add support to write firmware version
drivers/gpu/nova-core/driver.rs | 16 + drivers/gpu/nova-core/falcon.rs | 15 + drivers/gpu/nova-core/fb.rs | 68 ++- drivers/gpu/nova-core/firmware/gsp.rs | 7 +- drivers/gpu/nova-core/firmware/riscv.rs | 11 +- drivers/gpu/nova-core/gpu.rs | 2 +- drivers/gpu/nova-core/gsp.rs | 142 ++++- drivers/gpu/nova-core/gsp/boot.rs | 80 ++- drivers/gpu/nova-core/gsp/cmdq.rs | 522 ++++++++++++++++ drivers/gpu/nova-core/gsp/commands.rs | 117 ++++ drivers/gpu/nova-core/gsp/fw.rs | 599 +++++++++++++++++- drivers/gpu/nova-core/gsp/fw/commands.rs | 100 +++ drivers/gpu/nova-core/gsp/fw/r570_144.rs | 2 +- drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs | 703 ++++++++++++++++++++++ drivers/gpu/nova-core/nova_core.rs | 1 + drivers/gpu/nova-core/num.rs | 49 ++ drivers/gpu/nova-core/regs.rs | 17 +- drivers/gpu/nova-core/sbuffer.rs | 222 +++++++ init/Kconfig | 3 + rust/kernel/lib.rs | 4 + rust/kernel/slice.rs | 63 ++ scripts/Makefile.build | 3 +- 22 files changed, 2715 insertions(+), 31 deletions(-)
---
base-commit: ed136b2f7e5c159324b27d1e761bad753d2a711e
change-id: 20251027-gsp_boot-c6bb048a304e
Best regards,
Signature · 1 line
Alexandre Courbot <[email protected]>
Alexandre Courbot
maintainerPATCH v7 1/14 gpu: nova-core: compute layout of more framebuffer regions required for GSP
Compute more of the required FB layout information to boot the GSP firmware.
This information is dependent on the firmware itself, so first we need to import and abstract the required firmware bindings in the nvfw module.
Then, a new FB HAL method is introduced in fb::hal that uses these bindings and hardware information to compute the correct layout information.
This information is then used in fb and the result made visible in FbLayout.
These 3 things are grouped into the same patch to avoid lots of unused warnings that would be tedious to work around. As they happen in different files, they should not be too difficult to track separately.
--- drivers/gpu/nova-core/fb.rs | 67 +++++++++++- drivers/gpu/nova-core/firmware/gsp.rs | 4 +- drivers/gpu/nova-core/firmware/riscv.rs | 2 +- drivers/gpu/nova-core/gsp.rs | 4 + drivers/gpu/nova-core/gsp/boot.rs | 4 +- drivers/gpu/nova-core/gsp/fw.rs | 101 ++++++++++++++++- drivers/gpu/nova-core/gsp/fw/r570_144.rs | 1 - drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs | 125 ++++++++++++++++++++++ 8 files changed, 298 insertions(+), 10 deletions(-)
drivers/gpu/nova-core/fb.rs +64 -3
@@ -10,8 +10,10 @@use crate ::dma::DmaObject ;use crate ::driver::Bar0 ; +use crate ::firmware::gsp::GspFirmware ;use crate ::gpu::Chipset ; -use crate ::num::usize_as_u64; +use crate ::gsp; +use crate ::num::{usize_as_u64,FromSafeCast };use crate ::regs;mod hal;
@@ -88,14 +90,28 @@ pub(crate) fn unregister(&self, bar: &Bar0) {#[derive( Debug )] #[expect(dead_code)] pub (crate )struct FbLayout { +/// Range of the framebuffer. Starts at `0`. pub (crate ) fb:Range <u64 >, +/// VGA workspace, small area of reserved memory at the end of the framebuffer. pub (crate ) vga_workspace:Range <u64 >, +/// FRTS range. pub (crate ) frts:Range <u64 >, +/// Memory area containing the GSP bootloader image. +pub (crate ) boot:Range <u64 >, +/// Memory area containing the GSP firmware image. +pub (crate ) elf:Range <u64 >, +/// WPR2 heap. +pub (crate ) wpr2_heap:Range <u64 >, +// WPR2 region range, starting with an instance of `GspFwWprMeta`. +pub (crate ) wpr2:Range <u64 >, +pub (crate ) heap:Range <u64 >, +pub (crate ) vf_partition_count:u8 , }impl FbLayout { -/// Computes the FB layout. -pub (crate )fn new (chipset:Chipset , bar: &Bar0 ) ->Result <Self > { +/// Computes the FB layout for `chipset`, for running the `bl` GSP bootloader and `gsp` GSP +/// firmware. +pub (crate )fn new (chipset:Chipset , bar: &Bar0 , gsp_fw: &GspFirmware ) ->Result <Self > {let hal = hal::fb_hal (chipset);let fb = {
@@ -139,10 +155,55 @@ pub(crate) fn new(chipset: Chipset, bar: &Bar0) -> Result<Self> { frts_base..frts_base +FRTS_SIZE }; +let boot = { +const BOOTLOADER_DOWN_ALIGN :Alignment =Alignment ::new ::<SZ_4K >(); +let bootloader_size = u64::from_safe_cast (gsp_fw.bootloader.ucode.size ()); +let bootloader_base = (frts.start - bootloader_size).align_down (BOOTLOADER_DOWN_ALIGN ); + + 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 ); + + elf_addr..elf_addr + elf_size + }; + +let wpr2_heap = { +const WPR2_HEAP_DOWN_ALIGN :Alignment =Alignment ::new ::<SZ_1M >(); +let wpr2_heap_size = +crate ::gsp::LibosParams ::from_chipset (chipset).wpr_heap_size (chipset, fb.end); +let wpr2_heap_addr = (elf.start - wpr2_heap_size).align_down (WPR2_HEAP_DOWN_ALIGN ); + + wpr2_heap_addr..(elf.start).align_down (WPR2_HEAP_DOWN_ALIGN ) + }; + +let wpr2 = { +const WPR2_DOWN_ALIGN :Alignment =Alignment ::new ::<SZ_1M >(); +let wpr2_addr = (wpr2_heap.start - u64::from_safe_cast (size_of ::<gsp::GspFwWprMeta >())) + .align_down (WPR2_DOWN_ALIGN ); + + wpr2_addr..frts.end + }; + +let heap = { +const HEAP_SIZE :u64 =usize_as_u64 (SZ_1M ); + + wpr2.start -HEAP_SIZE ..wpr2.start + }; +Ok (Self { fb, vga_workspace, frts, + boot, + elf, + wpr2_heap, + wpr2, + heap, + vf_partition_count:0 , }) } }
drivers/gpu/nova-core/firmware/gsp.rs +2 -2
@@ -130,11 +130,11 @@ pub(crate) struct GspFirmware {/// Level 0 page table (single 4KB page) with one entry: DMA address of first level 1 page. level0: DmaObject,/// Size in bytes of the firmware contained in [`Self::fw`]. - size: usize, + pub(crate) size: usize,/// Device-mapped GSP signatures matching the GPU's [`Chipset`]. signatures: DmaObject,/// GSP bootloader, verifies the GSP firmware before loading and running it. - bootloader: RiscvFirmware, + pub(crate) bootloader: RiscvFirmware, }impl GspFirmware {
drivers/gpu/nova-core/firmware/riscv.rs +1 -1
@@ -64,7 +64,7 @@ pub(crate) struct RiscvFirmware {/// Application version. app_version: u32,/// Device-mapped firmware image. - ucode: DmaObject, + pub(crate) ucode: DmaObject, }impl RiscvFirmware {
drivers/gpu/nova-core/gsp.rs +4 -0
@@ -3,11 +3,15 @@mod boot;use kernel::prelude::*; +use kernel::ptr::Alignment ;mod fw; +pub (crate )use fw::{GspFwWprMeta ,LibosParams }; +pub (crate )const GSP_PAGE_SHIFT :usize =12 ;pub (crate )const GSP_PAGE_SIZE :usize =1 <<GSP_PAGE_SHIFT ; +pub (crate )const GSP_HEAP_ALIGNMENT :Alignment =Alignment ::new ::<{1 <<20 }>();/// GSP runtime data. ///
drivers/gpu/nova-core/gsp/boot.rs +2 -2
@@ -113,12 +113,12 @@ pub(crate) fn boot(let bios =Vbios ::new (dev, bar)?; -let _gsp_fw =KBox ::pin_init ( +let gsp_fw =KBox ::pin_init (GspFirmware ::new (dev, chipset,FIRMWARE_VERSION )?,GFP_KERNEL , )?; -let fb_layout =FbLayout ::new (chipset, bar)?; +let fb_layout =FbLayout ::new (chipset, bar, &gsp_fw)?;dev_dbg! (dev,"{:#x?}\n" , fb_layout);Self ::run_fwsec_frts (dev, gsp_falcon, bar, &bios, &fb_layout)?;
drivers/gpu/nova-core/gsp/fw.rs +100 -1
105 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw/r570_144.rs +0 -1
@@ -12,7 +12,6 @@#![cfg_attr(test, allow(unsafe_op_in_unsafe_fn))] #![allow( dead_code, - unused_imports, clippy::all, clippy::undocumented_unsafe_blocks, clippy::ptr_as_ptr,
drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs +125 -0
126 lines not on this page · raw message
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 2/14 gpu: nova-core: Set correct DMA mask
In reply to Alexandre CourbotFrom: Alistair Popple <[email protected]>
Set the correct DMA mask. Without this DMA will fail on some setups.
--- drivers/gpu/nova-core/driver.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/gpu/nova-core/driver.rs +16 -0
@@ -3,6 +3,8 @@use kernel::{ auxiliary, c_str, device::Core , + dma::Device , + dma::DmaMask , pci, pci::{Class ,ClassMask ,Vendor }, prelude::*,
@@ -20,6 +22,15 @@ pub(crate) struct NovaCore { }const BAR0_SIZE :usize =SZ_16M ; + +// For now we only support Ampere which can use up to 47-bit DMA addresses. +// +// TODO: Add an abstraction for this to support newer GPUs which may support +// larger DMA addresses. Limiting these GPUs to smaller address widths won't +// have any adverse affects, unless installed on systems which require larger +// DMA addresses. These systems should be quite rare. +const GPU_DMA_BITS :u32 =47 ; +pub (crate )type Bar0 = pci::Bar <BAR0_SIZE >; kernel::pci_device_table!(
@@ -57,6 +68,11 @@ fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> Result<Pin<KBox<Self pdev.enable_device_mem ()?; pdev.set_master (); +// SAFETY: No concurrent DMA allocations or mappings can be made because +// the device is still being probed and therefore isn't being used by +// other threads of execution. +unsafe { pdev.dma_set_mask_and_coherent (DmaMask ::new ::<GPU_DMA_BITS >())? }; +let devres_bar =Arc ::pin_init ( pdev.iomap_region_sized ::<BAR0_SIZE >(0 ,c_str! ("nova-core/bar0" )), GFP_KERNEL,
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 3/14 gpu: nova-core: num: add functions to safely convert a const value to a smaller type
In reply to Alexandre CourbotThere are times where we need to store a constant value defined as a larger type (e.g. through a binding) into a smaller type, knowing that the value will fit. Rust, unfortunately, only provides us with the as operator for that effect, that we want to eschew.
Extend the num module with functions allowing to perform the conversion infallibly, at compile time.
Example:
const FOO_VALUE: u32 = 1;
// `FOO_VALUE` fits into a `u8`, so the conversion is valid.
let foo = num::u32_to_u8::<{ FOO_VALUE }>();We are going to use this feature extensively in Nova.
--- drivers/gpu/nova-core/num.rs | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
drivers/gpu/nova-core/num.rs +49 -0
@@ -161,3 +161,52 @@ fn into_safe_cast(self) -> T {T ::from_safe_cast (self) } } + +macro_rules! impl_const_into { + ($from:ty => { $($into:ty),* }) => { + $( +paste! { +#[doc = ::core::concat!( +"Performs a build-time safe conversion of a [`" , +::core::stringify!($from), +"`] constant value into a [`" , +::core::stringify!($into), +"`]." )] +/// +/// This checks at compile-time that the conversion is lossless, and triggers a build +/// error if it isn't. +/// +/// # Examples +/// +/// ``` +/// use kernel::num; +/// +/// // Succeeds because the value of the source fits into the destination's type. +#[doc = ::core::concat!( +"assert_eq!(num::" , +::core::stringify!($from), +"_into_" , +::core::stringify!($into), +"(1" , +::core::stringify!($from), +"), 1" , +::core::stringify!($into), +");" )] +/// ``` +#[allow(unused)] +pub (crate )const fn [<$from _into_ $into>]<const N : $from>() -> $into { +if N > $into::MAX as $from { +build_error! ("Value overflow." ); + }else { +N as $into + } + } + } + )* + }; +} + +impl_const_into! (usize => {u8 ,u16 ,u32 }); +impl_const_into! (u64 => {u8 ,u16 ,u32 }); +impl_const_into! (u32 => {u8 ,u16 }); +impl_const_into! (u16 => {u8 });
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 4/14 gpu: nova-core: Create initial Gsp
In reply to Alexandre CourbotFrom: Alistair Popple <[email protected]>
The GSP requires several areas of memory to operate. Each of these have their own simple embedded page tables. Set these up and map them for DMA to/from GSP using CoherentAllocation's. Return the DMA handle describing where each of these regions are for future use when booting GSP.
--- drivers/gpu/nova-core/gpu.rs | 2 +- drivers/gpu/nova-core/gsp.rs | 110 ++++++++++++++++++++-- drivers/gpu/nova-core/gsp/fw.rs | 67 ++++++++++++- drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs | 19 ++++ 4 files changed, 185 insertions(+), 13 deletions(-)
drivers/gpu/nova-core/gpu.rs +1 -1
@@ -218,7 +218,7 @@ pub(crate) fn new<'a>( sec2_falcon: Falcon::new(pdev.as_ref(), spec.chipset)?, - gsp <- Gsp::new(), + gsp <- Gsp::new(pdev)?, _: { gsp.boot(pdev, bar, spec.chipset, gsp_falcon, sec2_falcon)? },
drivers/gpu/nova-core/gsp.rs +102 -8
127 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw.rs +63 -4
96 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs +19 -0
@@ -124,3 +124,22 @@ fn default() -> Self { } } } +pub type LibosAddress =u64_ ; +pub const LibosMemoryRegionKind_LIBOS_MEMORY_REGION_NONE :LibosMemoryRegionKind =0 ; +pub const LibosMemoryRegionKind_LIBOS_MEMORY_REGION_CONTIGUOUS :LibosMemoryRegionKind =1 ; +pub const LibosMemoryRegionKind_LIBOS_MEMORY_REGION_RADIX3 :LibosMemoryRegionKind =2 ; +pub type LibosMemoryRegionKind = ffi::c_uint ; +pub const LibosMemoryRegionLoc_LIBOS_MEMORY_REGION_LOC_NONE :LibosMemoryRegionLoc =0 ; +pub const LibosMemoryRegionLoc_LIBOS_MEMORY_REGION_LOC_SYSMEM :LibosMemoryRegionLoc =1 ; +pub const LibosMemoryRegionLoc_LIBOS_MEMORY_REGION_LOC_FB :LibosMemoryRegionLoc =2 ; +pub type LibosMemoryRegionLoc = ffi::c_uint ; +#[repr( C )] +#[derive( Debug , Default , Copy , Clone )] +pub struct LibosMemoryRegionInitArgument { +pub id8:LibosAddress , +pub pa:LibosAddress , +pub size:LibosAddress , +pub kind:u8_ , +pub loc:u8_ , +pub __bindgen_padding_0: [u8 ;6usize ], +}
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 5/14 gpu: nova-core: gsp: Create wpr metadata
In reply to Alexandre CourbotFrom: Alistair Popple <[email protected]>
The GSP requires some pieces of metadata to boot. These are passed in a struct which the GSP transfers via DMA. Create this struct and get a handle to it for future use when booting the GSP.
--- drivers/gpu/nova-core/fb.rs | 1 - drivers/gpu/nova-core/firmware/gsp.rs | 3 +- drivers/gpu/nova-core/firmware/riscv.rs | 6 +-- drivers/gpu/nova-core/gsp.rs | 4 ++ drivers/gpu/nova-core/gsp/boot.rs | 7 +++ drivers/gpu/nova-core/gsp/fw.rs | 56 ++++++++++++++++++++++- drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs | 2 + 7 files changed, 72 insertions(+), 7 deletions(-)
drivers/gpu/nova-core/fb.rs +0 -1
@@ -88,7 +88,6 @@ pub(crate) fn unregister(&self, bar: &Bar0) {/// /// Contains ranges of GPU memory reserved for a given purpose during the GSP boot process. #[derive( Debug )] -#[expect(dead_code)] pub (crate )struct FbLayout {/// Range of the framebuffer. Starts at `0`. pub (crate ) fb:Range <u64 >,
drivers/gpu/nova-core/firmware/gsp.rs +1 -2
@@ -132,7 +132,7 @@ pub(crate) struct GspFirmware {/// Size in bytes of the firmware contained in [`Self::fw`]. pub(crate) size: usize,/// Device-mapped GSP signatures matching the GPU's [`Chipset`]. - signatures: DmaObject, + pub(crate) signatures: DmaObject,/// GSP bootloader, verifies the GSP firmware before loading and running it. pub(crate) bootloader: RiscvFirmware, }
@@ -218,7 +218,6 @@ pub(crate) fn new<'a, 'b>( })) } -#[expect(unused)] /// Returns the DMA handle of the radix3 level 0 page table. pub (crate )fn radix3_dma_handle (&self) ->DmaAddress { self.level0.dma_handle ()
drivers/gpu/nova-core/firmware/riscv.rs +3 -3
@@ -56,11 +56,11 @@ fn new(bin_fw: &BinFirmware<'_>) -> Result<Self> {#[expect(unused)] pub (crate )struct RiscvFirmware {/// Offset at which the code starts in the firmware image. - code_offset:u32 , +pub (crate ) code_offset:u32 ,/// Offset at which the data starts in the firmware image. - data_offset:u32 , +pub (crate ) data_offset:u32 ,/// Offset at which the manifest starts in the firmware image. - manifest_offset:u32 , +pub (crate ) manifest_offset:u32 ,/// Application version. app_version:u32 ,/// Device-mapped firmware image.
drivers/gpu/nova-core/gsp.rs +4 -0
@@ -10,6 +10,8 @@use kernel::prelude::*;use kernel::transmute::AsBytes ; +use crate ::fb::FbLayout ; +mod fw;use fw::LibosMemoryRegionInitArgument ;
@@ -105,8 +107,10 @@ pub(crate) fn new(pdev: &pci::Device<device::Bound>) -> Result<impl PinInit<Self// kgspSetupLibosInitArgs_IMPL (creates pLibosInitArgs[] array) let loginit =LogBuffer ::new (dev)?;dma_write! (libos[0 ] =LibosMemoryRegionInitArgument ::new ("LOGINIT" , &loginit.0 ))?; +let logintr =LogBuffer ::new (dev)?;dma_write! (libos[1 ] =LibosMemoryRegionInitArgument ::new ("LOGINTR" , &logintr.0 ))?; +let logrm =LogBuffer ::new (dev)?;dma_write! (libos[2 ] =LibosMemoryRegionInitArgument ::new ("LOGRM" , &logrm.0 ))?;
drivers/gpu/nova-core/gsp/boot.rs +7 -0
@@ -1,6 +1,8 @@// SPDX-License-Identifier: GPL-2.0 use kernel::device; +use kernel::dma::CoherentAllocation ; +use kernel::dma_write;use kernel::pci;use kernel::prelude::*;
@@ -14,6 +16,7 @@ FIRMWARE_VERSION, };use crate ::gpu::Chipset ; +use crate ::gsp::GspFwWprMeta ;use crate ::regs;use crate ::vbios::Vbios ;
@@ -132,6 +135,10 @@ pub(crate) fn boot( bar, )?; +let wpr_meta = +CoherentAllocation ::<GspFwWprMeta >::alloc_coherent (dev,1 ,GFP_KERNEL | __GFP_ZERO)?; +dma_write! (wpr_meta[0 ] =GspFwWprMeta ::new (&gsp_fw, &fb_layout))?; +Ok (()) } }
drivers/gpu/nova-core/gsp/fw.rs +55 -1
71 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs +2 -0
@@ -9,6 +9,8 @@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 const GSP_FW_WPR_META_REVISION :u32 =1 ; +pub const GSP_FW_WPR_META_MAGIC :i64 = -2577556379034558285 ;pub type __u8 = ffi::c_uchar ;pub type __u16 = ffi::c_ushort ;pub type __u32 = ffi::c_uint ;
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 6/14 gpu: nova-core: Add a slice-buffer (sbuffer) datastructure
In reply to Alexandre CourbotFrom: Joel Fernandes <[email protected]>
A data structure that can be used to write across multiple slices which may be out of order in memory. This lets SBuffer user correctly and safely write out of memory order, without error-prone tracking of pointers/offsets.
let mut buf1 = [0u8; 3];
let mut buf2 = [0u8; 5];
let mut sbuffer = SBuffer::new([&mut buf1[..], &mut buf2[..]]);
let data = b"hello";
let result = sbuffer.write(data);
An internal conversion of gsp.rs to use this resulted in a nice -ve delta:gsp.rs: 37 insertions(+), 99 deletions(-)
--- drivers/gpu/nova-core/nova_core.rs | 1 + drivers/gpu/nova-core/sbuffer.rs | 225 +++++++++++++++++++++++++++++++++++++ 2 files changed, 226 insertions(+)
drivers/gpu/nova-core/nova_core.rs +1 -0
@@ -15,6 +15,7 @@mod gsp;mod num;mod regs; +mod sbuffer;mod vbios;pub (crate )const MODULE_NAME : &kernel::str::CStr = <LocalModule as kernel::ModuleMetadata >::NAME ;
drivers/gpu/nova-core/sbuffer.rs new file +225 -0
225 lines not on this page · raw message
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 7/14 gpu: nova-core: Add zeroable trait to bindings
In reply to Alexandre CourbotFrom: Alistair Popple <[email protected]>
Derive the Zeroable trait for existing bindgen generated bindings. This is safe because all bindgen generated types are simple integer types for which any bit pattern, including all zeros, is valid.
--- drivers/gpu/nova-core/gsp/fw/r570_144.rs | 1 + drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/nova-core/gsp/fw/r570_144.rs +1 -0
@@ -25,4 +25,5 @@ unsafe_op_in_unsafe_fn )]use kernel::ffi; +use kernel::prelude::Zeroable ;include! ("r570_144/bindings.rs" );
drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs +8 -8
@@ -20,7 +20,7 @@pub type u32_ =__u32 ;pub type u64_ =__u64 ;#[repr( C )] -#[derive( Copy , Clone )] +#[derive( Copy , Clone , Zeroable )] pub struct GspFwWprMeta {pub magic:u64_ ,pub revision:u64_ ,
@@ -55,19 +55,19 @@ pub struct GspFwWprMeta { pub verified: u64_, }#[repr( C )] -#[derive( Copy , Clone )] +#[derive( Copy , Clone , Zeroable )] 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 )] +#[derive( Debug , Default , Copy , Clone , Zeroable )] pub struct GspFwWprMeta__bindgen_ty_1__bindgen_ty_1 {pub sysmemAddrOfSignature:u64_ ,pub sizeOfSignature:u64_ , }#[repr( C )] -#[derive( Debug , Default , Copy , Clone )] +#[derive( Debug , Default , Copy , Clone , Zeroable )] pub struct GspFwWprMeta__bindgen_ty_1__bindgen_ty_2 {pub gspFwHeapFreeListWprOffset:u32_ ,pub unused0:u32_ ,
@@ -83,13 +83,13 @@ fn default() -> Self { } }#[repr( C )] -#[derive( Copy , Clone )] +#[derive( Copy , Clone , Zeroable )] 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 )] +#[derive( Debug , Default , Copy , Clone , Zeroable )] pub struct GspFwWprMeta__bindgen_ty_2__bindgen_ty_1 {pub partitionRpcAddr:u64_ ,pub partitionRpcRequestOffset:u16_ ,
@@ -101,7 +101,7 @@ pub struct GspFwWprMeta__bindgen_ty_2__bindgen_ty_1 { pub lsUcodeVersion: u32_, }#[repr( C )] -#[derive( Debug , Default , Copy , Clone )] +#[derive( Debug , Default , Copy , Clone , Zeroable )] pub struct GspFwWprMeta__bindgen_ty_2__bindgen_ty_2 {pub partitionRpcPadding: [u32_ ;4usize ],pub sysmemAddrOfCrashReportQueue:u64_ ,
@@ -136,7 +136,7 @@ fn default() -> Self {pub const LibosMemoryRegionLoc_LIBOS_MEMORY_REGION_LOC_FB :LibosMemoryRegionLoc =2 ;pub type LibosMemoryRegionLoc = ffi::c_uint ;#[repr( C )] -#[derive( Debug , Default , Copy , Clone )] +#[derive( Debug , Default , Copy , Clone , Zeroable )] pub struct LibosMemoryRegionInitArgument {pub id8:LibosAddress ,pub pa:LibosAddress ,
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 8/14 rust: enable slice_flatten feature and abstract it through an extension trait
In reply to Alexandre CourbotIn Rust 1.80, the previously unstable slice::flatten family of methods have been stabilized and renamed to as_flattened.
This creates an issue as we want to use as_flattened, but need to support the MSRV (which at the moment is Rust 1.78) where it is named flatten.
Solve this by enabling the slice_flatten feature, and abstracting as_flatten behind an extension trait that calls the right method depending on the Rust version.
This extension trait can be removed once the MSRV passes 1.80.
--- init/Kconfig | 3 +++ rust/kernel/lib.rs | 4 ++++ rust/kernel/slice.rs | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/Makefile.build | 3 ++- 4 files changed, 72 insertions(+), 1 deletion(-)
init/Kconfig +3 -0
@@ -147,6 +147,9 @@ config LD_CAN_USE_KEEP_IN_OVERLAY # https://github.com/llvm/llvm-project/pull/130661 def_bool LD_IS_BFD || LLD_VERSION >= 210000 +config RUSTC_HAS_SLICE_AS_FLATTENED + def_bool RUSTC_VERSION >= 108000 + config RUSTC_HAS_COERCE_POINTEE def_bool RUSTC_VERSION >= 108400
rust/kernel/lib.rs +4 -0
@@ -21,6 +21,9 @@#![feature(inline_const)] #![feature(pointer_is_aligned)] // +// Stable since Rust 1.80.0. +#![feature(slice_flatten)] +// // Stable since Rust 1.81.0. #![feature(lint_reasons)] //
@@ -128,6 +131,7 @@pub mod security;pub mod seq_file;pub mod sizes; +pub mod slice;mod static_assert;#[doc(hidden)] pub mod std_vendor;
rust/kernel/slice.rs new file +63 -0
63 lines not on this page · raw message
scripts/Makefile.build +2 -1
@@ -308,6 +308,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE # The features in this list are the ones allowed for non-`rust/` code. # +# - Stable since Rust 1.80.0: `feature(slice_flatten)`. # - Stable since Rust 1.81.0: `feature(lint_reasons)`. # - Stable since Rust 1.82.0: `feature(asm_const)`, # `feature(offset_of_nested)`, `feature(raw_ref_op)`.
@@ -317,7 +318,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE # # Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on # the unstable features in use. -rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,used_with_arg +rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,slice_flatten,used_with_arg # `--out-dir` is required to avoid temporaries being created by `rustc` in the # current working directory, which may be not accessible in the out-of-tree
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 9/14 gpu: nova-core: gsp: Add GSP command queue bindings and handling
In reply to Alexandre CourbotFrom: Alistair Popple <[email protected]>
This commit introduces core infrastructure for handling GSP command and message queues in the nova-core driver. The command queue system enables bidirectional communication between the host driver and GSP firmware through a remote message passing interface.
The interface is based on passing serialised data structures over a ring buffer with separate transmit and receive queues. Commands are sent by writing to the CPU transmit queue and waiting for completion via the receive queue.
To ensure safety mutable or immutable (depending on whether it is a send or receive operation) references are taken on the command queue when allocating the message to write/read to. This ensures message memory remains valid and the command queue can't be mutated whilst an operation is in progress.
Currently this is only used by the probe() routine and therefore can only used by a single thread of execution. Locking to enable safe access from multiple threads will be introduced in a future series when that becomes necessary.
--- drivers/gpu/nova-core/gsp.rs | 6 + drivers/gpu/nova-core/gsp/cmdq.rs | 504 ++++++++++++++++++++++ drivers/gpu/nova-core/gsp/fw.rs | 330 ++++++++++++++ drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs | 409 ++++++++++++++++++ drivers/gpu/nova-core/regs.rs | 4 + drivers/gpu/nova-core/sbuffer.rs | 2 - 6 files changed, 1253 insertions(+), 2 deletions(-)
drivers/gpu/nova-core/gsp.rs +6 -0
@@ -11,7 +11,9 @@use kernel::transmute::AsBytes ;use crate ::fb::FbLayout ; +use crate ::gsp::cmdq::Cmdq ; +pub (crate )mod cmdq;mod fw;use fw::LibosMemoryRegionInitArgument ;
@@ -33,6 +35,7 @@ pub(crate) struct Gsp { loginit: LogBuffer, logintr: LogBuffer, logrm: LogBuffer, + pub(crate) cmdq: Cmdq, }#[repr( C )]
@@ -114,11 +117,14 @@ pub(crate) fn new(pdev: &pci::Device<device::Bound>) -> Result<impl PinInit<Selflet logrm =LogBuffer ::new (dev)?;dma_write! (libos[2 ] =LibosMemoryRegionInitArgument ::new ("LOGRM" , &logrm.0 ))?; +let cmdq =Cmdq ::new (dev)?; +Ok (try_pin_init! (Self { libos, loginit, logintr, logrm, + cmdq, })) } }
drivers/gpu/nova-core/gsp/cmdq.rs new file +504 -0
504 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw.rs +330 -0
354 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs +409 -0
429 lines not on this page · raw message
drivers/gpu/nova-core/regs.rs +4 -0
@@ -72,6 +72,10 @@ pub(crate) fn chipset(self) -> Result<Chipset> { 30:30 ecc_mode_enabled as bool; }); +register! (NV_PGSP_QUEUE_HEAD @0x00110c00 { +31 :0 addressas u32 ; +}); +impl NV_PFB_PRI_MMU_LOCAL_MEMORY_RANGE {/// Returns the usable framebuffer size, in bytes. pub (crate )fn usable_fb_size (self) ->u64 {
drivers/gpu/nova-core/sbuffer.rs +0 -2
@@ -49,7 +49,6 @@ impl<'a, I> SBufferIter<I>/// let sum: u8 = sbuffer.sum(); /// assert_eq!(sum, 45); /// ``` -#[expect(unused)] pub (crate )fn new_reader (slices:impl IntoIterator <IntoIter =I >) ->Self where I :Iterator <Item = &'a [u8 ]>,
@@ -71,7 +70,6 @@ pub(crate) fn new_reader(slices: impl IntoIterator<IntoIter = I>) -> Self/// assert_eq!(buf2, [5, 6, 7, 8, 9]); /// /// ``` -#[expect(unused)] pub (crate )fn new_writer (slices:impl IntoIterator <IntoIter =I >) ->Self where I :Iterator <Item = &'amut [u8 ]>,
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 10/14 gpu: nova-core: gsp: Create rmargs
In reply to Alexandre CourbotFrom: Alistair Popple <[email protected]>
Initialise the GSP resource manager arguments (rmargs) which provide initialisation parameters to the GSP firmware during boot. The rmargs structure contains arguments to configure the GSP message/command queue location.
These are mapped for coherent DMA and added to the libos data structure for access when booting GSP.
--- drivers/gpu/nova-core/gsp.rs | 17 ++++++++++++ drivers/gpu/nova-core/gsp/cmdq.rs | 22 +++++++++++++++- drivers/gpu/nova-core/gsp/fw.rs | 54 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-)
drivers/gpu/nova-core/gsp.rs +17 -0
@@ -16,6 +16,7 @@pub (crate )mod cmdq;mod fw; +use fw::GspArgumentsCached ;use fw::LibosMemoryRegionInitArgument ;pub (crate )use fw::{GspFwWprMeta ,LibosParams };
@@ -36,6 +37,7 @@ pub(crate) struct Gsp { logintr: LogBuffer, logrm: LogBuffer, pub(crate) cmdq: Cmdq, + rmargs: CoherentAllocation<GspArgumentsCached>, }#[repr( C )]
@@ -119,11 +121,26 @@ pub(crate) fn new(pdev: &pci::Device<device::Bound>) -> Result<impl PinInit<Selflet cmdq =Cmdq ::new (dev)?; +let rmargs =CoherentAllocation ::<GspArgumentsCached >::alloc_coherent ( + dev, +1 , +GFP_KERNEL | __GFP_ZERO, + )?; +dma_write! (libos[3 ] =LibosMemoryRegionInitArgument ::new ("RMARGS" , &rmargs))?; + +dma_write! ( + rmargs[0 ] = fw::GspArgumentsCached ::new ( + fw::MessageQueueInitArguments ::new (&cmdq), + fw::GspSrInitArguments ::new () + ) + )?; +Ok (try_pin_init! (Self { libos, loginit, logintr, logrm, + rmargs, cmdq, })) }
drivers/gpu/nova-core/gsp/cmdq.rs +21 -1
@@ -6,7 +6,7 @@use core::sync::atomic::Ordering ;use kernel::device; -use kernel::dma::CoherentAllocation ; +use kernel::dma::{CoherentAllocation ,DmaAddress };use kernel::dma_write;use kernel::io::poll::read_poll_timeout;use kernel::prelude::*;
@@ -283,6 +283,22 @@ pub(crate) struct Cmdq { }impl Cmdq { +/// Offset of the data after the PTEs. +const POST_PTE_OFFSET :usize = core::mem::offset_of!(GspMem , cpuq); + +/// Offset of command queue ring buffer. +pub (crate )const CMDQ_OFFSET :usize = core::mem::offset_of!(GspMem , cpuq) + + core::mem::offset_of!(Msgq , msgq) + -Self ::POST_PTE_OFFSET ; + +/// Offset of message queue ring buffer. +pub (crate )const STATQ_OFFSET :usize = core::mem::offset_of!(GspMem , gspq) + + core::mem::offset_of!(Msgq , msgq) + -Self ::POST_PTE_OFFSET ; + +/// Number of page table entries for the GSP shared region. +pub (crate )const NUM_PTES :usize =size_of ::<GspMem >() >>GSP_PAGE_SHIFT ; +pub (crate )fn new (dev: &device::Device <device::Bound >) ->Result <Cmdq > {let gsp_mem =DmaGspMem ::new (dev)?;
@@ -501,4 +517,8 @@ pub(crate) fn receive_msg_from_gsp<M: MessageFromGsp, R>( .advance_cpu_read_ptr(u32::try_from(msg_header.length().div_ceil(GSP_PAGE_SIZE))?); result } + +pub (crate )fn dma_handle (&self) ->DmaAddress { + self.gsp_mem.0 .dma_handle () + } }
drivers/gpu/nova-core/gsp/fw.rs +54 -0
63 lines not on this page · raw message
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 11/14 gpu: nova-core: gsp: Add RM registry and sysinfo bindings and commands
In reply to Alexandre CourbotFrom: Alistair Popple <[email protected]>
Add the RM registry and system information commands that enable the host driver to configure GSP firmware parameters during initialization.
The RM registry is serialized into a packed format and sent via the command queue. For now only two parameters which are required to boot GSP are hardcoded. In future a kernel module parameter will be added to enable other parameters to be added.
Also add the system info command, which provides required hardware information to the GSP. These commands use the GSP command queue infrastructure to issue commands to the GSP which is read during GSP boot.
--- drivers/gpu/nova-core/gsp.rs | 1 + drivers/gpu/nova-core/gsp/boot.rs | 6 +- drivers/gpu/nova-core/gsp/cmdq.rs | 2 - drivers/gpu/nova-core/gsp/commands.rs | 117 +++++++++++++++++ drivers/gpu/nova-core/gsp/fw.rs | 1 + drivers/gpu/nova-core/gsp/fw/commands.rs | 100 +++++++++++++++ drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs | 148 ++++++++++++++++++++++ drivers/gpu/nova-core/sbuffer.rs | 1 - 8 files changed, 372 insertions(+), 4 deletions(-)
drivers/gpu/nova-core/gsp.rs +1 -0
@@ -14,6 +14,7 @@use crate ::gsp::cmdq::Cmdq ;pub (crate )mod cmdq; +pub (crate )mod commands;mod fw;use fw::GspArgumentsCached ;
drivers/gpu/nova-core/gsp/boot.rs +5 -1
@@ -16,6 +16,7 @@ FIRMWARE_VERSION, };use crate ::gpu::Chipset ; +use crate ::gsp::commands::{build_registry, set_system_info};use crate ::gsp::GspFwWprMeta ;use crate ::regs;use crate ::vbios::Vbios ;
@@ -105,7 +106,7 @@ fn run_fwsec_frts(/// /// Upon return, the GSP is up and running, and its runtime object given as return value. pub (crate )fn boot ( - self:Pin <&mut Self >, +mut self:Pin <&mut Self >, pdev: &pci::Device <device::Bound >, bar: &Bar0 , chipset: Chipset,
@@ -139,6 +140,9 @@ pub(crate) fn boot(CoherentAllocation ::<GspFwWprMeta >::alloc_coherent (dev,1 ,GFP_KERNEL | __GFP_ZERO)?;dma_write! (wpr_meta[0 ] =GspFwWprMeta ::new (&gsp_fw, &fb_layout))?; +set_system_info (&mut self.cmdq, pdev, bar)?; +build_registry (&mut self.cmdq, bar)?; +Ok (()) } }
drivers/gpu/nova-core/gsp/cmdq.rs +0 -2
@@ -325,7 +325,6 @@ fn notify_gsp(bar: &Bar0) { .write(bar); } -#[expect(unused)] pub (crate )fn send_gsp_command <M ,E >(&mut self, bar: &Bar0 , init:impl Init <M ,E >) ->Result where M :CommandToGsp ,
@@ -337,7 +336,6 @@ pub(crate) fn send_gsp_command<M, E>(&mut self, bar: &Bar0, init: impl Init<M, E self.send_gsp_command_base_with_payload (bar,0 , init, |_|Ok (())) } -#[expect(unused)] pub (crate )fn send_gsp_command_with_payload <M ,E >( &mut self, bar: &Bar0,
drivers/gpu/nova-core/gsp/commands.rs new file +117 -0
117 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw.rs +1 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 +pub (crate )mod commands;mod r570_144;// Alias to avoid repeating the version number with every use.
drivers/gpu/nova-core/gsp/fw/commands.rs new file +100 -0
100 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs +148 -0
160 lines not on this page · raw message
drivers/gpu/nova-core/sbuffer.rs +0 -1
@@ -193,7 +193,6 @@ fn get_slice_mut(&mut self, len: usize) -> Option<&'a mut [u8]> {/// Ideally we would implement [`Write`], but it is not available in `core`. /// So mimic `std::io::Write::write_all`. -#[expect(unused)] pub (crate )fn write_all (&mut self,mut src: &[u8 ]) ->Result {while !src.is_empty () {match self.get_slice_mut (src.len ()) {
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 12/14 nova-core: falcon: Add support to check if RISC-V is active
In reply to Alexandre CourbotFrom: Joel Fernandes <[email protected]>
Add definition for RISCV_CPUCTL register and use it in a new falcon API to check if the RISC-V core of a Falcon is active. It is required by the sequencer to know if the GSP's RISCV processor is active.
--- drivers/gpu/nova-core/falcon.rs | 9 +++++++++ drivers/gpu/nova-core/regs.rs | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/gpu/nova-core/falcon.rs +9 -0
@@ -601,4 +601,13 @@ pub(crate) fn signature_reg_fuse_version( self.hal .signature_reg_fuse_version (self, bar, engine_id_mask, ucode_id) } + +/// Check if the RISC-V core is active. +/// +/// Returns `true` if the RISC-V core is active, `false` otherwise. +#[expect(unused)] +pub (crate )fn is_riscv_active (&self, bar: &Bar0 ) ->bool { +let cpuctl = regs::NV_PRISCV_RISCV_CPUCTL ::read (bar, &E ::ID ); + cpuctl.active_stat () + } }
drivers/gpu/nova-core/regs.rs +6 -1
@@ -325,7 +325,12 @@ pub(crate) fn mem_scrubbing_done(self) -> bool {// PRISCV -register! (NV_PRISCV_RISCV_BCR_CTRL @PFalconBase [0x00001668 ] { +register! (NV_PRISCV_RISCV_CPUCTL @PFalcon2Base [0x00000388 ] { +0 :0 haltedas bool ; +7 :7 active_statas bool ; +}); + +register! (NV_PRISCV_RISCV_BCR_CTRL @PFalcon2Base [0x00000668 ] {0 :0 validas bool ;4 :4 core_selectas bool =>PeregrineCoreSelect ;8 :8 br_fetchas bool ;
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 13/14 nova-core: falcon: Add support to write firmware version
In reply to Alexandre CourbotFrom: Joel Fernandes <[email protected]>
This will be needed by both the GSP boot code as well as GSP resume code in the sequencer.
--- drivers/gpu/nova-core/falcon.rs | 8 ++++++++ drivers/gpu/nova-core/regs.rs | 6 ++++++ 2 files changed, 14 insertions(+)
drivers/gpu/nova-core/falcon.rs +8 -0
@@ -610,4 +610,12 @@ pub(crate) fn is_riscv_active(&self, bar: &Bar0) -> bool {let cpuctl = regs::NV_PRISCV_RISCV_CPUCTL ::read (bar, &E ::ID ); cpuctl.active_stat () } + +/// Write the application version to the OS register. +#[expect(dead_code)] +pub (crate )fn write_os_version (&self, bar: &Bar0 , app_version:u32 ) { + regs::NV_PFALCON_FALCON_OS ::default () + .set_value (app_version) + .write (bar, &E ::ID ); + } }
drivers/gpu/nova-core/regs.rs +6 -0
@@ -216,6 +216,12 @@ pub(crate) fn vga_workspace_addr(self) -> Option<u64> { 31:0 value as u32; }); +// Used to store version information about the firmware running +// on the Falcon processor. +register! (NV_PFALCON_FALCON_OS @PFalconBase [0x00000080 ] { +31 :0 valueas u32 ; +}); +register! (NV_PFALCON_FALCON_RM @PFalconBase [0x00000084 ] {31 :0 valueas u32 ; });
Signature · 1 line
2.51.0
Alexandre Courbot
maintainerPATCH v7 14/14 nova-core: gsp: Boot GSP
In reply to Alexandre CourbotFrom: Alistair Popple <[email protected]>
Boot the GSP to the RISC-V active state. Completing the boot requires running the CPU sequencer which will be added in a future commit.
--- drivers/gpu/nova-core/falcon.rs | 2 -- drivers/gpu/nova-core/firmware/riscv.rs | 3 +- drivers/gpu/nova-core/gsp/boot.rs | 63 ++++++++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 5 deletions(-)
drivers/gpu/nova-core/falcon.rs +0 -2
@@ -605,14 +605,12 @@ pub(crate) fn signature_reg_fuse_version(/// Check if the RISC-V core is active. /// /// Returns `true` if the RISC-V core is active, `false` otherwise. -#[expect(unused)] pub (crate )fn is_riscv_active (&self, bar: &Bar0 ) ->bool {let cpuctl = regs::NV_PRISCV_RISCV_CPUCTL ::read (bar, &E ::ID ); cpuctl.active_stat () }/// Write the application version to the OS register. -#[expect(dead_code)] pub (crate )fn write_os_version (&self, bar: &Bar0 , app_version:u32 ) { regs::NV_PFALCON_FALCON_OS ::default () .set_value (app_version)
drivers/gpu/nova-core/firmware/riscv.rs +1 -2
@@ -53,7 +53,6 @@ fn new(bin_fw: &BinFirmware<'_>) -> Result<Self> { }/// A parsed firmware for a RISC-V core, ready to be loaded and run. -#[expect(unused)] pub (crate )struct RiscvFirmware {/// Offset at which the code starts in the firmware image. pub (crate ) code_offset:u32 ,
@@ -62,7 +61,7 @@ pub(crate) struct RiscvFirmware {/// Offset at which the manifest starts in the firmware image. pub(crate) manifest_offset: u32,/// Application version. - app_version: u32, + pub(crate) app_version: u32,/// Device-mapped firmware image. pub(crate) ucode: DmaObject, }
drivers/gpu/nova-core/gsp/boot.rs +62 -1
83 lines not on this page · raw message
Signature · 1 line
2.51.0