drm/panthor: Don't add write fences to the shared BOs
[drm/drm-misc.git] / arch / riscv / include / asm / tlbflush.h
blob72e559934952939aa410ef7cdda4ef7ad2696a26
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com>
4 * Copyright (C) 2012 Regents of the University of California
5 */
7 #ifndef _ASM_RISCV_TLBFLUSH_H
8 #define _ASM_RISCV_TLBFLUSH_H
10 #include <linux/mm_types.h>
11 #include <asm/smp.h>
12 #include <asm/errata_list.h>
14 #define FLUSH_TLB_MAX_SIZE ((unsigned long)-1)
15 #define FLUSH_TLB_NO_ASID ((unsigned long)-1)
17 #ifdef CONFIG_MMU
18 static inline void local_flush_tlb_all(void)
20 __asm__ __volatile__ ("sfence.vma" : : : "memory");
23 static inline void local_flush_tlb_all_asid(unsigned long asid)
25 if (asid != FLUSH_TLB_NO_ASID)
26 ALT_SFENCE_VMA_ASID(asid);
27 else
28 local_flush_tlb_all();
31 /* Flush one page from local TLB */
32 static inline void local_flush_tlb_page(unsigned long addr)
34 ALT_SFENCE_VMA_ADDR(addr);
37 static inline void local_flush_tlb_page_asid(unsigned long addr,
38 unsigned long asid)
40 if (asid != FLUSH_TLB_NO_ASID)
41 ALT_SFENCE_VMA_ADDR_ASID(addr, asid);
42 else
43 local_flush_tlb_page(addr);
46 void flush_tlb_all(void);
47 void flush_tlb_mm(struct mm_struct *mm);
48 void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
49 unsigned long end, unsigned int page_size);
50 void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr);
51 void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
52 unsigned long end);
53 void flush_tlb_kernel_range(unsigned long start, unsigned long end);
54 void local_flush_tlb_kernel_range(unsigned long start, unsigned long end);
55 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
56 #define __HAVE_ARCH_FLUSH_PMD_TLB_RANGE
57 void flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start,
58 unsigned long end);
59 #endif
61 bool arch_tlbbatch_should_defer(struct mm_struct *mm);
62 void arch_tlbbatch_add_pending(struct arch_tlbflush_unmap_batch *batch,
63 struct mm_struct *mm,
64 unsigned long uaddr);
65 void arch_flush_tlb_batched_pending(struct mm_struct *mm);
66 void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch);
68 extern unsigned long tlb_flush_all_threshold;
69 #else /* CONFIG_MMU */
70 #define local_flush_tlb_all() do { } while (0)
71 #endif /* CONFIG_MMU */
73 #endif /* _ASM_RISCV_TLBFLUSH_H */