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

1 // SPDX-License-Identifier: GPL-2.0-only
13 #include <linux/dma-direct.h>
14 #include <linux/dma-map-ops.h>
22 static void __dma_sync(void *vaddr, size_t size, int direction) in __dma_sync() argument
25 unsigned long end = start + size; in __dma_sync()
32 * invalidate only when cache-line aligned otherwise there is in __dma_sync()
35 if ((start | end) & (L1_CACHE_BYTES - 1)) in __dma_sync()
52 * In this case, each page of a buffer must be kmapped/kunmapped
57 * beyond the first page.
59 static inline void __dma_sync_page_highmem(struct page *page, in __dma_sync_page_highmem() argument
60 unsigned long offset, size_t size, int direction) in __dma_sync_page_highmem() argument
62 size_t seg_size = min((size_t)(PAGE_SIZE - offset), size); in __dma_sync_page_highmem()
65 int nr_segs = 1 + ((size - seg_size) + PAGE_SIZE - 1)/PAGE_SIZE; in __dma_sync_page_highmem()
71 start = (unsigned long)kmap_atomic(page + seg_nr) + seg_offset; in __dma_sync_page_highmem()
78 /* Calculate next buffer segment size */ in __dma_sync_page_highmem()
79 seg_size = min((size_t)PAGE_SIZE, size - cur_size); in __dma_sync_page_highmem()
81 /* Add the segment size to our running total */ in __dma_sync_page_highmem()
92 * takes a struct page instead of a virtual address
94 static void __dma_sync_page(phys_addr_t paddr, size_t size, int dir) in __dma_sync_page() argument
96 struct page *page = pfn_to_page(paddr >> PAGE_SHIFT); in __dma_sync_page() local
100 __dma_sync_page_highmem(page, offset, size, dir); in __dma_sync_page()
102 unsigned long start = (unsigned long)page_address(page) + offset; in __dma_sync_page()
103 __dma_sync((void *)start, size, dir); in __dma_sync_page()
107 void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, in arch_sync_dma_for_device() argument
110 __dma_sync_page(paddr, size, dir); in arch_sync_dma_for_device()
113 void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size, in arch_sync_dma_for_cpu() argument
116 __dma_sync_page(paddr, size, dir); in arch_sync_dma_for_cpu()
119 void arch_dma_prep_coherent(struct page *page, size_t size) in arch_dma_prep_coherent() argument
121 unsigned long kaddr = (unsigned long)page_address(page); in arch_dma_prep_coherent()
123 flush_dcache_range(kaddr, kaddr + size); in arch_dma_prep_coherent()