From: Rhys Lloyd <krakow20@gmail.com>
To: acourbot@nvidia.com, dakr@kernel.org
Cc: Rhys Lloyd <krakow20@gmail.com>,
rust-for-linux@vger.kernel.org, airlied@gmail.com,
simona@ffwll.ch, nouveau@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3] gpu: nova-core: vbios: change PmuLookupTableEntry to use size_of
Date: Fri, 18 Jul 2025 00:36:25 -0700 [thread overview]
Message-ID: <20250718073633.194032-3-krakow20@gmail.com> (raw)
In-Reply-To: <20250718073633.194032-1-krakow20@gmail.com>
Annotate the PmuLookupTableEntry with an `#[repr(C, packed)]` attribute.
Removes another magic number by making the struct the same size as
the data it needs to read, allowing the use of
`size_of::<PmuLookupTableEntry>()`
Signed-off-by: Rhys Lloyd <krakow20@gmail.com>
---
Changes in v2:
- get_data helper function renamed to data
Changes in v3:
- Change PmuLookupTableEntry.data back to u32
- Remove helper function
- Annotate `PmuLookupTableEntry` with `#[repr(C, packed)]`
---
drivers/gpu/nova-core/vbios.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
index 5b5d9f38cbb3..4c8368946bd6 100644
--- a/drivers/gpu/nova-core/vbios.rs
+++ b/drivers/gpu/nova-core/vbios.rs
@@ -893,6 +893,7 @@ fn try_from(base: BiosImageBase) -> Result<Self> {
///
/// See the [`PmuLookupTable`] description for more information.
#[expect(dead_code)]
+#[repr(C, packed)]
struct PmuLookupTableEntry {
application_id: u8,
target_id: u8,
@@ -901,7 +902,7 @@ struct PmuLookupTableEntry {
impl PmuLookupTableEntry {
fn new(data: &[u8]) -> Result<Self> {
- if data.len() < 6 {
+ if data.len() < core::mem::size_of::<Self>() {
return Err(EINVAL);
}
base-commit: 14ae91a81ec8fa0bc23170d4aa16dd2a20d54105
--
2.50.1
next prev parent reply other threads:[~2025-07-18 7:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-18 7:36 [PATCH] gpu: nova-core: vbios: use offset_of in PmuLookupTableHeader::new Rhys Lloyd
2025-07-18 7:36 ` [PATCH v2] gpu: nova-core: vbios: use size_of instead of magic number Rhys Lloyd
2025-07-25 13:29 ` Alexandre Courbot
2025-07-18 7:36 ` Rhys Lloyd [this message]
2025-07-25 13:30 ` [PATCH v3] gpu: nova-core: vbios: change PmuLookupTableEntry to use size_of Alexandre Courbot
2025-07-25 13:35 ` [PATCH] gpu: nova-core: vbios: use offset_of in PmuLookupTableHeader::new Alexandre Courbot
2025-07-25 14:04 ` Danilo Krummrich
2025-07-27 9:51 ` Rhys Lloyd
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=20250718073633.194032-3-krakow20@gmail.com \
--to=krakow20@gmail.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
/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;
as well as URLs for NNTP newsgroup(s).