From: Alok Kumar <alkumar@nvidia.com>
To: <dakr@kernel.org>, <acourbot@nvidia.com>, <kvm@vger.kernel.org>,
<rust-for-linux@vger.kernel.org>, <nova-gpu@lists.linux.dev>,
<linux-pci@vger.kernel.org>
Cc: <alex@shazbot.org>, <jgg@nvidia.com>, <yishaih@nvidia.com>,
<skolothumtho@nvidia.com>, <kevin.tian@intel.com>,
<airlied@gmail.com>, <simona@ffwll.ch>, <ojeda@kernel.org>,
<alex.gaynor@gmail.com>, <boqun.feng@gmail.com>,
<gary@garyguo.net>, <bjorn3_gh@protonmail.com>,
<lossin@kernel.org>, <a.hindborg@kernel.org>,
<aliceryhl@google.com>, <tmgross@umich.edu>,
<markus.probst@posteo.de>, <jhubbard@nvidia.com>,
<apopple@nvidia.com>, <joelagnelf@nvidia.com>,
<ecourtney@nvidia.com>, <cjia@nvidia.com>, <smitra@nvidia.com>,
<kjaju@nvidia.com>, <alkumar@nvidia.com>, <ankita@nvidia.com>,
<aniketa@nvidia.com>, <kwankhede@nvidia.com>,
<targupta@nvidia.com>, <linux-kernel@vger.kernel.org>,
<zhiwang@kernel.org>, <zhiw@nvidia.com>, <boqun@kernel.org>,
<daniel.almeida@collabora.com>, <tamird@kernel.org>,
<work@onurozkan.dev>, <jgg@ziepe.ca>, <bhelgaas@google.com>,
<kwilczynski@kernel.org>, <dri-devel@lists.freedesktop.org>,
<peter@colberg.org>, <xinmengs@nvidia.com>
Subject: [PATCH v5 25/35] gpu: nova-core: vgpu: add GSP plugin communication buffer
Date: Tue, 24 Nov 2026 19:29:21 +0530 [thread overview]
Message-ID: <20261124135937.18583-26-alkumar@nvidia.com> (raw)
In-Reply-To: <20261124135937.18583-1-alkumar@nvidia.com>
From: Zhi Wang <zhiw@nvidia.com>
Each vGPU instance shares a communication buffer with its GSP plugin,
located at the start of the instance's management heap. It contains the
control and response regions used for plugin RPCs, the message and
migration buffers, and the plugin logs.
Describe its layout with a `CommBuffer` type, and add `CommBufferRegion`
which maps the buffer through BAR1 and provides the operations needed
before the first RPC: checking the plugin's boot-ready marker, obtaining
the VRAM regions of the logs, and initializing the control and response
regions.
The ready marker is stored in the control region's sequence number
field, so the regions must only be initialized after the plugin has
reported itself ready.
Signed-off-by: Zhi Wang <zhiw@nvidia.com>
Co-developed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Alok Kumar <alkumar@nvidia.com>
---
drivers/gpu/nova-core/mm.rs | 1 -
drivers/gpu/nova-core/mm/vram.rs | 1 +
drivers/gpu/nova-core/vgpu.rs | 1 +
drivers/gpu/nova-core/vgpu/fw.rs | 20 ++
drivers/gpu/nova-core/vgpu/gsp_plugin_comm.rs | 201 ++++++++++++++++++
5 files changed, 223 insertions(+), 1 deletion(-)
create mode 100644 drivers/gpu/nova-core/vgpu/gsp_plugin_comm.rs
diff --git a/drivers/gpu/nova-core/mm.rs b/drivers/gpu/nova-core/mm.rs
index f1f86931928c..9489502d3362 100644
--- a/drivers/gpu/nova-core/mm.rs
+++ b/drivers/gpu/nova-core/mm.rs
@@ -69,7 +69,6 @@ macro_rules! impl_pfn_bounded {
mod regs;
pub(super) mod tlb;
pub(super) mod vmm;
-#[expect(dead_code)]
pub(crate) mod vram;
/// GPU Memory Manager - owns all core MM components.
diff --git a/drivers/gpu/nova-core/mm/vram.rs b/drivers/gpu/nova-core/mm/vram.rs
index 6054eed9aeb0..7774b15e4c89 100644
--- a/drivers/gpu/nova-core/mm/vram.rs
+++ b/drivers/gpu/nova-core/mm/vram.rs
@@ -74,6 +74,7 @@ pub(crate) struct VramRegion {
range: Range<u64>,
}
+#[expect(dead_code)]
impl VramRegion {
/// Returns the range covered by this region.
pub(crate) const fn range(&self) -> &Range<u64> {
diff --git a/drivers/gpu/nova-core/vgpu.rs b/drivers/gpu/nova-core/vgpu.rs
index 65362ca31ba3..eaff5b8b318d 100644
--- a/drivers/gpu/nova-core/vgpu.rs
+++ b/drivers/gpu/nova-core/vgpu.rs
@@ -29,6 +29,7 @@
mod commands;
mod fw;
+mod gsp_plugin_comm;
mod hal;
mod instance;
mod vram;
diff --git a/drivers/gpu/nova-core/vgpu/fw.rs b/drivers/gpu/nova-core/vgpu/fw.rs
index 2d32e196a771..84a89c32a77b 100644
--- a/drivers/gpu/nova-core/vgpu/fw.rs
+++ b/drivers/gpu/nova-core/vgpu/fw.rs
@@ -8,3 +8,23 @@
pub(super) mod commands;
mod r000_00;
+
+// Alias to avoid repeating the version number with every use.
+use r000_00 as bindings;
+
+pub(super) use bindings::{
+ GSP_PLUGIN_BOOTLOADED,
+ VGPU_CPU_GSP_COMMUNICATION_BUFF_TOTAL_SIZE,
+ VGPU_CPU_GSP_CTRL_BUFF_REGION as RawControlRegion,
+ VGPU_CPU_GSP_CTRL_BUFF_REGION_SIZE,
+ VGPU_CPU_GSP_CTRL_BUFF_VERSION,
+ VGPU_CPU_GSP_ERROR_BUFF_REGION_SIZE,
+ VGPU_CPU_GSP_GUEST_RPC_TRACE_BUFF_REGION_SIZE,
+ VGPU_CPU_GSP_INIT_TASK_LOG_BUFF_REGION_SIZE,
+ VGPU_CPU_GSP_KERNEL_TASK_LOG_BUFF_REGION_SIZE,
+ VGPU_CPU_GSP_MESSAGE_BUFF_REGION_SIZE,
+ VGPU_CPU_GSP_MIGRATION_BUFF_REGION_SIZE,
+ VGPU_CPU_GSP_RESPONSE_BUFF_REGION as RawResponseRegion,
+ VGPU_CPU_GSP_RESPONSE_BUFF_REGION_SIZE,
+ VGPU_CPU_GSP_VGPU_TASK_LOG_BUFF_REGION_SIZE, //
+};
diff --git a/drivers/gpu/nova-core/vgpu/gsp_plugin_comm.rs b/drivers/gpu/nova-core/vgpu/gsp_plugin_comm.rs
new file mode 100644
index 000000000000..983d5002ff5b
--- /dev/null
+++ b/drivers/gpu/nova-core/vgpu/gsp_plugin_comm.rs
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+
+//! GSP plugin communication buffer mappings and access.
+
+use core::mem::offset_of;
+
+use kernel::{
+ io::{
+ io_project,
+ io_read,
+ io_write,
+ Mmio, //
+ },
+ num::casts::FromSafeCast,
+ prelude::*, //
+};
+
+use crate::mm::{
+ bar_user::{
+ BarMapping,
+ BarUser, //
+ },
+ vram::VramRegion,
+ SharedGpuMm, //
+};
+
+use super::fw::{
+ self,
+ RawControlRegion,
+ RawResponseRegion, //
+};
+
+/// Layout of the plugin communication region, located at the start of the management heap.
+///
+/// This type is never instantiated; it only describes the layout of the region for I/O
+/// projections.
+///
+/// r000 layout, with byte offsets from the management heap (not to scale):
+///
+/// ```text
+/// 0x000000 +----------------------------------------+
+/// | Control (boot-ready marker) 4 KiB |
+/// 0x001000 +----------------------------------------+
+/// | Response 4 KiB |
+/// 0x002000 +----------------------------------------+
+/// | Message 4 KiB |
+/// 0x003000 +----------------------------------------+
+/// | Migration 2 MiB |
+/// 0x203000 +----------------------------------------+
+/// | Error 4 KiB |
+/// 0x204000 +----------------------------------------+
+/// | Init task log 128 KiB |
+/// 0x224000 +----------------------------------------+
+/// | vGPU task log 256 KiB |
+/// 0x264000 +----------------------------------------+
+/// | Kernel task log 64 KiB |
+/// 0x274000 +----------------------------------------+
+/// | Guest RPC trace 64 KiB |
+/// 0x284000 +----------------------------------------+
+/// ```
+#[repr(C)]
+struct CommBuffer {
+ control: RawControlRegion,
+ response: RawResponseRegion,
+ message: [u8; cv!(fw::VGPU_CPU_GSP_MESSAGE_BUFF_REGION_SIZE)],
+ migration: [u8; cv!(fw::VGPU_CPU_GSP_MIGRATION_BUFF_REGION_SIZE)],
+ error: [u8; cv!(fw::VGPU_CPU_GSP_ERROR_BUFF_REGION_SIZE)],
+ init_log: [u8; cv!(fw::VGPU_CPU_GSP_INIT_TASK_LOG_BUFF_REGION_SIZE)],
+ vgpu_log: [u8; cv!(fw::VGPU_CPU_GSP_VGPU_TASK_LOG_BUFF_REGION_SIZE)],
+ kernel_log: [u8; cv!(fw::VGPU_CPU_GSP_KERNEL_TASK_LOG_BUFF_REGION_SIZE)],
+ guest_trace: [u8; cv!(fw::VGPU_CPU_GSP_GUEST_RPC_TRACE_BUFF_REGION_SIZE)],
+}
+
+static_assert!(size_of::<CommBuffer>() == cv!(fw::VGPU_CPU_GSP_COMMUNICATION_BUFF_TOTAL_SIZE));
+static_assert!(size_of::<RawControlRegion>() == cv!(fw::VGPU_CPU_GSP_CTRL_BUFF_REGION_SIZE));
+static_assert!(size_of::<RawResponseRegion>() == cv!(fw::VGPU_CPU_GSP_RESPONSE_BUFF_REGION_SIZE));
+
+/// Physical VRAM regions containing the vGPU plugin logs.
+#[expect(dead_code)]
+pub(super) struct PluginLogRegions {
+ pub(super) init: VramRegion,
+ pub(super) vgpu: VramRegion,
+ pub(super) kernel: VramRegion,
+}
+
+/// BAR1 mapping of the plugin communication region in its management heap.
+///
+/// See [`CommBuffer`] for the layout of the region.
+pub(super) struct CommBufferRegion<'map, 'gpu> {
+ map: BarMapping<'map, 'gpu>,
+}
+
+#[expect(dead_code)]
+impl<'map, 'gpu> CommBufferRegion<'map, 'gpu> {
+ /// Map the communication portion of a plugin management heap.
+ pub(super) fn new(
+ bar_user: &'map BarUser<'gpu>,
+ mm: &'map SharedGpuMm<'gpu>,
+ management_heap: &VramRegion,
+ ) -> Result<Self> {
+ let region = management_heap.subregion(0..u64::from_safe_cast(size_of::<CommBuffer>()))?;
+
+ Ok(Self {
+ map: BarMapping::new(bar_user, mm, region, true)?,
+ })
+ }
+
+ /// Returns the MMIO view of the communication region.
+ ///
+ /// Fails if the region has been unmapped.
+ fn view(&self) -> Result<Mmio<'_, CommBuffer>> {
+ self.map.view()
+ }
+
+ /// Return the physical regions occupied by the three plugin logs.
+ pub(super) fn plugin_logs(&self) -> Result<PluginLogRegions> {
+ let log_region = |offset, size| {
+ let start = u64::from_safe_cast(offset);
+
+ self.map.region().subregion(start..start + u64::from(size))
+ };
+
+ Ok(PluginLogRegions {
+ init: log_region(
+ offset_of!(CommBuffer, init_log),
+ fw::VGPU_CPU_GSP_INIT_TASK_LOG_BUFF_REGION_SIZE,
+ )?,
+ vgpu: log_region(
+ offset_of!(CommBuffer, vgpu_log),
+ fw::VGPU_CPU_GSP_VGPU_TASK_LOG_BUFF_REGION_SIZE,
+ )?,
+ kernel: log_region(
+ offset_of!(CommBuffer, kernel_log),
+ fw::VGPU_CPU_GSP_KERNEL_TASK_LOG_BUFF_REGION_SIZE,
+ )?,
+ })
+ }
+
+ /// Return whether firmware has published the plugin boot marker.
+ pub(super) fn is_plugin_ready(&self) -> Result<bool> {
+ let value = io_read!(self.view()?, .control.__bindgen_anon_1.message_seq_num);
+
+ Ok(value == fw::GSP_PLUGIN_BOOTLOADED)
+ }
+
+ /// Initialize the shared control and response buffers for plugin RPC.
+ #[expect(dead_code)]
+ pub(super) fn initialize(&self) -> Result {
+ let comm = self.view()?;
+ let control = io_project!(comm, .control.__bindgen_anon_1);
+ let response = io_project!(comm, .response.__bindgen_anon_1);
+
+ io_write!(
+ control,
+ .response_buff_offset,
+ u64::from_safe_cast(offset_of!(CommBuffer, response))
+ );
+ io_write!(
+ control,
+ .message_buff_offset,
+ u64::from_safe_cast(offset_of!(CommBuffer, message))
+ );
+ io_write!(
+ control,
+ .migration_buff_offset,
+ u64::from_safe_cast(offset_of!(CommBuffer, migration))
+ );
+ io_write!(
+ control,
+ .error_buff_offset,
+ u64::from_safe_cast(offset_of!(CommBuffer, error))
+ );
+ io_write!(
+ control,
+ .guest_rpc_trace_buff_offset,
+ u64::from_safe_cast(offset_of!(CommBuffer, guest_trace))
+ );
+ io_write!(control, .migration_buf_cpu_access_offset, 0);
+ io_write!(control, .is_migration_in_progress, 0);
+ io_write!(control, .error_buff_cpu_get_idx, 0);
+ io_write!(control, .guest_rpc_trace_buff_cpu_get_idx, 0);
+ io_write!(control, .attached_vgpu_count, 1);
+ io_write!(control, .is_gr_init_done, 0);
+
+ io_write!(control, .message_type, 0);
+ // Replace the boot-ready marker with the initial RPC sequence.
+ io_write!(control, .message_seq_num, 0);
+ io_write!(response, .message_seq_num_processed, 0);
+ io_write!(response, .result_code, 0);
+ io_write!(control, .version, fw::VGPU_CPU_GSP_CTRL_BUFF_VERSION);
+
+ Ok(())
+ }
+
+ /// Invalidate the PTEs and release the communication mapping.
+ #[expect(dead_code)]
+ pub(super) fn unmap(&mut self) -> Result {
+ self.map.unmap()
+ }
+}
--
2.53.0
next prev parent reply other threads:[~2026-11-24 14:06 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 13:58 [PATCH v5 00/35] Introduce NVIDIA vGPU manager Alok Kumar
2026-11-24 13:58 ` [PATCH v5 01/35] gpu: nova-core: populate VF information in GSP_INIT Alok Kumar
2026-11-24 13:58 ` [PATCH v5 02/35] gpu: nova-core: gsp: pass boot context through setup helpers Alok Kumar
2026-11-24 13:58 ` [PATCH v5 03/35] gpu: nova-core: gsp: decouple boot context from VgpuManager Alok Kumar
2026-11-24 13:59 ` [PATCH v5 04/35] gpu: nova-core: vgpu: detect boot state independently Alok Kumar
2026-11-24 13:59 ` [PATCH v5 05/35] gpu: nova-core: gpu: add a channel ID pool for vGPU Alok Kumar
2026-11-24 13:59 ` [PATCH v5 06/35] gpu: nova-core: gsp: decode the FIFO engine table Alok Kumar
2026-11-24 13:59 ` [PATCH v5 07/35] gpu: nova-core: vgpu: initialize runtime parameters after GSP boot Alok Kumar
2026-11-24 13:59 ` [PATCH v5 08/35] gpu: nova-core: vgpu: reserve the 48-VM WPR2 heap Alok Kumar
2026-11-24 13:59 ` [PATCH v5 09/35] gpu: nova-core: mm: replace BarUserAccess accessors with typed MMIO view Alok Kumar
2026-11-24 13:59 ` [PATCH v5 10/35] gpu: nova-core: mm: retain BAR1 reservations after unmap failure Alok Kumar
2026-11-24 13:59 ` [PATCH v5 11/35] gpu: nova-core: mm: borrow BarUser for temporary BAR1 access Alok Kumar
2026-11-24 13:59 ` [PATCH v5 12/35] gpu: nova-core: mm: add VramBlock Alok Kumar
2026-11-24 13:59 ` [PATCH v5 13/35] gpu: nova-core: mm: add VramRegion Alok Kumar
2026-11-24 13:59 ` [PATCH v5 14/35] gpu: nova-core: mm: add BarMapping Alok Kumar
2026-11-24 13:59 ` [PATCH v5 15/35] gpu: nova-core: mm: add SharedGpuMm Alok Kumar
2026-11-24 13:59 ` [PATCH v5 16/35] gpu: nova-core: gsp: cmdq: gmc: add types for variable-length payloads Alok Kumar
2026-11-24 13:59 ` [PATCH v5 17/35] gpu: nova-core: gsp: add the vGPU commands to GmcCommandId Alok Kumar
2026-11-24 13:59 ` [PATCH v5 18/35] gpu: nova-core: gsp: cmdq: add send_gmc_command_await_event Alok Kumar
2026-11-24 13:59 ` [PATCH v5 19/35] gpu: nova-core: vgpu: add r000 plugin bindings Alok Kumar
2026-11-24 13:59 ` [PATCH v5 20/35] gpu: nova-core: gsp: factor out NVKV payload conversion Alok Kumar
2026-11-24 13:59 ` [PATCH v5 21/35] gpu: nova-core: vgpu: add VRAM slot pool Alok Kumar
2026-11-24 13:59 ` [PATCH v5 22/35] gpu: nova-core: vgpu: query VF assignments and properties Alok Kumar
2026-11-24 13:59 ` [PATCH v5 23/35] gpu: nova-core: vgpu: add instance create/destroy Alok Kumar
2026-11-24 13:59 ` [PATCH v5 24/35] gpu: nova-core: vgpu: encode vGPU boot requests Alok Kumar
2026-11-24 13:59 ` Alok Kumar [this message]
2026-11-24 13:59 ` [PATCH v5 26/35] gpu: nova-core: vgpu: add instance boot Alok Kumar
2026-11-24 13:59 ` [PATCH v5 27/35] gpu: nova-core: vgpu: add instance shutdown Alok Kumar
2026-11-24 13:59 ` [PATCH v5 28/35] gpu: nova-core: vgpu: add GSP plugin RPC transactions Alok Kumar
2026-11-24 13:59 ` [PATCH v5 29/35] gpu: nova-core: vgpu: negotiate the GSP plugin RPC version Alok Kumar
2026-11-24 13:59 ` [PATCH v5 30/35] gpu: nova-core: vgpu: send GSP plugin configuration parameters Alok Kumar
2026-11-24 13:59 ` [PATCH v5 31/35] gpu: nova-core: vgpu: update the GSP plugin BME state Alok Kumar
2026-11-24 13:59 ` [PATCH v5 32/35] gpu: nova-core: vgpu: add CeUtils commands Alok Kumar
2026-11-24 13:59 ` [PATCH v5 33/35] gpu: nova-core: vgpu: scrub guest VRAM with CeUtils Alok Kumar
2026-11-24 13:59 ` [PATCH v5 34/35] gpu: nova-core: vgpu: introduce SR-IOV PF APIs Alok Kumar
2026-11-24 13:59 ` [PATCH v5 35/35] gpu: nova-core: mm: keep BAR1 self-test page tables alive Alok Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124135937.18583-26-alkumar@nvidia.com \
--to=alkumar@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=alex@shazbot.org \
--cc=aliceryhl@google.com \
--cc=aniketa@nvidia.com \
--cc=ankita@nvidia.com \
--cc=apopple@nvidia.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=boqun@kernel.org \
--cc=cjia@nvidia.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=jgg@nvidia.com \
--cc=jgg@ziepe.ca \
--cc=jhubbard@nvidia.com \
--cc=joelagnelf@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=kjaju@nvidia.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=markus.probst@posteo.de \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=peter@colberg.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=skolothumtho@nvidia.com \
--cc=smitra@nvidia.com \
--cc=tamird@kernel.org \
--cc=targupta@nvidia.com \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
--cc=xinmengs@nvidia.com \
--cc=yishaih@nvidia.com \
--cc=zhiw@nvidia.com \
--cc=zhiwang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox