Lines Matching +full:page +full:- +full:size
1 /* SPDX-License-Identifier: GPL-2.0 */
9 #include <linux/dma-mapping.h>
27 void *(*alloc)(struct device *dev, size_t size,
30 void (*free)(struct device *dev, size_t size, void *vaddr,
32 struct page *(*alloc_pages)(struct device *dev, size_t size,
35 void (*free_pages)(struct device *dev, size_t size, struct page *vaddr,
37 struct sg_table *(*alloc_noncontiguous)(struct device *dev, size_t size,
40 void (*free_noncontiguous)(struct device *dev, size_t size,
46 void *cpu_addr, dma_addr_t dma_addr, size_t size,
49 dma_addr_t (*map_page)(struct device *dev, struct page *page,
50 unsigned long offset, size_t size,
53 size_t size, enum dma_data_direction dir,
65 size_t size, enum dma_data_direction dir,
68 size_t size, enum dma_data_direction dir,
71 size_t size, enum dma_data_direction dir);
73 dma_addr_t dma_handle, size_t size,
79 void (*cache_sync)(struct device *dev, void *vaddr, size_t size,
89 #include <asm/dma-mapping.h>
93 if (dev->dma_ops) in get_dma_ops()
94 return dev->dma_ops; in get_dma_ops()
101 dev->dma_ops = dma_ops; in set_dma_ops()
119 if (dev && dev->cma_area) in dev_get_cma_area()
120 return dev->cma_area; in dev_get_cma_area()
125 int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
128 struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
130 bool dma_release_from_contiguous(struct device *dev, struct page *pages,
132 struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp);
133 void dma_free_contiguous(struct device *dev, struct page *page, size_t size);
135 void dma_contiguous_early_fixup(phys_addr_t base, unsigned long size);
144 static inline int dma_contiguous_reserve_area(phys_addr_t size, in dma_contiguous_reserve_area() argument
148 return -ENOSYS; in dma_contiguous_reserve_area()
150 static inline struct page *dma_alloc_from_contiguous(struct device *dev, in dma_alloc_from_contiguous()
156 struct page *pages, int count) in dma_release_from_contiguous()
161 static inline struct page *dma_alloc_contiguous(struct device *dev, size_t size, in dma_alloc_contiguous() argument
166 static inline void dma_free_contiguous(struct device *dev, struct page *page, in dma_free_contiguous() argument
167 size_t size) in dma_free_contiguous() argument
169 __free_pages(page, get_order(size)); in dma_free_contiguous()
175 dma_addr_t device_addr, size_t size);
177 int dma_alloc_from_dev_coherent(struct device *dev, ssize_t size,
181 void *cpu_addr, size_t size, int *ret);
184 phys_addr_t phys_addr, dma_addr_t device_addr, size_t size) in dma_declare_coherent_memory() argument
186 return -ENOSYS; in dma_declare_coherent_memory()
189 #define dma_alloc_from_dev_coherent(dev, size, handle, ret) (0) argument
196 void *dma_alloc_from_global_coherent(struct device *dev, ssize_t size,
200 size_t size, int *ret);
201 int dma_init_global_coherent(phys_addr_t phys_addr, size_t size);
204 ssize_t size, dma_addr_t *dma_handle) in dma_alloc_from_global_coherent() argument
213 void *cpu_addr, size_t size, int *ret) in dma_mmap_from_global_coherent() argument
220 * This is the actual return value from the ->alloc_noncontiguous method.
222 * the DMA-API internal vmaping and freeing easier we stash away the page
224 * e.g. when a vmap-variant that takes a scatterlist comes along.
228 struct page **pages;
234 void *cpu_addr, dma_addr_t dma_addr, size_t size,
237 void *cpu_addr, dma_addr_t dma_addr, size_t size,
239 struct page *dma_common_alloc_pages(struct device *dev, size_t size,
241 void dma_common_free_pages(struct device *dev, size_t size, struct page *vaddr,
244 struct page **dma_common_find_pages(void *cpu_addr);
245 void *dma_common_contiguous_remap(struct page *page, size_t size, pgprot_t prot,
247 void *dma_common_pages_remap(struct page **pages, size_t size, pgprot_t prot,
249 void dma_common_free_remap(void *cpu_addr, size_t size);
251 struct page *dma_alloc_from_pool(struct device *dev, size_t size,
254 bool dma_free_from_pool(struct device *dev, void *start, size_t size);
257 dma_addr_t dma_start, u64 size);
265 return dev->dma_coherent; in dev_is_dma_coherent()
277 * Check whether potential kmalloc() buffers are safe for non-coherent DMA.
284 * caches have already been aligned to a DMA-safe size. in dma_kmalloc_safe()
290 * kmalloc() buffers are DMA-safe irrespective of size if the device in dma_kmalloc_safe()
291 * is coherent or the direction is DMA_TO_DEVICE (non-desctructive in dma_kmalloc_safe()
301 * Check whether the given size, assuming it is for a kmalloc()'ed buffer, is
302 * sufficiently aligned for non-coherent DMA.
304 static inline bool dma_kmalloc_size_aligned(size_t size) in dma_kmalloc_size_aligned() argument
310 if (size >= 2 * ARCH_DMA_MINALIGN || in dma_kmalloc_size_aligned()
311 IS_ALIGNED(kmalloc_size_roundup(size), dma_get_cache_alignment())) in dma_kmalloc_size_aligned()
318 * Check whether the given object size may have originated from a kmalloc()
319 * buffer with a slab alignment below the DMA-safe alignment and needs
320 * bouncing for non-coherent DMA. The pointer alignment is not considered and
321 * in-structure DMA-safe offsets are the responsibility of the caller. Such
330 static inline bool dma_kmalloc_needs_bounce(struct device *dev, size_t size, in dma_kmalloc_needs_bounce() argument
333 return !dma_kmalloc_safe(dev, dir) && !dma_kmalloc_size_aligned(size); in dma_kmalloc_needs_bounce()
336 void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
338 void arch_dma_free(struct device *dev, size_t size, void *cpu_addr,
349 * Page protection so that devices that can't snoop CPU caches can use the
363 return prot; /* no protection bits supported without page tables */ in dma_pgprot()
368 void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
371 static inline void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, in arch_sync_dma_for_device() argument
378 void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
381 static inline void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size, in arch_sync_dma_for_cpu() argument
396 void arch_dma_prep_coherent(struct page *page, size_t size);
398 static inline void arch_dma_prep_coherent(struct page *page, size_t size) in arch_dma_prep_coherent() argument
404 void arch_dma_mark_clean(phys_addr_t paddr, size_t size);
406 static inline void arch_dma_mark_clean(phys_addr_t paddr, size_t size) in arch_dma_mark_clean() argument
411 void *arch_dma_set_uncached(void *addr, size_t size);
412 void arch_dma_clear_uncached(void *addr, size_t size);
429 void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
433 u64 size, bool coherent) in arch_setup_dma_ops() argument
488 * addresses (in the case of dma-direct) or IOVA addresses (in the