[RFC] ARM: Don't use complete() during __cpu_die

From: Krzysztof Kozlowski
Date: Wed Feb 04 2015 - 10:14:41 EST


The complete() should not be used on offlined CPU.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@xxxxxxxxxxx>
---
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 <linux/completion.h>
#include <linux/cpufreq.h>
#include <linux/irq_work.h>
+#include <linux/wait.h>

#include <linux/atomic.h>
#include <asm/smp.h>
@@ -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


--Boundary_(ID_cjP6p7DPiBprQ99gyu2RZA)--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/