* [PATCH 0/4] gpu: nova-core: gsp: preparatory patches for the r000 firmware
@ 2026-11-27 14:04 Alexandre Courbot
2026-11-27 14:04 ` [PATCH 1/4] gpu: nova-core: gsp: add the r000 queue element header Alexandre Courbot
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Alexandre Courbot @ 2026-11-27 14:04 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, David Airlie, Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Eliot Courtney,
Zhi Wang, nova-gpu, dri-devel, linux-kernel, Alexandre Courbot
These patches come from John's series switching nova-core to the r000
GSP firmware [1]. They do not depend on the switch itself, and both the
rest of the r000 work and the vGPU series build on them, so I would
like to get them in soon.
Patch 1 adds the r000 queue element header. It has no user yet. It was
posted on its own before [2], only doc comments have changed since.
Patches 2 and 3 make the static GPU configuration something the boot
sequence returns, since that is where r000 provides it. Patch 4 adds
the GPU short name and GID to the schema of the GSP_INIT reply, which
is not used yet either.
The only runtime change is in patch 3: the static configuration is now
queried at the end of the boot sequence instead of after it.
The patches were reworked since v3 (patch 2 also moves the type, patch
4 is new), so Timur's Reviewed-by on v3 is not carried.
Based on drm-rust-next.
[1] https://lore.kernel.org/20260918010719.1176945-1-jhubbard@nvidia.com
[2] https://lore.kernel.org/20261117-msgelement-v1-1-b918ffae5e7b@nvidia.com
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
John Hubbard (4):
gpu: nova-core: gsp: add the r000 queue element header
gpu: nova-core: gsp: rename and move the static configuration type
gpu: nova-core: gsp: return the static GPU configuration from boot
gpu: nova-core: gsp: add the short name and GID to the GSP_INIT reply
drivers/gpu/nova-core/api.rs | 8 +-
drivers/gpu/nova-core/gpu.rs | 36 ++---
drivers/gpu/nova-core/gsp.rs | 13 +-
drivers/gpu/nova-core/gsp/boot.rs | 15 +-
drivers/gpu/nova-core/gsp/commands.rs | 70 +++++++++
drivers/gpu/nova-core/gsp/commands/rpc.rs | 68 +--------
drivers/gpu/nova-core/gsp/fw.rs | 186 ++++++++++++++++++++++-
drivers/gpu/nova-core/gsp/fw/commands.rs | 13 +-
drivers/gpu/nova-core/gsp/fw/r000_00/bindings.rs | 97 ++++++++++++
drivers/gpu/nova-core/mctp.rs | 20 ++-
10 files changed, 424 insertions(+), 102 deletions(-)
---
base-commit: abfb640b2374e26de8ff81d488c39d8254db538e
change-id: 20261127-nova-r000-staging-905c7f559e47
Best regards,
--
Alexandre Courbot <acourbot@nvidia.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] gpu: nova-core: gsp: add the r000 queue element header
2026-11-27 14:04 [PATCH 0/4] gpu: nova-core: gsp: preparatory patches for the r000 firmware Alexandre Courbot
@ 2026-11-27 14:04 ` Alexandre Courbot
2026-11-27 14:52 ` Gary Guo
2026-11-27 14:04 ` [PATCH 2/4] gpu: nova-core: gsp: rename and move the static configuration type Alexandre Courbot
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Alexandre Courbot @ 2026-11-27 14:04 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, David Airlie, Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Eliot Courtney,
Zhi Wang, nova-gpu, dri-devel, linux-kernel, Alexandre Courbot
From: John Hubbard <jhubbard@nvidia.com>
The upcoming r000 firmware uses a new queue element header that includes
MCTP and NVDM headers describing the type of message (RPC or GMC) that
follows.
Add that header as the `QueueElementHeader` type, along with the two
NVDM types that the GSP queues use and the MCTP version and NVDM vendor
checks that validating it requires.
The type is written out field by field rather than wrapped around the
generated binding, as `GSP_MSG_QUEUE_ELEMENT` keeps a 16-byte encryption
tag, only used with confidential computing, in a union with its last two
fields, making the binding 16 bytes larger than what the GSP expects on
the queues. Static assertions check every field offset and the size of
the type against the binding.
The header has no user yet: it replaces `GspMsgElement` at the transport
level in a later patch that switches to the r000 firmware, and is built
as dead code until then.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Co-developed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/gpu/nova-core/gsp/fw.rs | 186 ++++++++++++++++++++++-
drivers/gpu/nova-core/gsp/fw/r000_00/bindings.rs | 97 ++++++++++++
drivers/gpu/nova-core/mctp.rs | 20 ++-
3 files changed, 300 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw.rs
index 5c216d777dff..2e499a74fa46 100644
--- a/drivers/gpu/nova-core/gsp/fw.rs
+++ b/drivers/gpu/nova-core/gsp/fw.rs
@@ -48,6 +48,11 @@
cmdq::Cmdq, //
GSP_PAGE_SIZE,
},
+ mctp::{
+ MctpHeader,
+ NvdmHeader,
+ NvdmType, //
+ },
num::{
self,
FromSafeCast, //
@@ -835,7 +840,7 @@ pub(crate) fn msg_length(&self) -> usize {
size_of::<Self>() + self.rpc_header().rpc_length()
}
- /// Returns the number of elements (i.e. memory pages) used by this message.
+ /// Returns the number of slots (i.e. memory pages) used by this message.
pub(crate) fn element_count(&self) -> u32 {
self.inner.elemCount
}
@@ -901,6 +906,185 @@ pub(crate) fn function(&self) -> Result<MsgFunction, u32> {
}
}
+/// First word of every r000 queue element: `"MCTP"` in ASCII.
+const MCTP_MAGIC: u32 = 0x4D43_5450;
+
+/// Header opening every element of the r000 GSP queues.
+///
+/// A queue element is laid out as follows:
+///
+/// ```text
+/// +------------------------------------+
+/// | Queue element header | QueueElementHeader: MCTP magic, element length,
+/// | | MCTP header, NVDM header, message length.
+/// +------------------------------------+
+/// | Message header | RPC header or GMC API header. The NVDM type
+/// | | selects between the two.
+/// +------------------------------------+
+/// | Payload | Message-specific data.
+/// +------------------------------------+
+/// ```
+///
+/// This is the `noEncryption` layout of the `GSP_MSG_QUEUE_ELEMENT` binding. That binding keeps
+/// a 16-byte encryption tag, used only with confidential computing, in a union with the two
+/// trailing fields of the queue element header, so wrapping the binding would make every element
+/// 16 bytes larger than what the GSP expects. The fields are therefore declared again here, with
+/// their offsets checked against the binding.
+#[repr(C)]
+pub(crate) struct QueueElementHeader {
+ /// Always [`MCTP_MAGIC`].
+ mctp_magic: u32,
+ /// Length in bytes of the whole element, this header included.
+ ///
+ /// Under confidential computing the GSP pads elements out to whole queue slots, so this can
+ /// be larger than `nvdm_payload_size` plus the size of this header, but never smaller.
+ mctp_payload_size: u32,
+ /// MCTP transport header of the element.
+ mctp_header: MctpHeader,
+ /// NVDM header of the message.
+ nvdm_header: NvdmHeader,
+ /// Length in bytes of the message following this header: the message header and its
+ /// payload.
+ nvdm_payload_size: u32,
+ reserved: u32,
+}
+
+/// Static validation of [`QueueElementHeader`] against its bindings type. Kept in a sub-module to
+/// stay out of the way of the rest of the code.
+mod queue_element_header_validation {
+ use super::*;
+
+ // Offsets of `QueueElementHeader`'s fields
+
+ static_assert!(
+ core::mem::offset_of!(QueueElementHeader, mctp_magic)
+ == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, mctpMagic)
+ );
+ static_assert!(
+ core::mem::offset_of!(QueueElementHeader, mctp_payload_size)
+ == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, mctpPayloadSize)
+ );
+ static_assert!(
+ core::mem::offset_of!(QueueElementHeader, mctp_header)
+ == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, mctpHeader)
+ );
+ static_assert!(
+ core::mem::offset_of!(QueueElementHeader, nvdm_header)
+ == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, nvdmHeader)
+ );
+
+ /// The `noEncryption` member of the union of `GSP_MSG_QUEUE_ELEMENT`, which holds the two
+ /// trailing fields of [`QueueElementHeader`].
+ // Using `allow` instead of `expect` as rustc 1.85 ignores uses from `static_assert!` and
+ // reports this as dead code.
+ #[allow(dead_code)]
+ type QueueElementNoEncryption = r000_00::GSP_MSG_QUEUE_ELEMENT__bindgen_ty_1__bindgen_ty_2;
+
+ // Offsets of fields under [`QueueElementNoEncryption`] within `GSP_MSG_QUEUE_ELEMENT`.
+
+ // Using `allow` instead of `expect` as rustc 1.85 ignores uses from `static_assert!` and
+ // reports this as dead code.
+ #[allow(dead_code)]
+ const QUEUE_ELEMENT_NO_ENCRYPTION_OFFSET: usize =
+ core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, __bindgen_anon_1)
+ + core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT__bindgen_ty_1, noEncryption);
+
+ static_assert!(
+ core::mem::offset_of!(QueueElementHeader, nvdm_payload_size)
+ == QUEUE_ELEMENT_NO_ENCRYPTION_OFFSET
+ + core::mem::offset_of!(QueueElementNoEncryption, nvdmPayloadSize)
+ );
+ static_assert!(
+ core::mem::offset_of!(QueueElementHeader, reserved)
+ == QUEUE_ELEMENT_NO_ENCRYPTION_OFFSET
+ + core::mem::offset_of!(QueueElementNoEncryption, reserved)
+ );
+
+ // Ensure the size of `QueueElementHeader` matches the `noEncryption` layout.
+
+ static_assert!(
+ size_of::<QueueElementHeader>()
+ == QUEUE_ELEMENT_NO_ENCRYPTION_OFFSET + size_of::<QueueElementNoEncryption>()
+ );
+}
+
+#[expect(dead_code)]
+impl QueueElementHeader {
+ /// Creates the queue element header of an element carrying a message of NVDM type `nvdm_type`
+ /// and `message_len` bytes, message header included.
+ ///
+ /// # Errors
+ ///
+ /// - `EOVERFLOW` if a length does not fit its 32-bit field.
+ pub(crate) fn init(nvdm_type: NvdmType, message_len: usize) -> impl Init<Self, Error> {
+ try_init!(QueueElementHeader {
+ mctp_magic: MCTP_MAGIC,
+ mctp_payload_size: size_of::<Self>()
+ .checked_add(message_len)
+ .ok_or(EOVERFLOW)?
+ .try_into()
+ .map_err(|_| EOVERFLOW)?,
+ mctp_header: MctpHeader::single_packet(),
+ nvdm_header: NvdmHeader::new(nvdm_type),
+ nvdm_payload_size: message_len.try_into().map_err(|_| EOVERFLOW)?,
+ reserved: 0,
+ })
+ }
+
+ /// Returns the length of the whole element, this header included.
+ pub(crate) fn element_len(&self) -> usize {
+ num::u32_as_usize(self.mctp_payload_size)
+ }
+
+ /// Returns the length of the message following this header, message header included.
+ pub(crate) fn message_len(&self) -> usize {
+ num::u32_as_usize(self.nvdm_payload_size)
+ }
+
+ /// Returns the number of slots (i.e. memory pages) used by this element.
+ pub(crate) fn element_count(&self) -> u32 {
+ self.mctp_payload_size.div_ceil(cv!(GSP_PAGE_SIZE))
+ }
+
+ /// Returns the NVDM type of the message following this header, or `EINVAL` if it is not a
+ /// known one.
+ pub(crate) fn nvdm_type(&self) -> Result<NvdmType> {
+ self.nvdm_header.nvdm_type()
+ }
+
+ /// Validates the framing of the element.
+ ///
+ /// # Errors
+ ///
+ /// - `EIO` if the magic, the MCTP version or the NVDM vendor is wrong, or if the element
+ /// length is smaller than this header and the message together, or larger than the
+ /// maximum element size.
+ pub(crate) fn validate(&self) -> Result {
+ if self.mctp_magic != MCTP_MAGIC
+ || !self.mctp_header.has_expected_version()
+ || !self.nvdm_header.has_nvidia_vendor()
+ {
+ return Err(EIO);
+ }
+
+ let element_len = self.element_len();
+ if element_len < size_of::<Self>().saturating_add(self.message_len())
+ || element_len > GSP_MSG_QUEUE_ELEMENT_SIZE_MAX
+ {
+ return Err(EIO);
+ }
+
+ Ok(())
+ }
+}
+
+// SAFETY: All fields are integer types or transparent wrappers over one, with no padding.
+unsafe impl AsBytes for QueueElementHeader {}
+
+// SAFETY: All fields are integer types or transparent wrappers over one, for which all bit
+// patterns are valid.
+unsafe impl FromBytes for QueueElementHeader {}
+
bounded_enum! {
/// Commands of the GMC API.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
diff --git a/drivers/gpu/nova-core/gsp/fw/r000_00/bindings.rs b/drivers/gpu/nova-core/gsp/fw/r000_00/bindings.rs
index 552299c98169..959e397c26aa 100644
--- a/drivers/gpu/nova-core/gsp/fw/r000_00/bindings.rs
+++ b/drivers/gpu/nova-core/gsp/fw/r000_00/bindings.rs
@@ -30,6 +30,49 @@ fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.write_str("__IncompleteArrayField")
}
}
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::core::marker::PhantomData<T>);
+impl<T> __BindgenUnionField<T> {
+ #[inline]
+ pub const fn new() -> Self {
+ __BindgenUnionField(::core::marker::PhantomData)
+ }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T {
+ ::core::mem::transmute(self)
+ }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T {
+ ::core::mem::transmute(self)
+ }
+}
+impl<T> ::core::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self {
+ Self::new()
+ }
+}
+impl<T> ::core::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl<T> ::core::marker::Copy for __BindgenUnionField<T> {}
+impl<T> ::core::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+impl<T> ::core::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::core::hash::Hasher>(&self, _state: &mut H) {}
+}
+impl<T> ::core::cmp::PartialEq for __BindgenUnionField<T> {
+ fn eq(&self, _other: &__BindgenUnionField<T>) -> bool {
+ true
+ }
+}
+impl<T> ::core::cmp::Eq for __BindgenUnionField<T> {}
pub type __u8 = ffi::c_uchar;
pub type __u16 = ffi::c_ushort;
pub type __u32 = ffi::c_uint;
@@ -39,6 +82,60 @@ fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
pub type u32_ = __u32;
pub type u64_ = __u64;
#[repr(C)]
+#[derive(Debug, Default, Copy, Clone, MaybeZeroable)]
+pub struct GSP_MSG_QUEUE_ENCRYPTION_TAG {
+ pub authTagBuffer: [u8_; 16usize],
+}
+#[repr(C)]
+#[derive(MaybeZeroable)]
+pub struct GSP_MSG_QUEUE_ELEMENT {
+ pub mctpMagic: u32_,
+ pub mctpPayloadSize: u32_,
+ pub mctpHeader: u32_,
+ pub nvdmHeader: u32_,
+ pub __bindgen_anon_1: GSP_MSG_QUEUE_ELEMENT__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(MaybeZeroable)]
+pub struct GSP_MSG_QUEUE_ELEMENT__bindgen_ty_1 {
+ pub withEncryption: __BindgenUnionField<GSP_MSG_QUEUE_ELEMENT__bindgen_ty_1__bindgen_ty_1>,
+ pub noEncryption: __BindgenUnionField<GSP_MSG_QUEUE_ELEMENT__bindgen_ty_1__bindgen_ty_2>,
+ pub bindgen_union_field: [u32; 6usize],
+}
+#[repr(C)]
+#[derive(Debug, Default, MaybeZeroable)]
+pub struct GSP_MSG_QUEUE_ELEMENT__bindgen_ty_1__bindgen_ty_1 {
+ pub encryptionTag: GSP_MSG_QUEUE_ENCRYPTION_TAG,
+ pub nvdmPayloadSize: u32_,
+ pub reserved: u32_,
+ pub payload: __IncompleteArrayField<u8_>,
+}
+#[repr(C)]
+#[derive(Debug, Default, MaybeZeroable)]
+pub struct GSP_MSG_QUEUE_ELEMENT__bindgen_ty_1__bindgen_ty_2 {
+ pub nvdmPayloadSize: u32_,
+ pub reserved: u32_,
+ pub payload: __IncompleteArrayField<u8_>,
+}
+impl Default for GSP_MSG_QUEUE_ELEMENT__bindgen_ty_1 {
+ fn default() -> Self {
+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
+ unsafe {
+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
+ s.assume_init()
+ }
+ }
+}
+impl Default for GSP_MSG_QUEUE_ELEMENT {
+ fn default() -> Self {
+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
+ unsafe {
+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
+ s.assume_init()
+ }
+ }
+}
+#[repr(C)]
#[derive(MaybeZeroable)]
pub struct GMCAPI_HEADER {
pub command: u32_,
diff --git a/drivers/gpu/nova-core/mctp.rs b/drivers/gpu/nova-core/mctp.rs
index f62e79f56b05..e4d0639cde0f 100644
--- a/drivers/gpu/nova-core/mctp.rs
+++ b/drivers/gpu/nova-core/mctp.rs
@@ -28,6 +28,10 @@ pub(crate) enum NvdmType with TryFrom<Bounded<u32, 8>> {
Cot = 0x14,
/// FSP command response.
FspResponse = 0x15,
+ /// RPC message to or from GSP-RM.
+ RmRpc = 0x25,
+ /// GMC (GPU Management Controller) API message to or from GSP-RM.
+ GmcApi = 0x26,
}
}
@@ -67,6 +71,11 @@ pub(crate) fn single_packet() -> Self {
pub(crate) fn is_single_packet(self) -> bool {
self.som().into_bool() && self.eom().into_bool()
}
+
+ /// Returns `true` if this MCTP header carries the version that this driver uses.
+ pub(crate) fn has_expected_version(self) -> bool {
+ u32::from(self.version()) == Self::VERSION
+ }
}
/// MCTP message type for PCI vendor-defined messages.
@@ -93,10 +102,17 @@ pub(crate) fn new(nvdm_type: NvdmType) -> Self {
.with_nvdm_type(nvdm_type)
}
- /// Validates this header against the expected NVIDIA NVDM format and type.
- pub(crate) fn validate(self, expected_type: NvdmType) -> bool {
+ /// Returns `true` if this NVDM header belongs to a PCI vendor-defined message from NVIDIA.
+ ///
+ /// The GPU firmware only ever sends such messages, so a mismatch is a sign of corruption.
+ pub(crate) fn has_nvidia_vendor(self) -> bool {
u8::from(self.msg_type()) == MSG_TYPE_VENDOR_PCI
&& u16::from(self.vendor_id()) == Vendor::NVIDIA.as_raw()
+ }
+
+ /// Validates this header against the expected NVIDIA NVDM format and type.
+ pub(crate) fn validate(self, expected_type: NvdmType) -> bool {
+ self.has_nvidia_vendor()
&& matches!(self.nvdm_type(), Ok(nvdm_type) if nvdm_type == expected_type)
}
}
--
2.56.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/4] gpu: nova-core: gsp: rename and move the static configuration type
2026-11-27 14:04 [PATCH 0/4] gpu: nova-core: gsp: preparatory patches for the r000 firmware Alexandre Courbot
2026-11-27 14:04 ` [PATCH 1/4] gpu: nova-core: gsp: add the r000 queue element header Alexandre Courbot
@ 2026-11-27 14:04 ` Alexandre Courbot
2026-11-27 14:04 ` [PATCH 3/4] gpu: nova-core: gsp: return the static GPU configuration from boot Alexandre Courbot
2026-11-27 14:04 ` [PATCH 4/4] gpu: nova-core: gsp: add the short name and GID to the GSP_INIT reply Alexandre Courbot
3 siblings, 0 replies; 6+ messages in thread
From: Alexandre Courbot @ 2026-11-27 14:04 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, David Airlie, Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Eliot Courtney,
Zhi Wang, nova-gpu, dri-devel, linux-kernel, Alexandre Courbot
From: John Hubbard <jhubbard@nvidia.com>
With the r000 firmware, GSP-RM reports the static GPU configuration in
its reply to GSP_INIT, a GMC command, and no RPC command fetches it.
The type that holds the configuration is named after the r570 RPC
command that fetches it, and it is defined among the RPC commands.
In order to make the type available to a GMC reply, name it after its
contents, and move it out of the RPC commands, up into the commands
module.
No functional changes.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/gpu/nova-core/api.rs | 6 +--
drivers/gpu/nova-core/gpu.rs | 4 +-
drivers/gpu/nova-core/gsp.rs | 2 +-
drivers/gpu/nova-core/gsp/commands.rs | 65 +++++++++++++++++++++++++++++
drivers/gpu/nova-core/gsp/commands/rpc.rs | 68 +++----------------------------
5 files changed, 76 insertions(+), 69 deletions(-)
diff --git a/drivers/gpu/nova-core/api.rs b/drivers/gpu/nova-core/api.rs
index dc877ddebe8c..f800ba6c4183 100644
--- a/drivers/gpu/nova-core/api.rs
+++ b/drivers/gpu/nova-core/api.rs
@@ -18,7 +18,7 @@
use crate::{
driver,
gpu::Gpu,
- gsp::commands::rpc::GetGspStaticInfoReply, //
+ gsp::commands::GspStaticInfo, //
};
/// API handle for the auxiliary bus child drivers to interact with nova-core.
@@ -39,8 +39,8 @@ pub fn of(adev: &auxiliary::Device<Bound>) -> Result<NovaCoreApiHandle<'_>> {
NovaCoreApiHandle::of(adev)
}
- /// Returns the GPU [`GetGspStaticInfoReply`].
- pub fn gsp_static_info(&self) -> &GetGspStaticInfoReply {
+ /// Returns the GPU [`GspStaticInfo`].
+ pub fn gsp_static_info(&self) -> &GspStaticInfo {
&self.gpu.gsp_static_info
}
diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
index 8ab1687847ff..590d81f4e479 100644
--- a/drivers/gpu/nova-core/gpu.rs
+++ b/drivers/gpu/nova-core/gpu.rs
@@ -32,7 +32,7 @@
gsp::{
self,
cmdq::Cmdq,
- commands::rpc::GetGspStaticInfoReply,
+ commands::GspStaticInfo,
Gsp,
GspBootContext, //
},
@@ -394,7 +394,7 @@ pub(crate) struct Gpu<'gpu> {
#[uses('tree)]
_gsp_subtree: GspSubtree<'gsp_resources>,
/// Static GPU information as provided by the GSP.
- pub(crate) gsp_static_info: GetGspStaticInfoReply,
+ pub(crate) gsp_static_info: GspStaticInfo,
/// GPU memory manager owning memory management resources.
///
/// Must be kept declared *before* `gsp_resources`, so that its components are dropped while
diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs
index 2f1cdf8b7bec..398d6525b133 100644
--- a/drivers/gpu/nova-core/gsp.rs
+++ b/drivers/gpu/nova-core/gsp.rs
@@ -159,7 +159,7 @@ pub(crate) fn new(
}
/// Query the GSP for the static GPU information.
- pub(crate) fn get_static_info(&self) -> Result<commands::rpc::GetGspStaticInfoReply> {
+ pub(crate) fn get_static_info(&self) -> Result<commands::GspStaticInfo> {
self.cmdq.send_rpc_command(commands::rpc::GetGspStaticInfo)
}
}
diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/gsp/commands.rs
index 5f1c944678be..4aae94b7ca2e 100644
--- a/drivers/gpu/nova-core/gsp/commands.rs
+++ b/drivers/gpu/nova-core/gsp/commands.rs
@@ -2,3 +2,68 @@
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
pub(crate) mod rpc;
+
+use core::{
+ ffi::FromBytesUntilNulError,
+ ops::Range,
+ str::Utf8Error, //
+};
+
+use kernel::prelude::*;
+
+/// The static GPU configuration, which GSP-RM reports in reply to
+/// [`GetGspStaticInfo`](rpc::GetGspStaticInfo).
+pub struct GspStaticInfo {
+ gpu_name: [u8; 64],
+ gpu_short_name: [u8; 64],
+ /// The 16-byte SHA-1 based GPU identifier (GID) reported by GSP-RM.
+ pub gpu_gid: [u8; 16],
+ /// BAR1 Page Directory Entry base address.
+ pub(crate) bar1_pde_base: u64,
+ /// Usable FB (VRAM) regions for driver memory allocation.
+ pub(crate) usable_fb_regions: KVec<Range<u64>>,
+ /// Exclusive end of the FB physical address space.
+ pub(crate) total_fb_end: u64,
+}
+
+/// Error type for [`GspStaticInfo::gpu_name`].
+#[derive(Debug)]
+pub enum GpuNameError {
+ /// The GPU name string does not contain a null terminator.
+ NoNullTerminator(FromBytesUntilNulError),
+
+ /// The GPU name string contains invalid UTF-8.
+ InvalidUtf8(Utf8Error),
+}
+
+impl GspStaticInfo {
+ /// Returns the name of the GPU as a string.
+ ///
+ /// Returns an error if the string given by the GSP does not contain a null terminator or
+ /// contains invalid UTF-8.
+ pub fn gpu_name(&self) -> Result<&str, GpuNameError> {
+ CStr::from_bytes_until_nul(&self.gpu_name)
+ .map_err(GpuNameError::NoNullTerminator)?
+ .to_str()
+ .map_err(GpuNameError::InvalidUtf8)
+ }
+
+ /// Returns the short name of the GPU as a string.
+ ///
+ /// Returns an error if the string given by the GSP does not contain a null terminator or
+ /// contains invalid UTF-8.
+ pub fn gpu_short_name(&self) -> core::result::Result<&str, GpuNameError> {
+ CStr::from_bytes_until_nul(&self.gpu_short_name)
+ .map_err(GpuNameError::NoNullTerminator)?
+ .to_str()
+ .map_err(GpuNameError::InvalidUtf8)
+ }
+
+ /// Returns the total usable VRAM size in bytes, i.e. the summed lengths of all usable FB
+ /// regions.
+ pub fn vram_size(&self) -> u64 {
+ self.usable_fb_regions.iter().fold(0, |size, region| {
+ size.saturating_add(region.end - region.start)
+ })
+ }
+}
diff --git a/drivers/gpu/nova-core/gsp/commands/rpc.rs b/drivers/gpu/nova-core/gsp/commands/rpc.rs
index 023090ac6bd9..ab6d1114cead 100644
--- a/drivers/gpu/nova-core/gsp/commands/rpc.rs
+++ b/drivers/gpu/nova-core/gsp/commands/rpc.rs
@@ -3,10 +3,7 @@
use core::{
array,
- convert::Infallible,
- ffi::FromBytesUntilNulError,
- ops::Range,
- str::Utf8Error, //
+ convert::Infallible, //
};
use kernel::{
@@ -30,6 +27,7 @@
Cmdq,
NoReply, //
},
+ commands::GspStaticInfo,
fw::{
self,
MsgFunction, //
@@ -208,7 +206,7 @@ pub(crate) fn wait_gsp_init_done(cmdq: &Cmdq<'_>) -> Result {
impl CommandToGsp for GetGspStaticInfo {
const FUNCTION: MsgFunction = MsgFunction::GetGspStaticInfo;
type Command = fw::commands::GspStaticConfigInfo;
- type Reply = GetGspStaticInfoReply;
+ type Reply = GspStaticInfo;
type InitError = Infallible;
fn init(&self) -> impl Init<Self::Command, Self::InitError> {
@@ -216,21 +214,7 @@ fn init(&self) -> impl Init<Self::Command, Self::InitError> {
}
}
-/// The reply from the GSP to the [`GetGspStaticInfo`] command.
-pub struct GetGspStaticInfoReply {
- gpu_name: [u8; 64],
- gpu_short_name: [u8; 64],
- /// The 16-byte SHA-1 based GPU identifier (GID) reported by GSP-RM.
- pub gpu_gid: [u8; 16],
- /// BAR1 Page Directory Entry base address.
- pub(crate) bar1_pde_base: u64,
- /// Usable FB (VRAM) regions for driver memory allocation.
- pub(crate) usable_fb_regions: KVec<Range<u64>>,
- /// Exclusive end of the FB physical address space.
- pub(crate) total_fb_end: u64,
-}
-
-impl MessageFromGsp for GetGspStaticInfoReply {
+impl MessageFromGsp for GspStaticInfo {
const FUNCTION: MsgFunction = MsgFunction::GetGspStaticInfo;
type Message = fw::commands::GspStaticConfigInfo;
type InitError = Error;
@@ -245,7 +229,7 @@ fn read(
}
let total_fb_end = msg.total_fb_end().ok_or(EINVAL)?;
- Ok(GetGspStaticInfoReply {
+ Ok(GspStaticInfo {
gpu_name: msg.gpu_name_str(),
gpu_short_name: msg.gpu_short_name_str(),
gpu_gid: msg.gpu_gid(),
@@ -256,48 +240,6 @@ fn read(
}
}
-/// Error type for [`GetGspStaticInfoReply::gpu_name`].
-#[derive(Debug)]
-pub enum GpuNameError {
- /// The GPU name string does not contain a null terminator.
- NoNullTerminator(FromBytesUntilNulError),
-
- /// The GPU name string contains invalid UTF-8.
- InvalidUtf8(Utf8Error),
-}
-
-impl GetGspStaticInfoReply {
- /// Returns the name of the GPU as a string.
- ///
- /// Returns an error if the string given by the GSP does not contain a null terminator or
- /// contains invalid UTF-8.
- pub fn gpu_name(&self) -> Result<&str, GpuNameError> {
- CStr::from_bytes_until_nul(&self.gpu_name)
- .map_err(GpuNameError::NoNullTerminator)?
- .to_str()
- .map_err(GpuNameError::InvalidUtf8)
- }
-
- /// Returns the short name of the GPU as a string.
- ///
- /// Returns an error if the string given by the GSP does not contain a null terminator or
- /// contains invalid UTF-8.
- pub fn gpu_short_name(&self) -> core::result::Result<&str, GpuNameError> {
- CStr::from_bytes_until_nul(&self.gpu_short_name)
- .map_err(GpuNameError::NoNullTerminator)?
- .to_str()
- .map_err(GpuNameError::InvalidUtf8)
- }
-
- /// Returns the total usable VRAM size in bytes, i.e. the summed lengths of all usable FB
- /// regions.
- pub fn vram_size(&self) -> u64 {
- self.usable_fb_regions.iter().fold(0, |size, region| {
- size.saturating_add(region.end - region.start)
- })
- }
-}
-
pub(crate) use fw::commands::PowerStateLevel;
/// The `UnloadingGuestDriver` command, used to shut down the GSP.
--
2.56.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] gpu: nova-core: gsp: return the static GPU configuration from boot
2026-11-27 14:04 [PATCH 0/4] gpu: nova-core: gsp: preparatory patches for the r000 firmware Alexandre Courbot
2026-11-27 14:04 ` [PATCH 1/4] gpu: nova-core: gsp: add the r000 queue element header Alexandre Courbot
2026-11-27 14:04 ` [PATCH 2/4] gpu: nova-core: gsp: rename and move the static configuration type Alexandre Courbot
@ 2026-11-27 14:04 ` Alexandre Courbot
2026-11-27 14:04 ` [PATCH 4/4] gpu: nova-core: gsp: add the short name and GID to the GSP_INIT reply Alexandre Courbot
3 siblings, 0 replies; 6+ messages in thread
From: Alexandre Courbot @ 2026-11-27 14:04 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, David Airlie, Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Eliot Courtney,
Zhi Wang, nova-gpu, dri-devel, linux-kernel, Alexandre Courbot
From: John Hubbard <jhubbard@nvidia.com>
With the r000 firmware, GSP-RM reports the static GPU configuration in
its reply to the GSP_INIT command that ends the boot, so the boot
sequence holds the configuration when it returns.
Nova-core fetches the configuration with an RPC command after the boot,
once the interrupt handler is registered. On r000, the boot sequence
would have to keep the GSP_INIT reply for that later step to read.
Return the configuration from the boot sequence, together with the
unload bundle, and send the RPC command at the end of the boot sequence
instead.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/gpu/nova-core/api.rs | 2 +-
drivers/gpu/nova-core/gpu.rs | 36 +++++++++++++++++++-----------------
drivers/gpu/nova-core/gsp.rs | 13 ++++++++-----
drivers/gpu/nova-core/gsp/boot.rs | 15 +++++++++++----
4 files changed, 39 insertions(+), 27 deletions(-)
diff --git a/drivers/gpu/nova-core/api.rs b/drivers/gpu/nova-core/api.rs
index f800ba6c4183..a665eabc44c2 100644
--- a/drivers/gpu/nova-core/api.rs
+++ b/drivers/gpu/nova-core/api.rs
@@ -41,7 +41,7 @@ pub fn of(adev: &auxiliary::Device<Bound>) -> Result<NovaCoreApiHandle<'_>> {
/// Returns the GPU [`GspStaticInfo`].
pub fn gsp_static_info(&self) -> &GspStaticInfo {
- &self.gpu.gsp_static_info
+ self.gpu.gsp_static_info()
}
/// Returns the GPU [`Spec`].
diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
index 590d81f4e479..e4db5ce47316 100644
--- a/drivers/gpu/nova-core/gpu.rs
+++ b/drivers/gpu/nova-core/gpu.rs
@@ -32,7 +32,6 @@
gsp::{
self,
cmdq::Cmdq,
- commands::GspStaticInfo,
Gsp,
GspBootContext, //
},
@@ -341,8 +340,8 @@ struct GspResources<'gpu> {
/// GSP runtime data.
#[pin]
gsp: Gsp<'gpu>,
- /// GSP unload firmware bundle, if any.
- unload_bundle: Option<gsp::UnloadBundle<'gpu>>,
+ /// The static GPU configuration and the unload bundle that the boot sequence returned.
+ boot_result: gsp::BootResult<'gpu>,
}
/// The GSP event handler's registration and the enable of its subtree at `TOP`.
@@ -393,8 +392,6 @@ pub(crate) struct Gpu<'gpu> {
#[pin]
#[uses('tree)]
_gsp_subtree: GspSubtree<'gsp_resources>,
- /// Static GPU information as provided by the GSP.
- pub(crate) gsp_static_info: GspStaticInfo,
/// GPU memory manager owning memory management resources.
///
/// Must be kept declared *before* `gsp_resources`, so that its components are dropped while
@@ -425,7 +422,7 @@ fn drop(self: Pin<&mut Self>) {
let this = self.project();
let device = *this.device;
let bar = *this.bar;
- let bundle = this.unload_bundle.take();
+ let bundle = this.boot_result.unload_bundle.take();
let _ = this
.gsp
@@ -505,7 +502,7 @@ pub(crate) fn new<'a>(
// This member must be initialized last, so the `UnloadBundle` can never be dropped
// from outside of the constructed `GspResources`, ensuring that the unload sequence
// is properly run in case of failure.
- unload_bundle: gsp.boot(GspBootContext {
+ boot_result: gsp.boot(GspBootContext {
pdev,
bar,
chipset: spec.chipset,
@@ -537,9 +534,9 @@ pub(crate) fn new<'a>(
gsp_resources.gsp.cmdq.drain()?;
},
- gsp_static_info: {
+ _: {
// Obtain and display basic GPU information.
- let info = gsp_resources.gsp.get_static_info()?;
+ let info = &gsp_resources.boot_result.static_info;
match info.gpu_name() {
Ok(name) => dev_info!(dev, "GPU name: {}\n", name),
Err(e) => dev_warn!(dev, "GPU name unavailable: {:?}\n", e),
@@ -557,13 +554,12 @@ pub(crate) fn new<'a>(
info.vram_size() / u64::SZ_1M
);
}
-
- info
},
// Create GPU memory manager owning memory management resources.
mm: {
- let usable_vram = gsp_static_info.usable_fb_regions.first().ok_or(ENODEV)?;
+ let info = &gsp_resources.boot_result.static_info;
+ let usable_vram = info.usable_fb_regions.first().ok_or(ENODEV)?;
let buddy_params = GpuBuddyParams {
base_offset: usable_vram.start,
size: usable_vram.end - usable_vram.start,
@@ -574,13 +570,14 @@ pub(crate) fn new<'a>(
bar,
gsp_resources.spec.chipset,
buddy_params,
- VramAddress::from_raw(gsp_static_info.total_fb_end),
+ VramAddress::from_raw(info.total_fb_end),
)?
},
// Create BAR1 user interface for CPU access to GPU virtual memory.
bar_user <- {
- let pdb_addr = VramAddress::from_raw(gsp_static_info.bar1_pde_base);
+ let info = &gsp_resources.boot_result.static_info;
+ let pdb_addr = VramAddress::from_raw(info.bar1_pde_base);
let bar1_idx = crate::driver::bar1_resource_index(pdev)?;
let bar1_size = pdev.resource_len(bar1_idx)?;
@@ -594,6 +591,11 @@ pub(crate) fn new<'a>(
})
}
+ /// Returns the static GPU configuration that GSP-RM reported at boot.
+ pub(crate) fn gsp_static_info(&self) -> &gsp::commands::GspStaticInfo {
+ &self.gsp_resources.boot_result.static_info
+ }
+
/// Waits for GFW, the GPU's boot firmware, to report completion.
///
/// The driver must not program the GPU before then.
@@ -616,14 +618,14 @@ pub(crate) fn wait_gfw_boot_completion(
pub(crate) fn run_selftests(self: Pin<&mut Self>, pdev: &pci::Device<device::Bound>) {
let this = self.project();
let dev = pdev.as_ref();
- let regions = &this.gsp_static_info.usable_fb_regions;
+ let info = &this.gsp_resources.boot_result.static_info;
if let Err(err) = crate::mm::selftest::run(
dev,
this.mm,
- regions,
+ &info.usable_fb_regions,
&this.bar_user,
- this.gsp_static_info.bar1_pde_base,
+ info.bar1_pde_base,
this.spec.chipset,
) {
dev_err!(dev, "self-tests failed: {:?}\n", err);
diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs
index 398d6525b133..bf0028e52e3c 100644
--- a/drivers/gpu/nova-core/gsp.rs
+++ b/drivers/gpu/nova-core/gsp.rs
@@ -157,12 +157,15 @@ pub(crate) fn new(
}))
})
}
-
- /// Query the GSP for the static GPU information.
- pub(crate) fn get_static_info(&self) -> Result<commands::GspStaticInfo> {
- self.cmdq.send_rpc_command(commands::rpc::GetGspStaticInfo)
- }
}
/// Opaque bundle required to unload the GSP. Created by [`Gsp::boot`], consumed by [`Gsp::unload`].
pub(crate) struct UnloadBundle<'a>(KBox<dyn hal::UnloadBundle + 'a>);
+
+/// The output of [`Gsp::boot`]: the static GPU configuration and the unload bundle.
+pub(crate) struct BootResult<'a> {
+ /// The unload bundle for [`Gsp::unload`], if one could be built.
+ pub(crate) unload_bundle: Option<UnloadBundle<'a>>,
+ /// The static GPU configuration as reported by GSP-RM.
+ pub(crate) static_info: commands::GspStaticInfo,
+}
diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/boot.rs
index 9d5da5b165ac..a45f2b21a2ab 100644
--- a/drivers/gpu/nova-core/gsp/boot.rs
+++ b/drivers/gpu/nova-core/gsp/boot.rs
@@ -27,12 +27,12 @@ impl<'gsp> super::Gsp<'gsp> {
/// user-space, patching them with signatures, and building firmware-specific intricate data
/// structures that the GSP will use at runtime.
///
- /// Upon return, the GSP is up and running, and its unload bundle (to be given as argument to
- /// [`Self::unload`]) returned.
+ /// Returns, with the GSP running, the static configuration that GSP-RM reported and the
+ /// unload bundle for [`Self::unload`].
pub(crate) fn boot(
self: Pin<&mut Self>,
mut ctx: super::GspBootContext<'_, 'gsp>,
- ) -> Result<Option<super::UnloadBundle<'gsp>>> {
+ ) -> Result<super::BootResult<'gsp>> {
let pdev = ctx.pdev;
let chipset = ctx.chipset;
let gsp_falcon = ctx.gsp_falcon;
@@ -84,7 +84,14 @@ pub(crate) fn boot(
// Wait until GSP is fully initialized.
commands::rpc::wait_gsp_init_done(&self.cmdq)?;
- Ok(unload_guard.dismiss().1)
+ let static_info = self
+ .cmdq
+ .send_rpc_command(commands::rpc::GetGspStaticInfo)?;
+
+ Ok(super::BootResult {
+ unload_bundle: unload_guard.dismiss().1,
+ static_info,
+ })
}
/// Shut down the GSP and wait until it is offline.
--
2.56.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/4] gpu: nova-core: gsp: add the short name and GID to the GSP_INIT reply
2026-11-27 14:04 [PATCH 0/4] gpu: nova-core: gsp: preparatory patches for the r000 firmware Alexandre Courbot
` (2 preceding siblings ...)
2026-11-27 14:04 ` [PATCH 3/4] gpu: nova-core: gsp: return the static GPU configuration from boot Alexandre Courbot
@ 2026-11-27 14:04 ` Alexandre Courbot
3 siblings, 0 replies; 6+ messages in thread
From: Alexandre Courbot @ 2026-11-27 14:04 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, David Airlie, Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Eliot Courtney,
Zhi Wang, nova-gpu, dri-devel, linux-kernel, Alexandre Courbot
From: John Hubbard <jhubbard@nvidia.com>
The static GPU configuration holds the short name of the GPU and the GPU
identifier (GID). Nova-drm reports both to user space, and the r570
static-info reply provides both.
The r000 GSP-RM sends both in its reply to GSP_INIT, and nova-core's
schema of that reply has no key for either.
Add the two keys to the schema. Move the lengths of the names and of the
identifier onto the static configuration type, so that the schema and
the type share them.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/gpu/nova-core/gsp/commands.rs | 11 ++++++++---
drivers/gpu/nova-core/gsp/fw/commands.rs | 13 +++++++------
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/gsp/commands.rs
index 4aae94b7ca2e..390be8fdd0ba 100644
--- a/drivers/gpu/nova-core/gsp/commands.rs
+++ b/drivers/gpu/nova-core/gsp/commands.rs
@@ -14,10 +14,10 @@
/// The static GPU configuration, which GSP-RM reports in reply to
/// [`GetGspStaticInfo`](rpc::GetGspStaticInfo).
pub struct GspStaticInfo {
- gpu_name: [u8; 64],
- gpu_short_name: [u8; 64],
+ gpu_name: [u8; Self::MAX_GPU_NAME_LEN],
+ gpu_short_name: [u8; Self::MAX_GPU_NAME_LEN],
/// The 16-byte SHA-1 based GPU identifier (GID) reported by GSP-RM.
- pub gpu_gid: [u8; 16],
+ pub gpu_gid: [u8; Self::GID_LEN],
/// BAR1 Page Directory Entry base address.
pub(crate) bar1_pde_base: u64,
/// Usable FB (VRAM) regions for driver memory allocation.
@@ -37,6 +37,11 @@ pub enum GpuNameError {
}
impl GspStaticInfo {
+ /// Length of the buffers holding the GPU names, NUL terminator included.
+ pub(crate) const MAX_GPU_NAME_LEN: usize = 64;
+ /// Length of the GPU identifier.
+ pub(crate) const GID_LEN: usize = 16;
+
/// Returns the name of the GPU as a string.
///
/// Returns an error if the string given by the GSP does not contain a null terminator or
diff --git a/drivers/gpu/nova-core/gsp/fw/commands.rs b/drivers/gpu/nova-core/gsp/fw/commands.rs
index b4bdbddad79f..214f1a8c68df 100644
--- a/drivers/gpu/nova-core/gsp/fw/commands.rs
+++ b/drivers/gpu/nova-core/gsp/fw/commands.rs
@@ -18,6 +18,7 @@
use crate::{
gpu::Chipset,
gsp::{
+ commands::GspStaticInfo,
nvkv::{
nvkv_decode,
nvkv_encode,
@@ -386,7 +387,9 @@ struct GspInitRequest {
// https://github.com/rust-lang/rust/pull/154377
#[allow(dead_code)]
struct GspInitResponseSchema => GspInitResponse {
- gpu_name: TruncatingArray<u8, { GspInitResponse::MAX_GPU_NAME_LEN }, 0x2000>,
+ gpu_name: TruncatingArray<u8, { GspStaticInfo::MAX_GPU_NAME_LEN }, 0x2000>,
+ gpu_short_name: TruncatingArray<u8, { GspStaticInfo::MAX_GPU_NAME_LEN }, 0x2001>,
+ gpu_gid: TruncatingArray<u8, { GspStaticInfo::GID_LEN }, 0x2002>,
fb_regions: Accumulated<FbRegionSchema>,
bar1_pde_base: Required<Key<u64, 0x1020>>,
vmmu_segment_size: Key<u64, 0x1050>,
@@ -398,16 +401,14 @@ struct GspInitResponseSchema => GspInitResponse {
// https://github.com/rust-lang/rust/pull/154377
#[allow(dead_code)]
struct GspInitResponse {
- gpu_name: ArrayVec<u8, { Self::MAX_GPU_NAME_LEN }>,
+ gpu_name: ArrayVec<u8, { GspStaticInfo::MAX_GPU_NAME_LEN }>,
+ gpu_short_name: ArrayVec<u8, { GspStaticInfo::MAX_GPU_NAME_LEN }>,
+ gpu_gid: ArrayVec<u8, { GspStaticInfo::GID_LEN }>,
fb_regions: KVVec<FbRegion>,
bar1_pde_base: u64,
vmmu_segment_size: u64,
}
-impl GspInitResponse {
- const MAX_GPU_NAME_LEN: usize = 64;
-}
-
nvkv_decode! {
/// Schema for one FB region of the `GSP_INIT` response.
struct FbRegionSchema => FbRegion {
--
2.56.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/4] gpu: nova-core: gsp: add the r000 queue element header
2026-11-27 14:04 ` [PATCH 1/4] gpu: nova-core: gsp: add the r000 queue element header Alexandre Courbot
@ 2026-11-27 14:52 ` Gary Guo
0 siblings, 0 replies; 6+ messages in thread
From: Gary Guo @ 2026-11-27 14:52 UTC (permalink / raw)
To: Alexandre Courbot, Danilo Krummrich, Alice Ryhl, David Airlie,
Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Eliot Courtney,
Zhi Wang, nova-gpu, dri-devel, linux-kernel
On Fri Nov 27, 2026 at 2:04 PM GMT, Alexandre Courbot wrote:
> From: John Hubbard <jhubbard@nvidia.com>
>
> The upcoming r000 firmware uses a new queue element header that includes
> MCTP and NVDM headers describing the type of message (RPC or GMC) that
> follows.
>
> Add that header as the `QueueElementHeader` type, along with the two
> NVDM types that the GSP queues use and the MCTP version and NVDM vendor
> checks that validating it requires.
>
> The type is written out field by field rather than wrapped around the
> generated binding, as `GSP_MSG_QUEUE_ELEMENT` keeps a 16-byte encryption
> tag, only used with confidential computing, in a union with its last two
> fields, making the binding 16 bytes larger than what the GSP expects on
> the queues. Static assertions check every field offset and the size of
> the type against the binding.
>
> The header has no user yet: it replaces `GspMsgElement` at the transport
> level in a later patch that switches to the r000 firmware, and is built
> as dead code until then.
>
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> Co-developed-by: Alexandre Courbot <acourbot@nvidia.com>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
> drivers/gpu/nova-core/gsp/fw.rs | 186 ++++++++++++++++++++++-
> drivers/gpu/nova-core/gsp/fw/r000_00/bindings.rs | 97 ++++++++++++
> drivers/gpu/nova-core/mctp.rs | 20 ++-
> 3 files changed, 300 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw.rs
> index 5c216d777dff..2e499a74fa46 100644
> --- a/drivers/gpu/nova-core/gsp/fw.rs
> +++ b/drivers/gpu/nova-core/gsp/fw.rs
> @@ -48,6 +48,11 @@
> cmdq::Cmdq, //
> GSP_PAGE_SIZE,
> },
> + mctp::{
> + MctpHeader,
> + NvdmHeader,
> + NvdmType, //
> + },
> num::{
> self,
> FromSafeCast, //
> @@ -835,7 +840,7 @@ pub(crate) fn msg_length(&self) -> usize {
> size_of::<Self>() + self.rpc_header().rpc_length()
> }
>
> - /// Returns the number of elements (i.e. memory pages) used by this message.
> + /// Returns the number of slots (i.e. memory pages) used by this message.
> pub(crate) fn element_count(&self) -> u32 {
> self.inner.elemCount
> }
> @@ -901,6 +906,185 @@ pub(crate) fn function(&self) -> Result<MsgFunction, u32> {
> }
> }
>
> +/// First word of every r000 queue element: `"MCTP"` in ASCII.
> +const MCTP_MAGIC: u32 = 0x4D43_5450;
> +
> +/// Header opening every element of the r000 GSP queues.
> +///
> +/// A queue element is laid out as follows:
> +///
> +/// ```text
> +/// +------------------------------------+
> +/// | Queue element header | QueueElementHeader: MCTP magic, element length,
> +/// | | MCTP header, NVDM header, message length.
> +/// +------------------------------------+
> +/// | Message header | RPC header or GMC API header. The NVDM type
> +/// | | selects between the two.
> +/// +------------------------------------+
> +/// | Payload | Message-specific data.
> +/// +------------------------------------+
> +/// ```
> +///
> +/// This is the `noEncryption` layout of the `GSP_MSG_QUEUE_ELEMENT` binding. That binding keeps
> +/// a 16-byte encryption tag, used only with confidential computing, in a union with the two
> +/// trailing fields of the queue element header, so wrapping the binding would make every element
> +/// 16 bytes larger than what the GSP expects. The fields are therefore declared again here, with
> +/// their offsets checked against the binding.
> +#[repr(C)]
> +pub(crate) struct QueueElementHeader {
> + /// Always [`MCTP_MAGIC`].
> + mctp_magic: u32,
> + /// Length in bytes of the whole element, this header included.
> + ///
> + /// Under confidential computing the GSP pads elements out to whole queue slots, so this can
> + /// be larger than `nvdm_payload_size` plus the size of this header, but never smaller.
> + mctp_payload_size: u32,
> + /// MCTP transport header of the element.
> + mctp_header: MctpHeader,
> + /// NVDM header of the message.
> + nvdm_header: NvdmHeader,
> + /// Length in bytes of the message following this header: the message header and its
> + /// payload.
> + nvdm_payload_size: u32,
> + reserved: u32,
> +}
> +
> +/// Static validation of [`QueueElementHeader`] against its bindings type. Kept in a sub-module to
> +/// stay out of the way of the rest of the code.
If you just want "grouping" then
const _: () = {
};
is usually the way and you don't need `super::*` with it.
> +mod queue_element_header_validation {
> + use super::*;
> +
> + // Offsets of `QueueElementHeader`'s fields
> +
> + static_assert!(
> + core::mem::offset_of!(QueueElementHeader, mctp_magic)
Perhaps import offset_of in the scope?
> + == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, mctpMagic)
> + );
> + static_assert!(
> + core::mem::offset_of!(QueueElementHeader, mctp_payload_size)
> + == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, mctpPayloadSize)
> + );
> + static_assert!(
> + core::mem::offset_of!(QueueElementHeader, mctp_header)
> + == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, mctpHeader)
> + );
> + static_assert!(
> + core::mem::offset_of!(QueueElementHeader, nvdm_header)
> + == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, nvdmHeader)
> + );
> +
> + /// The `noEncryption` member of the union of `GSP_MSG_QUEUE_ELEMENT`, which holds the two
> + /// trailing fields of [`QueueElementHeader`].
> + // Using `allow` instead of `expect` as rustc 1.85 ignores uses from `static_assert!` and
> + // reports this as dead code.
> + #[allow(dead_code)]
> + type QueueElementNoEncryption = r000_00::GSP_MSG_QUEUE_ELEMENT__bindgen_ty_1__bindgen_ty_2;
> +
> + // Offsets of fields under [`QueueElementNoEncryption`] within `GSP_MSG_QUEUE_ELEMENT`.
> +
> + // Using `allow` instead of `expect` as rustc 1.85 ignores uses from `static_assert!` and
> + // reports this as dead code.
> + #[allow(dead_code)]
> + const QUEUE_ELEMENT_NO_ENCRYPTION_OFFSET: usize =
> + core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, __bindgen_anon_1)
> + + core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT__bindgen_ty_1, noEncryption);
> +
> + static_assert!(
> + core::mem::offset_of!(QueueElementHeader, nvdm_payload_size)
> + == QUEUE_ELEMENT_NO_ENCRYPTION_OFFSET
> + + core::mem::offset_of!(QueueElementNoEncryption, nvdmPayloadSize)
> + );
> + static_assert!(
> + core::mem::offset_of!(QueueElementHeader, reserved)
> + == QUEUE_ELEMENT_NO_ENCRYPTION_OFFSET
> + + core::mem::offset_of!(QueueElementNoEncryption, reserved)
> + );
> +
> + // Ensure the size of `QueueElementHeader` matches the `noEncryption` layout.
> +
> + static_assert!(
> + size_of::<QueueElementHeader>()
> + == QUEUE_ELEMENT_NO_ENCRYPTION_OFFSET + size_of::<QueueElementNoEncryption>()
> + );
> +}
> +
> +#[expect(dead_code)]
> +impl QueueElementHeader {
> + /// Creates the queue element header of an element carrying a message of NVDM type `nvdm_type`
> + /// and `message_len` bytes, message header included.
> + ///
> + /// # Errors
> + ///
> + /// - `EOVERFLOW` if a length does not fit its 32-bit field.
> + pub(crate) fn init(nvdm_type: NvdmType, message_len: usize) -> impl Init<Self, Error> {
> + try_init!(QueueElementHeader {
> + mctp_magic: MCTP_MAGIC,
> + mctp_payload_size: size_of::<Self>()
> + .checked_add(message_len)
> + .ok_or(EOVERFLOW)?
> + .try_into()
> + .map_err(|_| EOVERFLOW)?,
> + mctp_header: MctpHeader::single_packet(),
> + nvdm_header: NvdmHeader::new(nvdm_type),
> + nvdm_payload_size: message_len.try_into().map_err(|_| EOVERFLOW)?,
> + reserved: 0,
> + })
> + }
> +
> + /// Returns the length of the whole element, this header included.
> + pub(crate) fn element_len(&self) -> usize {
> + num::u32_as_usize(self.mctp_payload_size)
> + }
> +
> + /// Returns the length of the message following this header, message header included.
> + pub(crate) fn message_len(&self) -> usize {
> + num::u32_as_usize(self.nvdm_payload_size)
> + }
> +
> + /// Returns the number of slots (i.e. memory pages) used by this element.
> + pub(crate) fn element_count(&self) -> u32 {
> + self.mctp_payload_size.div_ceil(cv!(GSP_PAGE_SIZE))
> + }
> +
> + /// Returns the NVDM type of the message following this header, or `EINVAL` if it is not a
> + /// known one.
> + pub(crate) fn nvdm_type(&self) -> Result<NvdmType> {
> + self.nvdm_header.nvdm_type()
> + }
> +
> + /// Validates the framing of the element.
> + ///
> + /// # Errors
> + ///
> + /// - `EIO` if the magic, the MCTP version or the NVDM vendor is wrong, or if the element
> + /// length is smaller than this header and the message together, or larger than the
> + /// maximum element size.
> + pub(crate) fn validate(&self) -> Result {
> + if self.mctp_magic != MCTP_MAGIC
> + || !self.mctp_header.has_expected_version()
> + || !self.nvdm_header.has_nvidia_vendor()
> + {
> + return Err(EIO);
> + }
> +
> + let element_len = self.element_len();
> + if element_len < size_of::<Self>().saturating_add(self.message_len())
> + || element_len > GSP_MSG_QUEUE_ELEMENT_SIZE_MAX
> + {
> + return Err(EIO);
> + }
> +
> + Ok(())
> + }
> +}
> +
> +// SAFETY: All fields are integer types or transparent wrappers over one, with no padding.
> +unsafe impl AsBytes for QueueElementHeader {}
Use zerocopy derives instead perhaps?
Best,
Gary
> +
> +// SAFETY: All fields are integer types or transparent wrappers over one, for which all bit
> +// patterns are valid.
> +unsafe impl FromBytes for QueueElementHeader {}
> +
> bounded_enum! {
> /// Commands of the GMC API.
> #[derive(Debug, Clone, Copy, PartialEq, Eq)]
> diff --git a/drivers/gpu/nova-core/mctp.rs b/drivers/gpu/nova-core/mctp.rs
> index f62e79f56b05..e4d0639cde0f 100644
> --- a/drivers/gpu/nova-core/mctp.rs
> +++ b/drivers/gpu/nova-core/mctp.rs
> @@ -28,6 +28,10 @@ pub(crate) enum NvdmType with TryFrom<Bounded<u32, 8>> {
> Cot = 0x14,
> /// FSP command response.
> FspResponse = 0x15,
> + /// RPC message to or from GSP-RM.
> + RmRpc = 0x25,
> + /// GMC (GPU Management Controller) API message to or from GSP-RM.
> + GmcApi = 0x26,
> }
> }
>
> @@ -67,6 +71,11 @@ pub(crate) fn single_packet() -> Self {
> pub(crate) fn is_single_packet(self) -> bool {
> self.som().into_bool() && self.eom().into_bool()
> }
> +
> + /// Returns `true` if this MCTP header carries the version that this driver uses.
> + pub(crate) fn has_expected_version(self) -> bool {
> + u32::from(self.version()) == Self::VERSION
> + }
> }
>
> /// MCTP message type for PCI vendor-defined messages.
> @@ -93,10 +102,17 @@ pub(crate) fn new(nvdm_type: NvdmType) -> Self {
> .with_nvdm_type(nvdm_type)
> }
>
> - /// Validates this header against the expected NVIDIA NVDM format and type.
> - pub(crate) fn validate(self, expected_type: NvdmType) -> bool {
> + /// Returns `true` if this NVDM header belongs to a PCI vendor-defined message from NVIDIA.
> + ///
> + /// The GPU firmware only ever sends such messages, so a mismatch is a sign of corruption.
> + pub(crate) fn has_nvidia_vendor(self) -> bool {
> u8::from(self.msg_type()) == MSG_TYPE_VENDOR_PCI
> && u16::from(self.vendor_id()) == Vendor::NVIDIA.as_raw()
> + }
> +
> + /// Validates this header against the expected NVIDIA NVDM format and type.
> + pub(crate) fn validate(self, expected_type: NvdmType) -> bool {
> + self.has_nvidia_vendor()
> && matches!(self.nvdm_type(), Ok(nvdm_type) if nvdm_type == expected_type)
> }
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-27 14:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27 14:04 [PATCH 0/4] gpu: nova-core: gsp: preparatory patches for the r000 firmware Alexandre Courbot
2026-11-27 14:04 ` [PATCH 1/4] gpu: nova-core: gsp: add the r000 queue element header Alexandre Courbot
2026-11-27 14:52 ` Gary Guo
2026-11-27 14:04 ` [PATCH 2/4] gpu: nova-core: gsp: rename and move the static configuration type Alexandre Courbot
2026-11-27 14:04 ` [PATCH 3/4] gpu: nova-core: gsp: return the static GPU configuration from boot Alexandre Courbot
2026-11-27 14:04 ` [PATCH 4/4] gpu: nova-core: gsp: add the short name and GID to the GSP_INIT reply Alexandre Courbot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®