From: Pedro Yudi Honda <niyudi.honda@usp.br>
To: dakr@kernel.org, acourbot@nvidia.com, apopple@nvidia.com
Cc: 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,
Pedro Yudi Honda <niyudi.honda@usp.br>
Subject: [PATCH v2 5/5] drm/nova: use `zerocopy` in riscv.rs
Date: Wed, 1 Jul 2026 14:40:56 -0300 [thread overview]
Message-ID: <20260701174056.12604-6-niyudi.honda@gmail.com> (raw)
In-Reply-To: <20260701174056.12604-1-niyudi.honda@gmail.com>
From: Pedro Yudi Honda <niyudi.honda@usp.br>
In riscv.rs, replave the following `transmute` traits with their
`zerocopy` equivalents:
- `transmute::FromBytes` -> `zerocopy::FromBytes`
Update call sites accordingly.
Signed-off-by: Pedro Yudi Honda <niyudi.honda@usp.br>
---
drivers/gpu/nova-core/firmware/riscv.rs | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/nova-core/firmware/riscv.rs b/drivers/gpu/nova-core/firmware/riscv.rs
index 2afa7f36404e..ba56bc7d4188 100644
--- a/drivers/gpu/nova-core/firmware/riscv.rs
+++ b/drivers/gpu/nova-core/firmware/riscv.rs
@@ -7,8 +7,7 @@
device,
dma::Coherent,
firmware::Firmware,
- prelude::*,
- transmute::FromBytes, //
+ prelude::*, //
};
use crate::{
@@ -18,7 +17,7 @@
/// Descriptor for microcode running on a RISC-V core.
#[repr(C)]
-#[derive(Debug)]
+#[derive(Debug, FromBytes)]
struct RmRiscvUCodeDesc {
version: u32,
bootloader_offset: u32,
@@ -36,9 +35,6 @@ struct RmRiscvUCodeDesc {
monitor_code_size: u32,
}
-// SAFETY: all bit patterns are valid for this type, and it doesn't use interior mutability.
-unsafe impl FromBytes for RmRiscvUCodeDesc {}
-
impl RmRiscvUCodeDesc {
/// Interprets the header of `bin_fw` as a [`RmRiscvUCodeDesc`] and returns it.
///
@@ -50,7 +46,7 @@ fn new(bin_fw: &BinFirmware<'_>) -> Result<Self> {
bin_fw
.fw
.get(offset..end)
- .and_then(Self::from_bytes_copy)
+ .and_then(|b| Self::read_from_bytes(b).ok())
.ok_or(EINVAL)
}
}
--
2.34.1
next prev parent reply other threads:[~2026-07-01 17:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 17:40 [PATCH v2 0/5] drm/nova: replace `transmute` with `zerocopy` Pedro Yudi Honda
2026-07-01 17:40 ` [PATCH v2 1/5] drm/nova: use `zerocopy` in firmware.rs Pedro Yudi Honda
2026-07-01 17:40 ` [PATCH v2 2/5] drm/nova: use `zerocopy` in booter.rs Pedro Yudi Honda
2026-07-01 17:40 ` [PATCH v2 3/5] drm/nova: use `zerocopy` in fwsec.rs Pedro Yudi Honda
2026-07-01 17:40 ` [PATCH v2 4/5] drm/nova: use `zerocopy` in bootloader.rs Pedro Yudi Honda
2026-07-01 17:40 ` Pedro Yudi Honda [this message]
-- strict thread matches above, loose matches on Subject: below --
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 5/5] drm/nova: use `zerocopy` in riscv.rs Pedro Yudi Honda
2026-07-06 11:44 ` Alistair Popple
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=20260701174056.12604-6-niyudi.honda@gmail.com \
--to=niyudi.honda@usp.br \
--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=nico.antinori.7@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox