From: lyude@redhat.com
To: Alexandre Courbot <acourbot@nvidia.com>,
Danilo Krummrich <dakr@kernel.org>,
Alice Ryhl <aliceryhl@google.com>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: John Hubbard <jhubbard@nvidia.com>,
Alistair Popple <apopple@nvidia.com>,
Joel Fernandes <joelagnelf@nvidia.com>,
Timur Tabi <ttabi@nvidia.com>, Edwin Peer <epeer@nvidia.com>,
nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH 3/9] gpu: nova-core: gsp: simplify sequencer opcode parsing
Date: Thu, 11 Dec 2025 17:04:00 -0500 [thread overview]
Message-ID: <8482d73df0a6b3a5cbddf5381e9bb8b261190fae.camel@redhat.com> (raw)
In-Reply-To: <20251208-nova-misc-v1-3-a3ce01376169@nvidia.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
On Mon, 2025-12-08 at 18:26 +0900, Alexandre Courbot wrote:
> The opcodes are already the right type in the C union, so we can use
> them directly instead of converting them to a byte stream and back
> again
> using `FromBytes`.
>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
> drivers/gpu/nova-core/gsp/fw.rs | 40 +++++--------------------------
> ---------
> 1 file changed, 5 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-
> core/gsp/fw.rs
> index 24e4eaaf1265..d06c0fdd6154 100644
> --- a/drivers/gpu/nova-core/gsp/fw.rs
> +++ b/drivers/gpu/nova-core/gsp/fw.rs
> @@ -472,13 +472,7 @@ pub(crate) fn reg_write_payload(&self) ->
> Result<RegWritePayload> {
> return Err(EINVAL);
> }
> // SAFETY: Opcode is verified to be `RegWrite`, so union
> contains valid `RegWritePayload`.
> - let payload_bytes = unsafe {
> - core::slice::from_raw_parts(
> -
> core::ptr::addr_of!(self.0.payload.regWrite).cast::<u8>(),
> - core::mem::size_of::<RegWritePayload>(),
> - )
> - };
> -
> Ok(*RegWritePayload::from_bytes(payload_bytes).ok_or(EINVAL)?)
> + Ok(RegWritePayload(unsafe { self.0.payload.regWrite }))
> }
>
> /// Returns the register modify payload by value.
> @@ -489,13 +483,7 @@ pub(crate) fn reg_modify_payload(&self) ->
> Result<RegModifyPayload> {
> return Err(EINVAL);
> }
> // SAFETY: Opcode is verified to be `RegModify`, so union
> contains valid `RegModifyPayload`.
> - let payload_bytes = unsafe {
> - core::slice::from_raw_parts(
> -
> core::ptr::addr_of!(self.0.payload.regModify).cast::<u8>(),
> - core::mem::size_of::<RegModifyPayload>(),
> - )
> - };
> -
> Ok(*RegModifyPayload::from_bytes(payload_bytes).ok_or(EINVAL)?)
> + Ok(RegModifyPayload(unsafe { self.0.payload.regModify }))
> }
>
> /// Returns the register poll payload by value.
> @@ -506,13 +494,7 @@ pub(crate) fn reg_poll_payload(&self) ->
> Result<RegPollPayload> {
> return Err(EINVAL);
> }
> // SAFETY: Opcode is verified to be `RegPoll`, so union
> contains valid `RegPollPayload`.
> - let payload_bytes = unsafe {
> - core::slice::from_raw_parts(
> -
> core::ptr::addr_of!(self.0.payload.regPoll).cast::<u8>(),
> - core::mem::size_of::<RegPollPayload>(),
> - )
> - };
> -
> Ok(*RegPollPayload::from_bytes(payload_bytes).ok_or(EINVAL)?)
> + Ok(RegPollPayload(unsafe { self.0.payload.regPoll }))
> }
>
> /// Returns the delay payload by value.
> @@ -523,13 +505,7 @@ pub(crate) fn delay_us_payload(&self) ->
> Result<DelayUsPayload> {
> return Err(EINVAL);
> }
> // SAFETY: Opcode is verified to be `DelayUs`, so union
> contains valid `DelayUsPayload`.
> - let payload_bytes = unsafe {
> - core::slice::from_raw_parts(
> -
> core::ptr::addr_of!(self.0.payload.delayUs).cast::<u8>(),
> - core::mem::size_of::<DelayUsPayload>(),
> - )
> - };
> -
> Ok(*DelayUsPayload::from_bytes(payload_bytes).ok_or(EINVAL)?)
> + Ok(DelayUsPayload(unsafe { self.0.payload.delayUs }))
> }
>
> /// Returns the register store payload by value.
> @@ -540,13 +516,7 @@ pub(crate) fn reg_store_payload(&self) ->
> Result<RegStorePayload> {
> return Err(EINVAL);
> }
> // SAFETY: Opcode is verified to be `RegStore`, so union
> contains valid `RegStorePayload`.
> - let payload_bytes = unsafe {
> - core::slice::from_raw_parts(
> -
> core::ptr::addr_of!(self.0.payload.regStore).cast::<u8>(),
> - core::mem::size_of::<RegStorePayload>(),
> - )
> - };
> -
> Ok(*RegStorePayload::from_bytes(payload_bytes).ok_or(EINVAL)?)
> + Ok(RegStorePayload(unsafe { self.0.payload.regStore }))
> }
> }
>
next prev parent reply other threads:[~2025-12-11 22:04 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 9:26 [PATCH 0/9] gpu: nova-core: miscellaneous improvements Alexandre Courbot
2025-12-08 9:26 ` [PATCH 1/9] gpu: nova-core: gsp: warn if data remains after processing a message Alexandre Courbot
2025-12-11 21:59 ` lyude
2025-12-08 9:26 ` [PATCH 2/9] gpu: nova-core: gsp: remove unnecessary Display impls Alexandre Courbot
2025-12-09 1:26 ` Alistair Popple
2025-12-11 22:02 ` lyude
2025-12-08 9:26 ` [PATCH 3/9] gpu: nova-core: gsp: simplify sequencer opcode parsing Alexandre Courbot
2025-12-11 22:04 ` lyude [this message]
2025-12-08 9:26 ` [PATCH 4/9] gpu: nova-core: gsp: remove unneeded sequencer trait Alexandre Courbot
2025-12-11 22:06 ` lyude
2025-12-08 9:26 ` [PATCH 5/9] gpu: nova-core: gsp: derive `Debug` on more sequencer types Alexandre Courbot
2025-12-11 22:06 ` lyude
2025-12-08 9:26 ` [PATCH 6/9] gpu: nova-core: gsp: derive Zeroable for GspStaticConfigInfo Alexandre Courbot
2025-12-11 22:07 ` lyude
2025-12-08 9:26 ` [PATCH 7/9] gpu: nova-core: firmware: fwsec: do not require bound device when unneeded Alexandre Courbot
2025-12-08 16:18 ` Timur Tabi
2025-12-08 16:51 ` John Hubbard
2025-12-08 17:55 ` Timur Tabi
2025-12-09 2:30 ` Alexandre Courbot
2025-12-11 22:08 ` lyude
2025-12-08 9:27 ` [PATCH 8/9] gpu: nova-core: use core library's CStr instead of kernel one Alexandre Courbot
2025-12-11 22:09 ` lyude
2025-12-08 9:27 ` [PATCH 9/9] gpu: nova-core: simplify str_from_null_terminated Alexandre Courbot
2025-12-11 22:10 ` lyude
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=8482d73df0a6b3a5cbddf5381e9bb8b261190fae.camel@redhat.com \
--to=lyude@redhat.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=epeer@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=ttabi@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;
as well as URLs for NNTP newsgroup(s).