Add usable_vram field to FbLayout to store the usable VRAM region for driver allocations. This is populated after GSP boot with the region extracted from GSP's fbRegionInfoParams.
FbLayout is now a two-phase structure: 1. new() computes firmware layout from hardware 2. set_usable_vram() populates usable region from GSP The new usable_vram field represents the actual usable VRAM region (~23.7GB on a 24GB GPU GA102 Ampere GPU). Signed-off-by: Joel Fernandes <[email protected]> --- drivers/gpu/nova-core/fb.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nova-core/fb.rs b/drivers/gpu/nova-core/fb.rs index c62abcaed547..779447952b19 100644 --- a/drivers/gpu/nova-core/fb.rs +++ b/drivers/gpu/nova-core/fb.rs @@ -97,6 +97,10 @@ pub(crate) fn unregister(&self, bar: &Bar0) { /// Layout of the GPU framebuffer memory. /// /// Contains ranges of GPU memory reserved for a given purpose during the GSP boot process. +/// +/// This structure is populated in 2 steps: +/// 1. [`FbLayout::new()`] computes firmware layout from hardware. +/// 2. [`FbLayout::set_usable_vram()`] populates usable region from GSP response. #[derive(Debug)] pub(crate) struct FbLayout { /// Range of the framebuffer. Starts at `0`. @@ -111,10 +115,14 @@ pub(crate) struct FbLayout { pub(crate) elf: Range<u64>, /// WPR2 heap. pub(crate) wpr2_heap: Range<u64>, - /// WPR2 region range, starting with an instance of `GspFwWprMeta`. + /// WPR2 region range, starting with an instance of [`GspFwWprMeta`]. pub(crate) wpr2: Range<u64>, + /// Non-WPR heap carved before WPR2, used by GSP firmware. pub(crate) heap: Range<u64>, pub(crate) vf_partition_count: u8, + /// Usable VRAM region for driver allocations (from GSP `fbRegionInfoParams`). + /// Initially [`None`], populated after GSP boot with usable region info. + pub(crate) usable_vram: Option<Range<u64>>, } impl FbLayout { @@ -212,6 +220,19 @@ pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result< wpr2, heap, vf_partition_count: 0, + usable_vram: None, }) } + + /// Set the usable VRAM region from GSP response. + /// + /// Called after GSP boot with the first usable region extracted from + /// GSP's `fbRegionInfoParams`. Usable regions are those that: + /// - 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) fn set_usable_vram(&mut self, base: u64, size: u64) { + self.usable_vram = Some(base..base.saturating_add(size)); + } } -- 2.34.1
