ARM: npcm: Add CPU hotplug callbacks for kexec support
Subsystems (3)
PATCH v3 1/1 ARM: npcm: Add CPU hotplug callbacks for kexec support
kexec_load() fails with -EINVAL on NPCM7xx because the platform does not provide the CPU hotplug callbacks that machine_kexec_prepare() requires on SMP systems. Add them.
The NPCM7xx cannot reset or power down a single core, so hand an offlined core back to the boot ROM instead of leaving it in a WFI loop in kernel text. The dying core switches to a static stack, takes the identity mapping, disables caches and branch prediction, flushes L1, leaves coherency, turns the MMU off and jumps to the reset vector in the ROM. The ROM then parks it as it does after a real reset, overwriting SCRPAD and waiting in WFE for npcm7xx_smp_boot_secondary(). The core can therefore be brought back online, and it no longer executes from RAM that a kexec'd kernel is free to overwrite.
cpu_kill() waits for the ROM to overwrite the kernel entry point left in SCRPAD before reporting the core dead.
Map the GCR once in smp_prepare_cpus() since it is now also needed after init.
---
Changes in v3:
- Park offlined secondary cores back in the boot ROM reset vector instead of a WFI loop in kernel text so cores can be re-onlined and do not execute from RAM across kexec.
- Poll GCR SCRPAD in cpu_kill() until the ROM overwrites the kernel entry point, and map GCR once in smp_prepare_cpus().
- Drop Tomer's Reviewed-by due to the implementation rewrite.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Fix NPCM7xx/NPCN8xx typo in the commit message.
arch/arm/mach-npcm/headsmp.S | 38 ++++++++++++ arch/arm/mach-npcm/platsmp.c | 109 ++++++++++++++++++++++++++++------- 2 files changed, 127 insertions(+), 20 deletions(-)
arch/arm/mach-npcm/headsmp.S +38 -0
@@ -5,6 +5,7 @@ #include <linux/linkage.h> #include <linux/init.h> #include <asm/assembler.h> +#include <asm/cp15.h> .arch armv7-a
@@ -17,3 +18,40 @@ ENTRY(npcm7xx_secondary_startup) b secondary_startup ENDPROC(npcm7xx_secondary_startup) + +#ifdef CONFIG_HOTPLUG_CPU +/* + * void npcm7xx_cpu_park(unsigned long phys_reset, unsigned long rom_addr) + * + * Exit cache coherency and jump back to the boot ROM reset vector via + * cpu_reset() in the identity mapping. Must be called after + * setup_mm_for_reboot() with IRQs and FIQs disabled, and must not access + * memory or the stack once SCTLR.C is cleared. + */ +ENTRY(npcm7xx_cpu_park) + mov r7, r0 + mov r8, r1 + + mrc p15, 0, r0, c1, c0, 0 + bic r0, r0, #(CR_I | CR_Z) + bic r0, r0, #(CR_C | CR_A) + mcr p15, 0, r0, c1, c0, 0 + isb + + bl v7_flush_dcache_louis + + mrc p15, 0, r0, c1, c0, 1 + bic r0, r0, #(1 << 6) @ clear ACTLR.SMP + mcr p15, 0, r0, c1, c0, 1 + + mov r0, #0 + mcr p15, 0, r0, c7, c5, 0 @ ICIALLU + mcr p15, 0, r0, c7, c5, 6 @ BPIALL + dsb + isb + + mov r0, r8 + mov r1, #0 + bx r7 +ENDPROC(npcm7xx_cpu_park) +#endif
arch/arm/mach-npcm/platsmp.c +89 -20
150 lines not on this page · raw message