mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] gpu: nova-core: gsp: cmdq: preparatory patches for r000 and vGPU
@ 2026-11-16 15:06 Alexandre Courbot
  2026-11-16 15:06 ` [PATCH 1/2] gpu: nova-core: gsp: cmdq: let GMC commands set their completion timeout Alexandre Courbot
  2026-11-16 15:06 ` [PATCH 2/2] gpu: nova-core: gsp: cmdq: support GMC replies without payload Alexandre Courbot
  0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Courbot @ 2026-11-16 15:06 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

A couple more command queue patches for the r000 and vGPU work. Patch 1
allows commands to specify a custom timeout, as some commands can take
longer than the default 5 seconds on occasion.

Patch 2 adds support for GMC commands that expect a return status, but
no returned payload.

Based on drm-rust-next.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
Alexandre Courbot (2):
      gpu: nova-core: gsp: cmdq: let GMC commands set their completion timeout
      gpu: nova-core: gsp: cmdq: support GMC replies without payload

 drivers/gpu/nova-core/gsp/cmdq.rs     |  5 +++--
 drivers/gpu/nova-core/gsp/cmdq/gmc.rs | 31 ++++++++++++++++++++++++-------
 drivers/gpu/nova-core/gsp/cmdq/rpc.rs |  2 +-
 3 files changed, 28 insertions(+), 10 deletions(-)
---
base-commit: 8045d0e7d208ad389a387f1407ce0db9070805af
change-id: 20261116-cmdq-timeout-6cf40c6afafc

Best regards,
--  
Alexandre Courbot <acourbot@nvidia.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] gpu: nova-core: gsp: cmdq: let GMC commands set their completion timeout
  2026-11-16 15:06 [PATCH 0/2] gpu: nova-core: gsp: cmdq: preparatory patches for r000 and vGPU Alexandre Courbot
@ 2026-11-16 15:06 ` Alexandre Courbot
  2026-11-16 15:06 ` [PATCH 2/2] gpu: nova-core: gsp: cmdq: support GMC replies without payload Alexandre Courbot
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Courbot @ 2026-11-16 15:06 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

Every wait on the message queue uses `Cmdq::RECEIVE_TIMEOUT`, but some
GMC commands (notably r000's GSP_INIT, and a few vGPU commands) might
take longer to complete.

Make the timeout a parameter of `await_msg_with`, and take it from a new
`CommandToGsp::COMPLETION_TIMEOUT` associated constant when waiting for
the reply to a GMC command. The constant defaults to
`Cmdq::RECEIVE_TIMEOUT`, so existing commands are unaffected.

No functional change intended.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/nova-core/gsp/cmdq.rs     |  5 +++--
 drivers/gpu/nova-core/gsp/cmdq/gmc.rs | 14 +++++++++-----
 drivers/gpu/nova-core/gsp/cmdq/rpc.rs |  2 +-
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
index 8d34acaef9ea..ad37c979d8b7 100644
--- a/drivers/gpu/nova-core/gsp/cmdq.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq.rs
@@ -686,7 +686,7 @@ fn consume_element<R>(
     /// Consumes messages from the queue until a message that satisfies `f` is encountered, and
     /// returns the result of `f`.
     ///
-    /// The message is waited for up to [`Cmdq::RECEIVE_TIMEOUT`] from the call.
+    /// The message is waited for up to `timeout` from the call.
     ///
     /// `f` is expected to return `Ok(Some(_))` with the result to return to the caller, and
     /// `Ok(None)` to signal that the received message was not the one expected (such messages are
@@ -700,9 +700,10 @@ fn consume_element<R>(
     /// - Any error returned by `f`.
     fn await_msg_with<R>(
         &mut self,
+        timeout: Delta,
         f: impl Fn(GspParsedMessage<'_>) -> Result<Option<R>>,
     ) -> Result<R> {
-        let deadline = Instant::<Monotonic>::now() + Cmdq::RECEIVE_TIMEOUT;
+        let deadline = Instant::<Monotonic>::now() + timeout;
         loop {
             let remaining = deadline - Instant::<Monotonic>::now();
             if remaining.is_negative() {
diff --git a/drivers/gpu/nova-core/gsp/cmdq/gmc.rs b/drivers/gpu/nova-core/gsp/cmdq/gmc.rs
index 04033c64ca72..512a327a1c89 100644
--- a/drivers/gpu/nova-core/gsp/cmdq/gmc.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq/gmc.rs
@@ -6,6 +6,7 @@
 use kernel::{
     device,
     prelude::*,
+    time::Delta,
     transmute::{
         AsBytes,
         FromBytes, //
@@ -61,6 +62,9 @@ pub(crate) trait CommandToGsp {
     /// value).
     const MAX_REPLY_SIZE: u32;
 
+    /// Time given to the GSP to complete this command once it is sent.
+    const COMPLETION_TIMEOUT: Delta = Cmdq::RECEIVE_TIMEOUT;
+
     /// Error type returned by [`CommandToGsp::init`].
     type InitError;
 
@@ -283,8 +287,8 @@ impl Cmdq<'_> {
     ///
     /// - `EMSGSIZE` if the command does not fit in a single command queue element.
     /// - `ETIMEDOUT` if space does not become available to send the command, or if the reply does
-    ///   not arrive within [`Self::RECEIVE_TIMEOUT`] of the send, however many events arrive
-    ///   while waiting.
+    ///   not arrive within [`CommandToGsp::COMPLETION_TIMEOUT`] of the send, however many events
+    ///   arrive while waiting.
     /// - `EIO` if the variable payload requested by the command has not been entirely
     ///   written to by its [`CommandToGsp::init_variable_payload`] method, or if a message fails
     ///   framing or checksum validation.
@@ -350,7 +354,7 @@ fn send_gmc_command<C>(&mut self, command: C) -> Result<u32>
     }
 
     /// Receives the reply of type `C::Reply` to the command sent with sequence number `seq`,
-    /// waiting up to [`Cmdq::RECEIVE_TIMEOUT`] from the call.
+    /// waiting up to [`CommandToGsp::COMPLETION_TIMEOUT`] from the call.
     ///
     /// Any GMC event that arrives first is passed to `on_event`, and any RPC message is logged.
     /// Neither extends the deadline.
@@ -376,8 +380,7 @@ fn await_gmc_reply<C: CommandToGsp>(
     {
         let dev = self.dev;
 
-        // TODO: replace `u32` with `NvStatus` once it lands.
-        self.await_msg_with(|message| -> Result<Option<Result<C::Reply, u32>>> {
+        self.await_msg_with(C::COMPLETION_TIMEOUT, |message| {
             let gmc_message = match message {
                 GspParsedMessage::Gmc(gmc_message) => gmc_message,
                 _ => {
@@ -386,6 +389,7 @@ fn await_gmc_reply<C: CommandToGsp>(
                 }
             };
 
+            // TODO: use `NvStatus` instead of `u32` for status once it lands.
             let status = match gmc_message.reply_status(C::COMMAND, seq) {
                 Some(status) => status,
                 // Reply to another command, e.g. one that timed out earlier.
diff --git a/drivers/gpu/nova-core/gsp/cmdq/rpc.rs b/drivers/gpu/nova-core/gsp/cmdq/rpc.rs
index 10d3f68b2f61..012f3c82e7c5 100644
--- a/drivers/gpu/nova-core/gsp/cmdq/rpc.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq/rpc.rs
@@ -401,6 +401,6 @@ fn await_rpc_msg<M: MessageFromGsp>(&mut self) -> Result<M>
             }
         };
 
-        self.await_msg_with(f)
+        self.await_msg_with(Cmdq::RECEIVE_TIMEOUT, f)
     }
 }

-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] gpu: nova-core: gsp: cmdq: support GMC replies without payload
  2026-11-16 15:06 [PATCH 0/2] gpu: nova-core: gsp: cmdq: preparatory patches for r000 and vGPU Alexandre Courbot
  2026-11-16 15:06 ` [PATCH 1/2] gpu: nova-core: gsp: cmdq: let GMC commands set their completion timeout Alexandre Courbot
@ 2026-11-16 15:06 ` Alexandre Courbot
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Courbot @ 2026-11-16 15:06 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

Some GMC commands are answered with a status and no payload. Their
reply type cannot be `NoReply`, which marks commands that the GSP does
not answer at all.

Implement `MessageFromGsp` for `()` so these commands can use it as
their reply type.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/nova-core/gsp/cmdq/gmc.rs | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/nova-core/gsp/cmdq/gmc.rs b/drivers/gpu/nova-core/gsp/cmdq/gmc.rs
index 512a327a1c89..f4311593e360 100644
--- a/drivers/gpu/nova-core/gsp/cmdq/gmc.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq/gmc.rs
@@ -3,6 +3,8 @@
 
 //! Support for the GMC (GPU Management Controller) API message type on the GSP command queue.
 
+use core::convert::Infallible;
+
 use kernel::{
     device,
     prelude::*,
@@ -53,8 +55,8 @@ pub(crate) trait CommandToGsp {
     /// after the GMC API header.
     type Command: FromBytes + AsBytes;
 
-    /// Type of the reply expected from the GSP, or [`NoReply`] for commands that don't have a
-    /// reply.
+    /// Type of the reply expected from the GSP. Can be [`NoReply`] for commands that don't have a
+    /// reply, or `()` for commands that only expect a status code without a reply payload.
     type Reply;
 
     /// Largest reply this command accepts, in bytes. Zero for commands that the GSP does not
@@ -178,6 +180,17 @@ fn read(
     ) -> Result<Self, Self::InitError>;
 }
 
+/// Reply type for commands that the GSP answers with a status and no payload.
+impl MessageFromGsp for () {
+    type InitError = Infallible;
+
+    fn read(
+        _payload: &mut SBufferIter<core::array::IntoIter<&[u8], 2>>,
+    ) -> Result<Self, Self::InitError> {
+        Ok(())
+    }
+}
+
 /// A GMC message ready to be processed from the message queue.
 pub(crate) struct GmcMessage<'a> {
     // Reference to the GMC API header of the message.

-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-16 15:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 15:06 [PATCH 0/2] gpu: nova-core: gsp: cmdq: preparatory patches for r000 and vGPU Alexandre Courbot
2026-11-16 15:06 ` [PATCH 1/2] gpu: nova-core: gsp: cmdq: let GMC commands set their completion timeout Alexandre Courbot
2026-11-16 15:06 ` [PATCH 2/2] gpu: nova-core: gsp: cmdq: support GMC replies without payload 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®