From: Zhi Wang <[email protected]> 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 <[email protected]> Suggested-by: Eliot Courtney <[email protected]> Signed-off-by: Zhi Wang <[email protected]> Signed-off-by: Alok Kumar <[email protected]> --- 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 fd0442f9a40b..3f8bdbb9a5b2 100644 --- a/drivers/gpu/nova-core/gpu.rs +++ b/drivers/gpu/nova-core/gpu.rs @@ -52,6 +52,7 @@ GpuMm, VramAddress, // }, + num, vgpu::VgpuState, // }; @@ -60,6 +61,10 @@ mod hal; mod regs; +use self::channel::TOTAL_CHANNELS; + +pub(crate) use self::channel::ChannelIdPool; + macro_rules! define_chipset { ({ $($variant:ident),* $(,)* }) => { @@ -410,6 +415,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). /// @@ -494,6 +501,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 { -- 2.53.0
