An element whose framing is valid but whose NVDM type is neither RPC nor
GMC currently fails the receive with EIO and stays at the head of the
queue, which stalls it for good.

Its length is known, so log it and move past it instead, as OpenRM does.

Signed-off-by: Alexandre Courbot <[email protected]>
---
 Documentation/gpu/nova/core/interrupts.rst |  8 ++++----
 drivers/gpu/nova-core/gsp/cmdq.rs          | 24 ++++++++++++------------
 drivers/gpu/nova-core/gsp/fw.rs            |  5 +++++
 3 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/Documentation/gpu/nova/core/interrupts.rst 
b/Documentation/gpu/nova/core/interrupts.rst
index a155c0532cfc..bb3509f636a3 100644
--- a/Documentation/gpu/nova/core/interrupts.rst
+++ b/Documentation/gpu/nova/core/interrupts.rst
@@ -581,16 +581,16 @@ reply or an unsolicited event:
 
 GMC replies match on command ID and sequence number, and GMC events arriving
 during a wait go to the caller's handler; unclaimed replies and unknown command
-IDs are logged at warning level, and other GMC events are dropped.
+IDs are logged at warning level, and other GMC events are dropped. Elements of
+unsupported NVDM types are also logged at warning level and dropped.
 
 A command's reply must carry the RPC sequence number that nova-core wrote into
 the command, as well as its function code to be considered a reply to that
 command. An unsolicited event answers no command, so a caller awaiting one
 matches on the function code alone.
 
-The read pointer advances past every valid element, whether it matched or was
-an event. An element that fails framing or message-header validation, or
-carries an unsupported NVDM type, stays at the queue head and every later
+The read pointer advances past every element that passes framing and
+message-header validation; otherwise it stays at the queue head and every later
 receive fails with ``EIO`` until the device is reset.
 
 The polling path and the IRQ thread both read the queue under the command-queue
diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs 
b/drivers/gpu/nova-core/gsp/cmdq.rs
index f6bede6a77e7..f526558d4d59 100644
--- a/drivers/gpu/nova-core/gsp/cmdq.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq.rs
@@ -57,7 +57,10 @@
         GSP_PAGE_SHIFT,
         GSP_PAGE_SIZE, //
     },
-    mctp::NvdmType,
+    mctp::{
+        NvdmHeader,
+        NvdmType, //
+    },
     num, //
 };
 
@@ -432,6 +435,8 @@ enum GspParsedMessage<'a> {
     Rpc(rpc::RpcMessage<'a>),
     /// A [GMC message](gmc::GmcMessage).
     Gmc(gmc::GmcMessage<'a>),
+    /// A message of a type that the queue does not use.
+    Other(NvdmHeader),
 }
 
 impl GspParsedMessage<'_> {
@@ -440,6 +445,9 @@ fn log(&self, dev: &device::Device) {
         match self {
             GspParsedMessage::Rpc(rpc) => rpc.log(dev),
             GspParsedMessage::Gmc(gmc) => gmc.log(dev),
+            GspParsedMessage::Other(nvdm_header) => {
+                dev_warn!(dev, "GSP receive: ignoring {:?}\n", nvdm_header);
+            }
         }
     }
 }
@@ -645,9 +653,8 @@ fn wait_for_msg(&self, timeout: Delta) -> 
Result<GspMessage<'_>> {
     /// # Errors
     ///
     /// - `ETIMEDOUT` if `timeout` has elapsed before any message becomes 
available.
-    /// - `EIO` if a message fails framing validation, or carries an NVDM type 
that the queue does
-    ///   not use. In this case, the read pointer does not advance and the 
queue is stalled. This
-    ///   is a fatal error.
+    /// - `EIO` if a message fails framing validation. In this case, the read 
pointer does not
+    ///   advance and the queue is stalled. This is a fatal error.
     ///
     /// If an error is returned, then `f` has not been called.
     ///
@@ -669,14 +676,7 @@ fn consume_element<R>(
             Ok(NvdmType::GmcApi) => {
                 GspParsedMessage::Gmc(gmc::GmcMessage::parse(self.dev, 
message)?)
             }
-            nvdm_type => {
-                dev_err!(
-                    &self.dev,
-                    "GSP receive: unexpected NVDM type {:?}\n",
-                    nvdm_type
-                );
-                return Err(EIO);
-            }
+            _ => GspParsedMessage::Other(message.header.nvdm_header()),
         };
 
         let res = f(message);
diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw.rs
index a576fc86708c..5fd8cff209df 100644
--- a/drivers/gpu/nova-core/gsp/fw.rs
+++ b/drivers/gpu/nova-core/gsp/fw.rs
@@ -665,6 +665,11 @@ pub(crate) fn element_count(&self) -> u32 {
         self.mctp_payload_size.div_ceil(cv!(GSP_PAGE_SIZE))
     }
 
+    /// Returns the NVDM header of the message following this header.
+    pub(crate) fn nvdm_header(&self) -> NvdmHeader {
+        self.nvdm_header
+    }
+
     /// Returns the NVDM type of the message following this header, or 
`EINVAL` if it is not a
     /// known one.
     pub(crate) fn nvdm_type(&self) -> Result<NvdmType> {

-- 
2.56.1

Reply via email to