Revert "UPSTREAM: ARM: Remove current_mm per-cpu variable"
[cascardo/linux.git] / arch / arm / mm / context.c
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;