The FRTS offset sent to FSP is still computed the r570 way: an estimate
of the memory reserved at the end of the framebuffer plus the PMU
region, aligned to 2 MiB.

OpenRM 615 (kfspPrepareBootCommands_GH100) starts from the 128 KiB VGA
workspace instead, and aligns the result to the 128 KiB WPR granularity.
Do the same in Nova.

Signed-off-by: Alexandre Courbot <[email protected]>
---
 drivers/gpu/nova-core/fb.rs            |  3 +++
 drivers/gpu/nova-core/fsp.rs           | 19 ++++++-------------
 drivers/gpu/nova-core/fsp/hal.rs       |  4 ----
 drivers/gpu/nova-core/fsp/hal/gb100.rs |  6 ------
 drivers/gpu/nova-core/fsp/hal/gb202.rs |  9 +--------
 drivers/gpu/nova-core/fsp/hal/gh100.rs |  9 +--------
 drivers/gpu/nova-core/gsp/fw.rs        |  5 +----
 7 files changed, 12 insertions(+), 43 deletions(-)

diff --git a/drivers/gpu/nova-core/fb.rs b/drivers/gpu/nova-core/fb.rs
index 5ceb7760c78e..4893a36d05a7 100644
--- a/drivers/gpu/nova-core/fb.rs
+++ b/drivers/gpu/nova-core/fb.rs
@@ -327,6 +327,9 @@ pub(crate) struct FbSizes {
 }
 
 impl FbSizes {
+    /// Size of the VGA workspace at the end of the framebuffer, in bytes.
+    pub(crate) const VGA_WORKSPACE_SIZE: u64 = u64::SZ_128K;
+
     /// Computes the framebuffer region sizes for GSP-FMC boot.
     pub(crate) fn new(chipset: Chipset, bar: Bar0<'_>, vgpu_state: VgpuState) 
-> Result<Self> {
         let hal = hal::fb_hal(chipset);
diff --git a/drivers/gpu/nova-core/fsp.rs b/drivers/gpu/nova-core/fsp.rs
index 5976a1730981..23150b5f7648 100644
--- a/drivers/gpu/nova-core/fsp.rs
+++ b/drivers/gpu/nova-core/fsp.rs
@@ -253,19 +253,12 @@ struct FspCotMessage {
 impl FspCotMessage {
     /// Computes the FRTS vidmem offset for the Chain-of-Trust message. It is 
measured backwards
     /// from the end of the framebuffer.
-    fn frts_vidmem_offset(hal: &dyn hal::FspHal, fb_info: &FbSizes) -> 
Result<u64> {
-        let mut offset = hal.fb_end_reserved_size();
-
+    fn frts_vidmem_offset(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))
-                // This must be aligned to WPR alignment (128 KiB) and be at 
least 128 KiB in size.
-                // 2 MiB satisfies both.
-                .align_up(Alignment::SZ_2M)
-                .ok_or(EINVAL)?;
-        }
-
-        Ok(offset)
+        (FbSizes::VGA_WORKSPACE_SIZE + u64::from(fb_info.pmu_reserved_size))
+            // FRTS must start on a WPR boundary.
+            .align_up(Alignment::SZ_128K)
+            .ok_or(EINVAL)
     }
 
     /// Returns an in-place initializer for [`FspCotMessage`].
@@ -277,7 +270,7 @@ fn new<'a>(
         let hal = hal::fsp_hal(args.chipset).ok_or(ENOTSUPP)?;
 
         let frts_vidmem_offset = if !args.resume {
-            Self::frts_vidmem_offset(hal, fb_info)?
+            Self::frts_vidmem_offset(fb_info)?
         } else {
             0
         };
diff --git a/drivers/gpu/nova-core/fsp/hal.rs b/drivers/gpu/nova-core/fsp/hal.rs
index f2de7cc296ce..600121770b07 100644
--- a/drivers/gpu/nova-core/fsp/hal.rs
+++ b/drivers/gpu/nova-core/fsp/hal.rs
@@ -20,10 +20,6 @@ pub(super) trait FspHal: Sync {
     /// Returns the FSP Chain of Trust protocol version this chipset 
advertises.
     fn cot_version(&self) -> u16;
 
-    // TODO: consider moving this into the TLV firmware metadata when ready
-    /// Returns the size reserved at the end of the framebuffer, in bytes.
-    fn fb_end_reserved_size(&self) -> u64;
-
     /// Return if the bug 3957833 is affected
     fn is_bug_3957833_affected(&self, _bar: Bar0<'_>) -> bool {
         false
diff --git a/drivers/gpu/nova-core/fsp/hal/gb100.rs 
b/drivers/gpu/nova-core/fsp/hal/gb100.rs
index 7cf53aa3d1ff..42f5ecfc6400 100644
--- a/drivers/gpu/nova-core/fsp/hal/gb100.rs
+++ b/drivers/gpu/nova-core/fsp/hal/gb100.rs
@@ -1,8 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. 
All rights reserved.
 
-use kernel::sizes::SizeConstants;
-
 use crate::{
     driver::Bar0,
     fsp::hal::FspHal, //
@@ -19,10 +17,6 @@ fn fsp_boot_status(&self, bar: Bar0<'_>) -> u32 {
     fn cot_version(&self) -> u16 {
         2
     }
-
-    fn fb_end_reserved_size(&self) -> u64 {
-        u64::SZ_2M + u64::SZ_128K
-    }
 }
 
 const GB100: Gb100 = Gb100;
diff --git a/drivers/gpu/nova-core/fsp/hal/gb202.rs 
b/drivers/gpu/nova-core/fsp/hal/gb202.rs
index e380bbc5d58d..1091b169a645 100644
--- a/drivers/gpu/nova-core/fsp/hal/gb202.rs
+++ b/drivers/gpu/nova-core/fsp/hal/gb202.rs
@@ -1,10 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. 
All rights reserved.
 
-use kernel::{
-    io::Io,
-    sizes::SizeConstants, //
-};
+use kernel::io::Io;
 
 use crate::{
     driver::Bar0,
@@ -24,10 +21,6 @@ fn fsp_boot_status(&self, bar: Bar0<'_>) -> u32 {
     fn cot_version(&self) -> u16 {
         2
     }
-
-    fn fb_end_reserved_size(&self) -> u64 {
-        u64::SZ_2M + u64::SZ_128K
-    }
 }
 
 const GB202: Gb202 = Gb202;
diff --git a/drivers/gpu/nova-core/fsp/hal/gh100.rs 
b/drivers/gpu/nova-core/fsp/hal/gh100.rs
index 7f6c8e404f30..f00ca29ca2d1 100644
--- a/drivers/gpu/nova-core/fsp/hal/gh100.rs
+++ b/drivers/gpu/nova-core/fsp/hal/gh100.rs
@@ -1,10 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. 
All rights reserved.
 
-use kernel::{
-    io::Io,
-    sizes::SizeConstants, //
-};
+use kernel::io::Io;
 
 use crate::{
     driver::Bar0,
@@ -31,10 +28,6 @@ fn cot_version(&self) -> u16 {
         1
     }
 
-    fn fb_end_reserved_size(&self) -> u64 {
-        u64::SZ_2M
-    }
-
     fn is_bug_3957833_affected(&self, bar: Bar0<'_>) -> bool {
         bar.read(NV_GFW_FSP_UCODE_VERSION).is_bug_3957833_affected()
     }
diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw.rs
index 48e0ea6aaea9..4fb150dfba8b 100644
--- a/drivers/gpu/nova-core/gsp/fw.rs
+++ b/drivers/gpu/nova-core/gsp/fw.rs
@@ -239,9 +239,6 @@ pub(crate) fn from_sizes<'a>(
         gsp_firmware: &'a GspFirmware<'_>,
         sizes: &'a FbSizes,
     ) -> impl Init<Self> + 'a {
-        /// VGA workspace size to reserve at the end of the framebuffer, in 
bytes.
-        const VGA_WORKSPACE_SIZE: u64 = u64::SZ_128K;
-
         let init_inner = init!(bindings::GspFwWprMeta {
             // CAST: we want to store the bits of `GSP_FW_WPR_META_MAGIC` 
unmodified.
             magic: bindings::GSP_FW_WPR_META_MAGIC as u64,
@@ -263,7 +260,7 @@ pub(crate) fn from_sizes<'a>(
             gspFwHeapSize: sizes.wpr2_heap_size,
             frtsSize: sizes.frts_size,
             gspFwHeapVfPartitionCount: sizes.vf_partition_count,
-            vgaWorkspaceSize: VGA_WORKSPACE_SIZE,
+            vgaWorkspaceSize: FbSizes::VGA_WORKSPACE_SIZE,
             pmuReservedSize: sizes.pmu_reserved_size,
             ..Zeroable::init_zeroed()
         });

-- 
2.56.1

Reply via email to