From: Timur Tabi <ttabi@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>,
Alexandre Courbot <acourbot@nvidia.com>,
John Hubbard <jhubbard@nvidia.com>,
Eliot Courtney <ecourtney@nvidia.com>, <nova-gpu@lists.linux.dev>
Subject: [PATCH v2 1/7] gpu: nova-core: add Tlv.get_u64
Date: Mon, 16 Nov 2026 13:54:35 -0600 [thread overview]
Message-ID: <20261116195441.940595-2-ttabi@nvidia.com> (raw)
In-Reply-To: <20261116195441.940595-1-ttabi@nvidia.com>
Introduce get_u64() to support variable-sized TLV integers. If the driver
expects that a particular tag might be a 64-bit value, it should use this
method read it.
TLVs can store unsigned integers in either 32-bit or 64-bit little-endian
format. The script that generates TLV files is written in Python, and
Python integers are arbitrarily sized. For any given integer, the script
will store it as a 32-bit integer if its value is less than 0x100000000,
without any regard to its purpose. This means that the driver may not
know until runtime whether a given TLV integer is encoded as four bytes
or eight.
Signed-off-by: Timur Tabi <ttabi@nvidia.com>
---
drivers/gpu/nova-core/firmware/tlv.rs | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/gpu/nova-core/firmware/tlv.rs b/drivers/gpu/nova-core/firmware/tlv.rs
index 7f278903dc8b..6a9b318454c4 100644
--- a/drivers/gpu/nova-core/firmware/tlv.rs
+++ b/drivers/gpu/nova-core/firmware/tlv.rs
@@ -257,6 +257,20 @@ pub(crate) fn load_file(
.ok_or(EINVAL)
}
+ /// Return a u64, from either a 32-bit or 64-bit little-endian tag.
+ #[expect(unused)]
+ pub(crate) fn get_u64(&self, tag: &[u8; 4]) -> Result<u64> {
+ let value = self.find(tag)?.value;
+
+ if let Ok(bytes) = <[u8; 4]>::try_from(value) {
+ Ok(u64::from(u32::from_le_bytes(bytes)))
+ } else if let Ok(bytes) = <[u8; 8]>::try_from(value) {
+ Ok(u64::from_le_bytes(bytes))
+ } else {
+ Err(EINVAL)
+ }
+ }
+
/// Return a string value.
pub(crate) fn get_string(&self, tag: &[u8; 4]) -> Result<&'a str> {
let tlv = self.find(tag)?;
--
2.54.0
next prev parent reply other threads:[~2026-11-16 19:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 19:54 [PATCH v2 0/7] Transition nova-core to use TLV variables for heap sizes Timur Tabi
2026-11-16 19:54 ` Timur Tabi [this message]
2026-11-16 19:54 ` [PATCH v2 2/7] gpu: nova-core: read GSP heap variables from TLV Timur Tabi
2026-11-16 19:54 ` [PATCH v2 3/7] gpu: nova-core: use the TLV heap sizes for pmu and non-wpr Timur Tabi
2026-11-16 19:54 ` [PATCH v2 4/7] gpu: nova-core: remove heap size related HAL functions Timur Tabi
2026-11-16 19:54 ` [PATCH v2 5/7] gpu: nova-core: add TLV versions of WPR heap size functions Timur Tabi
2026-11-16 19:54 ` [PATCH v2 6/7] gpu: nova-core: change wpr2_heap_params to use TLV values Timur Tabi
2026-11-16 19:54 ` [PATCH v2 7/7] gpu: nova-core: remove LibosParams 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=20261116195441.940595-2-ttabi@nvidia.com \
--to=ttabi@nvidia.com \
--cc=acourbot@nvidia.com \
--cc=dakr@kernel.org \
--cc=ecourtney@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=nova-gpu@lists.linux.dev \
/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