All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alexandre Courbot" <acourbot@nvidia.com>
Cc: "Alice Ryhl" <aliceryhl@google.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Timur Tabi" <ttabi@nvidia.com>,
	"Eliot Courtney" <ecourtney@nvidia.com>,
	"Zhi Wang" <zhiw@nvidia.com>, <nova-gpu@lists.linux.dev>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 1/6] gpu: nova-core: gsp: add the r000 queue element header
Date: Tue, 01 Dec 2026 15:12:26 +0100	[thread overview]
Message-ID: <DN9GHJNGXGDN.4VNE2XPYV3F8@kernel.org> (raw)
In-Reply-To: <20261201-nova-r000-staging-v4-1-de45770a47a1@nvidia.com>

On Tue Dec 1, 2026 at 9:15 AM CET, Alexandre Courbot wrote:
> +    pub(crate) fn validate(&self) -> Result {
> +        if self.mctp_magic != Self::MCTP_MAGIC
> +            || !self.mctp_header.has_expected_version()
> +            || !self.nvdm_header.has_nvidia_vendor()
> +        {
> +            return Err(EIO);
> +        }
> +
> +        let element_len = self.element_len();
> +        if element_len < size_of::<Self>() + self.message_len()
> +            || element_len > GSP_MSG_QUEUE_ELEMENT_SIZE_MAX
> +        {
> +            return Err(EIO);
> +        }
> +
> +        Ok(())
> +    }
> +}

[...]

> -    /// Validates this header against the expected NVIDIA NVDM format and type.
> -    pub(crate) fn validate(self, expected_type: NvdmType) -> bool {
> +    /// Returns `true` if this NVDM header belongs to a PCI vendor-defined message from NVIDIA.
> +    ///
> +    /// The GPU firmware only ever sends such messages, so a mismatch is a sign of corruption.
> +    pub(crate) fn has_nvidia_vendor(self) -> bool {
>          u8::from(self.msg_type()) == MSG_TYPE_VENDOR_PCI
>              && u16::from(self.vendor_id()) == Vendor::NVIDIA.as_raw()
> +    }
> +
> +    /// Validates this header against the expected NVIDIA NVDM format and type.
> +    pub(crate) fn validate(self, expected_type: NvdmType) -> bool {
> +        self.has_nvidia_vendor()
>              && matches!(self.nvdm_type(), Ok(nvdm_type) if nvdm_type == expected_type)
>      }
>  }

NIT: I find has_nvidia_vendor() slighly confusing, as it reads as if it can
legitimately return false. I think it should either be validate() and
validate_type(), or define validate() as done by this patch and rename
has_nvidia_vendor() to has_expected_vendor(), matching has_expected_version().

  reply	other threads:[~2026-12-01 14:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  8:15 [PATCH v4 0/6] gpu: nova-core: gsp: preparatory patches for the r000 firmware Alexandre Courbot
2026-12-01  8:15 ` [PATCH v4 1/6] gpu: nova-core: gsp: add the r000 queue element header Alexandre Courbot
2026-12-01 14:12   ` Danilo Krummrich [this message]
2026-12-02  4:51     ` Alexandre Courbot
2026-12-01  8:15 ` [PATCH v4 2/6] gpu: nova-core: firmware: tlv: add method to load the file referenced by a TLV Alexandre Courbot
2026-12-01  8:15 ` [PATCH v4 3/6] gpu: nova-core: gsp: logbuffer: add LogBuffers::init_arguments() Alexandre Courbot
2026-12-01 14:22   ` Danilo Krummrich
2026-12-02  4:51     ` Alexandre Courbot
2026-12-01  8:15 ` [PATCH v4 4/6] gpu: nova-core: gsp: logbuffer: make LogBuffer generic over its size Alexandre Courbot
2026-12-01  8:15 ` [PATCH v4 5/6] gpu: nova-core: gsp: logbuffer: add RetainedLogBuffers::is_empty() Alexandre Courbot
2026-12-01  8:15 ` [PATCH v4 6/6] gpu: nova-core: gsp: logbuffer: add LIBOS3 log buffers and state monitor buffer Alexandre Courbot
2026-12-01  8:48   ` Eliot Courtney
2026-12-01 14:23 ` [PATCH v4 0/6] gpu: nova-core: gsp: preparatory patches for the r000 firmware Danilo Krummrich
2026-12-02  5:29 ` Alexandre Courbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DN9GHJNGXGDN.4VNE2XPYV3F8@kernel.org \
    --to=dakr@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nova-gpu@lists.linux.dev \
    --cc=simona@ffwll.ch \
    --cc=ttabi@nvidia.com \
    --cc=zhiw@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.