From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Danilo Krummrich" <dakr@kernel.org>
Cc: "Timur Tabi" <ttabi@nvidia.com>, "Gary Guo" <gary@garyguo.net>,
<nova-gpu@lists.linux.dev>,
"Eliot Courtney" <ecourtney@nvidia.com>,
"John Hubbard" <jhubbard@nvidia.com>, <zhiw@nvidia.com>
Subject: Re: [PATCH 3/8] gpu: nova-core: add TLV parser for firmware files
Date: Thu, 11 Jun 2026 15:51:37 +0900 [thread overview]
Message-ID: <DJ60RSEY0KDF.6DPM9OTEHPC9@nvidia.com> (raw)
In-Reply-To: <DJ5Q9J19NVQO.15OGQVSCIKO06@kernel.org>
On Thu Jun 11, 2026 at 7:37 AM JST, Danilo Krummrich wrote:
<...>
>> +pub(crate) struct TlvBlock<'a> {
>> + pub(crate) tag: &'a str,
>> + pub(crate) value: &'a [u8],
>> +}
>> +
>> +/// On-wire TLV block header: 4-byte ASCII tag + little-endian payload length (bytes, excluding
>> +/// padding to a 4-byte boundary).
>> +struct TlvBlockHeader<'a> {
>> + tag: &'a str,
>> + length: usize,
>> +}
>> +
>> +impl<'a> TlvBlockHeader<'a> {
>> + const SIZE: usize = size_of::<[u8; 4]>() + size_of::<u32>();
>> +
>> + /// Parses the first [`Self::SIZE`] bytes of `hdr` (caller may pass a longer slice).
>> + fn parse(hdr: &'a [u8]) -> Option<Self> {
>> + let hdr = hdr.get(..Self::SIZE)?;
>> + let tag_bytes = hdr.get(..4)?;
>> + let tag = core::str::from_utf8(tag_bytes).ok()?;
>> + if !tag.is_ascii() {
>> + return None;
>> + }
>> + let len_arr = <[u8; 4]>::try_from(hdr.get(4..Self::SIZE)?).ok()?;
>> + let length = u32::from_le_bytes(len_arr) as usize;
>
> Here and in a couple other cases, nova-core depends on !CPU_BIG_ENDIAN, so that
> shouldn't be necessary.
>
> I'm not concerned to keep it for documentation purposes, but it may be a bit
> inconsistent with the rest of the driver.
While relying in the little endianness is useful for things like using
`FromBytes` on data structures, I think it still makes sense to handle
it in cases like this one where it is easy to do so.
Code moves, and in the (remote :)) chance that TLV takes off and other
drivers want to pick it up, this is one less fix to pick.
next prev parent reply other threads:[~2026-06-11 6:51 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 17:49 [PATCH 0/8] Transition Nova Core to TLV firmware images Timur Tabi
2026-06-10 17:49 ` [PATCH 1/8] rust: firmware: add request_into_buf() Timur Tabi
2026-06-10 18:03 ` Gary Guo
2026-06-10 18:24 ` Timur Tabi
2026-06-10 20:26 ` Gary Guo
2026-06-10 20:28 ` Timur Tabi
2026-06-10 21:46 ` Danilo Krummrich
2026-06-11 4:58 ` Alexandre Courbot
2026-06-11 6:49 ` Alexandre Courbot
2026-06-10 17:49 ` [PATCH 2/8] gpu: nova-core: add request_tlv to load TLV images Timur Tabi
2026-06-10 22:00 ` Danilo Krummrich
2026-06-10 17:49 ` [PATCH 3/8] gpu: nova-core: add TLV parser for firmware files Timur Tabi
2026-06-10 22:37 ` Danilo Krummrich
2026-06-11 6:51 ` Alexandre Courbot [this message]
2026-06-10 17:49 ` [PATCH 4/8] gpu: nova-core: transition booter_load to TLV images Timur Tabi
2026-06-10 17:49 ` [PATCH 5/8] gpu: nova-core: transition gsp " Timur Tabi
2026-06-10 17:49 ` [PATCH 6/8] gpu: nova-core: transition gen_bootloader " Timur Tabi
2026-06-10 17:49 ` [PATCH 7/8] gpu: nova-core: transition fsp " Timur Tabi
2026-06-10 17:49 ` [PATCH 8/8] gpu: nova-core: update firmware module info for " Timur Tabi
2026-06-10 18:16 ` [PATCH 0/8] Transition Nova Core to TLV firmware images John Hubbard
2026-06-10 18:19 ` Timur Tabi
2026-06-10 18:59 ` Timur Tabi
2026-06-10 21:21 ` John Hubbard
2026-06-10 21:43 ` Timur Tabi
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=DJ60RSEY0KDF.6DPM9OTEHPC9@nvidia.com \
--to=acourbot@nvidia.com \
--cc=dakr@kernel.org \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=nova-gpu@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox