1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2015 Regents of the University of California
6 #ifndef _ASM_RISCV_CACHEFLUSH_H
7 #define _ASM_RISCV_CACHEFLUSH_H
11 static inline void local_flush_icache_all(void)
13 asm volatile ("fence.i" ::: "memory");
16 #define PG_dcache_clean PG_arch_1
18 static inline void flush_dcache_page(struct page *page)
21 * HugeTLB pages are always fully mapped and only head page will be
22 * set PG_dcache_clean (see comments in flush_icache_pte()).
25 page = compound_head(page);
27 if (test_bit(PG_dcache_clean, &page->flags))
28 clear_bit(PG_dcache_clean, &page->flags);
30 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
33 * RISC-V doesn't have an instruction to flush parts of the instruction cache,
34 * so instead we just flush the whole thing.
36 #define flush_icache_range(start, end) flush_icache_all()
37 #define flush_icache_user_page(vma, pg, addr, len) \
38 flush_icache_mm(vma->vm_mm, 0)
42 #define flush_icache_all() local_flush_icache_all()
43 #define flush_icache_mm(mm, local) flush_icache_all()
45 #else /* CONFIG_SMP */
47 void flush_icache_all(void);
48 void flush_icache_mm(struct mm_struct *mm, bool local);
50 #endif /* CONFIG_SMP */
52 extern unsigned int riscv_cbom_block_size;
53 extern unsigned int riscv_cboz_block_size;
54 void riscv_init_cbo_blocksizes(void);
56 #ifdef CONFIG_RISCV_DMA_NONCOHERENT
57 void riscv_noncoherent_supported(void);
59 static inline void riscv_noncoherent_supported(void) {}
63 * Bits in sys_riscv_flush_icache()'s flags argument.
65 #define SYS_RISCV_FLUSH_ICACHE_LOCAL 1UL
66 #define SYS_RISCV_FLUSH_ICACHE_ALL (SYS_RISCV_FLUSH_ICACHE_LOCAL)
68 #include <asm-generic/cacheflush.h>
70 #endif /* _ASM_RISCV_CACHEFLUSH_H */