[PATCH 1/9] gpu: nova-core: gsp: warn if data remains after processing a message

Alexandre Courbot posted 9 patches 1 week, 4 days ago
There is a newer version of this series
[PATCH 1/9] gpu: nova-core: gsp: warn if data remains after processing a message
Posted by Alexandre Courbot 1 week, 4 days ago
Not processing the whole data from a received message is a strong
indicator of a bug - emit a warning when such cases are detected.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/nova-core/gsp/cmdq.rs | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
index dab73377c526..5ce85ee1ffce 100644
--- a/drivers/gpu/nova-core/gsp/cmdq.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq.rs
@@ -662,7 +662,17 @@ pub(crate) fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Resul
             let (cmd, contents_1) = M::Message::from_bytes_prefix(message.contents.0).ok_or(EIO)?;
             let mut sbuffer = SBufferIter::new_reader([contents_1, message.contents.1]);
 
-            M::read(cmd, &mut sbuffer).map_err(|e| e.into())
+            let res = M::read(cmd, &mut sbuffer).map_err(|e| e.into());
+
+            if res.is_ok() && !sbuffer.is_empty() {
+                dev_warn!(
+                    &self.dev,
+                    "GSP message {:?} has unprocessed data\n",
+                    function
+                );
+            }
+
+            res
         } else {
             Err(ERANGE)
         };

-- 
2.52.0
Re: [PATCH 1/9] gpu: nova-core: gsp: warn if data remains after processing a message
Posted by lyude@redhat.com 1 week ago
Reviewed-by: Lyude Paul <lyude@redhat.com>

On Mon, 2025-12-08 at 18:26 +0900, Alexandre Courbot wrote:
> Not processing the whole data from a received message is a strong
> indicator of a bug - emit a warning when such cases are detected.
> 
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
>  drivers/gpu/nova-core/gsp/cmdq.rs | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-
> core/gsp/cmdq.rs
> index dab73377c526..5ce85ee1ffce 100644
> --- a/drivers/gpu/nova-core/gsp/cmdq.rs
> +++ b/drivers/gpu/nova-core/gsp/cmdq.rs
> @@ -662,7 +662,17 @@ pub(crate) fn receive_msg<M:
> MessageFromGsp>(&mut self, timeout: Delta) -> Resul
>              let (cmd, contents_1) =
> M::Message::from_bytes_prefix(message.contents.0).ok_or(EIO)?;
>              let mut sbuffer = SBufferIter::new_reader([contents_1,
> message.contents.1]);
>  
> -            M::read(cmd, &mut sbuffer).map_err(|e| e.into())
> +            let res = M::read(cmd, &mut sbuffer).map_err(|e|
> e.into());
> +
> +            if res.is_ok() && !sbuffer.is_empty() {
> +                dev_warn!(
> +                    &self.dev,
> +                    "GSP message {:?} has unprocessed data\n",
> +                    function
> +                );
> +            }
> +
> +            res
>          } else {
>              Err(ERANGE)
>          };