1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright(c) 2017 IBM Corporation. All rights reserved.
6 #include <linux/string.h>
7 #include <linux/export.h>
8 #include <linux/uaccess.h>
10 #include <asm/cacheflush.h>
13 * CONFIG_ARCH_HAS_PMEM_API symbols
15 void arch_wb_cache_pmem(void *addr
, size_t size
)
17 unsigned long start
= (unsigned long) addr
;
18 flush_dcache_range(start
, start
+ size
);
20 EXPORT_SYMBOL_GPL(arch_wb_cache_pmem
);
22 void arch_invalidate_pmem(void *addr
, size_t size
)
24 unsigned long start
= (unsigned long) addr
;
25 flush_dcache_range(start
, start
+ size
);
27 EXPORT_SYMBOL_GPL(arch_invalidate_pmem
);
30 * CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE symbols
32 long __copy_from_user_flushcache(void *dest
, const void __user
*src
,
35 unsigned long copied
, start
= (unsigned long) dest
;
37 copied
= __copy_from_user(dest
, src
, size
);
38 flush_dcache_range(start
, start
+ size
);
43 void *memcpy_flushcache(void *dest
, const void *src
, size_t size
)
45 unsigned long start
= (unsigned long) dest
;
47 memcpy(dest
, src
, size
);
48 flush_dcache_range(start
, start
+ size
);
52 EXPORT_SYMBOL(memcpy_flushcache
);
54 void memcpy_page_flushcache(char *to
, struct page
*page
, size_t offset
,
57 memcpy_flushcache(to
, page_to_virt(page
) + offset
, len
);
59 EXPORT_SYMBOL(memcpy_page_flushcache
);