2 * Copyright (C) 2017 ARM Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include <linux/uaccess.h>
18 #include <asm/barrier.h>
19 #include <asm/cacheflush.h>
21 void memcpy_flushcache(void *dst, const void *src, size_t cnt)
24 * We assume this should not be called with @dst pointing to
25 * non-cacheable memory, such that we don't need an explicit
26 * barrier to order the cache maintenance against the memcpy.
28 memcpy(dst, src, cnt);
29 __clean_dcache_area_pop(dst, cnt);
31 EXPORT_SYMBOL_GPL(memcpy_flushcache);
33 void memcpy_page_flushcache(char *to, struct page *page, size_t offset,
36 memcpy_flushcache(to, page_address(page) + offset, len);
39 unsigned long __copy_user_flushcache(void *to, const void __user *from,
42 unsigned long rc = __arch_copy_from_user(to, from, n);
45 __clean_dcache_area_pop(to, n - rc);