[PATCH v5 03/35] gpu: nova-core: gsp: decouple boot context from VgpuManager
From: Alok Kumar
Date: Tue Nov 24 2026 - 09:01:44 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 | 5 +++--
5 files changed, 10 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 3d693656a5d6..ad200242f0f5 100644
--- a/drivers/gpu/nova-core/gpu.rs
+++ b/drivers/gpu/nova-core/gpu.rs
@@ -443,7 +443,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,
)
@@ -516,7 +516,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 a69362138cce..efb94aad417a 100644
--- a/drivers/gpu/nova-core/gsp.rs
+++ b/drivers/gpu/nova-core/gsp.rs
@@ -50,7 +50,7 @@
fw::GspArgumentsPadded, //
},
num,
- vgpu::VgpuManager, //
+ vgpu::VgpuState, //
};
pub(crate) const GSP_PAGE_SHIFT: usize = 12;
@@ -69,7 +69,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 9ecab9418be4..1b2cd342c404 100644
--- a/drivers/gpu/nova-core/gsp/fw/commands.rs
+++ b/drivers/gpu/nova-core/gsp/fw/commands.rs
@@ -246,7 +246,7 @@ fn new(dev: &pci::Device<device::Bound>) -> Self {
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,
};
@@ -286,7 +286,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..e074a8294d36 100644
--- a/drivers/gpu/nova-core/vgpu.rs
+++ b/drivers/gpu/nova-core/vgpu.rs
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
use core::num::NonZero;
@@ -85,7 +86,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