powerpc/85xx: Wakeup kexec smp slave cpus in second kernel
Subsystems (2)
RFC PATCH 1/1 powerpc/85xx: Wakeup kexec smp slave cpus in second kernel
From: Chen Yu <[email protected]>
In current 85xx smp kexec implementation,master cpu reset slave cpus by mpic_reset_core, before jump to second kernel.In order to wake slave cpus up in second kernel,we debug this patch on p2041rdb.
The main principle of this patch,is to get slave cpus polling for flag to change, thus waiting for master cpu to set it with non-zero cpu number(see misc_32.S). This flag is placed in kexec control page,so it would not be overlapped when copying kimage. The master cpu put flag's physical address in r28 as a parameter passed to second kernel, so the latter knows how to wake slave cpus up in smp_85xx_kick_cpu.
The pseudo-code may be like:
void slave_cpu_spin(void)
{
int cpu = smp_processor_id();
while (*kexec_poll != cpu)
;
/*slave wakeup and jump*/
jump(*(kexec_poll+1));
}void master_cpu_wakeup(unsigned long *kexec_poll, int cpu)
{
*(kexec_poll+1) = __early_start;
mb();
*kexec_poll = cpu;
}However,after applied this patch,we got some kernel exception during booting second kernel, I'm not sure if it's caused by improper treament of cache,or tlb,or other.So I put this patch here hoping someone can check and review it.
--- arch/powerpc/include/asm/kexec.h | 7 ++ arch/powerpc/kernel/head_fsl_booke.S | 6 ++ arch/powerpc/kernel/misc_32.S | 63 +++++++++++++ arch/powerpc/platforms/85xx/smp.c | 162 +++++++++++++++++++++++++++++++--- 4 files changed, 224 insertions(+), 14 deletions(-)
arch/powerpc/include/asm/kexec.h +7 -0
@@ -87,6 +87,13 @@ extern int overlaps_crashkernel(unsigned long start, unsigned long size);extern void reserve_crashkernel (void );extern void machine_kexec_mask_interrupts (void ); +#ifdef CONFIG_FSL_BOOKE +#define KEXEC_MAGIC 0xdeadbeef +#define KEXEC_RESERVE_LIMIT 0x10 +extern const unsigned int relocate_smp_cpu_size; +extern const unsigned char relocate_smp_cpu_wait[]; +extern const unsigned int relocate_smp_cpu_offset; +#endif #else /* !CONFIG_KEXEC */ static inline void crash_kexec_secondary (struct pt_regs *regs) { }
arch/powerpc/kernel/head_fsl_booke.S +6 -0
@@ -178,6 +178,12 @@ _ENTRY(__early_start) * This is where the main kernel code starts. */ +#if defined(CONFIG_KEXEC) && defined(CONFIG_SMP) + /* r28 contain position where slave cpus spin*/ + lis r1,kexec_poll_phy@h + ori r1,r1,kexec_poll_phy@l + stw r28,0(r1) +#endif /* ptr to current */ lis r2,init_task@h ori r2,r2,init_task@l
arch/powerpc/kernel/misc_32.S +63 -0
73 lines not on this page · raw message
arch/powerpc/platforms/85xx/smp.c +148 -14
231 lines not on this page · raw message
Signature · 1 line
1.7.1
Quoted 7 lines
From: Chen Yu <[email protected]>
In current 85xx smp kexec implementation,master cpu reset slave cpus by
mpic_reset_core, before jump to second kernel.In order to wake slave cpus up in second kernel,we debug this patch on p2041rdb.
Quoted 5 lines
What problem causes that you do the modification? I am just curious as kexec feature always is fine on our
P2041RDB board.:-)Wei
Well, there might be someting wrong with my debug version.
It succeed this morning on linux 3.10.7 ,arch/powerpc/boot/corenet32_smp_defconfig,with kexec-tools-2.0.4, The second kernel is up with 4 cpus.
I'll check my previous version.
Thank you.