diff options
author | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | 2013-07-22 07:22:13 -0400 |
---|---|---|
committer | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | 2013-12-16 12:17:31 -0500 |
commit | 95322526ef62b84adb469c27535ab0252a369a85 (patch) | |
tree | 81fe36a9dd3361ebbcfbebee7a18207c0f58b7f9 /arch/arm64/include | |
parent | 6732bc65c277b697f6d8b645b15f63d1558c0cc4 (diff) |
arm64: kernel: cpu_{suspend/resume} implementation
Kernel subsystems like CPU idle and suspend to RAM require a generic
mechanism to suspend a processor, save its context and put it into
a quiescent state. The cpu_{suspend}/{resume} implementation provides
such a framework through a kernel interface allowing to save/restore
registers, flush the context to DRAM and suspend/resume to/from
low-power states where processor context may be lost.
The CPU suspend implementation relies on the suspend protocol registered
in CPU operations to carry out a suspend request after context is
saved and flushed to DRAM. The cpu_suspend interface:
int cpu_suspend(unsigned long arg);
allows to pass an opaque parameter that is handed over to the suspend CPU
operations back-end so that it can take action according to the
semantics attached to it. The arg parameter allows suspend to RAM and CPU
idle drivers to communicate to suspend protocol back-ends; it requires
standardization so that the interface can be reused seamlessly across
systems, paving the way for generic drivers.
Context memory is allocated on the stack, whose address is stashed in a
per-cpu variable to keep track of it and passed to core functions that
save/restore the registers required by the architecture.
Even though, upon successful execution, the cpu_suspend function shuts
down the suspending processor, the warm boot resume mechanism, based
on the cpu_resume function, makes the resume path operate as a
cpu_suspend function return, so that cpu_suspend can be treated as a C
function by the caller, which simplifies coding the PM drivers that rely
on the cpu_suspend API.
Upon context save, the minimal amount of memory is flushed to DRAM so
that it can be retrieved when the MMU is off and caches are not searched.
The suspend CPU operation, depending on the required operations (eg CPU vs
Cluster shutdown) is in charge of flushing the cache hierarchy either
implicitly (by calling firmware implementations like PSCI) or explicitly
by executing the required cache maintainance functions.
Debug exceptions are disabled during cpu_{suspend}/{resume} operations
so that debug registers can be saved and restored properly preventing
preemption from debug agents enabled in the kernel.
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Diffstat (limited to 'arch/arm64/include')
-rw-r--r-- | arch/arm64/include/asm/cpu_ops.h | 6 | ||||
-rw-r--r-- | arch/arm64/include/asm/suspend.h | 9 |
2 files changed, 15 insertions, 0 deletions
diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index c4cdb5e5b73d..152413076503 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h | |||
@@ -39,6 +39,9 @@ struct device_node; | |||
39 | * from the cpu to be killed. | 39 | * from the cpu to be killed. |
40 | * @cpu_die: Makes a cpu leave the kernel. Must not fail. Called from the | 40 | * @cpu_die: Makes a cpu leave the kernel. Must not fail. Called from the |
41 | * cpu being killed. | 41 | * cpu being killed. |
42 | * @cpu_suspend: Suspends a cpu and saves the required context. May fail owing | ||
43 | * to wrong parameters or error conditions. Called from the | ||
44 | * CPU being suspended. Must be called with IRQs disabled. | ||
42 | */ | 45 | */ |
43 | struct cpu_operations { | 46 | struct cpu_operations { |
44 | const char *name; | 47 | const char *name; |
@@ -50,6 +53,9 @@ struct cpu_operations { | |||
50 | int (*cpu_disable)(unsigned int cpu); | 53 | int (*cpu_disable)(unsigned int cpu); |
51 | void (*cpu_die)(unsigned int cpu); | 54 | void (*cpu_die)(unsigned int cpu); |
52 | #endif | 55 | #endif |
56 | #ifdef CONFIG_ARM64_CPU_SUSPEND | ||
57 | int (*cpu_suspend)(unsigned long); | ||
58 | #endif | ||
53 | }; | 59 | }; |
54 | 60 | ||
55 | extern const struct cpu_operations *cpu_ops[NR_CPUS]; | 61 | extern const struct cpu_operations *cpu_ops[NR_CPUS]; |
diff --git a/arch/arm64/include/asm/suspend.h b/arch/arm64/include/asm/suspend.h index a88558e223da..e9c149c042e0 100644 --- a/arch/arm64/include/asm/suspend.h +++ b/arch/arm64/include/asm/suspend.h | |||
@@ -15,4 +15,13 @@ struct cpu_suspend_ctx { | |||
15 | u64 ctx_regs[NR_CTX_REGS]; | 15 | u64 ctx_regs[NR_CTX_REGS]; |
16 | u64 sp; | 16 | u64 sp; |
17 | } __aligned(16); | 17 | } __aligned(16); |
18 | |||
19 | struct sleep_save_sp { | ||
20 | phys_addr_t *save_ptr_stash; | ||
21 | phys_addr_t save_ptr_stash_phys; | ||
22 | }; | ||
23 | |||
24 | extern void cpu_resume(void); | ||
25 | extern int cpu_suspend(unsigned long); | ||
26 | |||
18 | #endif | 27 | #endif |