linux/arch/arm/common
Nicolas Pitre 1c33be5749 ARM: b.L: core switcher code
This is the core code implementing big.LITTLE switcher functionality.
Rationale for this code is available here:

http://lwn.net/Articles/481055/

The main entry point for a switch request is:

void bL_switch_request(unsigned int cpu, unsigned int new_cluster_id)

If the calling CPU is not the wanted one, this wrapper takes care of
sending the request to the appropriate CPU with schedule_work_on().

At the moment the core switch operation is handled by bL_switch_to()
which must be called on the CPU for which a switch is requested.

What this code does:

  * Return early if the current cluster is the wanted one.

  * Close the gate in the kernel entry vector for both the inbound
    and outbound CPUs.

  * Wake up the inbound CPU so it can perform its reset sequence in
    parallel up to the kernel entry vector gate.

  * Migrate all interrupts in the GIC targeting the outbound CPU
    interface to the inbound CPU interface, including SGIs. This is
    performed by gic_migrate_target() in drivers/irqchip/irq-gic.c.

  * Call cpu_pm_enter() which takes care of flushing the VFP state to
    RAM and save the CPU interface config from the GIC to RAM.

  * Modify the cpu_logical_map to refer to the inbound physical CPU.

  * Call cpu_suspend() which saves the CPU state (general purpose
    registers, page table address) onto the stack and store the
    resulting stack pointer in an array indexed by the updated
    cpu_logical_map, then call the provided shutdown function.
    This happens in arch/arm/kernel/sleep.S.

At this point, the provided shutdown function executed by the outbound
CPU ungates the inbound CPU. Therefore the inbound CPU:

  * Picks up the saved stack pointer in the array indexed by its MPIDR
    in arch/arm/kernel/sleep.S.

  * The MMU and caches are re-enabled using the saved state on the
    provided stack, just like if this was a resume operation from a
    suspended state.

  * Then cpu_suspend() returns, although this is on the inbound CPU
    rather than the outbound CPU which called it initially.

  * The function cpu_pm_exit() is called which effect is to restore the
    CPU interface state in the GIC using the state previously saved by
    the outbound CPU.

  * Exit of bL_switch_to() to resume normal kernel execution on the
    new CPU.

However, the outbound CPU is potentially still running in parallel while
the inbound CPU is resuming normal kernel execution, hence we need
per CPU stack isolation to execute bL_do_switch().  After the outbound
CPU has ungated the inbound CPU, it calls mcpm_cpu_power_down() to:

  * Clean its L1 cache.

  * If it is the last CPU still alive in its cluster (last man standing),
    it also cleans its L2 cache and disables cache snooping from the other
    cluster.

  * Power down the CPU (or whole cluster).

Code called from bL_do_switch() might end up referencing 'current' for
some reasons.  However, 'current' is derived from the stack pointer.
With any arbitrary stack, the returned value for 'current' and any
dereferenced values through it are just random garbage which may lead to
segmentation faults.

The active page table during the execution of bL_do_switch() is also a
problem.  There is no guarantee that the inbound CPU won't destroy the
corresponding task which would free the attached page table while the
outbound CPU is still running and relying on it.

To solve both issues, we borrow some of the task space belonging to
the init/idle task which, by its nature, is lightly used and therefore
is unlikely to clash with our usage.  The init task is also never going
away.

Right now the logical CPU number is assumed to be equivalent to the
physical CPU number within each cluster. The kernel should also be
booted with only one cluster active.  These limitations will be lifted
eventually.

Signed-off-by: Nicolas Pitre <nico@linaro.org>
2013-07-30 09:02:13 -04:00
..
bL_switcher.c ARM: b.L: core switcher code 2013-07-30 09:02:13 -04:00
dmabounce.c ARM: dma-mapping: add support for dma_get_sgtable() 2012-07-30 12:25:47 +02:00
edma.c ARM: edma: remove duplicated include from edma.c 2013-07-16 20:36:46 +05:30
firmware.c ARM: Add interface for registering and calling firmware-specific operations 2013-04-09 01:52:06 +09:00
icst.c Update broken web addresses in arch directory. 2010-10-18 11:03:21 +02:00
it8152.c ARM: pxa: armcore: fix PCI PIO warnings 2012-10-09 21:58:01 +02:00
Kconfig ARM: davinci: move private EDMA API to arm/common 2013-06-18 10:52:03 +05:30
locomo.c arm: Fold irq_set_chip/irq_set_handler 2011-03-29 14:47:58 +02:00
Makefile ARM: b.L: core switcher code 2013-07-30 09:02:13 -04:00
mcpm_entry.c ARM: mcpm: introduce helpers for platform coherency exit/setup 2013-04-24 10:37:00 -04:00
mcpm_head.S ARM: 7740/1: MCPM: prettify debug output 2013-06-05 23:58:09 +01:00
mcpm_platsmp.c arm: delete __cpuinit/__CPUINIT usage from all ARM users 2013-07-14 19:36:52 -04:00
sa1111.c ARM: drivers: remove __dev* attributes. 2013-01-03 15:57:04 -08:00
scoop.c ARM: drivers: remove __dev* attributes. 2013-01-03 15:57:04 -08:00
sharpsl_param.c [ARM] 4733/1: export sharpsl_param 2008-10-03 10:18:35 +01:00
timer-sp.c sched_clock: Make ARM's sched_clock generic for all architectures 2013-06-12 14:02:13 -07:00
via82c505.c ARM: PCI: provide a default bus scan implementation 2012-05-13 17:12:17 +01:00
vlock.h ARM: mcpm: Add baremetal voting mutexes 2013-04-24 10:37:01 -04:00
vlock.S ARM: mcpm: Add baremetal voting mutexes 2013-04-24 10:37:01 -04:00