]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: dma: introduce dma::CoherentBox for memory initialization
authorDanilo Krummrich <dakr@kernel.org>
Fri, 20 Mar 2026 19:45:39 +0000 (20:45 +0100)
committerDanilo Krummrich <dakr@kernel.org>
Mon, 23 Mar 2026 21:35:38 +0000 (22:35 +0100)
commit80f4a7b5138d1c427ee5626e8a796aa6b2994a95
treecea1474b871f5a5962dafa19b65f1faadf9b9c45
parentf84ecffa3f745572164c1269f20eec2589d432c9
rust: dma: introduce dma::CoherentBox for memory initialization

Currently, dma::Coherent cannot safely provide (mutable) access to its
underlying memory because the memory might be concurrently accessed by a
DMA device. This makes it difficult to safely initialize the memory
before handing it over to the hardware.

Introduce dma::CoherentBox, a type that encapsulates a dma::Coherent
before its DMA address is exposed to the device. dma::CoherentBox can
guarantee exclusive access to the inner dma::Coherent and implement
Deref and DerefMut.

Once the memory is properly initialized, dma::CoherentBox can be
converted into a regular dma::Coherent.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20260320194626.36263-5-dakr@kernel.org
[ Remove unnecessary trait bounds. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/dma.rs