mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Courbot <acourbot@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>,
	Alice Ryhl <aliceryhl@google.com>,
	 David Airlie <airlied@gmail.com>,
	Simona Vetter <simona@ffwll.ch>,
	 Benno Lossin <lossin@kernel.org>, Gary Guo <gary@garyguo.net>
Cc: John Hubbard <jhubbard@nvidia.com>,
	 Alistair Popple <apopple@nvidia.com>,
	Timur Tabi <ttabi@nvidia.com>,
	 Eliot Courtney <ecourtney@nvidia.com>,
	Zhi Wang <zhiw@nvidia.com>,
	 nova-gpu@lists.linux.dev, linux-kernel@vger.kernel.org,
	 rust-for-linux@vger.kernel.org,
	Alexandre Courbot <acourbot@nvidia.com>
Subject: [PATCH v2 5/5] gpu: nova-core: gsp: cmdq: expose the sequence number of sent commands
Date: Mon, 02 Nov 2026 21:09:56 +0900	[thread overview]
Message-ID: <20261102-r000-cmdq-prep-v2-5-c2c2b69bdec0@nvidia.com> (raw)
In-Reply-To: <20261102-r000-cmdq-prep-v2-0-c2c2b69bdec0@nvidia.com>

The r000 firmware requires matching the sequence number of sent commands
with the responses received from the GSP. Make `send_command_element`
return the sequence number to that end, and ignore it for now.

No functional change intended.

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

diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
index 33cb9174c1e6..65f25d3c4d98 100644
--- a/drivers/gpu/nova-core/gsp/cmdq.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq.rs
@@ -524,27 +524,30 @@ impl CmdqInner<'_> {
     /// Allocate enough space on the command queue to store `command`, initialize it with
     /// [`CommandElement::write`], and send the command to the GSP.
     ///
+    /// Returns the sequence number of the sent element.
+    ///
     /// # Errors
     ///
     /// - `EMSGSIZE` if the command exceeds the maximum queue element size.
     /// - `ETIMEDOUT` if space does not become available within the timeout.
     ///
     /// Error codes returned by [`CommandElement::write`] are returned as-is.
-    fn send_command_element<E: CommandElement>(&mut self, command: E) -> Result {
+    fn send_command_element<E: CommandElement>(&mut self, command: E) -> Result<u32> {
         let size_in_bytes = command.size();
+        let seq = self.seq;
         let mut dst = self
             .gsp_mem
             .allocate_command(size_in_bytes, Self::ALLOCATE_TIMEOUT)?;
 
         // Fill the header.
-        let msg_element_init = GspMsgElement::init(self.seq, size_in_bytes);
+        let msg_element_init = GspMsgElement::init(seq, size_in_bytes);
         // SAFETY: `dst.header` is a valid reference, and is not touched if the initializer fails.
         unsafe {
             pin_init::raw_try_init(core::ptr::from_mut(dst.header), msg_element_init)?;
         }
 
         // Write the message payload.
-        command.write(self.dev, self.seq, &mut dst)?;
+        command.write(self.dev, seq, &mut dst)?;
 
         // Compute checksum now that the whole message is ready.
         dst.header
@@ -559,7 +562,7 @@ fn send_command_element<E: CommandElement>(&mut self, command: E) -> Result {
         self.seq += 1;
         self.gsp_mem.advance_cpu_write_ptr(elem_count);
 
-        Ok(())
+        Ok(seq)
     }
 
     /// Wait for a message to become available on the message queue.
diff --git a/drivers/gpu/nova-core/gsp/cmdq/rpc.rs b/drivers/gpu/nova-core/gsp/cmdq/rpc.rs
index 2c52ec78871b..36cba7c28d3e 100644
--- a/drivers/gpu/nova-core/gsp/cmdq/rpc.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq/rpc.rs
@@ -354,7 +354,9 @@ fn send_rpc_command<M>(&mut self, command: M) -> Result
         Error: From<M::InitError>,
     {
         match SplitState::new(command)? {
-            SplitState::Single(command) => self.send_command_element(RpcCommandElement(command)),
+            SplitState::Single(command) => self
+                .send_command_element(RpcCommandElement(command))
+                .map(|_| ()),
             SplitState::Split(command, mut continuations) => {
                 self.send_command_element(RpcCommandElement(command))?;
 

-- 
2.56.0


  parent reply	other threads:[~2026-11-02 12:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 12:09 [PATCH v2 0/5] gpu: nova-core: gsp: cmdq: preparatory changes for r000 support Alexandre Courbot
2026-11-02 12:09 ` [PATCH v2 1/5] gpu: nova-core: fix stride of NV_PFSP_* registers Alexandre Courbot
2026-11-02 12:09 ` [PATCH v2 2/5] gpu: nova-core: regs: add msgq v2 BAR0 register declarations Alexandre Courbot
2026-11-02 12:09 ` [PATCH v2 3/5] gpu: nova-core: gsp: cmdq: ring the GSP doorbell from the queue memory Alexandre Courbot
2026-11-02 12:09 ` [PATCH v2 4/5] gpu: nova-core: gsp: cmdq: compute the queue regions from a count and a slot Alexandre Courbot
2026-11-02 13:27   ` Eliot Courtney
2026-11-02 12:09 ` Alexandre Courbot [this message]
2026-11-02 13:17   ` [PATCH v2 5/5] gpu: nova-core: gsp: cmdq: expose the sequence number of sent commands Eliot Courtney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261102-r000-cmdq-prep-v2-5-c2c2b69bdec0@nvidia.com \
    --to=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nova-gpu@lists.linux.dev \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=ttabi@nvidia.com \
    --cc=zhiw@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®