[PATCH v3 04/31] gpu: nova-core: gpu: add a channel ID pool for vGPU
From: Zhi Wang
Date: Mon Sep 28 2026 - 06:30:19 EST
Channel ID reservations need a GPU-owned pool shared by vGPU instances.
The pool must remain at a stable address while its reservations exist.
Its storage also needs to remain available throughout GPU cleanup.
Create a private pinned ChannelIdPool with a single 2048-channel
capacity constant.
Cc: Alexandre Courbot <acourbot@xxxxxxxxxx>
Suggested-by: Eliot Courtney <ecourtney@xxxxxxxxxx>
Signed-off-by: Zhi Wang <zhiw@xxxxxxxxxx>
---
drivers/gpu/nova-core/gpu.rs | 9 +++++++++
drivers/gpu/nova-core/gpu/channel.rs | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
index 650bef8b5f44..c239b6614d44 100644
--- a/drivers/gpu/nova-core/gpu.rs
+++ b/drivers/gpu/nova-core/gpu.rs
@@ -48,6 +48,7 @@
GpuMm,
VramAddress, //
},
+ num,
vgpu::VgpuState, //
};
@@ -56,6 +57,10 @@
mod hal;
mod regs;
+use self::channel::TOTAL_CHANNELS;
+
+pub(crate) use self::channel::ChannelIdPool;
+
macro_rules! define_chipset {
({ $($variant:ident = $value:expr),* $(,)* }) =>
{
@@ -335,6 +340,8 @@ pub(crate) struct Gpu<'gpu> {
/// GSP and its resources.
#[pin]
gsp_resources: GspResources<'gpu>,
+ #[pin]
+ chid_pool: ChannelIdPool,
/// System memory page required for flushing all pending GPU-side memory writes done through
/// PCIE into system memory, via sysmembar (A GPU-initiated HW memory-barrier operation).
///
@@ -417,6 +424,8 @@ pub(crate) fn new<'a>(
// Initialize this early because `gsp_resources` depends on it.
sysmem_flush: SysmemFlush::register(dev, bar, spec.chipset)?,
+ chid_pool <- ChannelIdPool::new(cv!(num::u32_as_usize(TOTAL_CHANNELS))),
+
gsp_resources <- try_pin_init!(GspResources {
device: pdev,
diff --git a/drivers/gpu/nova-core/gpu/channel.rs b/drivers/gpu/nova-core/gpu/channel.rs
index 485efaba059d..75666c6768e6 100644
--- a/drivers/gpu/nova-core/gpu/channel.rs
+++ b/drivers/gpu/nova-core/gpu/channel.rs
@@ -21,6 +21,10 @@
}, //
};
+// TODO: Query the channel capacity through GMCAPI once an equivalent of
+// NV2080_CTRL_CMD_INTERNAL_FIFO_GET_NUM_CHANNELS is available.
+pub(super) const TOTAL_CHANNELS: u32 = 2048;
+
/// Pool for tracking reservations of channel IDs.
#[pin_data]
pub(crate) struct ChannelIdPool {