Lines Matching +full:page +full:- +full:size

1 /* SPDX-License-Identifier: GPL-2.0 */
9 #include <linux/dma-mapping.h>
17 void *(*alloc)(struct device *dev, size_t size,
20 void (*free)(struct device *dev, size_t size, void *vaddr,
22 struct page *(*alloc_pages_op)(struct device *dev, size_t size,
25 void (*free_pages)(struct device *dev, size_t size, struct page *vaddr,
31 void *cpu_addr, dma_addr_t dma_addr, size_t size,
34 dma_addr_t (*map_page)(struct device *dev, struct page *page,
35 unsigned long offset, size_t size,
38 size_t size, enum dma_data_direction dir,
50 size_t size, enum dma_data_direction dir,
53 size_t size, enum dma_data_direction dir,
56 size_t size, enum dma_data_direction dir);
58 dma_addr_t dma_handle, size_t size,
64 void (*cache_sync)(struct device *dev, void *vaddr, size_t size,
74 #include <asm/dma-mapping.h>
78 if (dev->dma_ops) in get_dma_ops()
79 return dev->dma_ops; in get_dma_ops()
86 dev->dma_ops = dma_ops; in set_dma_ops()
104 if (dev && dev->cma_area) in dev_get_cma_area()
105 return dev->cma_area; in dev_get_cma_area()
110 int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
113 struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
115 bool dma_release_from_contiguous(struct device *dev, struct page *pages,
117 struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp);
118 void dma_free_contiguous(struct device *dev, struct page *page, size_t size);
120 void dma_contiguous_early_fixup(phys_addr_t base, unsigned long size);
129 static inline int dma_contiguous_reserve_area(phys_addr_t size, in dma_contiguous_reserve_area() argument
133 return -ENOSYS; in dma_contiguous_reserve_area()
135 static inline struct page *dma_alloc_from_contiguous(struct device *dev, in dma_alloc_from_contiguous()
141 struct page *pages, int count) in dma_release_from_contiguous()
146 static inline struct page *dma_alloc_contiguous(struct device *dev, size_t size, in dma_alloc_contiguous() argument
151 static inline void dma_free_contiguous(struct device *dev, struct page *page, in dma_free_contiguous() argument
152 size_t size) in dma_free_contiguous() argument
154 __free_pages(page, get_order(size)); in dma_free_contiguous()
160 dma_addr_t device_addr, size_t size);
162 int dma_alloc_from_dev_coherent(struct device *dev, ssize_t size,
166 void *cpu_addr, size_t size, int *ret);
169 phys_addr_t phys_addr, dma_addr_t device_addr, size_t size) in dma_declare_coherent_memory() argument
171 return -ENOSYS; in dma_declare_coherent_memory()
174 #define dma_alloc_from_dev_coherent(dev, size, handle, ret) (0) argument
181 void *dma_alloc_from_global_coherent(struct device *dev, ssize_t size,
185 size_t size, int *ret);
186 int dma_init_global_coherent(phys_addr_t phys_addr, size_t size);
189 ssize_t size, dma_addr_t *dma_handle) in dma_alloc_from_global_coherent() argument
198 void *cpu_addr, size_t size, int *ret) in dma_mmap_from_global_coherent() argument
205 void *cpu_addr, dma_addr_t dma_addr, size_t size,
208 void *cpu_addr, dma_addr_t dma_addr, size_t size,
210 struct page *dma_common_alloc_pages(struct device *dev, size_t size,
212 void dma_common_free_pages(struct device *dev, size_t size, struct page *vaddr,
215 struct page **dma_common_find_pages(void *cpu_addr);
216 void *dma_common_contiguous_remap(struct page *page, size_t size, pgprot_t prot,
218 void *dma_common_pages_remap(struct page **pages, size_t size, pgprot_t prot,
220 void dma_common_free_remap(void *cpu_addr, size_t size);
222 struct page *dma_alloc_from_pool(struct device *dev, size_t size,
225 bool dma_free_from_pool(struct device *dev, void *start, size_t size);
228 dma_addr_t dma_start, u64 size);
236 return dev->dma_coherent; in dev_is_dma_coherent()
251 if (unlikely(dev->dma_skip_sync)) in dma_reset_need_sync()
252 dev->dma_skip_sync = false; in dma_reset_need_sync()
257 * Check whether potential kmalloc() buffers are safe for non-coherent DMA.
264 * caches have already been aligned to a DMA-safe size. in dma_kmalloc_safe()
270 * kmalloc() buffers are DMA-safe irrespective of size if the device in dma_kmalloc_safe()
271 * is coherent or the direction is DMA_TO_DEVICE (non-desctructive in dma_kmalloc_safe()
281 * Check whether the given size, assuming it is for a kmalloc()'ed buffer, is
282 * sufficiently aligned for non-coherent DMA.
284 static inline bool dma_kmalloc_size_aligned(size_t size) in dma_kmalloc_size_aligned() argument
290 if (size >= 2 * ARCH_DMA_MINALIGN || in dma_kmalloc_size_aligned()
291 IS_ALIGNED(kmalloc_size_roundup(size), dma_get_cache_alignment())) in dma_kmalloc_size_aligned()
298 * Check whether the given object size may have originated from a kmalloc()
299 * buffer with a slab alignment below the DMA-safe alignment and needs
300 * bouncing for non-coherent DMA. The pointer alignment is not considered and
301 * in-structure DMA-safe offsets are the responsibility of the caller. Such
310 static inline bool dma_kmalloc_needs_bounce(struct device *dev, size_t size, in dma_kmalloc_needs_bounce() argument
313 return !dma_kmalloc_safe(dev, dir) && !dma_kmalloc_size_aligned(size); in dma_kmalloc_needs_bounce()
316 void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
318 void arch_dma_free(struct device *dev, size_t size, void *cpu_addr,
329 * Page protection so that devices that can't snoop CPU caches can use the
343 return prot; /* no protection bits supported without page tables */ in dma_pgprot()
348 void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
351 static inline void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, in arch_sync_dma_for_device() argument
358 void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
361 static inline void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size, in arch_sync_dma_for_cpu() argument
376 void arch_dma_prep_coherent(struct page *page, size_t size);
378 static inline void arch_dma_prep_coherent(struct page *page, size_t size) in arch_dma_prep_coherent() argument
384 void arch_dma_mark_clean(phys_addr_t paddr, size_t size);
386 static inline void arch_dma_mark_clean(phys_addr_t paddr, size_t size) in arch_dma_mark_clean() argument
391 void *arch_dma_set_uncached(void *addr, size_t size);
392 void arch_dma_clear_uncached(void *addr, size_t size);
466 * addresses (in the case of dma-direct) or IOVA addresses (in the