aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2017-04-05 03:54:48 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2017-04-06 05:58:53 -0400
commit14d4ae5c4cb89c05262fe41cb7a26f6ba949d8df (patch)
tree5aad3d800484640eb9e90df5d0d6f6039c4e7a34
parent22bd64a621cc80beeb009abec3d3df98ec0131c5 (diff)
powerpc: Add optional smp_ops->prepare_cpu SMP callback
Some platforms (will) need to perform allocations before bringing a new CPU online. Doing it from smp_ops->setup_cpu is the wrong thing to do: - It has no useful failure path (too late) - Calling any allocator will enable interrupts prematurely causing problems with large decrementer among others Instead, add a new callback that is called from __cpu_up (so from the context trying to online the new CPU) at a point where we can safely allocate and handle failures. This will be used by XIVE support. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/include/asm/smp.h1
-rw-r--r--arch/powerpc/kernel/smp.c10
2 files changed, 11 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
index 32db16d2e7ad..2f8e36f91acd 100644
--- a/arch/powerpc/include/asm/smp.h
+++ b/arch/powerpc/include/asm/smp.h
@@ -44,6 +44,7 @@ struct smp_ops_t {
44#endif 44#endif
45 void (*probe)(void); 45 void (*probe)(void);
46 int (*kick_cpu)(int nr); 46 int (*kick_cpu)(int nr);
47 int (*prepare_cpu)(int nr);
47 void (*setup_cpu)(int nr); 48 void (*setup_cpu)(int nr);
48 void (*bringup_done)(void); 49 void (*bringup_done)(void);
49 void (*take_timebase)(void); 50 void (*take_timebase)(void);
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 46f89e66a273..b12f5f0a408f 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -521,6 +521,16 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
521 521
522 cpu_idle_thread_init(cpu, tidle); 522 cpu_idle_thread_init(cpu, tidle);
523 523
524 /*
525 * The platform might need to allocate resources prior to bringing
526 * up the CPU
527 */
528 if (smp_ops->prepare_cpu) {
529 rc = smp_ops->prepare_cpu(cpu);
530 if (rc)
531 return rc;
532 }
533
524 /* Make sure callin-map entry is 0 (can be leftover a CPU 534 /* Make sure callin-map entry is 0 (can be leftover a CPU
525 * hotplug 535 * hotplug
526 */ 536 */