^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __ASM_SH_CACHEFLUSH_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __ASM_SH_CACHEFLUSH_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Cache flushing:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * - flush_cache_all() flushes entire cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * - flush_cache_mm(mm) flushes the specified mm context's cache lines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * - flush_cache_dup mm(mm) handles cache flushing when forking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * - flush_cache_page(mm, vmaddr, pfn) flushes a single page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * - flush_cache_range(vma, start, end) flushes a range of pages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * - flush_dcache_page(pg) flushes(wback&invalidates) a page for dcache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * - flush_icache_range(start, end) flushes(invalidates) a range for icache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * - flush_icache_page(vma, pg) flushes(invalidates) a page for icache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * - flush_cache_sigtramp(vaddr) flushes the signal trampoline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) extern void (*local_flush_cache_all)(void *args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) extern void (*local_flush_cache_mm)(void *args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) extern void (*local_flush_cache_dup_mm)(void *args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) extern void (*local_flush_cache_page)(void *args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) extern void (*local_flush_cache_range)(void *args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) extern void (*local_flush_dcache_page)(void *args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) extern void (*local_flush_icache_range)(void *args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) extern void (*local_flush_icache_page)(void *args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) extern void (*local_flush_cache_sigtramp)(void *args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static inline void cache_noop(void *args) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) extern void (*__flush_wback_region)(void *start, int size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) extern void (*__flush_purge_region)(void *start, int size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) extern void (*__flush_invalidate_region)(void *start, int size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) extern void flush_cache_all(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) extern void flush_cache_mm(struct mm_struct *mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) extern void flush_cache_dup_mm(struct mm_struct *mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) extern void flush_cache_page(struct vm_area_struct *vma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) unsigned long addr, unsigned long pfn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) extern void flush_cache_range(struct vm_area_struct *vma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) unsigned long start, unsigned long end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) extern void flush_dcache_page(struct page *page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) extern void flush_icache_range(unsigned long start, unsigned long end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define flush_icache_user_range flush_icache_range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) extern void flush_icache_page(struct vm_area_struct *vma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct page *page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) extern void flush_cache_sigtramp(unsigned long address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct flusher_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct vm_area_struct *vma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) unsigned long addr1, addr2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define ARCH_HAS_FLUSH_ANON_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) extern void __flush_anon_page(struct page *page, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static inline void flush_anon_page(struct vm_area_struct *vma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct page *page, unsigned long vmaddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) if (boot_cpu_data.dcache.n_aliases && PageAnon(page))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) __flush_anon_page(page, vmaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static inline void flush_kernel_vmap_range(void *addr, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) __flush_wback_region(addr, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static inline void invalidate_kernel_vmap_range(void *addr, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) __flush_invalidate_region(addr, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static inline void flush_kernel_dcache_page(struct page *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) flush_dcache_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) extern void copy_to_user_page(struct vm_area_struct *vma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct page *page, unsigned long vaddr, void *dst, const void *src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) unsigned long len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) extern void copy_from_user_page(struct vm_area_struct *vma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct page *page, unsigned long vaddr, void *dst, const void *src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) unsigned long len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define flush_cache_vmap(start, end) local_flush_cache_all(NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define flush_cache_vunmap(start, end) local_flush_cache_all(NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define flush_dcache_mmap_lock(mapping) do { } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define flush_dcache_mmap_unlock(mapping) do { } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) void kmap_coherent_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) void *kmap_coherent(struct page *page, unsigned long addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) void kunmap_coherent(void *kvaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #define PG_dcache_clean PG_arch_1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) void cpu_cache_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static inline void *sh_cacheop_vaddr(void *vaddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if (__in_29bit_mode())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) vaddr = (void *)CAC_ADDR((unsigned long)vaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) return vaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #endif /* __ASM_SH_CACHEFLUSH_H */