Lines Matching full:coherent

59     /// such as [`Coherent::zeroed`].
68 /// Set up the device's DMA coherent addressing capabilities.
76 /// such as [`Coherent::zeroed`].
95 /// such as [`Coherent::zeroed`].
114 /// such as [`Coherent::zeroed`].
214 /// use kernel::dma::{attrs::*, Coherent};
218 /// let c: Coherent<[u64]> =
219 /// Coherent::zeroed_slice_with_attrs(dev, 4, GFP_KERNEL, attribs)?;
361 /// CPU-owned DMA allocation that can be converted into a device-shared [`Coherent`] object.
363 /// Unlike [`Coherent`], a [`CoherentBox`] is guaranteed to be fully owned by the CPU -- its DMA
368 /// convert it into a [`Coherent`] object to share it with the device.
380 /// Coherent,
387 /// let dmem: Coherent<u64> = dmem.into();
400 /// Coherent,
407 /// let dmem: Coherent<[u64]> = dmem.into();
410 pub struct CoherentBox<T: KnownSize + ?Sized>(Coherent<T>);
413 /// [`CoherentBox`] variant of [`Coherent::zeroed_slice_with_attrs`].
421 Coherent::zeroed_slice_with_attrs(dev, count, gfp_flags, dma_attrs).map(Self) in zeroed_slice_with_attrs()
457 /// Allocates a region of coherent memory of the same size as `data` and initializes it with a
460 /// This is the [`CoherentBox`] variant of [`Coherent::from_slice_with_attrs`].
490 let mut slice = Self(Coherent::<T>::alloc_slice_with_attrs( in from_slice_with_attrs()
526 Coherent::zeroed_with_attrs(dev, gfp_flags, dma_attrs).map(Self) in zeroed_with_attrs()
560 impl<T: AsBytes + FromBytes + KnownSize + ?Sized> From<CoherentBox<T>> for Coherent<T> { implementation
570 /// large coherent DMA regions.
572 /// A [`Coherent`] instance contains a pointer to the allocated region (in the
574 /// as the DMA address base of the region. The region is released once [`Coherent`]
579 /// - For the lifetime of an instance of [`Coherent`], the `cpu_addr` is a valid pointer
580 /// to an allocated region of coherent memory and `dma_handle` is the DMA address base of the
593 // Hence, find a way to revoke the device resources of a `Coherent`, but not the
594 // entire `Coherent` including the allocated memory itself.
595 pub struct Coherent<T: KnownSize + ?Sized> { struct
602 impl<T: KnownSize + ?Sized> Coherent<T> { argument
705 impl<T: AsBytes + FromBytes> Coherent<T> { impl
706 /// Allocates a region of `T` of coherent memory.
732 // - We just successfully allocated a coherent region which is adequately sized for `T`, in alloc_with_attrs()
743 /// Allocates a region of type `T` of coherent memory.
754 /// Coherent,
758 /// let c: Coherent<[u64; 4]> =
759 /// Coherent::zeroed_with_attrs(dev, GFP_KERNEL, DMA_ATTR_NO_WARN)?;
771 /// Performs the same functionality as [`Coherent::zeroed_with_attrs`], except the
778 /// Same as [`Coherent::zeroed_with_attrs`], but instead of a zero-initialization the memory is
794 // - If `__init` fails, `self` is dropped, which safely frees the underlying `Coherent`'s in init_with_attrs()
802 /// Same as [`Coherent::zeroed`], but instead of a zero-initialization the memory is initialized
816 /// Allocates a region of `[T; len]` of coherent memory.
822 ) -> Result<Coherent<[T]>> { in alloc_slice_with_attrs()
849 // - We just successfully allocated a coherent region which is adequately sized for in alloc_slice_with_attrs()
852 Ok(Coherent { in alloc_slice_with_attrs()
860 /// Allocates a zeroed region of type `T` of coherent memory.
862 /// Unlike `Coherent::<[T; N]>::zeroed_with_attrs`, `Coherent::<T>::zeroed_slices` support
874 /// Coherent,
878 /// let c: Coherent<[u64]> =
879 /// Coherent::zeroed_slice_with_attrs(dev, 4, GFP_KERNEL, DMA_ATTR_NO_WARN)?;
888 ) -> Result<Coherent<[T]>> { in zeroed_slice_with_attrs()
889 Coherent::alloc_slice_with_attrs(dev, len, gfp_flags | __GFP_ZERO, dma_attrs) in zeroed_slice_with_attrs()
892 /// Performs the same functionality as [`Coherent::zeroed_slice_with_attrs`], except the
899 ) -> Result<Coherent<[T]>> { in zeroed_slice()
903 /// Allocates a region of coherent memory of the same size as `data` and initializes it with a
912 /// Coherent
918 /// let c: Coherent<[u8]> =
919 /// Coherent::from_slice_with_attrs(dev, &data, GFP_KERNEL, DMA_ATTR_NO_WARN)?;
929 ) -> Result<Coherent<[T]>> in from_slice_with_attrs()
936 /// Performs the same functionality as [`Coherent::from_slice_with_attrs`], except the
943 ) -> Result<Coherent<[T]>> in from_slice()
951 impl<T> Coherent<[T]> { impl
957 #[expect(clippy::len_without_is_empty, reason = "Coherent slice is never empty")]
964 impl<T: KnownSize + ?Sized> Drop for Coherent<T> { implementation
969 // `Coherent`. in drop()
982 // SAFETY: It is safe to send a `Coherent` to another thread if `T`
984 unsafe impl<T: KnownSize + Send + ?Sized> Send for Coherent<T> {} implementation
986 // SAFETY: Sharing `&Coherent` across threads is safe if `T` is `Sync`, because all
990 unsafe impl<T: KnownSize + ?Sized + AsBytes + FromBytes + Sync> Sync for Coherent<T> {} implementation
992 impl<T: KnownSize + AsBytes + ?Sized> debugfs::BinaryWriter for Coherent<T> { implementation
1019 /// Unlike [`Coherent`], a `CoherentHandle` does not provide CPU access to the allocated memory.
1043 /// Allocates `size` bytes of coherent DMA memory without creating a kernel virtual mapping.
1086 /// Allocates `size` bytes of coherent DMA memory without creating a kernel virtual mapping.
1139 /// to a [`Coherent`] and `proj` is a [projection specification](kernel::ptr::project!).
1145 /// use kernel::dma::{attrs::*, Coherent};
1154 /// # fn test(alloc: &kernel::dma::Coherent<[MyStruct]>) -> Result {
1164 $crate::dma::Coherent::as_ptr(dma), $($proj)*
1167 unsafe { $crate::dma::Coherent::field_read(dma, ptr) }
1174 /// evaluating to a [`Coherent`], `proj` is a
1182 /// use kernel::dma::{attrs::*, Coherent};
1191 /// # fn test(alloc: &kernel::dma::Coherent<[MyStruct]>) -> Result {
1201 mut $crate::dma::Coherent::as_mut_ptr(dma), $($proj)*
1205 unsafe { $crate::dma::Coherent::field_write(dma, ptr, val) }