Lines Matching defs:CoherentAllocation
40 /// such as [`CoherentAllocation::alloc_attrs`].
57 /// such as [`CoherentAllocation::alloc_attrs`].
76 /// such as [`CoherentAllocation::alloc_attrs`].
178 /// use kernel::dma::{attrs::*, CoherentAllocation};
182 /// let c: CoherentAllocation<u64> =
183 /// CoherentAllocation::alloc_attrs(dev, 4, GFP_KERNEL, attribs)?;
333 /// A [`CoherentAllocation`] instance contains a pointer to the allocated region (in the
335 /// as the DMA address base of the region. The region is released once [`CoherentAllocation`]
340 /// - For the lifetime of an instance of [`CoherentAllocation`], the `cpu_addr` is a valid pointer
355 // Hence, find a way to revoke the device resources of a `CoherentAllocation`, but not the
356 // entire `CoherentAllocation` including the allocated memory itself.
357 pub struct CoherentAllocation<T: AsBytes + FromBytes> {
365 impl<T: AsBytes + FromBytes> CoherentAllocation<T> {
372 /// use kernel::dma::{attrs::*, CoherentAllocation};
375 /// let c: CoherentAllocation<u64> =
376 /// CoherentAllocation::alloc_attrs(dev, 4, GFP_KERNEL, DMA_ATTR_NO_WARN)?;
384 ) -> Result<CoherentAllocation<T>> {
422 /// Performs the same functionality as [`CoherentAllocation::alloc_attrs`], except the
428 ) -> Result<CoherentAllocation<T>> {
429 CoherentAllocation::alloc_attrs(dev, count, gfp_flags, Attrs(0))
491 /// [`CoherentAllocation::start_ptr`] or [`CoherentAllocation::start_ptr_mut`] could be used
503 // - The pointer is valid due to type invariant on `CoherentAllocation`,
511 /// Performs the same functionality as [`CoherentAllocation::as_slice`], except that a mutable
523 // - The pointer is valid due to type invariant on `CoherentAllocation`,
544 /// # fn test(alloc: &mut kernel::dma::CoherentAllocation<u8>) -> Result {
555 // - The pointer is valid due to type invariant on `CoherentAllocation`
575 // - The pointer is valid due to type invariant on `CoherentAllocation`
630 impl<T: AsBytes + FromBytes> Drop for CoherentAllocation<T> {
635 // `CoherentAllocation`.
648 // SAFETY: It is safe to send a `CoherentAllocation` to another thread if `T`
650 unsafe impl<T: AsBytes + FromBytes + Send> Send for CoherentAllocation<T> {}
658 /// use kernel::dma::{attrs::*, CoherentAllocation};
667 /// # fn test(alloc: &kernel::dma::CoherentAllocation<MyStruct>) -> Result {
676 let item = $crate::dma::CoherentAllocation::item_from_index(&$dma, $idx)?;
683 $crate::dma::CoherentAllocation::field_read(&$dma, ptr_field)
702 /// use kernel::dma::{attrs::*, CoherentAllocation};
711 /// # fn test(alloc: &kernel::dma::CoherentAllocation<MyStruct>) -> Result {
726 let item = $crate::dma::CoherentAllocation::item_from_index(&$dma, $idx)?;
728 unsafe { $crate::dma::CoherentAllocation::field_write(&$dma, item, $val) }
734 let item = $crate::dma::CoherentAllocation::item_from_index(&$dma, $idx)?;
740 $crate::dma::CoherentAllocation::field_write(&$dma, ptr_field, $val)