Skip to content

Commit a00eeed

Browse files
mpredfearnralfbaechle
authored andcommitted
MIPS: SMP: Use a completion event to signal CPU up
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>
1 parent 9799270 commit a00eeed

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
@@ -50,9 +50,7 @@
5050
#ifdef CONFIG_HOTPLUG_CPU
5151
void arch_cpu_idle_dead(void)
5252
{
53-
/* What the heck is this check doing ? */
54-
if (!cpumask_test_cpu(smp_processor_id(), &cpu_callin_map))
55-
play_dead();
53+
play_dead();
5654
}
5755
#endif
5856

‎arch/mips/kernel/smp.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ EXPORT_SYMBOL(cpu_sibling_map);
6868
cpumask_t cpu_core_map[NR_CPUS] __read_mostly;
6969
EXPORT_SYMBOL(cpu_core_map);
7070

71+
static DECLARE_COMPLETION(cpu_running);
72+
7173
/*
7274
* A logcal cpu mask containing only one VPE per core to
7375
* reduce the number of IPIs on large MT systems.
@@ -369,7 +371,7 @@ asmlinkage void start_secondary(void)
369371
cpumask_set_cpu(cpu, &cpu_coherent_mask);
370372
notify_cpu_starting(cpu);
371373

372-
cpumask_set_cpu(cpu, &cpu_callin_map);
374+
complete(&cpu_running);
373375
synchronise_count_slave(cpu);
374376

375377
set_cpu_online(cpu, true);
@@ -430,19 +432,20 @@ void smp_prepare_boot_cpu(void)
430432
{
431433
set_cpu_possible(0, true);
432434
set_cpu_online(0, true);
433-
cpumask_set_cpu(0, &cpu_callin_map);
434435
}
435436

436437
int __cpu_up(unsigned int cpu, struct task_struct *tidle)
437438
{
438439
mp_ops->boot_secondary(cpu, tidle);
439440

440441
/*
441-
* Trust is futile. We should really have timeouts ...
442+
* We must check for timeout here, as the CPU will not be marked
443+
* online until the counters are synchronised.
442444
*/
443-
while (!cpumask_test_cpu(cpu, &cpu_callin_map)) {
444-
udelay(100);
445-
schedule();
445+
if (!wait_for_completion_timeout(&cpu_running,
446+
msecs_to_jiffies(1000))) {
447+
pr_crit("CPU%u: failed to start\n", cpu);
448+
return -EIO;
446449
}
447450

448451
synchronise_count_master(cpu);

0 commit comments

Comments
 (0)