[PATCH 2/4] gpu: nova-core: gsp: rename and move the static configuration type
From: Alexandre Courbot
Date: Fri Nov 27 2026 - 09:04:48 EST
From: John Hubbard <jhubbard@xxxxxxxxxx>
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@xxxxxxxxxx>
Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
---
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