pub struct CoherentHandle { /* 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_handleis 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 CoherentHandle
impl CoherentHandle
Sourcepub fn alloc_with_attrs(
dev: &Device<Bound>,
size: usize,
gfp_flags: Flags,
dma_attrs: Attrs,
) -> Result<Self>
pub fn alloc_with_attrs( dev: &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: &Device<Bound>, size: usize, gfp_flags: Flags) -> Result<Self>
pub fn alloc(dev: &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_handle(&self) -> DmaAddress
pub fn dma_handle(&self) -> DmaAddress
Returns the DMA handle 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 Freeze for CoherentHandle
impl !RefUnwindSafe for CoherentHandle
impl Unpin for CoherentHandle
impl UnsafeUnpin for CoherentHandle
impl !UnwindSafe for CoherentHandle
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
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
slot. Read more