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