linux/arch/arm/mach-vexpress
Lorenzo Pieralisi 64270d82d4 ARM: vexpress: tc2: fix hotplug/idle/kexec race on cluster power down
On the TC2 testchip, when all CPUs in a cluster enter standbywfi
and commit a power down request, the power controller will wait
for standbywfil2 coming from L2 cache controller to shut the
cluster down.
By the time all CPUs in a cluster commit a power down request
and enter wfi, the power controller cannot backtrack, or put it
another way, a CPU must not be allowed to complete execution
independently of the power controller, the only way for it to
resume properly must be upon wake-up IRQ pending and subsequent
reset triggered from the power controller.

Current MCPM back-end for TC2 disables the GIC CPU IF only when
power down is committed through the tc2_pm_suspend() method, that
makes sense since a suspended CPU is still online and can receive
interrupts whereas a hotplugged CPU, since it is offline,
migrated all IRQs and shutdown the per-CPU peripherals, hence
their PPIs.

The flaw with this reasoning is the following. If all CPUs in
a clusters are entering a power down state either through CPU
idle or CPU hotplug, when the last man successfully completes
the MCPM power down sequence (and executes wfi), power controller
waits for L2 wfi signal to quiesce the cluster and shut it down.
If, when all CPUs are sitting in wfi, an online CPU hotplugs back
in one of the CPUs in the cluster being shutdown, that CPU
receives an IPI that causes wfi to complete (since tc2_pm_down()
method does not disable the GIC CPU IF in that case - CPU being
hotplugged out, not idle) and the power controller will never see
the stanbywfil2 signal coming from L2 that is required for
shutdown to happen and the system deadlocks.

Further to this issue, kexec hotplugs secondary CPUs out during
kernel reload/restart.
Because kexec may (deliberately) trash the old kernel text, it is
not OK for CPUs to follow the MCPM soft reboot path, since
instructions after the WFI may have been replaced by kexec.

If tc2_pm_down() does not disable the GIC cpu interface, there is a
race between CPU powerdown in the old kernel and the IPI from the
new kernel that triggers secondary boot, particularly if the
powerdown is slow (due to L2 cache cleaning for example).  If the
new kernel wins the race, the affected CPU(s) will not really be
reset and may execute garbage after the WFI.

The only solution to this problem consists in disabling the GIC
CPU IF on a CPU committed to power down regardless of the power
down entry method (CPU hotplug or CPU idle). This way, CPU wake-up
is under power controller control, which prevents unexpected wfi
exit caused by a pending IRQ.

This patch moves the GIC CPU IF disable call in the TC2 MCPM
implementation from the tc2_pm_suspend() method to the
tc2_pm_down() method to fix the mentioned race condition(s).

Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Tested-by: Dave Martin <Dave.Martin@arm.com> (for kexec)
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Olof Johansson <olof@lixom.net>
2013-09-30 09:27:36 -07:00
..
include/mach ARM: vexpress: Start using new Versatile Express infrastructure 2012-11-05 17:09:51 +00:00
Kconfig ARM: SoC platform changes for 3.12 2013-09-06 13:30:06 -07:00
Makefile ARM: vexpress: allow dcscb and tc2_pm in a combined ARMv6+v7 build 2013-09-09 17:38:20 -07:00
core.h ARM: vexpress: Select multi-cluster SMP operation if required 2013-05-29 15:50:35 -04:00
ct-ca9x4.c irqchip: Move ARM gic.h to include/linux/irqchip/arm-gic.h 2013-01-12 10:47:32 -06:00
dcscb.c ARM: vexpress/MCPM: fix cache disable sequence when CONFIG_FRAME_POINTER=y 2013-08-14 13:05:42 -07:00
dcscb_setup.S ARM: vexpress/dcscb: handle platform coherency exit/setup and CCI 2013-05-29 15:50:35 -04:00
hotplug.c ARM: cpu hotplug: remove majority of cache flushing from platforms 2013-04-18 20:08:04 +01:00
platsmp.c ARM: vexpress: Select multi-cluster SMP operation if required 2013-05-29 15:50:35 -04:00
spc.c ARM: vexpress/TC2: add Serial Power Controller (SPC) support 2013-08-07 14:55:24 +01:00
spc.h ARM: vexpress/TC2: add Serial Power Controller (SPC) support 2013-08-07 14:55:24 +01:00
tc2_pm.c ARM: vexpress: tc2: fix hotplug/idle/kexec race on cluster power down 2013-09-30 09:27:36 -07:00
v2m.c ARM SoC specific changes 2013-07-02 13:43:38 -07:00