Merge tag 'perf-tools-for-v6.4-3-2023-05-06' of git://git.kernel.org/pub/scm/linux...
[linux-block.git] / include / asm-generic / cacheflush.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
92a73bd2
CH
2#ifndef _ASM_GENERIC_CACHEFLUSH_H
3#define _ASM_GENERIC_CACHEFLUSH_H
5c01b46b 4
2b420aaf
AP
5#include <linux/instrumented.h>
6
8dbdd504
SR
7struct mm_struct;
8struct vm_area_struct;
9struct page;
10struct address_space;
11
5c01b46b
AB
12/*
13 * The cache doesn't need to be flushed when TLB entries change when
14 * the cache is mapped to physical memory, not virtual memory
15 */
4f0bd808 16#ifndef flush_cache_all
c296d4dc
QC
17static inline void flush_cache_all(void)
18{
19}
4f0bd808 20#endif
c296d4dc 21
4f0bd808 22#ifndef flush_cache_mm
c296d4dc
QC
23static inline void flush_cache_mm(struct mm_struct *mm)
24{
25}
4f0bd808 26#endif
c296d4dc 27
4f0bd808 28#ifndef flush_cache_dup_mm
c296d4dc
QC
29static inline void flush_cache_dup_mm(struct mm_struct *mm)
30{
31}
4f0bd808 32#endif
c296d4dc 33
4f0bd808 34#ifndef flush_cache_range
c296d4dc
QC
35static inline void flush_cache_range(struct vm_area_struct *vma,
36 unsigned long start,
37 unsigned long end)
38{
39}
4f0bd808 40#endif
c296d4dc 41
4f0bd808 42#ifndef flush_cache_page
c296d4dc
QC
43static inline void flush_cache_page(struct vm_area_struct *vma,
44 unsigned long vmaddr,
45 unsigned long pfn)
46{
47}
4f0bd808 48#endif
c296d4dc 49
76b3b58f 50#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
c296d4dc
QC
51static inline void flush_dcache_page(struct page *page)
52{
53}
08b0b005 54
76b3b58f 55#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
08b0b005 56#endif
76b3b58f 57
4f0bd808 58#ifndef flush_dcache_mmap_lock
c296d4dc
QC
59static inline void flush_dcache_mmap_lock(struct address_space *mapping)
60{
61}
4f0bd808 62#endif
c296d4dc 63
4f0bd808 64#ifndef flush_dcache_mmap_unlock
c296d4dc
QC
65static inline void flush_dcache_mmap_unlock(struct address_space *mapping)
66{
67}
4f0bd808 68#endif
c296d4dc 69
4f0bd808 70#ifndef flush_icache_range
c296d4dc
QC
71static inline void flush_icache_range(unsigned long start, unsigned long end)
72{
73}
4f0bd808 74#endif
c296d4dc 75
1268c333
CH
76#ifndef flush_icache_user_range
77#define flush_icache_user_range flush_icache_range
78#endif
79
4f0bd808 80#ifndef flush_icache_page
c296d4dc
QC
81static inline void flush_icache_page(struct vm_area_struct *vma,
82 struct page *page)
83{
84}
4f0bd808 85#endif
c296d4dc 86
885f7f8e
CH
87#ifndef flush_icache_user_page
88static inline void flush_icache_user_page(struct vm_area_struct *vma,
c296d4dc
QC
89 struct page *page,
90 unsigned long addr, int len)
91{
92}
4f0bd808 93#endif
c296d4dc 94
4f0bd808 95#ifndef flush_cache_vmap
c296d4dc
QC
96static inline void flush_cache_vmap(unsigned long start, unsigned long end)
97{
98}
4f0bd808 99#endif
c296d4dc 100
4f0bd808 101#ifndef flush_cache_vunmap
c296d4dc
QC
102static inline void flush_cache_vunmap(unsigned long start, unsigned long end)
103{
104}
4f0bd808 105#endif
5c01b46b 106
4f0bd808
MR
107#ifndef copy_to_user_page
108#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
f68aa5b4 109 do { \
2b420aaf 110 instrument_copy_to_user((void __user *)dst, src, len); \
f68aa5b4 111 memcpy(dst, src, len); \
885f7f8e 112 flush_icache_user_page(vma, page, vaddr, len); \
f68aa5b4 113 } while (0)
4f0bd808
MR
114#endif
115
2b420aaf 116
4f0bd808 117#ifndef copy_from_user_page
2b420aaf
AP
118#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
119 do { \
120 instrument_copy_from_user_before(dst, (void __user *)src, \
121 len); \
122 memcpy(dst, src, len); \
123 instrument_copy_from_user_after(dst, (void __user *)src, len, \
124 0); \
125 } while (0)
4f0bd808 126#endif
5c01b46b 127
92a73bd2 128#endif /* _ASM_GENERIC_CACHEFLUSH_H */