Lines Matching +full:single +full:- +full:tt

1 // SPDX-License-Identifier: GPL-2.0
5 //! C header: [`include/linux/dma-mapping.h`](srctree/include/linux/dma-mapping.h)
41 /// Note that this may be `u64` even on 32-bit architectures.
60 unsafe fn dma_set_mask(&self, mask: DmaMask) -> Result { in dma_set_mask()
62 // - By the type invariant of `device::Device`, `self.as_ref().as_raw()` is valid. in dma_set_mask()
63 // - The safety requirement of this function guarantees that there are no concurrent calls in dma_set_mask()
77 unsafe fn dma_set_coherent_mask(&self, mask: DmaMask) -> Result { in dma_set_coherent_mask()
79 // - By the type invariant of `device::Device`, `self.as_ref().as_raw()` is valid. in dma_set_coherent_mask()
80 // - The safety requirement of this function guarantees that there are no concurrent calls in dma_set_coherent_mask()
96 unsafe fn dma_set_mask_and_coherent(&self, mask: DmaMask) -> Result { in dma_set_mask_and_coherent()
98 // - By the type invariant of `device::Device`, `self.as_ref().as_raw()` is valid. in dma_set_mask_and_coherent()
99 // - The safety requirement of this function guarantees that there are no concurrent calls in dma_set_mask_and_coherent()
106 /// Set the maximum size of a single DMA segment the device may request.
117 // - By the type invariant of `device::Device`, `self.as_ref().as_raw()` is valid. in dma_set_max_seg_size()
118 // - The safety requirement of this function guarantees that there are no concurrent calls in dma_set_max_seg_size()
157 pub const fn new<const N: u32>() -> Self { in new()
189 pub const fn try_new(n: u32) -> Result<Self> { in try_new()
192 1..=64 => u64::MAX >> (64 - n), in try_new()
199 pub const fn value(&self) -> u64 { in value()
216 /// # fn test(dev: &Device<Bound>) -> Result {
228 pub(crate) fn as_raw(self) -> crate::ffi::c_ulong { in as_raw()
233 pub fn contains(self, flags: Attrs) -> bool { in contains()
240 fn bitor(self, rhs: Self) -> Self::Output { in bitor()
247 fn bitand(self, rhs: Self) -> Self::Output { in bitand()
254 fn not(self) -> Self::Output { in not()
277 /// Hints DMA-mapping subsystem that it's probably not worth the time to try
281 /// This tells the DMA-mapping subsystem to suppress allocation failure reports (similarly to
286 /// ideally inaccessible or at least read-only at lesser-privileged levels).
297 /// [`enum dma_data_direction`]: srctree/include/linux/dma-direction.h
327 /// Casts the bindgen-generated enum type to a `u32` at compile time.
329 /// This function will cause a compile-time error if the underlying value of the
331 const fn const_cast(val: bindings::dma_data_direction) -> u32 { in const_cast()
340 // Trigger a compile-time error in a const context. in const_cast()
352 fn from(direction: DataDirection) -> Self { in from()
356 // compile-time checks. in from()
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
384 /// # fn test(dev: &Device<Bound>) -> Result {
404 /// # fn test(dev: &Device<Bound>) -> Result {
420 ) -> Result<Self> { in zeroed_slice_with_attrs()
430 ) -> Result<Self> { in zeroed_slice()
437 pub fn init_at<E>(&mut self, i: usize, init: impl Init<T, E>) -> Result in init_at()
448 // - `ptr` is valid, properly aligned, and within this allocation. in init_at()
449 // - `T: AsBytes + FromBytes` guarantees all bit patterns are valid, so partial writes on in init_at()
451 // - The DMA address has not been exposed yet, so there is no concurrent device access. in init_at()
473 /// # fn test(dev: &Device<Bound>) -> Result {
486 ) -> Result<Self> in from_slice_with_attrs()
510 ) -> Result<Self> in from_slice()
519 /// Same as [`CoherentBox::zeroed_slice_with_attrs`], but for a single element.
525 ) -> Result<Self> { in zeroed_with_attrs()
529 /// Same as [`CoherentBox::zeroed_slice`], but for a single element.
531 pub fn zeroed(dev: &device::Device<Bound>, gfp_flags: kernel::alloc::Flags) -> Result<Self> { in zeroed()
540 fn deref(&self) -> &Self::Target { in deref()
542 // - We have not exposed the DMA address yet, so there can't be any concurrent access by a in deref()
544 // - We have exclusive access to `self.0`. in deref()
551 fn deref_mut(&mut self) -> &mut Self::Target { in deref_mut()
553 // - We have not exposed the DMA address yet, so there can't be any concurrent access by a in deref_mut()
555 // - We have exclusive access to `self.0`. in deref_mut()
562 fn from(value: CoherentBox<T>) -> Self { in from()
579 /// - For the lifetime of an instance of [`Coherent`], the `cpu_addr` is a valid pointer
582 /// - The size in bytes of the allocation is equal to size information via pointer.
605 pub fn size(&self) -> usize { in size()
611 pub fn as_ptr(&self) -> *const T { in as_ptr()
618 pub fn as_mut_ptr(&self) -> *mut T { in as_mut_ptr()
625 pub fn dma_handle(&self) -> DmaAddress { in dma_handle()
638 pub unsafe fn as_ref(&self) -> &T { in as_ref()
653 pub unsafe fn as_mut(&self) -> &mut T { in as_mut()
667 pub unsafe fn field_read<F: FromBytes>(&self, field: *const F) -> F { in field_read()
669 // - By the safety requirements field is valid. in field_read()
670 // - Using read_volatile() here is not sound as per the usual rules, the usage here is in field_read()
672 // race from a hardware or code outside kernel (e.g. user-space program), we need that in field_read()
692 // - By the safety requirements field is valid. in field_write()
693 // - Using write_volatile() here is not sound as per the usual rules, the usage here is in field_write()
695 // race from a hardware or code outside kernel (e.g. user-space program), we need that in field_write()
711 ) -> Result<Self> { in alloc_with_attrs()
732 // - We just successfully allocated a coherent region which is adequately sized for `T`, in alloc_with_attrs()
734 // - We also hold a refcounted reference to the device. in alloc_with_attrs()
757 /// # fn test(dev: &Device<Bound>) -> Result {
767 ) -> Result<Self> { in zeroed_with_attrs()
774 pub fn zeroed(dev: &device::Device<Bound>, gfp_flags: kernel::alloc::Flags) -> Result<Self> { in zeroed()
778 /// Same as [`Coherent::zeroed_with_attrs`], but instead of a zero-initialization the memory is
785 ) -> Result<Self> in init_with_attrs()
793 // - `ptr` is valid, properly aligned, and points to exclusively owned memory. in init_with_attrs()
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
809 ) -> Result<Self> in init()
822 ) -> Result<Coherent<[T]>> { in alloc_slice_with_attrs()
830 // `dma_alloc_attrs` cannot handle zero-length allocation, bail early. in alloc_slice_with_attrs()
849 // - We just successfully allocated a coherent region which is adequately sized for in alloc_slice_with_attrs()
851 // - We also hold a refcounted reference to the device. in alloc_slice_with_attrs()
877 /// # fn test(dev: &Device<Bound>) -> Result {
888 ) -> Result<Coherent<[T]>> { in zeroed_slice_with_attrs()
899 ) -> Result<Coherent<[T]>> { in zeroed_slice()
915 /// # fn test(dev: &Device<Bound>) -> Result {
929 ) -> Result<Coherent<[T]>> in from_slice_with_attrs()
943 ) -> Result<Coherent<[T]>> in from_slice()
958 pub fn len(&self) -> usize { in len()
997 ) -> Result<usize> { in write_to_slice()
1002 // If the offset is too large for a usize (e.g. on 32-bit platforms), in write_to_slice()
1028 /// - `cpu_handle` holds the opaque handle returned by `dma_alloc_attrs` with
1030 /// - `dma_handle` is the corresponding bus address for device DMA.
1031 /// - `size` is the allocation size in bytes as passed to `dma_alloc_attrs`.
1032 /// - `dma_attrs` contains the attributes used for the allocation, always including
1054 ) -> Result<Self> { in alloc_with_attrs()
1092 ) -> Result<Self> { in alloc()
1100 pub fn dma_handle(&self) -> DmaAddress { in dma_handle()
1106 pub fn size(&self) -> usize { in size()
1154 /// # fn test(alloc: &kernel::dma::Coherent<[MyStruct]>) -> Result {
1161 ($dma:expr, $($proj:tt)*) => {{
1191 /// # fn test(alloc: &kernel::dma::Coherent<[MyStruct]>) -> Result {
1198 (@parse [$dma:expr] [$($proj:tt)*] [, $val:expr]) => {{
1207 (@parse [$dma:expr] [$($proj:tt)*] [.$field:tt $($rest:tt)*]) => {
1210 (@parse [$dma:expr] [$($proj:tt)*] [[$index:expr]? $($rest:tt)*]) => {
1213 (@parse [$dma:expr] [$($proj:tt)*] [[$index:expr] $($rest:tt)*]) => {
1216 ($dma:expr, $($rest:tt)*) => {