Re: [PATCH 4/8] rust: dma: introduce dma::CoherentInit for memory initialization
From: Alice Ryhl
Date: Tue Mar 17 2026 - 02:57:13 EST
On Tue, Mar 03, 2026 at 05:22:55PM +0100, Danilo Krummrich wrote:
> 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::CoherentInit, a type that encapsulates a dma::Coherent
> before its DMA address is exposed to the device. dma::CoherentInit can
> guarantee exclusive access to the inner dma::Coherent and implement
> Deref and DerefMut.
>
> Once the memory is properly initialized, dma::CoherentInit can be
> converted into a regular dma::Coherent.
>
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
overall LGTM
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> + let ptr = core::ptr::from_mut(&mut self[i]);
&raw mut self[i].
Alice