[PATCH v5 07/35] gpu: nova-core: vgpu: initialize runtime parameters after GSP boot
From: Alok Kumar
Date: Tue Nov 24 2026 - 09:02:44 EST
From: Zhi Wang <zhiw@xxxxxxxxxx>
The vGPU manager needs the VMMU segment size and FIFO engine topology
returned by a successful GSP boot to divide instance resources.
Construct VgpuManager only for a vGPU-enabled boot. Retain the GPU-owned
channel pool, the ordered host-driven engine
list and the VMMU segment size. Expose the existing decoded VMMU value
from GspStaticInfo at its first consumer, preserving zero when firmware
omits the key.
Keep the runtime values in the manager for its instance module, and drop
the manager before the pool and memory resources it borrows.
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 | 20 ++++++++++++-
drivers/gpu/nova-core/gsp/commands.rs | 5 ++--
drivers/gpu/nova-core/gsp/commands/gmc.rs | 1 +
drivers/gpu/nova-core/gsp/fw/commands.rs | 2 +-
drivers/gpu/nova-core/vgpu.rs | 36 ++++++++++++++++++++++-
5 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
index b3775365a74e..cf7173b72a13 100644
--- a/drivers/gpu/nova-core/gpu.rs
+++ b/drivers/gpu/nova-core/gpu.rs
@@ -54,7 +54,10 @@
Timer,
TimerState, //
},
- vgpu::VgpuState,
+ vgpu::{
+ VgpuManager,
+ VgpuState, //
+ },
};
#[cfg_attr(not(CONFIG_KUNIT = "y"), expect(dead_code))]
@@ -395,6 +398,7 @@ unsafe fn new(
#[pin_data]
pub(crate) struct Gpu<'gpu> {
pub(crate) spec: Spec,
+ vgpu: Option<VgpuManager<'chid_pool>>,
/// GSP event interrupt registration, and the enable of its subtree.
///
/// Must be kept declared *before* `gsp_resources`, so that the handler is unregistered, and
@@ -602,6 +606,20 @@ pub(crate) fn new<'a>(
bar1,
)
},
+
+ vgpu: {
+ let info = &gsp_resources.boot_result.static_info;
+ match gsp_resources.vgpu_state {
+ VgpuState::Disabled => None,
+ VgpuState::Enabled { .. } => Some(VgpuManager::new(
+ chid_pool.get_ref(),
+ &info.fifo_engine_list(),
+ info.vmmu_segment_size,
+ TOTAL_CHANNELS,
+ )),
+ }
+ },
+
})
}
diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/gsp/commands.rs
index f5ec27995627..799f26e0ae74 100644
--- a/drivers/gpu/nova-core/gsp/commands.rs
+++ b/drivers/gpu/nova-core/gsp/commands.rs
@@ -11,7 +11,7 @@
use kernel::prelude::*;
-use super::fw::commands::FifoEngineList;
+pub(crate) use super::fw::commands::FifoEngineList;
/// The static GPU configuration, which GSP-RM reports in reply to [`GspInit`](gmc::GspInit).
pub struct GspStaticInfo {
@@ -25,6 +25,8 @@ pub struct GspStaticInfo {
pub(crate) usable_fb_regions: KVec<Range<u64>>,
/// Exclusive end of the FB physical address space.
pub(crate) total_fb_end: u64,
+ /// VMMU segment size in bytes, or zero if GSP-RM omitted it.
+ pub(crate) vmmu_segment_size: u64,
/// Host-driven engines in firmware FIFO order.
fifo_engine_list: FifoEngineList,
}
@@ -68,7 +70,6 @@ pub fn gpu_short_name(&self) -> core::result::Result<&str, GpuNameError> {
}
/// Returns the host-driven engines in their firmware FIFO order.
- #[expect(dead_code)]
pub(crate) fn fifo_engine_list(&self) -> FifoEngineList {
self.fifo_engine_list
}
diff --git a/drivers/gpu/nova-core/gsp/commands/gmc.rs b/drivers/gpu/nova-core/gsp/commands/gmc.rs
index 4f813a780d1b..14e04db90594 100644
--- a/drivers/gpu/nova-core/gsp/commands/gmc.rs
+++ b/drivers/gpu/nova-core/gsp/commands/gmc.rs
@@ -185,6 +185,7 @@ fn read(payload: &mut SBufferIter<core::array::IntoIter<&[u8], 2>>) -> Result<Se
usable_fb_regions,
total_fb_end: reply.total_fb_end().ok_or(EINVAL)?,
fifo_engine_list: reply.fifo_engine_list(),
+ vmmu_segment_size: reply.vmmu_segment_size,
})
}
}
diff --git a/drivers/gpu/nova-core/gsp/fw/commands.rs b/drivers/gpu/nova-core/gsp/fw/commands.rs
index af3948ed79f5..d9dd4841566f 100644
--- a/drivers/gpu/nova-core/gsp/fw/commands.rs
+++ b/drivers/gpu/nova-core/gsp/fw/commands.rs
@@ -387,7 +387,7 @@ pub(crate) struct GspInitResponse {
gpu_gid: ArrayVec<u8, { GspStaticInfo::GID_LEN }>,
fb_regions: KVVec<FbRegion>,
bar1_pde_base: u64,
- vmmu_segment_size: u64,
+ pub(crate) vmmu_segment_size: u64,
fifo_engine_count: FifoEngineCount,
fifo_engine_gmc_ids: [u32; MAX_FIFO_ENGINES],
fifo_engine_flags: [u32; MAX_FIFO_ENGINES],
diff --git a/drivers/gpu/nova-core/vgpu.rs b/drivers/gpu/nova-core/vgpu.rs
index c59e7d2f933c..8a6d87233aaf 100644
--- a/drivers/gpu/nova-core/vgpu.rs
+++ b/drivers/gpu/nova-core/vgpu.rs
@@ -14,7 +14,11 @@
Fsp,
VgpuMode, //
},
- gpu::Chipset, //
+ gpu::{
+ ChannelIdPool,
+ Chipset, //
+ },
+ gsp::commands::FifoEngineList, //
};
mod hal;
@@ -81,3 +85,33 @@ fn query_state(
}
}
}
+
+/// Runtime resources for an enabled vGPU boot.
+pub(crate) struct VgpuManager<'gpu> {
+ #[expect(dead_code)]
+ chid_pool: &'gpu ChannelIdPool,
+ /// VMMU segment size in bytes, or zero if GSP-RM omitted it.
+ #[expect(dead_code)]
+ vmmu_segment_size: u64,
+ #[expect(dead_code)]
+ total_channels: u32,
+ #[expect(dead_code)]
+ fifo_engine_list: FifoEngineList,
+}
+
+impl<'gpu> VgpuManager<'gpu> {
+ /// Retains runtime parameters from a completed vGPU-enabled GSP boot.
+ pub(crate) fn new(
+ chid_pool: &'gpu ChannelIdPool,
+ fifo_engine_list: &FifoEngineList,
+ vmmu_segment_size: u64,
+ total_channels: u32,
+ ) -> Self {
+ Self {
+ chid_pool,
+ vmmu_segment_size,
+ total_channels,
+ fifo_engine_list: *fifo_engine_list,
+ }
+ }
+}
--
2.53.0