[PATCH v3 10/33] gpu: nova-core: add GMC send path
From: John Hubbard
Date: Thu Sep 17 2026 - 21:10:43 EST
The r000 boot protocol has the driver send GSP_INIT, the request that
carries the driver's configuration to GSP-RM, as a GMC command. GMC and
RPC commands share the command queue and the RPC sequence counter, and
a GMC element, unlike an RPC element, carries no checksum.
Nova-core's send path filled in RPC elements only, so there was no way
to send a GMC command.
Add a send path for GMC commands. It has no caller yet. A following
patch adds the GSP_INIT sender.
Assisted-by: LLM
Reviewed-by: Timur Tabi <ttabi@xxxxxxxxxx>
Reviewed-by: Zhi Wang <zhiw@xxxxxxxxxx>
Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
---
drivers/gpu/nova-core/gsp/cmdq.rs | 43 +++++++++++++++++++++++++++++++
drivers/gpu/nova-core/gsp/fw.rs | 1 -
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
index a1c9b7cce255..c0c3d8596b30 100644
--- a/drivers/gpu/nova-core/gsp/cmdq.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq.rs
@@ -54,6 +54,7 @@
driver::Bar0,
gsp::{
fw::{
+ GspGmcMsgElement,
GspMsgElement,
MsgFunction,
MsgqRxHeader,
@@ -749,6 +750,48 @@ fn poison(&self, reason: fmt::Arguments<'_>) -> Error {
EIO
}
+ /// Sends a GMC API request to the GSP.
+ ///
+ /// `payload` follows the GMC API header in the element, and `max_response_size` is the largest
+ /// response that the caller accepts. The request carries the next sequence number, which GSP-RM
+ /// copies into its response. The number is consumed even if the send fails.
+ ///
+ /// # Errors
+ ///
+ /// Errors from [`DmaGspMem::allocate_command`] are propagated as-is.
+ #[expect(dead_code)]
+ fn send_gmc(&mut self, command_id: u32, payload: &[u8], max_response_size: u32) -> Result {
+ let seq = self.seq;
+ self.seq = self.seq.wrapping_add(1);
+
+ let dst = self
+ .gsp_mem
+ .allocate_command::<GspGmcMsgElement>(payload.len(), Self::ALLOCATE_TIMEOUT)?;
+
+ let msg_element =
+ GspGmcMsgElement::init(command_id, u64::from(seq), payload.len(), max_response_size);
+ // SAFETY: `dst.header` is a valid reference, and not written if the initializer fails.
+ unsafe {
+ pin_init::raw_try_init(core::ptr::from_mut(dst.header), msg_element)?;
+ }
+
+ SBufferIter::new_writer([&mut dst.contents.0[..], &mut dst.contents.1[..]])
+ .write_all(payload)?;
+
+ dev_dbg!(
+ &self.dev,
+ "GSP GMC: send: seq# {}, command_id=0x{:x}, length=0x{:x}\n",
+ seq,
+ command_id,
+ dst.header.length(),
+ );
+
+ let elem_count = dst.header.element_count();
+ self.gsp_mem.advance_cpu_write_ptr(elem_count);
+
+ Ok(())
+ }
+
/// Wait for a message to become available on the message queue.
///
/// This works purely at the transport layer and does not interpret or validate the message
diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw.rs
index 1aca5ca82764..75bc3d66f71f 100644
--- a/drivers/gpu/nova-core/gsp/fw.rs
+++ b/drivers/gpu/nova-core/gsp/fw.rs
@@ -1058,7 +1058,6 @@ pub(crate) struct GspGmcMsgElement {
size_of::<GspGmcMsgElement>() == size_of::<QueueElementHeader>() + size_of::<GmcApiHeader>()
);
-#[expect(dead_code)]
impl GspGmcMsgElement {
/// Creates the queue element header and the GMC API header of a request that carries
/// `payload_size` bytes of payload.
--
2.55.0