NVIDIA GPU driver infrastructure
 help / color / mirror / Atom feed
* [PATCH RFC 0/4] rust: dma: bridge zerocopy-derived types into the transmute byte-safety bound
@ 2026-06-28 17:10 SeungJong Ha via B4 Relay
  2026-06-28 17:10 ` [PATCH RFC 1/4] rust: transmute: add `impl_transmute_via_zerocopy!` macro SeungJong Ha via B4 Relay
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: SeungJong Ha via B4 Relay @ 2026-06-28 17:10 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, David Airlie, Simona Vetter
  Cc: rust-for-linux, linux-kernel, nova-gpu, dri-devel, SeungJong Ha

DMA-coherent allocations (CoherentAllocation/Coherent/dma::Pool) bound
their element type on kernel::transmute::{AsBytes, FromBytes}. This RFC
lets a type satisfy that bound by deriving zerocopy's byte-safety traits
instead of a hand-written unsafe impl.

The bound cannot be switched to zerocopy wholesale (some DMA structs are
unions that IntoBytes cannot derive), and a blanket bridge impl is
rejected by coherence. So the series bridges the two per type:

  1. add the bridge macro impl_transmute_via_zerocopy!, which emits the
     transmute impls only for a zerocopy-derived type.
  2. re-export zerocopy::Immutable from the prelude.
  3-4. worked example: convert nova-core's GspMem and msgq POD types.

This series was prepared with the Claude Code AI assistant (model
claude-opus-4-8): it drafted the macro, the nova-core conversion and the
changelogs, which the submitter reviewed and takes responsibility for. It
was verified by building nova-core on rust-next and a negative test
confirming IntoBytes rejects mis-sized padding. See
Documentation/process/coding-assistants.rst.

Assisted-by: Claude-Code:claude-opus-4-8
Signed-off-by: SeungJong Ha <engineer.jjhama@gmail.com>
---
SeungJong Ha (4):
      rust: transmute: add `impl_transmute_via_zerocopy!` macro
      rust: prelude: re-export `zerocopy::Immutable`
      gpu: nova-core: gsp: derive zerocopy traits for the msgq POD types
      gpu: nova-core: gsp: convert GspMem to zerocopy via the transmute bridge

 drivers/gpu/nova-core/gsp.rs                      | 13 ++-------
 drivers/gpu/nova-core/gsp/cmdq.rs                 | 15 +++++-----
 drivers/gpu/nova-core/gsp/fw.rs                   |  8 +++---
 drivers/gpu/nova-core/gsp/fw/r570_144.rs          |  2 ++
 drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs |  4 +--
 rust/kernel/prelude.rs                            |  2 ++
 rust/kernel/transmute.rs                          | 35 +++++++++++++++++++++++
 7 files changed, 54 insertions(+), 25 deletions(-)
---
base-commit: 780d569e6c4b422290f5cba319eb904b355d64be
change-id: 20260628-dma-zerocopy-bridge-dc1c96b610cf

Best regards,
--  
SeungJong Ha <engineer.jjhama@gmail.com>



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-06-29 11:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-28 17:10 [PATCH RFC 0/4] rust: dma: bridge zerocopy-derived types into the transmute byte-safety bound SeungJong Ha via B4 Relay
2026-06-28 17:10 ` [PATCH RFC 1/4] rust: transmute: add `impl_transmute_via_zerocopy!` macro SeungJong Ha via B4 Relay
2026-06-28 17:10 ` [PATCH RFC 2/4] rust: prelude: re-export `zerocopy::Immutable` SeungJong Ha via B4 Relay
2026-06-28 17:10 ` [PATCH RFC 3/4] gpu: nova-core: gsp: derive zerocopy traits for the msgq POD types SeungJong Ha via B4 Relay
2026-06-28 17:10 ` [PATCH RFC 4/4] gpu: nova-core: gsp: convert GspMem to zerocopy via the transmute bridge SeungJong Ha via B4 Relay
     [not found]   ` <20260628172200.B116D1F000E9@smtp.kernel.org>
2026-06-28 18:21     ` SeungJong Ha
2026-06-29  7:10       ` Alexandre Courbot
2026-06-29  7:59         ` SeungJong Ha
2026-06-29  9:49           ` Alexandre Courbot
2026-06-29  7:17 ` [PATCH RFC 0/4] rust: dma: bridge zerocopy-derived types into the transmute byte-safety bound Alexandre Courbot
2026-06-29  8:20   ` Alistair Popple
2026-06-29  8:57     ` Danilo Krummrich
2026-06-29 11:16   ` SeungJong Ha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox