Re: [PATCH v3 09/33] gpu: nova-core: add GMC API message types

From: Timur Tabi

Date: Fri Sep 18 2026 - 17:45:14 EST


On Thu, 2026-09-17 at 18:06 -0700, John Hubbard wrote:
>
> +#[repr(C)]
> +pub(crate) struct QueueElementHeader {
> +    magic: u32,
> +    /// Length of the whole element: the queue element header, the message header and the
> +    /// payload. Open RM calls it `mctpPayloadSize`.
> +    element_len: u32,
> +    mctp: MctpHeader,
> +    nvdm: NvdmHeader,
> +    /// Length of the message header and the payload, the queue element header excluded. Open
> RM
> +    /// calls it `nvdmPayloadSize`.
> +    message_len: u32,
> +    reserved: u32,
> +}
> +
> +static_assert!(
> +    core::mem::offset_of!(QueueElementHeader, magic)
> +        == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, mctpMagic)
> +);
> +static_assert!(
> +    core::mem::offset_of!(QueueElementHeader, element_len)
> +        == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, mctpPayloadSize)
> +);
> +static_assert!(
> +    core::mem::offset_of!(QueueElementHeader, mctp)
> +        == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, mctpHeader)
> +);
> +static_assert!(
> +    core::mem::offset_of!(QueueElementHeader, nvdm)
> +        == core::mem::offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, nvdmHeader)
> +);

Can you also static_assert! on the size of the struct?

> +    /// Returns the length of the payload that follows a message header of
> +    /// Returns the length of the payload that follows a message header of
> `message_header_len`
> +    /// bytes.
> +    fn payload_len(&self, message_header_len: usize) -> usize {
> +        num::u32_as_usize(self.message_len).saturating_sub(message_header_len)

Is it possible for message_header_len to exceed self.message_len? If so, then I think that
warrants a comment. If not, well, then that should have a comment, too.