summaryrefslogtreecommitdiff
path: root/drivers/gpu/nova-core/gsp/commands.rs
diff options
context:
space:
mode:
authorAlistair Popple <apopple@nvidia.com>2025-11-14 14:55:52 -0500
committerAlexandre Courbot <acourbot@nvidia.com>2025-11-15 21:54:18 +0900
commit13f85988d4fa31bda73a9504d71b10f7a14f1856 (patch)
tree5eb98bfad3afdd73bb9cd0c0cebd1ab6a4c74b53 /drivers/gpu/nova-core/gsp/commands.rs
parent0e7d572b4baa64c582dafc4af36cfc8a4c3c1252 (diff)
gpu: nova-core: gsp: Retrieve GSP static info to gather GPU information
After GSP initialization is complete, retrieve the static configuration information from GSP-RM. This information includes GPU name, capabilities, memory configuration, and other properties. On some GPU variants, it is also required to do this for initialization to complete. Signed-off-by: Alistair Popple <apopple@nvidia.com> Co-developed-by: Joel Fernandes <joelagnelf@nvidia.com> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com> Reviewed-by: Lyude Paul <lyude@redhat.com> [acourbot@nvidia.com: properly abstract the command's bindings, add relevant methods, make str_from_null_terminated return an Option, fix size of GPU name array.] Co-developed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Message-ID: <20251114195552.739371-14-joelagnelf@nvidia.com>
Diffstat (limited to 'drivers/gpu/nova-core/gsp/commands.rs')
-rw-r--r--drivers/gpu/nova-core/gsp/commands.rs56
1 files changed, 56 insertions, 0 deletions
diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/gsp/commands.rs
index b544603703d3..0425c65b5d6f 100644
--- a/drivers/gpu/nova-core/gsp/commands.rs
+++ b/drivers/gpu/nova-core/gsp/commands.rs
@@ -17,6 +17,7 @@ use kernel::{
};
use crate::{
+ driver::Bar0,
gsp::{
cmdq::{
Cmdq,
@@ -29,6 +30,7 @@ use crate::{
},
},
sbuffer::SBufferIter,
+ util,
};
/// The `GspSetSystemInfo` command.
@@ -169,3 +171,57 @@ pub(crate) fn wait_gsp_init_done(cmdq: &mut Cmdq) -> Result {
}
}
}
+
+/// The `GetGspStaticInfo` command.
+struct GetGspStaticInfo;
+
+impl CommandToGsp for GetGspStaticInfo {
+ const FUNCTION: MsgFunction = MsgFunction::GetGspStaticInfo;
+ type Command = GspStaticConfigInfo;
+ type InitError = Infallible;
+
+ fn init(&self) -> impl Init<Self::Command, Self::InitError> {
+ GspStaticConfigInfo::init_zeroed()
+ }
+}
+
+/// The reply from the GSP to the [`GetGspInfo`] command.
+pub(crate) struct GetGspStaticInfoReply {
+ gpu_name: [u8; 64],
+}
+
+impl MessageFromGsp for GetGspStaticInfoReply {
+ const FUNCTION: MsgFunction = MsgFunction::GetGspStaticInfo;
+ type Message = GspStaticConfigInfo;
+ type InitError = Infallible;
+
+ fn read(
+ msg: &Self::Message,
+ _sbuffer: &mut SBufferIter<array::IntoIter<&[u8], 2>>,
+ ) -> Result<Self, Self::InitError> {
+ Ok(GetGspStaticInfoReply {
+ gpu_name: msg.gpu_name_str(),
+ })
+ }
+}
+
+impl GetGspStaticInfoReply {
+ /// Returns the name of the GPU as a string, or `None` if the string given by the GSP was
+ /// invalid.
+ pub(crate) fn gpu_name(&self) -> Option<&str> {
+ util::str_from_null_terminated(&self.gpu_name)
+ }
+}
+
+/// Send the [`GetGspInfo`] command and awaits for its reply.
+pub(crate) fn get_gsp_info(cmdq: &mut Cmdq, bar: &Bar0) -> Result<GetGspStaticInfoReply> {
+ cmdq.send_command(bar, GetGspStaticInfo)?;
+
+ loop {
+ match cmdq.receive_msg::<GetGspStaticInfoReply>(Delta::from_secs(5)) {
+ Ok(info) => return Ok(info),
+ Err(ERANGE) => continue,
+ Err(e) => return Err(e),
+ }
+ }
+}