blob: cac7404b2bdd2cdcd1c4041f496aecbf4e9245fe [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __ASM_CACHEFLUSH_H
3#define __ASM_CACHEFLUSH_H
4
5/* Keep includes the same across arches. */
6#include <linux/mm.h>
7
David Brazdil0f672f62019-12-10 10:32:29 +00008#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
9
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000010/*
11 * The cache doesn't need to be flushed when TLB entries change when
12 * the cache is mapped to physical memory, not virtual memory
13 */
Olivier Deprez0e641232021-09-23 10:07:05 +020014#ifndef flush_cache_all
David Brazdil0f672f62019-12-10 10:32:29 +000015static inline void flush_cache_all(void)
16{
17}
Olivier Deprez0e641232021-09-23 10:07:05 +020018#endif
David Brazdil0f672f62019-12-10 10:32:29 +000019
Olivier Deprez0e641232021-09-23 10:07:05 +020020#ifndef flush_cache_mm
David Brazdil0f672f62019-12-10 10:32:29 +000021static inline void flush_cache_mm(struct mm_struct *mm)
22{
23}
Olivier Deprez0e641232021-09-23 10:07:05 +020024#endif
David Brazdil0f672f62019-12-10 10:32:29 +000025
Olivier Deprez0e641232021-09-23 10:07:05 +020026#ifndef flush_cache_dup_mm
David Brazdil0f672f62019-12-10 10:32:29 +000027static inline void flush_cache_dup_mm(struct mm_struct *mm)
28{
29}
Olivier Deprez0e641232021-09-23 10:07:05 +020030#endif
David Brazdil0f672f62019-12-10 10:32:29 +000031
Olivier Deprez0e641232021-09-23 10:07:05 +020032#ifndef flush_cache_range
David Brazdil0f672f62019-12-10 10:32:29 +000033static inline void flush_cache_range(struct vm_area_struct *vma,
34 unsigned long start,
35 unsigned long end)
36{
37}
Olivier Deprez0e641232021-09-23 10:07:05 +020038#endif
David Brazdil0f672f62019-12-10 10:32:29 +000039
Olivier Deprez0e641232021-09-23 10:07:05 +020040#ifndef flush_cache_page
David Brazdil0f672f62019-12-10 10:32:29 +000041static inline void flush_cache_page(struct vm_area_struct *vma,
42 unsigned long vmaddr,
43 unsigned long pfn)
44{
45}
Olivier Deprez0e641232021-09-23 10:07:05 +020046#endif
David Brazdil0f672f62019-12-10 10:32:29 +000047
Olivier Deprez0e641232021-09-23 10:07:05 +020048#ifndef flush_dcache_page
David Brazdil0f672f62019-12-10 10:32:29 +000049static inline void flush_dcache_page(struct page *page)
50{
51}
Olivier Deprez0e641232021-09-23 10:07:05 +020052#endif
David Brazdil0f672f62019-12-10 10:32:29 +000053
Olivier Deprez0e641232021-09-23 10:07:05 +020054#ifndef flush_dcache_mmap_lock
David Brazdil0f672f62019-12-10 10:32:29 +000055static inline void flush_dcache_mmap_lock(struct address_space *mapping)
56{
57}
Olivier Deprez0e641232021-09-23 10:07:05 +020058#endif
David Brazdil0f672f62019-12-10 10:32:29 +000059
Olivier Deprez0e641232021-09-23 10:07:05 +020060#ifndef flush_dcache_mmap_unlock
David Brazdil0f672f62019-12-10 10:32:29 +000061static inline void flush_dcache_mmap_unlock(struct address_space *mapping)
62{
63}
Olivier Deprez0e641232021-09-23 10:07:05 +020064#endif
David Brazdil0f672f62019-12-10 10:32:29 +000065
Olivier Deprez0e641232021-09-23 10:07:05 +020066#ifndef flush_icache_range
David Brazdil0f672f62019-12-10 10:32:29 +000067static inline void flush_icache_range(unsigned long start, unsigned long end)
68{
69}
Olivier Deprez0e641232021-09-23 10:07:05 +020070#endif
David Brazdil0f672f62019-12-10 10:32:29 +000071
Olivier Deprez0e641232021-09-23 10:07:05 +020072#ifndef flush_icache_page
David Brazdil0f672f62019-12-10 10:32:29 +000073static inline void flush_icache_page(struct vm_area_struct *vma,
74 struct page *page)
75{
76}
Olivier Deprez0e641232021-09-23 10:07:05 +020077#endif
David Brazdil0f672f62019-12-10 10:32:29 +000078
Olivier Deprez0e641232021-09-23 10:07:05 +020079#ifndef flush_icache_user_range
David Brazdil0f672f62019-12-10 10:32:29 +000080static inline void flush_icache_user_range(struct vm_area_struct *vma,
81 struct page *page,
82 unsigned long addr, int len)
83{
84}
Olivier Deprez0e641232021-09-23 10:07:05 +020085#endif
David Brazdil0f672f62019-12-10 10:32:29 +000086
Olivier Deprez0e641232021-09-23 10:07:05 +020087#ifndef flush_cache_vmap
David Brazdil0f672f62019-12-10 10:32:29 +000088static inline void flush_cache_vmap(unsigned long start, unsigned long end)
89{
90}
Olivier Deprez0e641232021-09-23 10:07:05 +020091#endif
David Brazdil0f672f62019-12-10 10:32:29 +000092
Olivier Deprez0e641232021-09-23 10:07:05 +020093#ifndef flush_cache_vunmap
David Brazdil0f672f62019-12-10 10:32:29 +000094static inline void flush_cache_vunmap(unsigned long start, unsigned long end)
95{
96}
Olivier Deprez0e641232021-09-23 10:07:05 +020097#endif
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000098
Olivier Deprez0e641232021-09-23 10:07:05 +020099#ifndef copy_to_user_page
100#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000101 do { \
102 memcpy(dst, src, len); \
103 flush_icache_user_range(vma, page, vaddr, len); \
104 } while (0)
Olivier Deprez0e641232021-09-23 10:07:05 +0200105#endif
106
107#ifndef copy_from_user_page
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000108#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
109 memcpy(dst, src, len)
Olivier Deprez0e641232021-09-23 10:07:05 +0200110#endif
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000111
112#endif /* __ASM_CACHEFLUSH_H */