[PATCH v4 11/17] gpu: nova-core: return ENOMSG for an unmatched GSP message
From: John Hubbard
Date: Sat Sep 12 2026 - 00:47:41 EST
The GSP posts unsolicited events on the same queue as command replies,
so a receive that asks for one message type has to report that the
message at the queue head was a different one.
That case returned ERANGE, which means a value outside a valid range and
says nothing about a message.
Return ENOMSG, no message of the desired type, instead.
Suggested-by: Gary Guo <gary@xxxxxxxxxxx>
Suggested-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
Assisted-by: LLM
Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
---
drivers/gpu/nova-core/gsp/cmdq.rs | 6 +++---
drivers/gpu/nova-core/gsp/commands.rs | 2 +-
drivers/gpu/nova-core/gsp/sequencer.rs | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
index 855c5a708525..45c3c3aea8f9 100644
--- a/drivers/gpu/nova-core/gsp/cmdq.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq.rs
@@ -588,7 +588,7 @@ pub(crate) fn send_command<M>(&self, bar: Bar0<'_>, command: M) -> Result<M::Rep
loop {
match inner.receive_msg::<M::Reply>(Self::RECEIVE_TIMEOUT) {
Ok(reply) => break Ok(reply),
- Err(ERANGE) => continue,
+ Err(ENOMSG) => continue,
Err(e) => break Err(e),
}
}
@@ -852,7 +852,7 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {
/// - `ETIMEDOUT` if `timeout` has elapsed before any message becomes available.
/// - `EIO` if the queue is poisoned or the message fails framing or checksum validation (see
/// [`Self::wait_for_msg`]), or if the matched message is too short for `M::Message`.
- /// - `ERANGE` if the message was not the awaited reply.
+ /// - `ENOMSG` if the message was not the awaited reply.
///
/// Error codes returned by [`MessageFromGsp::read`] are propagated as-is.
fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M>
@@ -890,7 +890,7 @@ fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M>
} else {
self.log_event(function, seq);
- Err(ERANGE)
+ Err(ENOMSG)
};
// Advance the read pointer past this message.
diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/gsp/commands.rs
index e087c9e8c35c..d1c80cf3c452 100644
--- a/drivers/gpu/nova-core/gsp/commands.rs
+++ b/drivers/gpu/nova-core/gsp/commands.rs
@@ -191,7 +191,7 @@ pub(crate) fn wait_gsp_init_done(cmdq: &Cmdq<'_>) -> Result {
loop {
match cmdq.receive_msg::<GspInitDone>(Cmdq::RECEIVE_TIMEOUT) {
Ok(_) => break Ok(()),
- Err(ERANGE) => continue,
+ Err(ENOMSG) => continue,
Err(e) => break Err(e),
}
}
diff --git a/drivers/gpu/nova-core/gsp/sequencer.rs b/drivers/gpu/nova-core/gsp/sequencer.rs
index dae34c11eb05..1782ed7d7ca6 100644
--- a/drivers/gpu/nova-core/gsp/sequencer.rs
+++ b/drivers/gpu/nova-core/gsp/sequencer.rs
@@ -346,7 +346,7 @@ pub(crate) fn run(
let seq_info = loop {
match cmdq.receive_msg::<GspSequence>(Cmdq::RECEIVE_TIMEOUT) {
Ok(seq_info) => break seq_info,
- Err(ERANGE) => continue,
+ Err(ENOMSG) => continue,
Err(e) => return Err(e),
}
};
--
2.55.0