3 * (C) COPYRIGHT ARM Limited. All rights reserved.
5 * This program is free software and is provided to you under the terms of the
6 * GNU General Public License version 2 as published by the Free Software
7 * Foundation, and any use by you of this program is subject to the terms
10 * A copy of the licence is included with the program, and can also be obtained
11 * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12 * Boston, MA 02110-1301, USA.
20 #include <kbase/src/common/mali_kbase.h>
24 #include <linux/highmem.h>
25 #include <linux/dma-mapping.h>
26 #include <linux/mutex.h>
27 #include <asm/cacheflush.h>
29 void kbase_sync_to_memory(phys_addr_t paddr, void *vaddr, size_t sz)
32 __cpuc_flush_dcache_area(vaddr, sz);
33 outer_flush_range(paddr, paddr + sz);
34 #elif defined(CONFIG_ARM64)
35 /* FIXME (MID64-46): There's no other suitable cache flush function for ARM64 */
37 #elif defined(CONFIG_X86)
38 struct scatterlist scl = { 0, };
39 sg_set_page(&scl, pfn_to_page(PFN_DOWN(paddr)), sz, paddr & (PAGE_SIZE - 1));
40 dma_sync_sg_for_cpu(NULL, &scl, 1, DMA_TO_DEVICE);
41 mb(); /* for outer_sync (if needed) */
43 #error Implement cache maintenance for your architecture here
47 void kbase_sync_to_cpu(phys_addr_t paddr, void *vaddr, size_t sz)
50 __cpuc_flush_dcache_area(vaddr, sz);
51 outer_flush_range(paddr, paddr + sz);
52 #elif defined(CONFIG_ARM64)
53 /* FIXME (MID64-46): There's no other suitable cache flush function for ARM64 */
55 #elif defined(CONFIG_X86)
56 struct scatterlist scl = { 0, };
57 sg_set_page(&scl, pfn_to_page(PFN_DOWN(paddr)), sz, paddr & (PAGE_SIZE - 1));
58 dma_sync_sg_for_cpu(NULL, &scl, 1, DMA_FROM_DEVICE);
60 #error Implement cache maintenance for your architecture here