From: Alice Ryhl <aliceryhl@google.com>
To: Joel Fernandes <joelagnelf@nvidia.com>
Cc: Rhys Lloyd <krakow20@gmail.com>,
acourbot@nvidia.com, dakr@kernel.org,
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: Re: [PATCH v2] gpu: nova-core: vbios: change PmuLookupTableEntry to relax alignment
Date: Mon, 14 Jul 2025 16:53:28 +0200 [thread overview]
Message-ID: <CAH5fLgiFOFm+Lh0K_PDZ2eCFa0EAOMk9GRh0Cgh2sm8fay=qnA@mail.gmail.com> (raw)
In-Reply-To: <20250714144837.GA2996266@joelnvbox>
On Mon, Jul 14, 2025 at 4:49 PM Joel Fernandes <joelagnelf@nvidia.com> wrote:
>
> Hello, Rhys,
>
> On Mon, Jul 14, 2025 at 04:02:23AM -0700, Rhys Lloyd wrote:
> > Instead of the data field containing a u32 and changing the alignment,
> > change data to [u8; 4] and convert to u32 with a helper function.
> > 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
> >
> > ---
> > drivers/gpu/nova-core/vbios.rs | 13 +++++++++----
> > 1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
> > index 5b5d9f38cbb3..339c66e63c7e 100644
> > --- a/drivers/gpu/nova-core/vbios.rs
> > +++ b/drivers/gpu/nova-core/vbios.rs
> > @@ -896,21 +896,26 @@ fn try_from(base: BiosImageBase) -> Result<Self> {
> > struct PmuLookupTableEntry {
> > application_id: u8,
> > target_id: u8,
> > - data: u32,
> > + data: [u8; 4],
>
> Instead of this, could we make the struct as #repr[(C, packed)] or does that
> not work for some reason?
It would probably, but packed structs aren't very nice to work with
because Rust has to be really careful to never generate a reference to
unaligned fields.
Alice
next prev parent reply other threads:[~2025-07-14 14:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 11:02 [PATCH v2] gpu: nova-core: vbios: change PmuLookupTableEntry to relax alignment Rhys Lloyd
2025-07-14 11:28 ` Danilo Krummrich
2025-07-14 14:48 ` Joel Fernandes
2025-07-14 14:53 ` Alice Ryhl [this message]
2025-07-14 15:22 ` Joel Fernandes
2025-07-16 1:28 ` 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='CAH5fLgiFOFm+Lh0K_PDZ2eCFa0EAOMk9GRh0Cgh2sm8fay=qnA@mail.gmail.com' \
--to=aliceryhl@google.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=joelagnelf@nvidia.com \
--cc=krakow20@gmail.com \
--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).