Merge tag 'spdx_identifiers-4.14-rc8' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / arch / metag / include / asm / tlbflush.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_METAG_TLBFLUSH_H
3 #define __ASM_METAG_TLBFLUSH_H
4
5 #include <linux/io.h>
6 #include <linux/sched.h>
7 #include <asm/metag_mem.h>
8 #include <asm/pgalloc.h>
9
10 /*
11  * TLB flushing:
12  *
13  *  - flush_tlb() flushes the current mm struct TLBs
14  *  - flush_tlb_all() flushes all processes TLBs
15  *  - flush_tlb_mm(mm) flushes the specified mm context TLB's
16  *  - flush_tlb_page(vma, vmaddr) flushes one page
17  *  - flush_tlb_range(mm, start, end) flushes a range of pages
18  *  - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
19  *  - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
20  *
21  * FIXME: Meta 2 can flush single TLB entries.
22  *
23  */
24
25 #if defined(CONFIG_METAG_META21) && !defined(CONFIG_SMP)
26 static inline void __flush_tlb(void)
27 {
28         /* flush TLB entries for just the current hardware thread */
29         int thread = hard_processor_id();
30         metag_out32(0, (LINSYSCFLUSH_TxMMCU_BASE +
31                         LINSYSCFLUSH_TxMMCU_STRIDE * thread));
32 }
33 #else
34 static inline void __flush_tlb(void)
35 {
36         /* flush TLB entries for all hardware threads */
37         metag_out32(0, LINSYSCFLUSH_MMCU);
38 }
39 #endif /* defined(CONFIG_METAG_META21) && !defined(CONFIG_SMP) */
40
41 #define flush_tlb() __flush_tlb()
42
43 #define flush_tlb_all() __flush_tlb()
44
45 #define local_flush_tlb_all() __flush_tlb()
46
47 static inline void flush_tlb_mm(struct mm_struct *mm)
48 {
49         if (mm == current->active_mm)
50                 __flush_tlb();
51 }
52
53 static inline void flush_tlb_page(struct vm_area_struct *vma,
54                                   unsigned long addr)
55 {
56         flush_tlb_mm(vma->vm_mm);
57 }
58
59 static inline void flush_tlb_range(struct vm_area_struct *vma,
60                                    unsigned long start, unsigned long end)
61 {
62         flush_tlb_mm(vma->vm_mm);
63 }
64
65 static inline void flush_tlb_pgtables(struct mm_struct *mm,
66                                       unsigned long start, unsigned long end)
67 {
68         flush_tlb_mm(mm);
69 }
70
71 static inline void flush_tlb_kernel_range(unsigned long start,
72                                           unsigned long end)
73 {
74         flush_tlb_all();
75 }
76
77 #endif /* __ASM_METAG_TLBFLUSH_H */
78