Skip to content

Commit 175c062

Browse files
mpredfearngregkh
authored andcommitted
MIPS: SMP: Use a completion event to signal CPU up
commit a00eeede507c975087b7b8df8cf2c9f88ba285de upstream. If a secondary CPU failed to start, for any reason, the CPU requesting the secondary to start would get stuck in the loop waiting for the secondary to be present in the cpu_callin_map. Rather than that, use a completion event to signal that the secondary CPU has started and is waiting to synchronise counters. Since the CPU presence will no longer be marked in cpu_callin_map, remove the redundant test from arch_cpu_idle_dead(). Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> Cc: Maciej W. Rozycki <macro@imgtec.com> Cc: Jiri Slaby <jslaby@suse.cz> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Chris Metcalf <cmetcalf@mellanox.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Qais Yousef <qsyousef@gmail.com> Cc: James Hogan <james.hogan@imgtec.com> Cc: Paul Burton <paul.burton@imgtec.com> Cc: Marcin Nowakowski <marcin.nowakowski@imgtec.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/14502/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 207c214 commit 175c062

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

arch/mips/kernel/process.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
#ifdef CONFIG_HOTPLUG_CPU
5050
void arch_cpu_idle_dead(void)
5151
{
52-
/* What the heck is this check doing ? */
53-
if (!cpumask_test_cpu(smp_processor_id(), &cpu_callin_map))
54-
play_dead();
52+
play_dead();
5553
}
5654
#endif
5755

arch/mips/kernel/smp.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ EXPORT_SYMBOL(cpu_sibling_map);
6464
cpumask_t cpu_core_map[NR_CPUS] __read_mostly;
6565
EXPORT_SYMBOL(cpu_core_map);
6666

67+
static DECLARE_COMPLETION(cpu_running);
68+
6769
/*
6870
* A logcal cpu mask containing only one VPE per core to
6971
* reduce the number of IPIs on large MT systems.
@@ -174,7 +176,7 @@ asmlinkage void start_secondary(void)
174176
cpumask_set_cpu(cpu, &cpu_coherent_mask);
175177
notify_cpu_starting(cpu);
176178

177-
cpumask_set_cpu(cpu, &cpu_callin_map);
179+
complete(&cpu_running);
178180
synchronise_count_slave(cpu);
179181

180182
set_cpu_online(cpu, true);
@@ -242,19 +244,20 @@ void smp_prepare_boot_cpu(void)
242244
{
243245
set_cpu_possible(0, true);
244246
set_cpu_online(0, true);
245-
cpumask_set_cpu(0, &cpu_callin_map);
246247
}
247248

248249
int __cpu_up(unsigned int cpu, struct task_struct *tidle)
249250
{
250251
mp_ops->boot_secondary(cpu, tidle);
251252

252253
/*
253-
* Trust is futile. We should really have timeouts ...
254+
* We must check for timeout here, as the CPU will not be marked
255+
* online until the counters are synchronised.
254256
*/
255-
while (!cpumask_test_cpu(cpu, &cpu_callin_map)) {
256-
udelay(100);
257-
schedule();
257+
if (!wait_for_completion_timeout(&cpu_running,
258+
msecs_to_jiffies(1000))) {
259+
pr_crit("CPU%u: failed to start\n", cpu);
260+
return -EIO;
258261
}
259262

260263
synchronise_count_master(cpu);

0 commit comments

Comments
 (0)