From: Alistair Popple <apopple@nvidia.com>
To: Pedro Yudi Honda <niyudi.honda@usp.br>
Cc: dakr@kernel.org, acourbot@nvidia.com, nico.antinori.7@gmail.com,
aliceryhl@google.com, airlied@gmail.com, simona@ffwll.ch,
dri-devel@lists.freedesktop.org, ojeda@kernel.org,
rust-for-linux@vger.kernel.org, nova-gpu@lists.linux.dev
Subject: Re: [PATCH v2 4/5] drm/nova: use `zerocopy` in bootloader.rs
Date: Mon, 6 Jul 2026 21:44:00 +1000 [thread overview]
Message-ID: <akuU7CUj1CgKsdmP@nvdebian.thelocal> (raw)
In-Reply-To: <20260702120324.40388-5-niyudi.honda@gmail.com>
On 2026-07-02 at 22:03 +1000, Pedro Yudi Honda <niyudi.honda@usp.br> wrote...
> From: Pedro Yudi Honda <niyudi.honda@usp.br>
>
> In firmware/fwsec/bootloader.rs, replace the following `transmute`
> traits with their `zerocopy` equivalents:
>
> - `transmute::FromBytes` -> `zerocopy::FromBytes`
> - `transmute::AsBytes` -> `zerocopy::IntoBytes`
> - add `zerocopy::Immutable` where necessary
>
> Update call sites accordingly.
Reviewed-by: Alistair Popple <apopple@nvidia.com>
>
> Signed-off-by: Pedro Yudi Honda <niyudi.honda@usp.br>
> ---
> .../gpu/nova-core/firmware/fwsec/bootloader.rs | 18 ++++--------------
> 1 file changed, 4 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs b/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs
> index 66b9f4d1b41c..03d3090bd9ef 100644
> --- a/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs
> +++ b/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs
> @@ -18,15 +18,9 @@
> Alignable,
> Alignment, //
> },
> - sizes,
> - transmute::{
> - AsBytes,
> - FromBytes, //
> - },
> + sizes, //
> };
>
> -use zerocopy::FromBytes as _;
> -
> use crate::{
> driver::Bar0,
> falcon::{
> @@ -57,7 +51,7 @@
> ///
> /// Most of its fields appear to be legacy and carry incorrect values, so they are left unused.
> #[repr(C)]
> -#[derive(Debug, Clone)]
> +#[derive(Debug, Clone, FromBytes)]
> struct BootloaderDesc {
> /// Starting tag of bootloader.
> start_tag: u32,
> @@ -73,15 +67,13 @@ struct BootloaderDesc {
> /// Size of data section in the image. Unused as we build the data section ourselves.
> _data_size: u32,
> }
> -// SAFETY: any byte sequence is valid for this struct.
> -unsafe impl FromBytes for BootloaderDesc {}
>
> /// Structure used by the boot-loader to load the rest of the code.
> ///
> /// This has to be filled by the GPU driver and copied into DMEM at offset
> /// [`BootloaderDesc.dmem_load_off`].
> #[repr(C, packed)]
> -#[derive(Debug, Clone)]
> +#[derive(Debug, Clone, IntoBytes, zerocopy_derive::Immutable)]
> struct BootloaderDmemDescV2 {
> /// Reserved, should always be first element.
> reserved: [u32; 4],
> @@ -120,8 +112,6 @@ struct BootloaderDmemDescV2 {
> /// Arguments to be passed to the target firmware being loaded.
> argv: u32,
> }
> -// SAFETY: This struct doesn't contain uninitialized bytes and doesn't have interior mutability.
> -unsafe impl AsBytes for BootloaderDmemDescV2 {}
>
> /// Wrapper for [`FwsecFirmware`] that includes the bootloader performing the actual load
> /// operation.
> @@ -160,7 +150,7 @@ pub(crate) fn new(
>
> fw.data()
> .get(desc_offset..)
> - .and_then(BootloaderDesc::from_bytes_copy_prefix)
> + .and_then(|b| BootloaderDesc::read_from_prefix(b).ok())
> .ok_or(EINVAL)?
> .0
> };
> --
> 2.34.1
>
next prev parent reply other threads:[~2026-07-06 11:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 12:03 [RESEND PATCH v2 0/5] drm/nova: replace `transmute` with `zerocopy` Pedro Yudi Honda
2026-07-02 12:03 ` [PATCH v2 1/5] drm/nova: use `zerocopy` in firmware.rs Pedro Yudi Honda
2026-07-06 7:15 ` Alistair Popple
2026-07-02 12:03 ` [PATCH v2 2/5] drm/nova: use `zerocopy` in booter.rs Pedro Yudi Honda
2026-07-06 11:39 ` Alistair Popple
2026-07-02 12:03 ` [PATCH v2 3/5] drm/nova: use `zerocopy` in fwsec.rs Pedro Yudi Honda
2026-07-06 11:43 ` Alistair Popple
2026-07-02 12:03 ` [PATCH v2 4/5] drm/nova: use `zerocopy` in bootloader.rs Pedro Yudi Honda
2026-07-06 11:44 ` Alistair Popple [this message]
2026-07-02 12:03 ` [PATCH v2 5/5] drm/nova: use `zerocopy` in riscv.rs Pedro Yudi Honda
2026-07-06 11:44 ` Alistair Popple
2026-07-04 13:00 ` [RESEND PATCH v2 0/5] drm/nova: replace `transmute` with `zerocopy` Miguel Ojeda
-- strict thread matches above, loose matches on Subject: below --
2026-07-01 17:40 [PATCH " Pedro Yudi Honda
2026-07-01 17:40 ` [PATCH v2 4/5] drm/nova: use `zerocopy` in bootloader.rs Pedro Yudi Honda
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=akuU7CUj1CgKsdmP@nvdebian.thelocal \
--to=apopple@nvidia.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=nico.antinori.7@gmail.com \
--cc=niyudi.honda@usp.br \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.