Lines Matching defs:Coherent

67     /// such as [`Coherent::zeroed`].
84 /// such as [`Coherent::zeroed`].
103 /// such as [`Coherent::zeroed`].
122 /// such as [`Coherent::zeroed`].
222 /// use kernel::dma::{attrs::*, Coherent};
226 /// let c: Coherent<[u64]> =
227 /// Coherent::zeroed_slice_with_attrs(dev, 4, GFP_KERNEL, attribs)?;
369 /// CPU-owned DMA allocation that can be converted into a device-shared [`Coherent`] object.
371 /// Unlike [`Coherent`], a [`CoherentBox`] is guaranteed to be fully owned by the CPU -- its DMA
376 /// convert it into a [`Coherent`] object to share it with the device.
388 /// Coherent,
395 /// let dmem: Coherent<u64> = dmem.into();
408 /// Coherent,
415 /// let dmem: Coherent<[u64]> = dmem.into();
418 pub struct CoherentBox<T: KnownSize + ?Sized>(Coherent<T>);
421 /// [`CoherentBox`] variant of [`Coherent::zeroed_slice_with_attrs`].
429 Coherent::zeroed_slice_with_attrs(dev, count, gfp_flags, dma_attrs).map(Self)
468 /// This is the [`CoherentBox`] variant of [`Coherent::from_slice_with_attrs`].
498 let mut slice = Self(Coherent::<T>::alloc_slice_with_attrs(
534 Coherent::zeroed_with_attrs(dev, gfp_flags, dma_attrs).map(Self)
568 impl<T: AsBytes + FromBytes + KnownSize + ?Sized> From<CoherentBox<T>> for Coherent<T> {
580 /// A [`Coherent`] instance contains a pointer to the allocated region (in the
582 /// as the DMA address base of the region. The region is released once [`Coherent`]
587 /// - For the lifetime of an instance of [`Coherent`], the `cpu_addr` is a valid pointer
601 // Hence, find a way to revoke the device resources of a `Coherent`, but not the
602 // entire `Coherent` including the allocated memory itself.
603 pub struct Coherent<T: KnownSize + ?Sized> {
610 impl<T: KnownSize + ?Sized> Coherent<T> {
666 impl<T: AsBytes + FromBytes> Coherent<T> {
715 /// Coherent,
719 /// let c: Coherent<[u64; 4]> =
720 /// Coherent::zeroed_with_attrs(dev, GFP_KERNEL, DMA_ATTR_NO_WARN)?;
732 /// Performs the same functionality as [`Coherent::zeroed_with_attrs`], except the
739 /// Same as [`Coherent::zeroed_with_attrs`], but instead of a zero-initialization the memory is
756 // `Coherent`'s DMA memory. `T: AsBytes + FromBytes` ensures there are no complex `Drop`
763 /// Same as [`Coherent::zeroed`], but instead of a zero-initialization the memory is initialized
783 ) -> Result<Coherent<[T]>> {
813 Ok(Coherent {
823 /// Unlike `Coherent::<[T; N]>::zeroed_with_attrs`, `Coherent::<T>::zeroed_slices` support
835 /// Coherent,
839 /// let c: Coherent<[u64]> =
840 /// Coherent::zeroed_slice_with_attrs(dev, 4, GFP_KERNEL, DMA_ATTR_NO_WARN)?;
849 ) -> Result<Coherent<[T]>> {
850 Coherent::alloc_slice_with_attrs(dev, len, gfp_flags | __GFP_ZERO, dma_attrs)
853 /// Performs the same functionality as [`Coherent::zeroed_slice_with_attrs`], except the
860 ) -> Result<Coherent<[T]>> {
873 /// Coherent
879 /// let c: Coherent<[u8]> =
880 /// Coherent::from_slice_with_attrs(dev, &data, GFP_KERNEL, DMA_ATTR_NO_WARN)?;
890 ) -> Result<Coherent<[T]>>
897 /// Performs the same functionality as [`Coherent::from_slice_with_attrs`], except the
904 ) -> Result<Coherent<[T]>>
912 impl<T> Coherent<[T]> {
918 #[expect(clippy::len_without_is_empty, reason = "Coherent slice is never empty")]
925 impl<T: KnownSize + ?Sized> Drop for Coherent<T> {
930 // `Coherent`.
943 // SAFETY: It is safe to send a `Coherent` to another thread if `T`
945 unsafe impl<T: KnownSize + Send + ?Sized> Send for Coherent<T> {}
947 // SAFETY: Sharing `&Coherent` across threads is safe if `T` is `Sync`, because all
951 unsafe impl<T: KnownSize + ?Sized + AsBytes + FromBytes + Sync> Sync for Coherent<T> {}
953 impl<T: KnownSize + AsBytes + ?Sized> debugfs::BinaryWriter for Coherent<T> {
984 /// Unlike [`Coherent`], a `CoherentHandle` does not provide CPU access to the allocated memory.
1101 /// View type for `Coherent`.
1163 /// `IoBackend` implementation for `Coherent`.
1239 impl<'a, T: ?Sized + KnownSize> IoBase<'a> for &'a Coherent<T> {