Commit 826e99be authored by James Hogan's avatar James Hogan Committed by Ralf Baechle

MIPS: SMP: Update cpu_foreign_map on CPU disable

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: cccf34e9 ("MIPS: c-r4k: Fix cache flushing for MT cores")
Signed-off-by: default avatarJames 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: default avatarRalf Baechle <ralf@linux-mips.org>
parent a05c3920
...@@ -271,6 +271,7 @@ static int octeon_cpu_disable(void) ...@@ -271,6 +271,7 @@ static int octeon_cpu_disable(void)
return -ENOTSUPP; return -ENOTSUPP;
set_cpu_online(cpu, false); set_cpu_online(cpu, false);
calculate_cpu_foreign_map();
cpumask_clear_cpu(cpu, &cpu_callin_map); cpumask_clear_cpu(cpu, &cpu_callin_map);
octeon_fixup_irqs(); octeon_fixup_irqs();
......
...@@ -53,6 +53,8 @@ extern cpumask_t cpu_coherent_mask; ...@@ -53,6 +53,8 @@ extern cpumask_t cpu_coherent_mask;
extern void asmlinkage smp_bootstrap(void); extern void asmlinkage smp_bootstrap(void);
extern void calculate_cpu_foreign_map(void);
/* /*
* this function sends a 'reschedule' IPI to another CPU. * this function sends a 'reschedule' IPI to another CPU.
* it goes straight through and wastes no time serializing * it goes straight through and wastes no time serializing
......
...@@ -363,6 +363,7 @@ static int bmips_cpu_disable(void) ...@@ -363,6 +363,7 @@ static int bmips_cpu_disable(void)
pr_info("SMP: CPU%d is offline\n", cpu); pr_info("SMP: CPU%d is offline\n", cpu);
set_cpu_online(cpu, false); set_cpu_online(cpu, false);
calculate_cpu_foreign_map();
cpumask_clear_cpu(cpu, &cpu_callin_map); cpumask_clear_cpu(cpu, &cpu_callin_map);
clear_c0_status(IE_IRQ5); clear_c0_status(IE_IRQ5);
......
...@@ -398,6 +398,7 @@ static int cps_cpu_disable(void) ...@@ -398,6 +398,7 @@ static int cps_cpu_disable(void)
atomic_sub(1 << cpu_vpe_id(&current_cpu_data), &core_cfg->vpe_mask); atomic_sub(1 << cpu_vpe_id(&current_cpu_data), &core_cfg->vpe_mask);
smp_mb__after_atomic(); smp_mb__after_atomic();
set_cpu_online(cpu, false); set_cpu_online(cpu, false);
calculate_cpu_foreign_map();
cpumask_clear_cpu(cpu, &cpu_callin_map); cpumask_clear_cpu(cpu, &cpu_callin_map);
return 0; return 0;
......
...@@ -124,7 +124,7 @@ static inline void set_cpu_core_map(int cpu) ...@@ -124,7 +124,7 @@ static inline void set_cpu_core_map(int cpu)
* Calculate a new cpu_foreign_map mask whenever a * Calculate a new cpu_foreign_map mask whenever a
* new cpu appears or disappears. * new cpu appears or disappears.
*/ */
static inline void calculate_cpu_foreign_map(void) void calculate_cpu_foreign_map(void)
{ {
int i, k, core_present; int i, k, core_present;
cpumask_t temp_foreign_map; cpumask_t temp_foreign_map;
......
...@@ -417,6 +417,7 @@ static int loongson3_cpu_disable(void) ...@@ -417,6 +417,7 @@ static int loongson3_cpu_disable(void)
return -EBUSY; return -EBUSY;
set_cpu_online(cpu, false); set_cpu_online(cpu, false);
calculate_cpu_foreign_map();
cpumask_clear_cpu(cpu, &cpu_callin_map); cpumask_clear_cpu(cpu, &cpu_callin_map);
local_irq_save(flags); local_irq_save(flags);
fixup_irqs(); fixup_irqs();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment