[PATCH v5 04/35] gpu: nova-core: vgpu: detect boot state independently
From: Alok Kumar
Date: Tue Nov 24 2026 - 09:02:39 EST
From: Zhi Wang <zhiw@xxxxxxxxxx>
The vGPU manager currently contains only the detected boot mode. Its
construction couples mode detection to an object with no runtime
management responsibilities.
Firmware setup needs the mode before allocating GSP resources, even
when vGPU is disabled. Keeping that value with GspResources also makes
it available throughout the firmware lifecycle without a manager.
Move detection to VgpuState and store its result in GspResources.
Borrow it directly when constructing the boot and unload contexts, and
remove the state-only manager wrapper. Preserve the FSP query order,
existing diagnostics and disabled fallback.
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/gpu.rs | 11 +++++------
drivers/gpu/nova-core/vgpu.rs | 25 ++++++++-----------------
2 files changed, 13 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
index ad200242f0f5..5c304a129df2 100644
--- a/drivers/gpu/nova-core/gpu.rs
+++ b/drivers/gpu/nova-core/gpu.rs
@@ -53,7 +53,7 @@
Timer,
TimerState, //
},
- vgpu::VgpuManager, //
+ vgpu::VgpuState,
};
#[cfg_attr(not(CONFIG_KUNIT = "y"), expect(dead_code))]
@@ -335,8 +335,7 @@ struct GspResources<'gpu> {
fsp: Option<Fsp<'gpu>>,
/// Timer state - contains system timer offset
timer: TimerState,
- /// vGPU state detected before GSP boot.
- vgpu: VgpuManager,
+ vgpu_state: VgpuState,
/// GSP runtime data.
#[pin]
gsp: Gsp<'gpu>,
@@ -443,7 +442,7 @@ fn drop(self: Pin<&mut Self>) {
gsp_falcon: &*this.gsp_falcon,
sec2_falcon: &*this.sec2_falcon,
fsp: this.fsp.as_mut(),
- vgpu_state: this.vgpu.state(),
+ vgpu_state: this.vgpu_state,
},
bundle,
)
@@ -502,7 +501,7 @@ pub(crate) fn new<'a>(
timer: Timer::setup(dev, bar, spec.chipset, fsp.as_ref())?,
- vgpu: VgpuManager::new(pdev, spec.chipset, fsp.as_mut()),
+ vgpu_state: VgpuState::detect(pdev, spec.chipset, fsp.as_mut()),
gsp <- Gsp::new(pdev, bar),
@@ -516,7 +515,7 @@ pub(crate) fn new<'a>(
gsp_falcon,
sec2_falcon,
fsp: fsp.as_mut(),
- vgpu_state: vgpu.state(),
+ vgpu_state,
})?,
}),
diff --git a/drivers/gpu/nova-core/vgpu.rs b/drivers/gpu/nova-core/vgpu.rs
index e074a8294d36..c59e7d2f933c 100644
--- a/drivers/gpu/nova-core/vgpu.rs
+++ b/drivers/gpu/nova-core/vgpu.rs
@@ -31,19 +31,16 @@ pub(crate) enum VgpuState {
},
}
-/// vGPU state manager.
-pub(crate) struct VgpuManager {
- state: VgpuState,
-}
-
-impl VgpuManager {
- /// Creates a vGPU manager by querying SR-IOV and the FSP PRC vGPU knob.
- pub(crate) fn new(
+impl VgpuState {
+ /// Detects the boot mode, falling back to disabled if querying the device fails.
+ ///
+ /// Call after creating the FSP and before allocating GSP firmware resources.
+ pub(crate) fn detect(
pdev: &pci::Device<device::Core<'_>>,
chipset: Chipset,
fsp: Option<&mut Fsp<'_>>,
) -> Self {
- let state = Self::detect_state(pdev, chipset, fsp).unwrap_or_else(|e| {
+ let state = Self::query_state(pdev, chipset, fsp).unwrap_or_else(|e| {
dev_warn!(
pdev,
"vGPU state detection failed: {:?}; disabling vGPU\n",
@@ -52,12 +49,11 @@ pub(crate) fn new(
VgpuState::Disabled
});
dev_dbg!(pdev, "vGPU state: {:?}\n", state);
-
- Self { state }
+ state
}
/// Detects the vGPU state from the chipset, SR-IOV capability and FSP PRC knob.
- fn detect_state(
+ fn query_state(
pdev: &pci::Device<device::Core<'_>>,
chipset: Chipset,
fsp: Option<&mut Fsp<'_>>,
@@ -84,9 +80,4 @@ fn detect_state(
VgpuMode::Disabled => Ok(VgpuState::Disabled),
}
}
-
- /// Returns the detected vGPU state for this boot.
- pub(crate) fn state(&self) -> &VgpuState {
- &self.state
- }
}
--
2.53.0