[PATCH v4 03/32] gpu: nova-core: gsp: decouple boot context from VgpuManager

From: Alok Kumar

Date: Fri Nov 06 2026 - 00:43:03 EST


From: Zhi Wang <zhiw@xxxxxxxxxx>

GSP boot uses the detected vGPU mode to size firmware resources and
populate GSP_INIT. Carrying the whole manager in the boot and unload
context couples these operations to its runtime interface.

The boot code only needs read access to the mode, and unloading does
not use the manager. A short state borrow is sufficient for both
context construction sites.

Make GspBootContext borrow VgpuState directly and read it in the
VRAM and GSP_INIT helpers. Return a state reference from the
manager without changing mode detection or the values passed to firmware.

No functional change is intended.

Cc: Alexandre Courbot <acourbot@xxxxxxxxxx>
Signed-off-by: Zhi Wang <zhiw@xxxxxxxxxx>
Signed-off-by: Alok Kumar <alkumar@xxxxxxxxxx>
---
drivers/gpu/nova-core/fb.rs | 2 +-
drivers/gpu/nova-core/gpu.rs | 4 ++--
drivers/gpu/nova-core/gsp.rs | 4 ++--
drivers/gpu/nova-core/gsp/fw/commands.rs | 4 ++--
drivers/gpu/nova-core/vgpu.rs | 4 ++--
5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/nova-core/fb.rs b/drivers/gpu/nova-core/fb.rs
index 26e94d908b77..882827bcfd3a 100644
--- a/drivers/gpu/nova-core/fb.rs
+++ b/drivers/gpu/nova-core/fb.rs
@@ -295,7 +295,7 @@ 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(ctx: &gsp::GspBootContext<'_, '_>, fb_size: u64) -> Result<(u8, u64)> {
- Ok(match ctx.vgpu.state() {
+ Ok(match *ctx.vgpu_state {
VgpuState::Disabled => (
0,
gsp::LibosParams::from_chipset(ctx.chipset).wpr_heap_size(ctx.chipset, fb_size)?,
diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
index e44f8cd8bdc2..d29e83f50137 100644
--- a/drivers/gpu/nova-core/gpu.rs
+++ b/drivers/gpu/nova-core/gpu.rs
@@ -447,7 +447,7 @@ fn drop(self: Pin<&mut Self>) {
gsp_falcon: &*this.gsp_falcon,
sec2_falcon: &*this.sec2_falcon,
fsp: this.fsp.as_mut(),
- vgpu: &*this.vgpu,
+ vgpu_state: this.vgpu.state(),
},
bundle,
)
@@ -522,7 +522,7 @@ pub(crate) fn new<'a>(
gsp_falcon,
sec2_falcon,
fsp: fsp.as_mut(),
- vgpu,
+ vgpu_state: vgpu.state(),
})?,
}),

diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs
index 9a6065bdac96..cac123cbeac4 100644
--- a/drivers/gpu/nova-core/gsp.rs
+++ b/drivers/gpu/nova-core/gsp.rs
@@ -66,7 +66,7 @@
fw::GspArgumentsPadded, //
},
num,
- vgpu::VgpuManager, //
+ vgpu::VgpuState, //
};

pub(crate) const GSP_PAGE_SHIFT: usize = 12;
@@ -85,7 +85,7 @@ pub(crate) struct GspBootContext<'ctx, 'gpu> {
pub(crate) gsp_falcon: &'ctx Falcon<'gpu, GspFalcon>,
pub(crate) sec2_falcon: &'ctx Falcon<'gpu, Sec2Falcon>,
pub(crate) fsp: Option<&'ctx mut Fsp<'gpu>>,
- pub(crate) vgpu: &'ctx VgpuManager,
+ pub(crate) vgpu_state: &'ctx VgpuState,
}

impl<'ctx, 'gpu> GspBootContext<'ctx, 'gpu> {
diff --git a/drivers/gpu/nova-core/gsp/fw/commands.rs b/drivers/gpu/nova-core/gsp/fw/commands.rs
index 689b7417597a..bda6a7ef5ef7 100644
--- a/drivers/gpu/nova-core/gsp/fw/commands.rs
+++ b/drivers/gpu/nova-core/gsp/fw/commands.rs
@@ -229,7 +229,7 @@ struct DomainBusDevice(u64) {

impl GspInitRequest {
fn build_vf_info(ctx: &GspBootContext<'_, '_>) -> Result<Option<VfInfo>> {
- let total_vfs = match ctx.vgpu.state() {
+ let total_vfs = match *ctx.vgpu_state {
VgpuState::Disabled => return Ok(None),
VgpuState::Enabled { total_vfs } => total_vfs,
};
@@ -272,7 +272,7 @@ fn build_vf_info(ctx: &GspBootContext<'_, '_>) -> Result<Option<VfInfo>> {
pub(crate) fn new(ctx: &GspBootContext<'_, '_>) -> Result<Self> {
let dev = ctx.pdev;
let chipset = ctx.chipset;
- let vgpu_state = ctx.vgpu.state();
+ let vgpu_state = *ctx.vgpu_state;
let mut regkeys = KVVec::new();
for &(name, value) in REGISTRY_ENTRIES {
regkeys.push(RegKey::new(name, value), GFP_KERNEL)?;
diff --git a/drivers/gpu/nova-core/vgpu.rs b/drivers/gpu/nova-core/vgpu.rs
index 6b7e045acea8..905b3a7331fd 100644
--- a/drivers/gpu/nova-core/vgpu.rs
+++ b/drivers/gpu/nova-core/vgpu.rs
@@ -85,7 +85,7 @@ fn detect_state(
}

/// Returns the detected vGPU state for this boot.
- pub(crate) fn state(&self) -> VgpuState {
- self.state
+ pub(crate) fn state(&self) -> &VgpuState {
+ &self.state
}
}
--
2.53.0