powerpc: mmu_gather rework
[pandora-kernel.git] / arch / powerpc / kernel / process.c
index 095043d..91e52df 100644 (file)
@@ -395,6 +395,9 @@ struct task_struct *__switch_to(struct task_struct *prev,
        struct thread_struct *new_thread, *old_thread;
        unsigned long flags;
        struct task_struct *last;
+#ifdef CONFIG_PPC_BOOK3S_64
+       struct ppc64_tlb_batch *batch;
+#endif
 
 #ifdef CONFIG_SMP
        /* avoid complexity of lazy save/restore of fpu
@@ -513,7 +516,17 @@ struct task_struct *__switch_to(struct task_struct *prev,
                old_thread->accum_tb += (current_tb - start_tb);
                new_thread->start_tb = current_tb;
        }
-#endif
+#endif /* CONFIG_PPC64 */
+
+#ifdef CONFIG_PPC_BOOK3S_64
+       batch = &__get_cpu_var(ppc64_tlb_batch);
+       if (batch->active) {
+               current_thread_info()->local_flags |= _TLF_LAZY_MMU;
+               if (batch->index)
+                       __flush_tlb_pending(batch);
+               batch->active = 0;
+       }
+#endif /* CONFIG_PPC_BOOK3S_64 */
 
        local_irq_save(flags);
 
@@ -528,6 +541,14 @@ struct task_struct *__switch_to(struct task_struct *prev,
        hard_irq_disable();
        last = _switch(old_thread, new_thread);
 
+#ifdef CONFIG_PPC_BOOK3S_64
+       if (current_thread_info()->local_flags & _TLF_LAZY_MMU) {
+               current_thread_info()->local_flags &= ~_TLF_LAZY_MMU;
+               batch = &__get_cpu_var(ppc64_tlb_batch);
+               batch->active = 1;
+       }
+#endif /* CONFIG_PPC_BOOK3S_64 */
+
        local_irq_restore(flags);
 
        return last;