diff options
Diffstat (limited to 'include/asm-ia64/mmu_context.h')
-rw-r--r-- | include/asm-ia64/mmu_context.h | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/include/asm-ia64/mmu_context.h b/include/asm-ia64/mmu_context.h index e3e5fededb04..0680d163be97 100644 --- a/include/asm-ia64/mmu_context.h +++ b/include/asm-ia64/mmu_context.h | |||
@@ -55,34 +55,46 @@ static inline void | |||
55 | delayed_tlb_flush (void) | 55 | delayed_tlb_flush (void) |
56 | { | 56 | { |
57 | extern void local_flush_tlb_all (void); | 57 | extern void local_flush_tlb_all (void); |
58 | unsigned long flags; | ||
58 | 59 | ||
59 | if (unlikely(__ia64_per_cpu_var(ia64_need_tlb_flush))) { | 60 | if (unlikely(__ia64_per_cpu_var(ia64_need_tlb_flush))) { |
60 | local_flush_tlb_all(); | 61 | spin_lock_irqsave(&ia64_ctx.lock, flags); |
61 | __ia64_per_cpu_var(ia64_need_tlb_flush) = 0; | 62 | { |
63 | if (__ia64_per_cpu_var(ia64_need_tlb_flush)) { | ||
64 | local_flush_tlb_all(); | ||
65 | __ia64_per_cpu_var(ia64_need_tlb_flush) = 0; | ||
66 | } | ||
67 | } | ||
68 | spin_unlock_irqrestore(&ia64_ctx.lock, flags); | ||
62 | } | 69 | } |
63 | } | 70 | } |
64 | 71 | ||
65 | static inline mm_context_t | 72 | static inline nv_mm_context_t |
66 | get_mmu_context (struct mm_struct *mm) | 73 | get_mmu_context (struct mm_struct *mm) |
67 | { | 74 | { |
68 | unsigned long flags; | 75 | unsigned long flags; |
69 | mm_context_t context = mm->context; | 76 | nv_mm_context_t context = mm->context; |
70 | 77 | ||
71 | if (context) | 78 | if (unlikely(!context)) { |
72 | return context; | 79 | spin_lock_irqsave(&ia64_ctx.lock, flags); |
73 | 80 | { | |
74 | spin_lock_irqsave(&ia64_ctx.lock, flags); | 81 | /* re-check, now that we've got the lock: */ |
75 | { | 82 | context = mm->context; |
76 | /* re-check, now that we've got the lock: */ | 83 | if (context == 0) { |
77 | context = mm->context; | 84 | cpus_clear(mm->cpu_vm_mask); |
78 | if (context == 0) { | 85 | if (ia64_ctx.next >= ia64_ctx.limit) |
79 | cpus_clear(mm->cpu_vm_mask); | 86 | wrap_mmu_context(mm); |
80 | if (ia64_ctx.next >= ia64_ctx.limit) | 87 | mm->context = context = ia64_ctx.next++; |
81 | wrap_mmu_context(mm); | 88 | } |
82 | mm->context = context = ia64_ctx.next++; | ||
83 | } | 89 | } |
90 | spin_unlock_irqrestore(&ia64_ctx.lock, flags); | ||
84 | } | 91 | } |
85 | spin_unlock_irqrestore(&ia64_ctx.lock, flags); | 92 | /* |
93 | * Ensure we're not starting to use "context" before any old | ||
94 | * uses of it are gone from our TLB. | ||
95 | */ | ||
96 | delayed_tlb_flush(); | ||
97 | |||
86 | return context; | 98 | return context; |
87 | } | 99 | } |
88 | 100 | ||
@@ -104,7 +116,7 @@ destroy_context (struct mm_struct *mm) | |||
104 | } | 116 | } |
105 | 117 | ||
106 | static inline void | 118 | static inline void |
107 | reload_context (mm_context_t context) | 119 | reload_context (nv_mm_context_t context) |
108 | { | 120 | { |
109 | unsigned long rid; | 121 | unsigned long rid; |
110 | unsigned long rid_incr = 0; | 122 | unsigned long rid_incr = 0; |
@@ -138,7 +150,7 @@ reload_context (mm_context_t context) | |||
138 | static inline void | 150 | static inline void |
139 | activate_context (struct mm_struct *mm) | 151 | activate_context (struct mm_struct *mm) |
140 | { | 152 | { |
141 | mm_context_t context; | 153 | nv_mm_context_t context; |
142 | 154 | ||
143 | do { | 155 | do { |
144 | context = get_mmu_context(mm); | 156 | context = get_mmu_context(mm); |
@@ -157,8 +169,6 @@ activate_context (struct mm_struct *mm) | |||
157 | static inline void | 169 | static inline void |
158 | activate_mm (struct mm_struct *prev, struct mm_struct *next) | 170 | activate_mm (struct mm_struct *prev, struct mm_struct *next) |
159 | { | 171 | { |
160 | delayed_tlb_flush(); | ||
161 | |||
162 | /* | 172 | /* |
163 | * We may get interrupts here, but that's OK because interrupt handlers cannot | 173 | * We may get interrupts here, but that's OK because interrupt handlers cannot |
164 | * touch user-space. | 174 | * touch user-space. |