]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: dma: add from-slice constructors for Coherent and CoherentBox
authorAlexandre Courbot <acourbot@nvidia.com>
Thu, 26 Mar 2026 15:22:07 +0000 (00:22 +0900)
committerAlexandre Courbot <acourbot@nvidia.com>
Sat, 28 Mar 2026 13:20:07 +0000 (22:20 +0900)
commit816718c611cab2164d718b91ad8204afcd0af81f
tree9ca32950ee9230252a0798634c6b9d85cc712e91
parent6dd782af1eb6be16a80349ea7822f0f8a23bb3e8
rust: dma: add from-slice constructors for Coherent and CoherentBox

A very common pattern is to create a block of coherent memory with the
content of an already-existing slice of bytes (e.g. a loaded firmware
blob).

`CoherentBox` makes this easier, but still implies a potentially
panicking operation with `copy_from_slice` that requires a `PANIC`
comment.

Add `from_slice_with_attrs` and `from_slice` methods to both `Coherent`
and `CoherentBox` to turn this into a trivial one-step operation.

Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/20260327-b4-nova-dma-removal-v2-1-616e1d0b5cb3@nvidia.com
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
rust/kernel/dma.rs