pub struct CoherentHandle<'a> { /* private fields */ }Expand description
An opaque DMA allocation without a kernel virtual mapping.
Unlike Coherent, a CoherentHandle does not provide CPU access to the allocated memory.
The allocation is always performed with DMA_ATTR_NO_KERNEL_MAPPING, meaning no kernel
virtual mapping is created for the buffer. The value returned by the C API as the CPU
address is an opaque handle used only to free the allocation.
This is useful for buffers that are only ever accessed by hardware.
§Invariants
cpu_handleholds the opaque handle returned bydma_alloc_attrswithDMA_ATTR_NO_KERNEL_MAPPINGset, and is only valid for passing back todma_free_attrs.dma_addris the corresponding bus address for device DMA.sizeis the allocation size in bytes as passed todma_alloc_attrs.dma_attrscontains the attributes used for the allocation, always includingDMA_ATTR_NO_KERNEL_MAPPING.
Implementations§
Source§impl<'a> CoherentHandle<'a>
impl<'a> CoherentHandle<'a>
Sourcepub fn alloc_with_attrs(
dev: &'a Device<Bound>,
size: usize,
gfp_flags: Flags,
dma_attrs: Attrs,
) -> Result<Self>
pub fn alloc_with_attrs( dev: &'a Device<Bound>, size: usize, gfp_flags: Flags, dma_attrs: Attrs, ) -> Result<Self>
Allocates size bytes of coherent DMA memory without creating a kernel virtual mapping.
Additional DMA attributes may be passed via dma_attrs; DMA_ATTR_NO_KERNEL_MAPPING is
always set implicitly.
Returns EINVAL if size is zero, ENOMEM if the allocation fails.
Sourcepub fn alloc(
dev: &'a Device<Bound>,
size: usize,
gfp_flags: Flags,
) -> Result<Self>
pub fn alloc( dev: &'a Device<Bound>, size: usize, gfp_flags: Flags, ) -> Result<Self>
Allocates size bytes of coherent DMA memory without creating a kernel virtual mapping.
Sourcepub fn dma_address(&self) -> DmaAddress
pub fn dma_address(&self) -> DmaAddress
Returns the DMA address for this allocation.
This address can be programmed into device hardware for DMA access.
Trait Implementations§
Source§impl Drop for CoherentHandle<'_>
impl Drop for CoherentHandle<'_>
impl Send for CoherentHandle<'_>
impl Sync for CoherentHandle<'_>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for CoherentHandle<'a>
impl<'a> !UnwindSafe for CoherentHandle<'a>
impl<'a> Freeze for CoherentHandle<'a>
impl<'a> Unpin for CoherentHandle<'a>
impl<'a> UnsafeUnpin for CoherentHandle<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<S, T> IntoSafeCast<T> for Swhere
T: FromSafeCast<S>,
impl<S, T> IntoSafeCast<T> for Swhere
T: FromSafeCast<S>,
Source§fn into_safe_cast(self) -> T
fn into_safe_cast(self) -> T
self into a T. This operation is guaranteed to be lossless.Source§impl<S, T> IntoSafeCastArch<T> for Swhere
T: FromSafeCastArch<S>,
impl<S, T> IntoSafeCastArch<T> for Swhere
T: FromSafeCastArch<S>,
Source§fn into_safe_cast_arch(self) -> T
fn into_safe_cast_arch(self) -> T
self into a T. This operation is guaranteed to be lossless.