Skip to content

Commit 14d4ae5

Browse files
ozbenhmpe
authored andcommitted
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 <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 22bd64a commit 14d4ae5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

arch/powerpc/include/asm/smp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct smp_ops_t {
4444
#endif
4545
void (*probe)(void);
4646
int (*kick_cpu)(int nr);
47+
int (*prepare_cpu)(int nr);
4748
void (*setup_cpu)(int nr);
4849
void (*bringup_done)(void);
4950
void (*take_timebase)(void);

arch/powerpc/kernel/smp.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,16 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
521521

522522
cpu_idle_thread_init(cpu, tidle);
523523

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+
524534
/* Make sure callin-map entry is 0 (can be leftover a CPU
525535
* hotplug
526536
*/

0 commit comments

Comments
 (0)