Lines Matching +full:page +full:- +full:size
1 /* SPDX-License-Identifier: GPL-2.0 */
9 #include <linux/dma-mapping.h>
26 void *(*alloc)(struct device *dev, size_t size,
29 void (*free)(struct device *dev, size_t size, void *vaddr,
31 struct page *(*alloc_pages)(struct device *dev, size_t size,
34 void (*free_pages)(struct device *dev, size_t size, struct page *vaddr,
36 struct sg_table *(*alloc_noncontiguous)(struct device *dev, size_t size,
39 void (*free_noncontiguous)(struct device *dev, size_t size,
45 void *cpu_addr, dma_addr_t dma_addr, size_t size,
48 dma_addr_t (*map_page)(struct device *dev, struct page *page,
49 unsigned long offset, size_t size,
52 size_t size, enum dma_data_direction dir,
64 size_t size, enum dma_data_direction dir,
67 size_t size, enum dma_data_direction dir,
70 size_t size, enum dma_data_direction dir);
72 dma_addr_t dma_handle, size_t size,
78 void (*cache_sync)(struct device *dev, void *vaddr, size_t size,
88 #include <asm/dma-mapping.h>
92 if (dev->dma_ops) in get_dma_ops()
93 return dev->dma_ops; in get_dma_ops()
100 dev->dma_ops = dma_ops; in set_dma_ops()
118 if (dev && dev->cma_area) in dev_get_cma_area()
119 return dev->cma_area; in dev_get_cma_area()
124 int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
127 struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
129 bool dma_release_from_contiguous(struct device *dev, struct page *pages,
131 struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp);
132 void dma_free_contiguous(struct device *dev, struct page *page, size_t size);
134 void dma_contiguous_early_fixup(phys_addr_t base, unsigned long size);
143 static inline int dma_contiguous_reserve_area(phys_addr_t size, in dma_contiguous_reserve_area() argument
147 return -ENOSYS; in dma_contiguous_reserve_area()
149 static inline struct page *dma_alloc_from_contiguous(struct device *dev, in dma_alloc_from_contiguous()
155 struct page *pages, int count) in dma_release_from_contiguous()
160 static inline struct page *dma_alloc_contiguous(struct device *dev, size_t size, in dma_alloc_contiguous() argument
165 static inline void dma_free_contiguous(struct device *dev, struct page *page, in dma_free_contiguous() argument
166 size_t size) in dma_free_contiguous() argument
168 __free_pages(page, get_order(size)); in dma_free_contiguous()
174 dma_addr_t device_addr, size_t size);
176 int dma_alloc_from_dev_coherent(struct device *dev, ssize_t size,
180 void *cpu_addr, size_t size, int *ret);
183 phys_addr_t phys_addr, dma_addr_t device_addr, size_t size) in dma_declare_coherent_memory() argument
185 return -ENOSYS; in dma_declare_coherent_memory()
188 #define dma_alloc_from_dev_coherent(dev, size, handle, ret) (0) argument
195 void *dma_alloc_from_global_coherent(struct device *dev, ssize_t size,
199 size_t size, int *ret);
200 int dma_init_global_coherent(phys_addr_t phys_addr, size_t size);
203 ssize_t size, dma_addr_t *dma_handle) in dma_alloc_from_global_coherent() argument
212 void *cpu_addr, size_t size, int *ret) in dma_mmap_from_global_coherent() argument
219 * This is the actual return value from the ->alloc_noncontiguous method.
221 * the DMA-API internal vmaping and freeing easier we stash away the page
223 * e.g. when a vmap-variant that takes a scatterlist comes along.
227 struct page **pages;
233 void *cpu_addr, dma_addr_t dma_addr, size_t size,
236 void *cpu_addr, dma_addr_t dma_addr, size_t size,
238 struct page *dma_common_alloc_pages(struct device *dev, size_t size,
240 void dma_common_free_pages(struct device *dev, size_t size, struct page *vaddr,
243 struct page **dma_common_find_pages(void *cpu_addr);
244 void *dma_common_contiguous_remap(struct page *page, size_t size, pgprot_t prot,
246 void *dma_common_pages_remap(struct page **pages, size_t size, pgprot_t prot,
248 void dma_common_free_remap(void *cpu_addr, size_t size);
250 struct page *dma_alloc_from_pool(struct device *dev, size_t size,
253 bool dma_free_from_pool(struct device *dev, void *start, size_t size);
256 dma_addr_t dma_start, u64 size);
264 return dev->dma_coherent; in dev_is_dma_coherent()
276 * Check whether potential kmalloc() buffers are safe for non-coherent DMA.
283 * caches have already been aligned to a DMA-safe size. in dma_kmalloc_safe()
289 * kmalloc() buffers are DMA-safe irrespective of size if the device in dma_kmalloc_safe()
290 * is coherent or the direction is DMA_TO_DEVICE (non-desctructive in dma_kmalloc_safe()
300 * Check whether the given size, assuming it is for a kmalloc()'ed buffer, is
301 * sufficiently aligned for non-coherent DMA.
303 static inline bool dma_kmalloc_size_aligned(size_t size) in dma_kmalloc_size_aligned() argument
309 if (size >= 2 * ARCH_DMA_MINALIGN || in dma_kmalloc_size_aligned()
310 IS_ALIGNED(kmalloc_size_roundup(size), dma_get_cache_alignment())) in dma_kmalloc_size_aligned()
317 * Check whether the given object size may have originated from a kmalloc()
318 * buffer with a slab alignment below the DMA-safe alignment and needs
319 * bouncing for non-coherent DMA. The pointer alignment is not considered and
320 * in-structure DMA-safe offsets are the responsibility of the caller. Such
329 static inline bool dma_kmalloc_needs_bounce(struct device *dev, size_t size, in dma_kmalloc_needs_bounce() argument
332 return !dma_kmalloc_safe(dev, dir) && !dma_kmalloc_size_aligned(size); in dma_kmalloc_needs_bounce()
335 void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
337 void arch_dma_free(struct device *dev, size_t size, void *cpu_addr,
348 * Page protection so that devices that can't snoop CPU caches can use the
362 return prot; /* no protection bits supported without page tables */ in dma_pgprot()
367 void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
370 static inline void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, in arch_sync_dma_for_device() argument
377 void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
380 static inline void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size, in arch_sync_dma_for_cpu() argument
395 void arch_dma_prep_coherent(struct page *page, size_t size);
397 static inline void arch_dma_prep_coherent(struct page *page, size_t size) in arch_dma_prep_coherent() argument
403 void arch_dma_mark_clean(phys_addr_t paddr, size_t size);
405 static inline void arch_dma_mark_clean(phys_addr_t paddr, size_t size) in arch_dma_mark_clean() argument
410 void *arch_dma_set_uncached(void *addr, size_t size);
411 void arch_dma_clear_uncached(void *addr, size_t size);
428 void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
432 u64 size, const struct iommu_ops *iommu, bool coherent) in arch_setup_dma_ops() argument
487 * addresses (in the case of dma-direct) or IOVA addresses (in the