2 * Copyright (C) 2015 Regents of the University of California
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
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.
14 #ifndef _ASM_RISCV_CACHEFLUSH_H
15 #define _ASM_RISCV_CACHEFLUSH_H
17 #include <asm-generic/cacheflush.h>
19 #undef flush_icache_range
20 #undef flush_icache_user_range
21 #undef flush_dcache_page
23 static inline void local_flush_icache_all(void)
25 asm volatile ("fence.i" ::: "memory");
28 #define PG_dcache_clean PG_arch_1
30 static inline void flush_dcache_page(struct page
*page
)
32 if (test_bit(PG_dcache_clean
, &page
->flags
))
33 clear_bit(PG_dcache_clean
, &page
->flags
);
37 * RISC-V doesn't have an instruction to flush parts of the instruction cache,
38 * so instead we just flush the whole thing.
40 #define flush_icache_range(start, end) flush_icache_all()
41 #define flush_icache_user_range(vma, pg, addr, len) flush_icache_all()
45 #define flush_icache_all() local_flush_icache_all()
46 #define flush_icache_mm(mm, local) flush_icache_all()
48 #else /* CONFIG_SMP */
50 #define flush_icache_all() sbi_remote_fence_i(NULL)
51 void flush_icache_mm(struct mm_struct
*mm
, bool local
);
53 #endif /* CONFIG_SMP */
56 * Bits in sys_riscv_flush_icache()'s flags argument.
58 #define SYS_RISCV_FLUSH_ICACHE_LOCAL 1UL
59 #define SYS_RISCV_FLUSH_ICACHE_ALL (SYS_RISCV_FLUSH_ICACHE_LOCAL)
61 #endif /* _ASM_RISCV_CACHEFLUSH_H */