Re: [PATCH v5 05/35] gpu: nova-core: gpu: add a channel ID pool for vGPU
From: Eliot Courtney
Date: Tue Dec 01 2026 - 01:42:45 EST
On Tue Nov 24, 2026 at 10:59 PM JST, Alok Kumar wrote:
> From: Zhi Wang <zhiw@xxxxxxxxxx>
>
> 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>
> Signed-off-by: Alok Kumar <alkumar@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 5c304a129df2..b3775365a74e 100644
> --- a/drivers/gpu/nova-core/gpu.rs
> +++ b/drivers/gpu/nova-core/gpu.rs
> @@ -49,6 +49,7 @@
> GpuMm,
> VramAddress, //
> },
> + num,
> timer::{
> Timer,
> TimerState, //
> @@ -61,6 +62,10 @@
> mod hal;
> mod regs;
>
> +use self::channel::TOTAL_CHANNELS;
> +
> +pub(crate) use self::channel::ChannelIdPool;
This doesn't need to be pub(crate) right now.
What about moving these two imports to the main "use crate::" block and
instead making "mod channel" -> "pub(crate) mod channel" (from when it's
firste needed, in patch 7). Conceptually, I think it makes sense for
users outside the gpu module to do things with channels.
> +
> macro_rules! define_chipset {
> ({ $($variant:ident),* $(,)* }) =>
> {
> @@ -409,6 +414,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).
> ///
> @@ -486,6 +493,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))),
nit: can be spelt cv!(TOTAL_CHANNELS).