Revert "UPSTREAM: ARM: Remove current_mm per-cpu variable"
authorOlof Johansson <olofj@chromium.org>
Fri, 5 Apr 2013 17:08:36 +0000 (10:08 -0700)
committerChromeBot <chrome-bot@google.com>
Wed, 10 Apr 2013 07:02:05 +0000 (00:02 -0700)
This originally removed some not-needed code, but the recent A15 errata
workaround actually needs current_mm still around. So for bring this
code back for that reason.

This reverts commit 696cfa01f12ec85ac7122eb57d77c8598f79ff71.

BUG=chromium:226280
TEST=build kernel for daisy

Change-Id: Ie44c6bfea7137ca185eb568f9047bca39f3e1b5c
Signed-off-by: Olof Johansson <olofj@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47426
Reviewed-by: Doug Anderson <dianders@chromium.org>
arch/arm/include/asm/mmu_context.h
arch/arm/mm/context.c

index 8da4b9c..94e265c 100644 (file)
@@ -43,6 +43,9 @@ void __check_kvm_seq(struct mm_struct *mm);
 #define ASID_FIRST_VERSION     (1 << ASID_BITS)
 
 extern unsigned int cpu_last_asid;
+#ifdef CONFIG_SMP
+DECLARE_PER_CPU(struct mm_struct *, current_mm);
+#endif
 
 void __init_new_context(struct task_struct *tsk, struct mm_struct *mm);
 void __new_context(struct mm_struct *mm);
@@ -157,6 +160,10 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
                __flush_icache_all();
 #endif
        if (!cpumask_test_and_set_cpu(cpu, mm_cpumask(next)) || prev != next) {
+#ifdef CONFIG_SMP
+               struct mm_struct **crt_mm = &per_cpu(current_mm, cpu);
+               *crt_mm = next;
+#endif
                check_and_switch_context(next, tsk);
                if (cache_is_vivt())
                        cpumask_clear_cpu(cpu, mm_cpumask(prev));
index 119bc52..4babb4a 100644 (file)
@@ -19,6 +19,9 @@
 
 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
 unsigned int cpu_last_asid = ASID_FIRST_VERSION;
+#ifdef CONFIG_SMP
+DEFINE_PER_CPU(struct mm_struct *, current_mm);
+#endif
 
 #ifdef CONFIG_ARM_LPAE
 void cpu_set_reserved_ttbr0(void)
@@ -140,7 +143,14 @@ static void reset_context(void *info)
 {
        unsigned int asid;
        unsigned int cpu = smp_processor_id();
-       struct mm_struct *mm = current->active_mm;
+       struct mm_struct *mm = per_cpu(current_mm, cpu);
+
+       /*
+        * Check if a current_mm was set on this CPU as it might still
+        * be in the early booting stages and using the reserved ASID.
+        */
+       if (!mm)
+               return;
 
        smp_rmb();
        asid = cpu_last_asid + cpu + 1;