cacheflush.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (C) 2015 Regents of the University of California
  3. *
  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.
  7. *
  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.
  12. */
  13. #ifndef _ASM_RISCV_CACHEFLUSH_H
  14. #define _ASM_RISCV_CACHEFLUSH_H
  15. #include <asm-generic/cacheflush.h>
  16. #undef flush_icache_range
  17. #undef flush_icache_user_range
  18. #undef flush_dcache_page
  19. static inline void local_flush_icache_all(void)
  20. {
  21. asm volatile ("fence.i" ::: "memory");
  22. }
  23. #define PG_dcache_clean PG_arch_1
  24. static inline void flush_dcache_page(struct page *page)
  25. {
  26. if (test_bit(PG_dcache_clean, &page->flags))
  27. clear_bit(PG_dcache_clean, &page->flags);
  28. }
  29. /*
  30. * RISC-V doesn't have an instruction to flush parts of the instruction cache,
  31. * so instead we just flush the whole thing.
  32. */
  33. #define flush_icache_range(start, end) flush_icache_all()
  34. #define flush_icache_user_range(vma, pg, addr, len) flush_icache_all()
  35. #ifndef CONFIG_SMP
  36. #define flush_icache_all() local_flush_icache_all()
  37. #define flush_icache_mm(mm, local) flush_icache_all()
  38. #else /* CONFIG_SMP */
  39. #define flush_icache_all() sbi_remote_fence_i(0)
  40. void flush_icache_mm(struct mm_struct *mm, bool local);
  41. #endif /* CONFIG_SMP */
  42. #endif /* _ASM_RISCV_CACHEFLUSH_H */