Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Christoph Hellwig | 92a73bd | 2020-06-07 21:41:39 -0700 | [diff] [blame] | 2 | #ifndef _ASM_GENERIC_CACHEFLUSH_H |
| 3 | #define _ASM_GENERIC_CACHEFLUSH_H |
Arnd Bergmann | 5c01b46 | 2009-05-13 22:56:36 +0000 | [diff] [blame] | 4 | |
Stephen Rothwell | 8dbdd50 | 2020-06-25 20:30:07 -0700 | [diff] [blame] | 5 | struct mm_struct; |
| 6 | struct vm_area_struct; |
| 7 | struct page; |
| 8 | struct address_space; |
| 9 | |
Arnd Bergmann | 5c01b46 | 2009-05-13 22:56:36 +0000 | [diff] [blame] | 10 | /* |
| 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 | */ |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 14 | #ifndef flush_cache_all |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 15 | static inline void flush_cache_all(void) |
| 16 | { |
| 17 | } |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 18 | #endif |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 19 | |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 20 | #ifndef flush_cache_mm |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 21 | static inline void flush_cache_mm(struct mm_struct *mm) |
| 22 | { |
| 23 | } |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 24 | #endif |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 25 | |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 26 | #ifndef flush_cache_dup_mm |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 27 | static inline void flush_cache_dup_mm(struct mm_struct *mm) |
| 28 | { |
| 29 | } |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 30 | #endif |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 31 | |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 32 | #ifndef flush_cache_range |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 33 | static inline void flush_cache_range(struct vm_area_struct *vma, |
| 34 | unsigned long start, |
| 35 | unsigned long end) |
| 36 | { |
| 37 | } |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 38 | #endif |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 39 | |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 40 | #ifndef flush_cache_page |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 41 | static inline void flush_cache_page(struct vm_area_struct *vma, |
| 42 | unsigned long vmaddr, |
| 43 | unsigned long pfn) |
| 44 | { |
| 45 | } |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 46 | #endif |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 47 | |
Christoph Hellwig | 76b3b58 | 2020-06-07 21:41:45 -0700 | [diff] [blame] | 48 | #ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 49 | static inline void flush_dcache_page(struct page *page) |
| 50 | { |
| 51 | } |
Matthew Wilcox (Oracle) | 08b0b00 | 2020-12-16 11:06:33 -0500 | [diff] [blame] | 52 | |
Christoph Hellwig | 76b3b58 | 2020-06-07 21:41:45 -0700 | [diff] [blame] | 53 | #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 |
Matthew Wilcox (Oracle) | 08b0b00 | 2020-12-16 11:06:33 -0500 | [diff] [blame] | 54 | #endif |
Christoph Hellwig | 76b3b58 | 2020-06-07 21:41:45 -0700 | [diff] [blame] | 55 | |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 56 | #ifndef flush_dcache_mmap_lock |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 57 | static inline void flush_dcache_mmap_lock(struct address_space *mapping) |
| 58 | { |
| 59 | } |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 60 | #endif |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 61 | |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 62 | #ifndef flush_dcache_mmap_unlock |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 63 | static inline void flush_dcache_mmap_unlock(struct address_space *mapping) |
| 64 | { |
| 65 | } |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 66 | #endif |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 67 | |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 68 | #ifndef flush_icache_range |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 69 | static inline void flush_icache_range(unsigned long start, unsigned long end) |
| 70 | { |
| 71 | } |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 72 | #endif |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 73 | |
Christoph Hellwig | 1268c33 | 2020-06-07 21:42:26 -0700 | [diff] [blame] | 74 | #ifndef flush_icache_user_range |
| 75 | #define flush_icache_user_range flush_icache_range |
| 76 | #endif |
| 77 | |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 78 | #ifndef flush_icache_page |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 79 | static inline void flush_icache_page(struct vm_area_struct *vma, |
| 80 | struct page *page) |
| 81 | { |
| 82 | } |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 83 | #endif |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 84 | |
Christoph Hellwig | 885f7f8 | 2020-06-07 21:42:22 -0700 | [diff] [blame] | 85 | #ifndef flush_icache_user_page |
| 86 | static inline void flush_icache_user_page(struct vm_area_struct *vma, |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 87 | struct page *page, |
| 88 | unsigned long addr, int len) |
| 89 | { |
| 90 | } |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 91 | #endif |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 92 | |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 93 | #ifndef flush_cache_vmap |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 94 | static inline void flush_cache_vmap(unsigned long start, unsigned long end) |
| 95 | { |
| 96 | } |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 97 | #endif |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 98 | |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 99 | #ifndef flush_cache_vunmap |
Qian Cai | c296d4d | 2019-07-16 16:27:06 -0700 | [diff] [blame] | 100 | static inline void flush_cache_vunmap(unsigned long start, unsigned long end) |
| 101 | { |
| 102 | } |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 103 | #endif |
Arnd Bergmann | 5c01b46 | 2009-05-13 22:56:36 +0000 | [diff] [blame] | 104 | |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 105 | #ifndef copy_to_user_page |
| 106 | #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ |
Mike Frysinger | f68aa5b | 2011-05-24 17:12:53 -0700 | [diff] [blame] | 107 | do { \ |
| 108 | memcpy(dst, src, len); \ |
Christoph Hellwig | 885f7f8 | 2020-06-07 21:42:22 -0700 | [diff] [blame] | 109 | flush_icache_user_page(vma, page, vaddr, len); \ |
Mike Frysinger | f68aa5b | 2011-05-24 17:12:53 -0700 | [diff] [blame] | 110 | } while (0) |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 111 | #endif |
| 112 | |
| 113 | #ifndef copy_from_user_page |
Arnd Bergmann | 5c01b46 | 2009-05-13 22:56:36 +0000 | [diff] [blame] | 114 | #define copy_from_user_page(vma, page, vaddr, dst, src, len) \ |
| 115 | memcpy(dst, src, len) |
Mike Rapoport | 4f0bd80 | 2019-12-23 13:00:03 +0200 | [diff] [blame] | 116 | #endif |
Arnd Bergmann | 5c01b46 | 2009-05-13 22:56:36 +0000 | [diff] [blame] | 117 | |
Christoph Hellwig | 92a73bd | 2020-06-07 21:41:39 -0700 | [diff] [blame] | 118 | #endif /* _ASM_GENERIC_CACHEFLUSH_H */ |