>From feaad18a483871747170fa797f80b49592489ad1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Wed, 4 Feb 2015 16:14:41 +0100 Subject: [RFC] ARM: Don't use complete() during __cpu_die The complete() should not be used on offlined CPU. Signed-off-by: Krzysztof Kozlowski --- arch/arm/kernel/smp.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 86ef244c5a24..f3a5ad80a253 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -76,6 +77,9 @@ enum ipi_msg_type { static DECLARE_COMPLETION(cpu_running); +#define CPU_DIE_WAIT_BIT 0 +static unsigned long wait_cpu_die; + static struct smp_operations smp_ops; void __init smp_set_ops(struct smp_operations *ops) @@ -133,7 +137,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle) pr_err("CPU%u: failed to boot: %d\n", cpu, ret); } - + set_bit(CPU_DIE_WAIT_BIT, &wait_cpu_die); memset(&secondary_data, 0, sizeof(secondary_data)); return ret; } @@ -213,7 +217,17 @@ int __cpu_disable(void) return 0; } -static DECLARE_COMPLETION(cpu_died); +static int wait_for_cpu_die(void) +{ + might_sleep(); + + if (!test_bit(CPU_DIE_WAIT_BIT, &wait_cpu_die)) + return 0; + + return out_of_line_wait_on_bit_timeout(&wait_cpu_die, CPU_DIE_WAIT_BIT, + bit_wait_timeout, TASK_UNINTERRUPTIBLE, + msecs_to_jiffies(5000)); +} /* * called on the thread which is asking for a CPU to be shutdown - @@ -221,7 +235,7 @@ static DECLARE_COMPLETION(cpu_died); */ void __cpu_die(unsigned int cpu) { - if (!wait_for_completion_timeout(&cpu_died, msecs_to_jiffies(5000))) { + if (wait_for_cpu_die()) { pr_err("CPU%u: cpu didn't die\n", cpu); return; } @@ -267,7 +281,7 @@ void __ref cpu_die(void) * this returns, power and/or clocks can be removed at any point * from this CPU and its cache by platform_cpu_kill(). */ - complete(&cpu_died); + clear_bit(CPU_DIE_WAIT_BIT, &wait_cpu_die); /* * Ensure that the cache lines associated with that completion are -- 1.9.1