MIPS: SMP: Update cpu_foreign_map on CPU disable
authorJames Hogan <james.hogan@imgtec.com>
Wed, 13 Jul 2016 13:12:45 +0000 (14:12 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Fri, 29 Jul 2016 08:19:28 +0000 (10:19 +0200)
When a CPU is disabled via CPU hotplug, cpu_foreign_map is not updated.
This could result in cache management SMP calls being sent to offline
CPUs instead of online siblings in the same core.

Add a call to calculate_cpu_foreign_map() in the various MIPS cpu
disable callbacks after set_cpu_online(). All cases are updated for
consistency and to keep cpu_foreign_map strictly up to date, not just
those which may support hardware multithreading.

Fixes: cccf34e9411c ("MIPS: c-r4k: Fix cache flushing for MT cores")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: David Daney <david.daney@cavium.com>
Cc: Kevin Cernekee <cernekee@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Huacai Chen <chenhc@lemote.com>
Cc: Hongliang Tao <taohl@lemote.com>
Cc: Hua Yan <yanh@lemote.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/13799/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/cavium-octeon/smp.c
arch/mips/include/asm/smp.h
arch/mips/kernel/smp-bmips.c
arch/mips/kernel/smp-cps.c
arch/mips/kernel/smp.c
arch/mips/loongson64/loongson-3/smp.c

index 33aab89259f3a5df6daa2c2f37ff7e1459bc827e..4d457d602d3bed95683e4a9b9f5d6cf4d9540c2c 100644 (file)
@@ -271,6 +271,7 @@ static int octeon_cpu_disable(void)
                return -ENOTSUPP;
 
        set_cpu_online(cpu, false);
+       calculate_cpu_foreign_map();
        cpumask_clear_cpu(cpu, &cpu_callin_map);
        octeon_fixup_irqs();
 
index 03722d4326a1aad05935b58805ec8d881703201e..0c534a03bb36d9e1afbe8efe10021890149ef16f 100644 (file)
@@ -53,6 +53,8 @@ extern cpumask_t cpu_coherent_mask;
 
 extern void asmlinkage smp_bootstrap(void);
 
+extern void calculate_cpu_foreign_map(void);
+
 /*
  * this function sends a 'reschedule' IPI to another CPU.
  * it goes straight through and wastes no time serializing
index e02addc0307f32454efa0db4ba22d7f7540d2bef..6d0f1321e0841077531787e07380088b8d6468f0 100644 (file)
@@ -363,6 +363,7 @@ static int bmips_cpu_disable(void)
        pr_info("SMP: CPU%d is offline\n", cpu);
 
        set_cpu_online(cpu, false);
+       calculate_cpu_foreign_map();
        cpumask_clear_cpu(cpu, &cpu_callin_map);
        clear_c0_status(IE_IRQ5);
 
index 234e7e781a944e1586723d8b831146bae6786c3a..39ba5b14802fce2440cfaabb8f6d1d207a0e67a4 100644 (file)
@@ -398,6 +398,7 @@ static int cps_cpu_disable(void)
        atomic_sub(1 << cpu_vpe_id(&current_cpu_data), &core_cfg->vpe_mask);
        smp_mb__after_atomic();
        set_cpu_online(cpu, false);
+       calculate_cpu_foreign_map();
        cpumask_clear_cpu(cpu, &cpu_callin_map);
 
        return 0;
index 0c98b4a313be11bdc786cdebf21f035a912a3573..a4d4309ecff20cc142c664c1e4da988c4bb01386 100644 (file)
@@ -124,7 +124,7 @@ static inline void set_cpu_core_map(int cpu)
  * Calculate a new cpu_foreign_map mask whenever a
  * new cpu appears or disappears.
  */
-static inline void calculate_cpu_foreign_map(void)
+void calculate_cpu_foreign_map(void)
 {
        int i, k, core_present;
        cpumask_t temp_foreign_map;
index e59759af63d9f0c929e4635e5e3993e299254e89..2fec6f753a3591f41208481db502eb8e3bf396a4 100644 (file)
@@ -417,6 +417,7 @@ static int loongson3_cpu_disable(void)
                return -EBUSY;
 
        set_cpu_online(cpu, false);
+       calculate_cpu_foreign_map();
        cpumask_clear_cpu(cpu, &cpu_callin_map);
        local_irq_save(flags);
        fixup_irqs();