Re: [PATCH v5 09/14] gpu: nova-core: gsp: cmdq: split the transport part of the receive path

From: Alexandre Courbot

Date: Mon Oct 26 2026 - 21:09:09 EST


On Wed Oct 21, 2026 at 10:56 AM JST, Eliot Courtney wrote:
> On Tue Oct 20, 2026 at 7:08 PM JST, Alexandre Courbot wrote:
>> `receive_msg` currently handles both the transport and RPC layers.
>> Retire it and split its logic between the new `consume_element`, a
>> transport-level method which passes the parsed message contents to a
>> closure before advancing the CPU read pointer past it, and the
>> already-existing `await_msg`, which calls `consume_element` with a
>> closure matching the RPC message.
>>
>> This introduces a small behavioral change: a matched RPC message that is
>> too short to contain the message component itself no longer stalls the
>> queue. This behavior is justified because it fixes an inconsistency:
>> unmatched RPC messages were always skipped, whereas matched RPC messages
>> could block the queue if they were too short. While a misconstructed RPC
>> message is a problem, it is not a fatal queue error as long as the
>> transport framing and checksum are valid.
>>
>> Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
>> ---
>
> [...]
>
>> - /// Receive a message from the GSP.
>> + /// Wait for the next element on the message queue, pass it to `f`, advance the read pointer
>> + /// past the message, and returns the result of `f`.
>> ///
>> - /// A message whose function code is `M::FUNCTION` is decoded and returned. Any other message
>> - /// is logged as an event.
>> - ///
>> - /// The read pointer is always advanced past the message, regardless of whether it matched.
>> + /// The read pointer advances regardless of whether `f` succeeds or not.
>> ///
>> /// # Errors
>> ///
>> /// - `ETIMEDOUT` if `timeout` has elapsed before any message becomes available.
>> - /// - `EIO` if a message fails framing or checksum validation.
>> - /// - `ENOMSG` if the message was not the awaited reply.
>> + /// - `EIO` if a message fails framing or checksum validation. In this case, the read pointer
>> + /// does not advance and the queue is stalled. This is a fatal error.
>> ///
>> - /// Error codes returned by [`MessageFromGsp::read`] are propagated as-is.
>> - fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M>
>> - where
>> - // This allows all error types, including `Infallible`, to be used for `M::InitError`.
>> - Error: From<M::InitError>,
>> - {
>> + /// If an error is returned, then `f` has not been called.
>
> optional nit: Clarify in a comment that w.r.t. `EIO` and `f` not being
> called, that only applies for the outermost Err. i.e., we do have
> R = Result<>, so we have Result<Result<>> but we're only talking about
> the outer (transport) Result here. Maybe one way to clarify this is
> that `R` contains the output of the message layer and may itself
> be a Result<>, and this function returns a Result for the transport
> layer. Not sure of the best way to phrase it but you know what I mean.

Given that `R` is produced by `f` this is more or less explicit I think,
but I'll add the following to remove all ambiguity:

/// Note that `R` may itself be a `Result`. In this case, the above only applies to the outer
/// `Result` returned by this method.