Transition nova-core to use TLV variables for heap sizes
Subsystems (4)
v2 cover Transition nova-core to use TLV variables for heap sizes
Starting with r615, the GSP-RM firmware TLVs (i.e. gsp.tlv) contain an an additional six variables that that should be used to calculate the various heap sizes that GSP-RM needs in order to boot.
These values are specific to each GPU and RM version, and are obtained by scraping them from the OpenRM source tree.
Note that although this patch set is necessary to support r620 and later, there are other, unrelated changes necessary to complete that support.
This patch set is based on Alex's r000_rebase_all branch:
https://github.com/Gnurou/linux/tree/r000_rebase_all
v2:
- broke down patchset into smaller chunks, without merging LibosParams into GspFwHeapParams first. Instead, we just augment GspFwHeapParams in pieces, and then delete LibosParams at the end.
- Changed get_u64 to use try_from
Timur Tabi (7):
gpu: nova-core: add Tlv.get_u64
gpu: nova-core: read GSP heap variables from TLV
gpu: nova-core: use the TLV heap sizes for pmu and non-wpr
gpu: nova-core: remove heap size related HAL functions
gpu: nova-core: add TLV versions of WPR heap size functions
gpu: nova-core: change wpr2_heap_params to use TLV values
gpu: nova-core: remove LibosParams
drivers/gpu/nova-core/fb.rs | 34 ++++--- drivers/gpu/nova-core/fb/hal.rs | 6 -- drivers/gpu/nova-core/fb/hal/ga100.rs | 8 -- drivers/gpu/nova-core/fb/hal/ga102.rs | 8 -- drivers/gpu/nova-core/fb/hal/gb100.rs | 41 +------- drivers/gpu/nova-core/fb/hal/gb202.rs | 13 +-- drivers/gpu/nova-core/fb/hal/gh100.rs | 12 +-- drivers/gpu/nova-core/fb/hal/tu102.rs | 16 ---- drivers/gpu/nova-core/firmware/gsp.rs | 8 +- drivers/gpu/nova-core/firmware/tlv.rs | 13 +++ drivers/gpu/nova-core/gsp.rs | 4 +- drivers/gpu/nova-core/gsp/fw.rs | 126 ++++++++----------------- drivers/gpu/nova-core/gsp/hal/gh100.rs | 2 +- 13 files changed, 86 insertions(+), 205 deletions(-)
Signature · 1 line
2.54.0
PATCH v2 1/7 gpu: nova-core: add Tlv.get_u64
Introduce get_u64() to support variable-sized TLV integers. If the driver expects that a particular tag might be a 64-bit value, it should use this method read it.
TLVs can store unsigned integers in either 32-bit or 64-bit little-endian format. The script that generates TLV files is written in Python, and Python integers are arbitrarily sized. For any given integer, the script will store it as a 32-bit integer if its value is less than 0x100000000, without any regard to its purpose. This means that the driver may not know until runtime whether a given TLV integer is encoded as four bytes or eight.
--- drivers/gpu/nova-core/firmware/tlv.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/gpu/nova-core/firmware/tlv.rs +14 -0
@@ -257,6 +257,20 @@ pub(crate) fn load_file( .ok_or(EINVAL) } +/// Return a u64, from either a 32-bit or 64-bit little-endian tag. +#[expect(unused)] +pub (crate )fn get_u64 (&self, tag: &[u8 ;4 ]) ->Result <u64 > { +let value = self.find (tag)?.value; + +if let Ok (bytes) = <[u8 ;4 ]>::try_from (value) { +Ok (u64::from (u32::from_le_bytes (bytes))) + }else if let Ok (bytes) = <[u8 ;8 ]>::try_from (value) { +Ok (u64::from_le_bytes (bytes)) + }else { +Err (EINVAL ) + } + } +/// Return a string value. pub (crate )fn get_string (&self, tag: &[u8 ;4 ]) ->Result <&'astr > {let tlv = self.find (tag)?;
Signature · 1 line
2.54.0
Re: [PATCH v2 1/7] gpu: nova-core: add Tlv.get_u64
Quoted 12 lines · Timur Tabi
Introduce
get_u64()to support variable-sized TLV integers. If the driver expects that a particular tag might be a 64-bit value, it should use this method read it.TLVs can store unsigned integers in either 32-bit or 64-bit little-endian format. The script that generates TLV files is written in Python, and Python integers are arbitrarily sized. For any given integer, the script will store it as a 32-bit integer if its value is less than
0x100000000, without any regard to its purpose. This means that the driver may not know until runtime whether a given TLV integer is encoded as four bytes or eight.
Quoted 2 lines
Signed-off-by Timur Tabi <[email protected]>---
PATCH v2 2/7 gpu: nova-core: read GSP heap variables from TLV
In reply to Timur TabiUpdate Nova-core to read and store the new heap size variables from gsp.tlv in a GspFwHeapParams struct, which is changed from an enum. Also provide a constructor (currently unused) to create a GspFwHeapParams object from the TLV.
GSP-RM firmware TLVs (specifically gsp.tlv) that are based on r615 and later contain an additional six variables that contain values used to specify various heap sizes that GSP-RM needs in order to boot. These values are specific to each GPU and RM version, and are obtained by scraping them from the OpenRM source tree, just like every other TLV variable.
--- drivers/gpu/nova-core/firmware/tlv.rs | 1 - drivers/gpu/nova-core/gsp/fw.rs | 33 ++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-)
drivers/gpu/nova-core/firmware/tlv.rs +0 -1
@@ -258,7 +258,6 @@ pub(crate) fn load_file( }/// Return a u64, from either a 32-bit or 64-bit little-endian tag. -#[expect(unused)] pub (crate )fn get_u64 (&self, tag: &[u8 ;4 ]) ->Result <u64 > {let value = self.find (tag)?.value;
drivers/gpu/nova-core/gsp/fw.rs +30 -3
@@ -37,7 +37,8 @@ }, firmware::{ bindata::UcodesImage, - gsp::GspFirmware, // + gsp::GspFirmware, + tlv::Tlv, // }, gpu::{Architecture ,
@@ -65,8 +66,21 @@/// build-time constant, so the driver chooses it, and this constant is the one copy. pub (crate )const GSP_MSG_QUEUE_ELEMENT_SIZE_MAX :usize =GSP_PAGE_SIZE *16 ; -/// Empty type to group methods related to heap parameters for running the GSP firmware. -enum GspFwHeapParams {} +/// Heap memory requirements and constraints for booting GSP-RM. +pub (crate )struct GspFwHeapParams { +#[expect(unused)] + tlv_gsp_fw_heap_base_size:u64 , +#[expect(unused)] + tlv_gsp_hw_heap_size_per_gb:u64 , +#[expect(unused)] + tlv_gsp_fw_heap_base_size_vgpu:u64 , +#[expect(unused)] + tlv_gsp_fw_heap_size_per_vm:u64 , +#[expect(unused)] + tlv_pmu_reserved_size:u32 , +#[expect(unused)] + tlv_non_wpr_heap_size:u64 , +}/// Minimum required alignment for the GSP heap. const GSP_HEAP_ALIGNMENT :Alignment =Alignment ::new ::<{1 <<20 }>();
@@ -85,6 +99,19 @@ fn base_rm_size(chipset: Chipset) -> u64 { } } +/// Returns the heap parameters from the TLV +#[expect(unused)] +pub (crate )fn from_tlv (tlv: &Tlv <'_>) ->Result <Self > { +Ok (Self { + tlv_gsp_fw_heap_base_size: tlv.get_u64 (b"HBSZ" )?, + tlv_gsp_hw_heap_size_per_gb: tlv.get_u64 (b"HSPG" )?, + tlv_gsp_fw_heap_base_size_vgpu: tlv.get_u64 (b"HBSV" )?, + tlv_gsp_fw_heap_size_per_vm: tlv.get_u64 (b"HSPV" )?, + tlv_pmu_reserved_size: tlv.get_u32 (b"PRSZ" )?, + tlv_non_wpr_heap_size: tlv.get_u64 (b"GNWH" )?, + }) + } +/// Returns the amount of heap memory required to support a single channel allocation. fn client_alloc_size () ->u64 { u64::from (bindings::GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE )
Signature · 1 line
2.54.0
Re: [PATCH v2 2/7] gpu: nova-core: read GSP heap variables from TLV
Quoted 55 lines · Timur Tabi
Update Nova-core to read and store the new heap size variables from gsp.tlv in a GspFwHeapParams struct, which is changed from an enum. Also provide a constructor (currently unused) to create a GspFwHeapParams object from the TLV.
GSP-RM firmware TLVs (specifically gsp.tlv) that are based on r615 and later contain an additional six variables that contain values used to specify various heap sizes that GSP-RM needs in order to boot. These values are specific to each GPU and RM version, and are obtained by scraping them from the OpenRM source tree, just like every other TLV variable.
Signed-off-by Timur Tabi <[email protected]>--- drivers/gpu/nova-core/firmware/tlv.rs | 1 - drivers/gpu/nova-core/gsp/fw.rs | 33 ++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-)drivers/gpu/nova-core/firmware/tlv.rs +0
-1@@ -258,7 +258,6 @@ pub(crate) fn load_file( }/// Return a u64, from either a 32-bit or 64-bit little-endian tag. -#[expect(unused)] pub (crate )fn get_u64 (&self, tag: &[u8 ;4 ]) ->Result <u64 > {let value = self.find (tag)?.value;drivers/gpu/nova-core/gsp/fw.rs +7
-3@@ -37,7 +37,8 @@ }, firmware::{ bindata::UcodesImage, - gsp::GspFirmware, // + gsp::GspFirmware, + tlv::Tlv, // }, gpu::{Architecture ,@@ -65,8 +66,21 @@/// build-time constant, so the driver chooses it, and this constant is the one copy. pub (crate )const GSP_MSG_QUEUE_ELEMENT_SIZE_MAX :usize =GSP_PAGE_SIZE *16 ; -/// Empty type to group methods related to heap parameters for running the GSP firmware. -enum GspFwHeapParams {} +/// Heap memory requirements and constraints for booting GSP-RM. +pub (crate )struct GspFwHeapParams { +#[expect(unused)] + tlv_gsp_fw_heap_base_size:u64 , + #[expect(unused)]
drivers/gpu/nova-core/gsp/fw.rs line 83
Quoted 10 lines
drivers/gpu/nova-core/gsp/fw.rs +10
-0+ tlv_gsp_hw_heap_size_per_gb: u64, +#[expect(unused)] + tlv_gsp_fw_heap_base_size_vgpu: u64, +#[expect(unused)] + tlv_gsp_fw_heap_size_per_vm: u64, +#[expect(unused)] + tlv_pmu_reserved_size: u32, +#[expect(unused)] + tlv_non_wpr_heap_size: u64, +}
Sorry for the review delay!
nit: I'm not sure the tlv_gsp_* prefix is adding much. WDYT about names more like:wpr2_heap_base_sizewpr2_heap_size_per_gibvgpu_wpr2_heap_base_sizevgpu_wpr2_heap_size_per_vfpmu_reserved_sizenon_wpr_heap_size
Then the type of heap (out of wpr2, non-wpr) is clearly identified. Some doccomments on the non-obvious part of each var might be nice too (e.g. that the wpr2 heap size computation is dependent on whether vGPU is on or not, which is why there are different vars here).
Other than that,
Re: [PATCH v2 2/7] gpu: nova-core: read GSP heap variables from TLV
Quoted 16 lines · Eliot Courtney
drivers/gpu/nova-core/gsp/fw.rs line 83
Quoted 13 lines
drivers/gpu/nova-core/gsp/fw.rs +13
-0+#[expect(unused)] + tlv_gsp_fw_heap_base_size: u64, +#[expect(unused)] + tlv_gsp_hw_heap_size_per_gb: u64, +#[expect(unused)] + tlv_gsp_fw_heap_base_size_vgpu: u64, +#[expect(unused)] + tlv_gsp_fw_heap_size_per_vm: u64, +#[expect(unused)] + tlv_pmu_reserved_size: u32, +#[expect(unused)] + tlv_non_wpr_heap_size: u64, +}Sorry for the review delay!
Quoted 8 lines
nit: I'm not sure the tlv_gsp_* prefix is adding much. WDYT about names more like:
wpr2_heap_base_sizewpr2_heap_size_per_gibvgpu_wpr2_heap_base_sizevgpu_wpr2_heap_size_per_vfpmu_reserved_sizenon_wpr_heap_size
Well, I wanted to indicate that these are directly the TLV variable values, not something that was calculated and just stored in GspFwHeapParams.
Maybe we want to rename GspFwHeapParams to TlvFwHeapParams, but I can't guarantee that we won't (in the future) store some calculated values in GspFwHeapParams.
PATCH v2 3/7 gpu: nova-core: use the TLV heap sizes for pmu and non-wpr
In reply to Timur TabiInstead of using hard-coded per-GPU values for the Non-WPR heap size and the PMU reserved size, use the values from gsp.tlv instead.
This change will allow us to remove those HAL functions from FbHal.
--- drivers/gpu/nova-core/fb.rs | 16 +++++++++++----- drivers/gpu/nova-core/fb/hal.rs | 2 ++ drivers/gpu/nova-core/firmware/gsp.rs | 8 +++++++- drivers/gpu/nova-core/gsp.rs | 1 + drivers/gpu/nova-core/gsp/fw.rs | 7 ++----- drivers/gpu/nova-core/gsp/hal/gh100.rs | 2 +- 6 files changed, 24 insertions(+), 12 deletions(-)
drivers/gpu/nova-core/fb.rs +11 -5
@@ -264,7 +264,7 @@ pub(crate) fn new( };let non_wpr_heap = { -let non_wpr_heap_size = hal.non_wpr_heap_size (); +let non_wpr_heap_size = gsp_fw.heap_params.tlv_non_wpr_heap_size;FbRange (wpr2.start - non_wpr_heap_size..wpr2.start) };
@@ -278,7 +278,7 @@ pub(crate) fn new( wpr2, non_wpr_heap, vf_partition_count, - pmu_reserved_size: hal.pmu_reserved_size(), + pmu_reserved_size: gsp_fw.heap_params.tlv_pmu_reserved_size, }) } }
@@ -328,7 +328,13 @@ pub(crate) struct FbSizes {impl FbSizes {/// Computes the framebuffer region sizes for GSP-FMC boot. -pub (crate )fn new (chipset:Chipset , bar:Bar0 <'_>, vgpu_state:VgpuState ) ->Result <Self > { +pub (crate )fn new ( + chipset:Chipset , + bar:Bar0 <'_>, + gsp_fw: &GspFirmware <'_>, + + vgpu_state:VgpuState , + ) ->Result <Self > {let hal = hal::fb_hal (chipset);let fb_size = hal.vidmem_size (bar);let (vf_partition_count, wpr2_heap_size) =wpr2_heap_params (chipset, vgpu_state, fb_size)?;
@@ -336,8 +342,8 @@ pub(crate) fn new(chipset: Chipset, bar: Bar0<'_>, vgpu_state: VgpuState) -> ResOk (Self { frts_size: hal.frts_size (), wpr2_heap_size, - non_wpr_heap_size: hal.non_wpr_heap_size (), - pmu_reserved_size: hal.pmu_reserved_size (), + non_wpr_heap_size: gsp_fw.heap_params.tlv_non_wpr_heap_size, + pmu_reserved_size: gsp_fw.heap_params.tlv_pmu_reserved_size, vf_partition_count, }) }
drivers/gpu/nova-core/fb/hal.rs +2 -0
@@ -34,9 +34,11 @@ pub(crate) trait FbHal {fn vidmem_size (&self, bar:Bar0 <'_>) ->u64 ;/// Returns the amount of VRAM to reserve for the PMU. +#[expect(unused)] fn pmu_reserved_size (&self) ->u32 ;/// Returns the non-WPR heap size for this chipset, in bytes. +#[expect(unused)] fn non_wpr_heap_size (&self) ->u64 ;/// Returns the FRTS size, in bytes.
drivers/gpu/nova-core/firmware/gsp.rs +7 -1
@@ -18,7 +18,8 @@ Tlv, }, }, - gpu::Chipset, // + gpu::Chipset, + gsp::GspFwHeapParams, // };/// The GSP firmware image, its signatures, and the GSP bootloader.
@@ -31,6 +32,8 @@ pub(crate) struct GspFirmware<'a> { pub(crate) signatures: Coherent<'a, [u8]>,/// GSP bootloader, verifies the GSP firmware before loading and running it. pub(crate) bootloader: RiscvFirmware<'a>, +/// Heap sizing parameters reported by the firmware metadata. + pub(crate) heap_params: GspFwHeapParams, }impl <'a>GspFirmware <'a> {
@@ -49,6 +52,8 @@ pub(crate) fn new(let signatures =Coherent ::from_slice (dev, tlv.get_bytes (b"SIGN" )?,GFP_KERNEL )?; +let heap_params =GspFwHeapParams ::from_tlv (&tlv)?; + Ok(try_pin_init!(Self { radix3 <- Radix3::new(dev, fw_vvec), signatures,
@@ -57,6 +62,7 @@ pub(crate) fn new(RiscvFirmware ::new (dev, &bl)? }, + heap_params, })) }) }
drivers/gpu/nova-core/gsp.rs +1 -0
@@ -29,6 +29,7 @@pub (crate )use fw::{GspFmcBootParams , +GspFwHeapParams ,GspFwWprMeta ,LibosMemoryRegionInitArgument ,LibosParams ,//
drivers/gpu/nova-core/gsp/fw.rs +2 -5
@@ -76,10 +76,8 @@ pub(crate) struct GspFwHeapParams { tlv_gsp_fw_heap_base_size_vgpu: u64,#[expect(unused)] tlv_gsp_fw_heap_size_per_vm: u64, -#[expect(unused)] - tlv_pmu_reserved_size: u32, -#[expect(unused)] - tlv_non_wpr_heap_size: u64, + pub(crate) tlv_pmu_reserved_size: u32, + pub(crate) tlv_non_wpr_heap_size: u64, }/// Minimum required alignment for the GSP heap.
@@ -100,7 +98,6 @@ fn base_rm_size(chipset: Chipset) -> u64 { }/// Returns the heap parameters from the TLV -#[expect(unused)] pub (crate )fn from_tlv (tlv: &Tlv <'_>) ->Result <Self > {Ok (Self { tlv_gsp_fw_heap_base_size: tlv.get_u64 (b"HBSZ" )?,
drivers/gpu/nova-core/gsp/hal/gh100.rs +1 -1
@@ -151,7 +151,7 @@ fn boot<'gpu>(let chipset = ctx.chipset;let gsp_falcon = ctx.gsp_falcon; -let fb_sizes =FbSizes ::new (chipset, ctx.bar, ctx.vgpu.state ())?; +let fb_sizes =FbSizes ::new (chipset, ctx.bar, gsp_fw, ctx.vgpu.state ())?;dev_dbg! (dev,"{:#x?}\n" , fb_sizes); let wpr_meta =
Signature · 1 line
2.54.0
Re: [PATCH v2 3/7] gpu: nova-core: use the TLV heap sizes for pmu and non-wpr
Quoted 20 lines · Timur Tabi
Instead of using hard-coded per-GPU values for the Non-WPR heap size and the PMU reserved size, use the values from gsp.tlv instead.
This change will allow us to remove those HAL functions from FbHal.
Signed-off-by Timur Tabi <[email protected]>--- drivers/gpu/nova-core/fb.rs | 16 +++++++++++----- drivers/gpu/nova-core/fb/hal.rs | 2 ++ drivers/gpu/nova-core/firmware/gsp.rs | 8 +++++++- drivers/gpu/nova-core/gsp.rs | 1 + drivers/gpu/nova-core/gsp/fw.rs | 7 ++----- drivers/gpu/nova-core/gsp/hal/gh100.rs | 2 +- 6 files changed, 24 insertions(+), 12 deletions(-)drivers/gpu/nova-core/fb.rs +0
-0
drivers/gpu/nova-core/fb.rs pub(crate) fn new( · line 268
Quoted 6 lines
drivers/gpu/nova-core/fb.rs +1
-1@@ -264,7 +264,7 @@ pub(crate) fn new( };let non_wpr_heap = { -let non_wpr_heap_size = hal.non_wpr_heap_size (); +let non_wpr_heap_size = gsp_fw.heap_params.tlv_non_wpr_heap_size;FbRange (wpr2.start - non_wpr_heap_size..wpr2.start)
Now that this is using a firmware defined value, it's possible this could underflow, so what about using checked_sub instead?
Quoted 12 lines
drivers/gpu/nova-core/fb.rs +1
-1};@@ -278,7 +278,7 @@ pub(crate) fn new( wpr2, non_wpr_heap, vf_partition_count, - pmu_reserved_size: hal.pmu_reserved_size(), + pmu_reserved_size: gsp_fw.heap_params.tlv_pmu_reserved_size, }) } }
drivers/gpu/nova-core/fb.rs pub(crate) struct FbSizes { · line 336
Quoted 10 lines
drivers/gpu/nova-core/fb.rs +6
-1@@ -328,7 +328,13 @@ pub(crate) struct FbSizes {impl FbSizes {/// Computes the framebuffer region sizes for GSP-FMC boot. -pub (crate )fn new (chipset:Chipset , bar:Bar0 <'_>, vgpu_state:VgpuState ) ->Result <Self > { +pub (crate )fn new ( + chipset:Chipset , + bar:Bar0 <'_>, + gsp_fw: &GspFirmware <'_>, + + vgpu_state: VgpuState,
nit: blank line between gsp_fw and vgpu_state
Quoted 20 lines
drivers/gpu/nova-core/fb.rs +3
-2+ ) -> Result<Self> {let hal = hal::fb_hal (chipset);let fb_size = hal.vidmem_size (bar);let (vf_partition_count, wpr2_heap_size) =wpr2_heap_params (chipset, vgpu_state, fb_size)?;@@ -336,8 +342,8 @@ pub(crate) fn new(chipset: Chipset, bar: Bar0<'_>, vgpu_state: VgpuState) -> ResOk (Self { frts_size: hal.frts_size (), wpr2_heap_size, - non_wpr_heap_size: hal.non_wpr_heap_size (), - pmu_reserved_size: hal.pmu_reserved_size (), + non_wpr_heap_size: gsp_fw.heap_params.tlv_non_wpr_heap_size, + pmu_reserved_size: gsp_fw.heap_params.tlv_pmu_reserved_size, vf_partition_count, }) }drivers/gpu/nova-core/fb/hal.rs +0
-0
drivers/gpu/nova-core/fb/hal.rs pub(crate) trait FbHal { · line 38
Quoted 5 lines
drivers/gpu/nova-core/fb/hal.rs +1
-0@@ -34,9 +34,11 @@ pub(crate) trait FbHal {fn vidmem_size (&self, bar:Bar0 <'_>) ->u64 ;/// Returns the amount of VRAM to reserve for the PMU. +#[expect(unused)] fn pmu_reserved_size (&self) ->u32 ;
Unfortunately MSRV rust 1.85 doesn't have as good a handling of expect(unused) as the latest one, so this patch produces some unused warnings. If you want to keep this patch separate to patch 4, I think it needs #[expect(dead_code)] on pmu_reserved_size_tu102(), non_wpr_heap_size_tu102() and pmu_reserved_size_gb100(). Thanks!
With above comments resolved,
Re: [PATCH v2 3/7] gpu: nova-core: use the TLV heap sizes for pmu and non-wpr
Quoted 7 lines · Eliot Courtney
drivers/gpu/nova-core/fb.rs pub(crate) fn new( · line 268
Quoted 4 lines
let non_wpr_heap = {drivers/gpu/nova-core/fb.rs +1
-1-let non_wpr_heap_size = hal.non_wpr_heap_size (); +let non_wpr_heap_size = gsp_fw.heap_params.tlv_non_wpr_heap_size;FbRange (wpr2.start - non_wpr_heap_size..wpr2.start)Now that this is using a firmware defined value, it's possible this could underflow, so what about using
checked_subinstead?
Sure.
Quoted 11 lines
drivers/gpu/nova-core/fb.rs pub(crate) struct FbSizes { · line 336
Quoted 10 lines
impl FbSizes { /// Computes the framebuffer region sizes for GSP-FMC boot.drivers/gpu/nova-core/fb.rs +6
-1-pub (crate )fn new (chipset:Chipset , bar:Bar0 <'_>, vgpu_state:VgpuState ) ->Result <Self > { +pub (crate )fn new ( + chipset:Chipset , + bar:Bar0 <'_>, + gsp_fw: &GspFirmware <'_>, + + vgpu_state: VgpuState,
Quoted 1 line
nit: blank line between
gsp_fwandvgpu_state
Ok. It's fixed in a later patch, which is why I didn't see it.
Quoted 9 lines
Quoted 3 lines
/// Returns the amount of VRAM to reserve for the PMU. + #[expect(unused)] fn pmu_reserved_size(&self) -> u32;Unfortunately MSRV rust 1.85 doesn't have as good a handling of expect(unused) as the latest one, so this patch produces some unused warnings. If you want to keep this patch separate to patch 4, I think it needs #[expect(dead_code)] on
pmu_reserved_size_tu102(),non_wpr_heap_size_tu102()andpmu_reserved_size_gb100(). Thanks!
Well, that doesn't work in 1.94:
warning: this lint expectation is unfulfilled
--> drivers/gpu/nova-core/fb/hal/tu102.rs:45:10
| 45 | #[expect(dead_code)] | ^^^^^^^^^
I changed it to #[allow(dead_code)] and that seems to work, though. I'll post a v3 with that.
Honestly, I've never been a fan of adding and then removing unused-code attributes within a patch set. If you're telling me that they now depend on the the Rust compiler version, then maybe we need to relax these rules a bit.
Just FYI, when building this tree, I already get warnings like this. I've just ignored them.
warning: this lint expectation is unfulfilled
--> drivers/gpu/nova-core/gsp/nvkv/encode.rs:4:45
| 4 | #![cfg_attr(not(CONFIG_KUNIT = "y"), expect(dead_code))] | ^^^^^^^^^
warning: this lint expectation is unfulfilled
--> drivers/gpu/nova-core/gsp/nvkv/decode.rs:4:45
| 4 | #![cfg_attr(not(CONFIG_KUNIT = "y"), expect(dead_code))] | ^^^^^^^^^
Re: [PATCH v2 3/7] gpu: nova-core: use the TLV heap sizes for pmu and non-wpr
Quoted 1 line · Timur Tabi
On Fri, 2026-11-20 at 15:47 +0900, Eliot Courtney wrote:
...
Quoted 2 lines
Honestly, I've never been a fan of adding and then removing unused-code attributes within a patch set. If you're telling me that they now depend on the the Rust compiler version, then
We are stuck doing this, though.
Quoted 3 lines
maybe we need to relax these rules a bit.
Just FYI, when building this tree, I already get warnings like this. I've just ignored them.
Please don't get accustomed to ignoring Rust build warnings, because Nova (and Rust for Linux) are expected to build completely cleanly.
The convention is very strongly "no warnings on the build".
Quoted 7 lines
warning: this lint expectation is unfulfilled
-->drivers/gpu/nova-core/gsp/nvkv/encode.rs:4:45| 4 | #![cfg_attr(not(CONFIG_KUNIT = "y"), expect(dead_code))] | ^^^^^^^^^
Quoted 5 lines
warning: this lint expectation is unfulfilled
-->drivers/gpu/nova-core/gsp/nvkv/decode.rs:4:45| 4 | #![cfg_attr(not(CONFIG_KUNIT = "y"), expect(dead_code))] | ^^^^^^^^^
Eliot can fix those, but only if he knows about them. Don't suffer in silence. :)
thanks,
Signature · 1 line
John Hubbard
PATCH v2 4/7 gpu: nova-core: remove heap size related HAL functions
In reply to Timur TabiNow that Nova-core reads all heap size values from the TLVs, we can remove all of the HAL functions that used to provide that data.
--- drivers/gpu/nova-core/fb/hal.rs | 8 ------ drivers/gpu/nova-core/fb/hal/ga100.rs | 8 ------ drivers/gpu/nova-core/fb/hal/ga102.rs | 8 ------ drivers/gpu/nova-core/fb/hal/gb100.rs | 41 +-------------------------- drivers/gpu/nova-core/fb/hal/gb202.rs | 13 +-------- drivers/gpu/nova-core/fb/hal/gh100.rs | 12 +------- drivers/gpu/nova-core/fb/hal/tu102.rs | 16 ----------- 7 files changed, 3 insertions(+), 103 deletions(-)
drivers/gpu/nova-core/fb/hal.rs +0 -8
@@ -33,14 +33,6 @@ pub(crate) trait FbHal {/// Returns the VRAM size, in bytes. fn vidmem_size (&self, bar:Bar0 <'_>) ->u64 ; -/// Returns the amount of VRAM to reserve for the PMU. -#[expect(unused)] -fn pmu_reserved_size (&self) ->u32 ; - -/// Returns the non-WPR heap size for this chipset, in bytes. -#[expect(unused)] -fn non_wpr_heap_size (&self) ->u64 ; -/// Returns the FRTS size, in bytes. fn frts_size (&self) ->u64 ; }
drivers/gpu/nova-core/fb/hal/ga100.rs +0 -8
@@ -70,14 +70,6 @@ fn vidmem_size(&self, bar: Bar0<'_>) -> u64 {super ::tu102::vidmem_size_gp102 (bar) } -fn pmu_reserved_size (&self) ->u32 { -super ::tu102::pmu_reserved_size_tu102 () - } - -fn non_wpr_heap_size (&self) ->u64 { -super ::tu102::non_wpr_heap_size_tu102 () - } -// GA100 is a special case where its FRTS region exists, but is empty. We // return a size of 0 because we still need to record where the region starts. fn frts_size (&self) ->u64 {
drivers/gpu/nova-core/fb/hal/ga102.rs +0 -8
@@ -37,14 +37,6 @@ fn vidmem_size(&self, bar: Bar0<'_>) -> u64 {vidmem_size_ga102 (bar) } -fn pmu_reserved_size (&self) ->u32 { -super ::tu102::pmu_reserved_size_tu102 () - } - -fn non_wpr_heap_size (&self) ->u64 { -super ::tu102::non_wpr_heap_size_tu102 () - } -fn frts_size (&self) ->u64 {super ::tu102::frts_size_tu102 () }
drivers/gpu/nova-core/fb/hal/gb100.rs +1 -40
59 lines not on this page · raw message
drivers/gpu/nova-core/fb/hal/gb202.rs +1 -12
@@ -6,8 +6,7 @@use kernel::{ io::Io , num::Bounded , - prelude::*, - sizes::SizeConstants ,// + prelude::*,// };use crate ::{
@@ -67,16 +66,6 @@ fn vidmem_size(&self, bar: Bar0<'_>) -> u64 {super ::ga102::vidmem_size_ga102 (bar) } -fn pmu_reserved_size (&self) ->u32 { -super ::gb100::pmu_reserved_size_gb100 () - } - -fn non_wpr_heap_size (&self) ->u64 { -// Non-WPR heap for GB20x (see OpenRM: kgspGetNonWprHeapSize, GB202+). This size is -// r000-specific. -3 * u64::SZ_1M - } -fn frts_size (&self) ->u64 {super ::tu102::frts_size_tu102 () }
drivers/gpu/nova-core/fb/hal/gh100.rs +1 -11
@@ -4,8 +4,7 @@use kernel::{ io::Io , num::Bounded , - prelude::*, - sizes::SizeConstants ,// + prelude::*,// };use crate ::{
@@ -59,15 +58,6 @@ fn vidmem_size(&self, bar: Bar0<'_>) -> u64 {super ::ga102::vidmem_size_ga102 (bar) } -fn pmu_reserved_size (&self) ->u32 { -super ::tu102::pmu_reserved_size_tu102 () - } - -fn non_wpr_heap_size (&self) ->u64 { -// Non-WPR heap for Hopper (see Open RM: kgspCalculateFbLayout_GH100). - u64::SZ_2M - } -fn frts_size (&self) ->u64 {super ::tu102::frts_size_tu102 () }
drivers/gpu/nova-core/fb/hal/tu102.rs +0 -16
@@ -42,14 +42,6 @@ pub(super) fn vidmem_size_gp102(bar: Bar0<'_>) -> u64 { .usable_fb_size() } -pub (super )const fn pmu_reserved_size_tu102 () ->u32 { -0 -} - -pub (super )const fn non_wpr_heap_size_tu102 () ->u64 { - u64::SZ_1M -} -pub (super )const fn frts_size_tu102 () ->u64 { u64::SZ_1M }
@@ -73,14 +65,6 @@ fn vidmem_size(&self, bar: Bar0<'_>) -> u64 {vidmem_size_gp102 (bar) } -fn pmu_reserved_size (&self) ->u32 { -pmu_reserved_size_tu102 () - } - -fn non_wpr_heap_size (&self) ->u64 { -non_wpr_heap_size_tu102 () - } -fn frts_size (&self) ->u64 {frts_size_tu102 () }
Signature · 1 line
2.54.0
Re: [PATCH v2 4/7] gpu: nova-core: remove heap size related HAL functions
Quoted 5 lines · Timur Tabi
Now that Nova-core reads all heap size values from the TLVs, we can remove all of the HAL functions that used to provide that data.
Signed-off-by Timur Tabi <[email protected]>---
PATCH v2 5/7 gpu: nova-core: add TLV versions of WPR heap size functions
In reply to Timur TabiAdd TLV versions of vgpu_wpr_heap_size() and wpr_heap_size() to GspFwHeapParams. These complement the same functions in LibosParams. We add them to GspFwHeapParams because LibosParams will be removed in a future commit, and the driver will use the GspFwHeapParams version instead.
--- drivers/gpu/nova-core/gsp/fw.rs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)
drivers/gpu/nova-core/gsp/fw.rs +29 -4
@@ -68,13 +68,9 @@/// Heap memory requirements and constraints for booting GSP-RM. pub (crate )struct GspFwHeapParams { -#[expect(unused)] tlv_gsp_fw_heap_base_size:u64 , -#[expect(unused)] tlv_gsp_hw_heap_size_per_gb:u64 , -#[expect(unused)] tlv_gsp_fw_heap_base_size_vgpu:u64 , -#[expect(unused)] tlv_gsp_fw_heap_size_per_vm:u64 ,pub (crate ) tlv_pmu_reserved_size:u32 ,pub (crate ) tlv_non_wpr_heap_size:u64 ,
@@ -127,6 +123,35 @@ fn management_overhead(fb_size: u64) -> Result<u64> { .align_up(GSP_HEAP_ALIGNMENT) .ok_or (EINVAL ) } + +/// Returns the WPR heap size to reserve when vGPU is enabled. +#[expect(unused)] +pub (crate )fn vgpu_wpr_heap_size (&self, total_vfs:u16 ) ->Result <u64 > { +//u64::from(bindings::GSP_FW_HEAP_SIZE_VGPU_DEFAULT) +let vm_size = self + .tlv_gsp_fw_heap_size_per_vm + .saturating_mul (u64::from (total_vfs)) + .align_up (GSP_HEAP_ALIGNMENT ) + .ok_or (EINVAL )?; + +Ok (self.tlv_gsp_fw_heap_base_size_vgpu.saturating_add (vm_size)) + } + +/// Returns the amount of memory (in bytes) to allocate for the WPR heap for a framebuffer size +/// of `fb_size` (in bytes). +#[expect(unused)] +pub (crate )fn wpr_heap_size (&self, fb_size:u64 ) ->Result <u64 > { +let fb_size_gb = fb_size.div_ceil (u64::SZ_1G ); +let management_overhead:u64 = self + .tlv_gsp_hw_heap_size_per_gb + .saturating_mul (fb_size_gb) + .align_up (GSP_HEAP_ALIGNMENT ) + .ok_or (EINVAL )?; + +Ok (self + .tlv_gsp_fw_heap_base_size + .saturating_add (management_overhead)) + } }/// Heap memory requirements and constraints for a given version of the GSP LIBOS.
Signature · 1 line
2.54.0
Re: [PATCH v2 5/7] gpu: nova-core: add TLV versions of WPR heap size functions
Quoted 31 lines · Timur Tabi
Add TLV versions of
vgpu_wpr_heap_size()andwpr_heap_size()to GspFwHeapParams. These complement the same functions in LibosParams. We add them to GspFwHeapParams because LibosParams will be removed in a future commit, and the driver will use the GspFwHeapParams version instead.Signed-off-by Timur Tabi <[email protected]>--- drivers/gpu/nova-core/gsp/fw.rs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)drivers/gpu/nova-core/gsp/fw.rs +0
-4@@ -68,13 +68,9 @@/// Heap memory requirements and constraints for booting GSP-RM. pub (crate )struct GspFwHeapParams { -#[expect(unused)] tlv_gsp_fw_heap_base_size:u64 , -#[expect(unused)] tlv_gsp_hw_heap_size_per_gb:u64 , -#[expect(unused)] tlv_gsp_fw_heap_base_size_vgpu:u64 , -#[expect(unused)] tlv_gsp_fw_heap_size_per_vm:u64 ,pub (crate ) tlv_pmu_reserved_size:u32 ,pub (crate ) tlv_non_wpr_heap_size:u64 ,@@ -127,6 +123,35 @@ fn management_overhead(fb_size: u64) -> Result<u64> { .align_up(GSP_HEAP_ALIGNMENT)
drivers/gpu/nova-core/gsp/fw.rs fn management_overhead(fb_size: u64) -> Result<u64> { · line 133
Quoted 10 lines
drivers/gpu/nova-core/gsp/fw.rs +8
-0.ok_or(EINVAL) } + +/// Returns the WPR heap size to reserve when vGPU is enabled. +#[expect(unused)] +pub (crate )fn vgpu_wpr_heap_size (&self, total_vfs:u16 ) ->Result <u64 > { +//u64::from(bindings::GSP_FW_HEAP_SIZE_VGPU_DEFAULT) +let vm_size = self + .tlv_gsp_fw_heap_size_per_vm + .saturating_mul (u64::from (total_vfs))
What about using checked_mul here (and other locations)? We already return a Result from these functions anyway.
drivers/gpu/nova-core/gsp/fw.rs fn management_overhead(fb_size: u64) -> Result<u64> { · line 145
Quoted 12 lines
drivers/gpu/nova-core/gsp/fw.rs +12
-0+ .align_up(GSP_HEAP_ALIGNMENT) + .ok_or (EINVAL )?; + +Ok (self.tlv_gsp_fw_heap_base_size_vgpu.saturating_add (vm_size)) + } + +/// Returns the amount of memory (in bytes) to allocate for the WPR heap for a framebuffer size +/// of `fb_size` (in bytes). +#[expect(unused)] +pub (crate )fn wpr_heap_size (&self, fb_size:u64 ) ->Result <u64 > { +let fb_size_gb = fb_size.div_ceil (u64::SZ_1G ); +let management_overhead:u64 = self
nit: unneccessary u64 type specified
Quoted 12 lines
drivers/gpu/nova-core/gsp/fw.rs +9
-0+ .tlv_gsp_hw_heap_size_per_gb + .saturating_mul (fb_size_gb) + .align_up (GSP_HEAP_ALIGNMENT ) + .ok_or (EINVAL )?; + +Ok (self + .tlv_gsp_fw_heap_base_size + .saturating_add (management_overhead)) + } }/// Heap memory requirements and constraints for a given version of the GSP LIBOS.
Re: [PATCH v2 5/7] gpu: nova-core: add TLV versions of WPR heap size functions
Quoted 11 lines · Eliot Courtney
drivers/gpu/nova-core/gsp/fw.rs fn management_overhead(fb_size: u64) -> Result<u64> { · line 133
Quoted 8 lines
drivers/gpu/nova-core/gsp/fw.rs +7
-0+/// Returns the WPR heap size to reserve when vGPU is enabled. +#[expect(unused)] +pub (crate )fn vgpu_wpr_heap_size (&self, total_vfs:u16 ) ->Result <u64 > { +//u64::from(bindings::GSP_FW_HEAP_SIZE_VGPU_DEFAULT) +let vm_size = self + .tlv_gsp_fw_heap_size_per_vm + .saturating_mul (u64::from (total_vfs))What about using
checked_mulhere (and other locations)? We already return aResultfrom these functions anyway.
A u64::MAX can't be align_up'd anyway, but I get your point. I'll change it.
PATCH v2 6/7 gpu: nova-core: change wpr2_heap_params to use TLV values
In reply to Timur TabiNow that GspFwHeapParams has TLV-based implementations of wpr_heap_size() and vgpu_wpr_heap_size(), change wpr2_heap_params() to use those functions instead of the LibosParams versions. This renders LibosParams unused, and it is marked as such.
--- drivers/gpu/nova-core/fb.rs | 20 +++++++++++--------- drivers/gpu/nova-core/gsp.rs | 3 +-- drivers/gpu/nova-core/gsp/fw.rs | 3 +-- 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/nova-core/fb.rs +11 -9
@@ -242,7 +242,8 @@ pub(crate) fn new(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 (vf_partition_count, wpr2_heap_size) = +wpr2_heap_params (&gsp_fw.heap_params, vgpu_state, fb.end)?;let wpr2_heap = {const WPR2_HEAP_DOWN_ALIGN :Alignment =Alignment ::new ::<SZ_1M >();
@@ -298,15 +299,16 @@ pub(crate) fn wpr2_range(bar: Bar0<'_>) -> Option<Range<u64>> { }/// Computes the number of VF partitions and the WPR2 heap size from the vGPU state. -fn wpr2_heap_params (chipset:Chipset , vgpu_state:VgpuState , fb_size:u64 ) ->Result <(u8 ,u64 )> { +fn wpr2_heap_params ( + heap_params: &gsp::GspFwHeapParams , + vgpu_state:VgpuState , + fb_size:u64 , +) ->Result <(u8 ,u64 )> {Ok (match vgpu_state { -VgpuState ::Disabled => ( -0 , - gsp::LibosParams ::from_chipset (chipset).wpr_heap_size (chipset, fb_size)?, - ), +VgpuState ::Disabled => (0 , heap_params.wpr_heap_size (fb_size)?),VgpuState ::Enabled { total_vfs } => ( u8::try_from (total_vfs.get ()).map_err (|_|EINVAL )?, - gsp::LibosParams ::vgpu_wpr_heap_size (), + heap_params.vgpu_wpr_heap_size (total_vfs.get ())?, ), }) }
@@ -332,12 +334,12 @@ pub(crate) fn new( chipset: Chipset, bar: Bar0<'_>, gsp_fw: &GspFirmware<'_>, - vgpu_state: VgpuState, ) -> Result<Self> {let hal = hal::fb_hal (chipset);let fb_size = hal.vidmem_size (bar); -let (vf_partition_count, wpr2_heap_size) =wpr2_heap_params (chipset, vgpu_state, fb_size)?; +let (vf_partition_count, wpr2_heap_size) = +wpr2_heap_params (&gsp_fw.heap_params, vgpu_state, fb_size)?;Ok (Self { frts_size: hal.frts_size (),
drivers/gpu/nova-core/gsp.rs +1 -2
@@ -31,8 +31,7 @@ GspFmcBootParams, GspFwHeapParams, GspFwWprMeta, - LibosMemoryRegionInitArgument, - LibosParams, // + LibosMemoryRegionInitArgument, // };pub (crate )use hal::boot_firmware_files;
drivers/gpu/nova-core/gsp/fw.rs +1 -2
@@ -125,7 +125,6 @@ fn management_overhead(fb_size: u64) -> Result<u64> { }/// Returns the WPR heap size to reserve when vGPU is enabled. -#[expect(unused)] pub (crate )fn vgpu_wpr_heap_size (&self, total_vfs:u16 ) ->Result <u64 > {//u64::from(bindings::GSP_FW_HEAP_SIZE_VGPU_DEFAULT) let vm_size = self
@@ -139,7 +138,6 @@ pub(crate) fn vgpu_wpr_heap_size(&self, total_vfs: u16) -> Result<u64> {/// Returns the amount of memory (in bytes) to allocate for the WPR heap for a framebuffer size /// of `fb_size` (in bytes). -#[expect(unused)] pub (crate )fn wpr_heap_size (&self, fb_size:u64 ) ->Result <u64 > {let fb_size_gb = fb_size.div_ceil (u64::SZ_1G );let management_overhead:u64 = self
@@ -162,6 +160,7 @@ pub(crate) struct LibosParams { allowed_heap_size: Range<u64>, } +#[expect(unused)] impl LibosParams {/// Version 2 of the GSP LIBOS (Turing and GA100) const LIBOS2: LibosParams = LibosParams {
Signature · 1 line
2.54.0
Re: [PATCH v2 6/7] gpu: nova-core: change wpr2_heap_params to use TLV values
Quoted 7 lines · Timur Tabi
Now that GspFwHeapParams has TLV-based implementations of
wpr_heap_size()andvgpu_wpr_heap_size(), changewpr2_heap_params()to use those functions instead of the LibosParams versions. This renders LibosParams unused, and it is marked as such.Signed-off-by Timur Tabi <[email protected]>---
PATCH v2 7/7 gpu: nova-core: remove LibosParams
In reply to Timur TabiAll functionality that was provided by LibosParams has now been replaced with TLV-based implementations in GspFwHeapParams, so we can remove LibosParams and all its dependencies.
This also allows us to remove the legacy methods base_rm_size(), client_alloc_size(), and management_overhead(). These were used to calculate intermediate values that are now represented by TLV values.
LibosParams and GspFwHeapParams were two types used to hold data and/or methods for calculating the heap sides that GSP-RM needs for booting. Although they technically represent distinct parts of the equations, they were always used together, so it makes sense to merge LibosParams into GspFwHeapParams.
--- drivers/gpu/nova-core/gsp/fw.rs | 96 --------------------------------- 1 file changed, 96 deletions(-)
drivers/gpu/nova-core/gsp/fw.rs +0 -96
@@ -7,8 +7,6 @@// Alias to avoid repeating the version number with every use. use r000_00as bindings; -use core::ops::Range ; -use kernel::{ bitfield, dma::Coherent ,
@@ -40,10 +38,6 @@ gsp::GspFirmware, tlv::Tlv, // }, - gpu::{ - Architecture, - Chipset, // - }, gsp::{ cmdq::Cmdq, GSP_PAGE_SHIFT,
@@ -80,19 +74,6 @@ pub(crate) struct GspFwHeapParams {const GSP_HEAP_ALIGNMENT :Alignment =Alignment ::new ::<{1 <<20 }>();impl GspFwHeapParams { -/// Returns the amount of GSP-RM heap memory used during GSP-RM boot and initialization (up to -/// and including the first client subdevice allocation). -fn base_rm_size (chipset:Chipset ) ->u64 { -match chipset.arch () { -Architecture ::Turing |Architecture ::Ampere |Architecture ::Ada => { - u64::from (bindings::GSP_FW_HEAP_PARAM_BASE_RM_SIZE_TU10X ) - } -Architecture ::Hopper |Architecture ::BlackwellGB10x |Architecture ::BlackwellGB20x => { - u64::from (bindings::GSP_FW_HEAP_PARAM_BASE_RM_SIZE_GH100 ) - } - } - } -/// Returns the heap parameters from the TLV pub (crate )fn from_tlv (tlv: &Tlv <'_>) ->Result <Self > {Ok (Self {
@@ -105,25 +86,6 @@ pub(crate) fn from_tlv(tlv: &Tlv<'_>) -> Result<Self> { }) } -/// Returns the amount of heap memory required to support a single channel allocation. -fn client_alloc_size () ->u64 { - u64::from (bindings::GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE ) - .align_up (GSP_HEAP_ALIGNMENT ) - .unwrap_or (u64::MAX ) - } - -/// Returns the amount of memory to reserve for management purposes for a framebuffer of size -/// `fb_size`. -fn management_overhead (fb_size:u64 ) ->Result <u64 > { -let fb_size_gb = fb_size.div_ceil (u64::SZ_1G ); - - u64::from (bindings::GSP_FW_HEAP_PARAM_SIZE_PER_GB ) - .checked_mul (fb_size_gb) - .ok_or (EINVAL )? - .align_up (GSP_HEAP_ALIGNMENT ) - .ok_or (EINVAL ) - } -/// Returns the WPR heap size to reserve when vGPU is enabled. pub (crate )fn vgpu_wpr_heap_size (&self, total_vfs:u16 ) ->Result <u64 > {//u64::from(bindings::GSP_FW_HEAP_SIZE_VGPU_DEFAULT)
@@ -152,64 +114,6 @@ pub(crate) fn wpr_heap_size(&self, fb_size: u64) -> Result<u64> { } } -/// Heap memory requirements and constraints for a given version of the GSP LIBOS. -pub (crate )struct LibosParams { -/// The base amount of heap required by the GSP operating system, in bytes. - carveout_size:u64 , -/// The minimum and maximum sizes allowed for the GSP FW heap, in bytes. - allowed_heap_size:Range <u64 >, -} - -#[expect(unused)] -impl LibosParams { -/// Version 2 of the GSP LIBOS (Turing and GA100) -const LIBOS2 :LibosParams =LibosParams { - carveout_size:cv! (bindings::GSP_FW_HEAP_PARAM_OS_SIZE_LIBOS2 ), - allowed_heap_size:cv! (bindings::GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS2_MIN_MB =>u64 ) - * u64::SZ_1M - ..cv! (bindings::GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS2_MAX_MB =>u64 ) * u64::SZ_1M , - }; - -/// Version 3 of the GSP LIBOS (GA102+) -const LIBOS3 :LibosParams =LibosParams { - carveout_size:cv! (bindings::GSP_FW_HEAP_PARAM_OS_SIZE_LIBOS3_BAREMETAL ), - allowed_heap_size:cv! (bindings::GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MIN_MB =>u64 ) - * u64::SZ_1M - ..cv! (bindings::GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MAX_MB =>u64 ) * u64::SZ_1M , - }; - -/// Returns the libos parameters corresponding to `chipset`. -pub (crate )fn from_chipset (chipset:Chipset ) -> &'staticLibosParams { -if chipset <Chipset ::GA102 { - &Self ::LIBOS2 - }else { - &Self ::LIBOS3 - } - } - -/// Returns the WPR heap size to reserve when vGPU is enabled. -pub (crate )fn vgpu_wpr_heap_size () ->u64 { - u64::from (bindings::GSP_FW_HEAP_SIZE_VGPU_DEFAULT ) - } - -/// Returns the amount of memory (in bytes) to allocate for the WPR heap for a framebuffer size -/// of `fb_size` (in bytes) for `chipset`. -pub (crate )fn wpr_heap_size (&self, chipset:Chipset , fb_size:u64 ) ->Result <u64 > { -// The WPR heap will contain the following: -// LIBOS carveout, -Ok (self - .carveout_size -// RM boot working memory, - .saturating_add (GspFwHeapParams ::base_rm_size (chipset)) -// One RM client, - .saturating_add (GspFwHeapParams ::client_alloc_size ()) -// Overhead for memory management. - .saturating_add (GspFwHeapParams ::management_overhead (fb_size)?) -// Clamp to the supported heap sizes. - .clamp (self.allowed_heap_size.start, self.allowed_heap_size.end -1 )) - } -} -/// Structure passed to the GSP bootloader, containing the framebuffer layout as well as the DMA /// addresses of the GSP bootloader and firmware. #[repr(transparent)]
Signature · 1 line
2.54.0
Re: [PATCH v2 7/7] gpu: nova-core: remove LibosParams
Quoted 8 lines · Timur Tabi
All functionality that was provided by LibosParams has now been replaced with TLV-based implementations in GspFwHeapParams, so we can remove LibosParams and all its dependencies.
This also allows us to remove the legacy methods
base_rm_size(),client_alloc_size(), andmanagement_overhead(). These were used to calculate intermediate values that are now represented by TLV values.
Quoted 8 lines
LibosParams and GspFwHeapParams were two types used to hold data and/or methods for calculating the heap sides that GSP-RM needs for booting. Although they technically represent distinct parts of the equations, they were always used together, so it makes sense to merge LibosParams into GspFwHeapParams.
Signed-off-by Timur Tabi <[email protected]>---