ARM: Add initial hibernation support for Cortex A8 and A9
Subsystems (3)
RFC PATCH 1/1 ARM: Add initial hibernation support for Cortex A8 and A9
Hibernation (Suspend-To-Disk) support for ARM Cortex A8 and A9.
This patch is based on the work of Hiroshi DOYU at Nokia, which is stated to be based on the original work of Romit and Raghu at TI.
The hibernation support is tested with S5PC210 (ARM Cortex A9 MP2). In order to add support for Cortex A9 on the original patch of Hiroshi DOYU, which support Cortex A8 only, we have edited the list of registers to be saved in the case of A9.
In the original work of Hiroshi DOYU, arch/arm/kernel/vmlinux.lds.S was modified; however, we have reverted it because it only created build failure in our tested system.
--- arch/arm/Kconfig | 4 + arch/arm/include/asm/memory.h | 1 + arch/arm/include/asm/suspend.h | 6 + arch/arm/kernel/Makefile | 1 + arch/arm/kernel/hibernate.c | 323 +++++++++++++++++++++++++++++++++++++++ arch/arm/kernel/hibernate_asm.S | 135 ++++++++++++++++ 6 files changed, 470 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/suspend.h create mode 100644 arch/arm/kernel/hibernate.c create mode 100644 arch/arm/kernel/hibernate_asm.S
arch/arm/Kconfig +4 -0
@@ -187,6 +187,10 @@ config VECTORS_BASE help The base address of exception vectors. +config ARCH_HIBERNATION_POSSIBLE + def_bool y + depends on CPU_V7 + source "init/Kconfig" source "kernel/Kconfig.freezer"
arch/arm/include/asm/memory.h +1 -0
@@ -203,6 +203,7 @@ static inline void *phys_to_virt(unsigned long x)*/ #define __pa (x) __virt_to_phys((unsigned long)(x))#define __va (x) ((void *)__phys_to_virt((unsigned long)(x))) +#define __pa_symbol (x) __pa(RELOC_HIDE((unsigned long)(x), 0))#define pfn_to_kaddr (pfn) __va((pfn) << PAGE_SHIFT)/*
arch/arm/include/asm/suspend.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __ASM_ARM_SUSPEND_H +#define __ASM_ARM_SUSPEND_H + +static inline int arch_prepare_suspend (void ) {return 0 ; } + +#endif /* __ASM_ARM_SUSPEND_H */
arch/arm/kernel/Makefile +1 -0
@@ -41,6 +41,7 @@ obj-$(CONFIG_ARM_THUMBEE) += thumbee.o obj-$(CONFIG_KGDB) += kgdb.o obj-$(CONFIG_ARM_UNWIND) += unwind.o obj-$(CONFIG_HAVE_TCM) += tcm.o +obj-$(CONFIG_HIBERNATION) += hibernate.o hibernate_asm.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
arch/arm/kernel/hibernate.c new file +323 -0
323 lines not on this page · raw message
arch/arm/kernel/hibernate_asm.S new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
1.7.1
RFC PATCH 1/1 Samsung SoC: Hibernation Initial Support
Hibernation (aka 'suspend to disk') support for Samsung SoCs.
This patch is based on the hibernation support for ARM (i.e., "ARM: Add initial hibernation support for Cortex A8 and A9"). This patch is tested with S5PC210.
This patch provides the followings in order to enable hibernation in Samsung SoCs.
1. Support call-backs for machine-specific hibernation codes.
2. Save and restore common registers (GPIO, UART, and CORE).
3. Set default struct platofrm_hibernation_ops
--- arch/arm/plat-samsung/include/plat/pm.h | 5 ++ arch/arm/plat-samsung/pm.c | 67 +++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 0 deletions(-)
arch/arm/plat-samsung/include/plat/pm.h +5 -0
@@ -40,6 +40,11 @@ extern unsigned long s3c_irqwake_eintallow;extern void (*pm_cpu_prep)(void );extern void (*pm_cpu_sleep)(void ); +#ifdef CONFIG_HIBERNATION +extern void (*hb_cpu_begin)(void ); +extern void (*hb_cpu_end)(void ); +#endif +/* Flags for PM Control */ extern unsigned long s3c_pm_flags;
arch/arm/plat-samsung/pm.c +67 -0
90 lines not on this page · raw message
Signature · 1 line
1.7.1
RFC PATCH 1/1 ARM: Add initial hibernation support for Cortex A8 and A9
In reply to MyungJoo HamQuoted 10 lines · MyungJoo Ham
Hibernation (Suspend-To-Disk) support for ARM Cortex A8 and A9.
This patch is based on the work of Hiroshi DOYU at Nokia, which is stated to be based on the original work of Romit and Raghu at TI.
The hibernation support is tested with S5PC210 (ARM Cortex A9 MP2). In order to add support for Cortex A9 on the original patch of Hiroshi DOYU, which support Cortex A8 only, we have edited the list of registers to be saved in the case of A9.
Quoted 6 lines
In the original work of Hiroshi DOYU,
arch/arm/kernel/vmlinux.lds.Swas modified; however, we have reverted it because it only created build failure in our tested system.Signed-off-by MyungJoo Ham <[email protected]>Signed-off-by Kyungmin Park <[email protected]>
Please note that I only had a quick look at the code and I won't have time to do a proper review before the end of the year. But I have a few comments which are consider essential.
Quoted 16 lines
arch/arm/kernel/hibernate.c new file +13
-0@@ -0,0 +1,323 @@ +/* +* Hibernation support specific for ARM +* +* Copyright (C) 2010 Nokia Corporation +* Copyright (C) 2010 Texas Instruments, Inc. +* Copyright (C) 2006 Rafael J. Wysocki <[email protected]> +* +* Contact: Hiroshi DOYU <[email protected]> +* +* License terms: GNU General Public License (GPL) version 2 +*/ + +#include <linux/module.h>
arch/arm/kernel/hibernate.c line 23
Quoted 10 lines
arch/arm/kernel/hibernate.c new file +10
-0+#include <linux/mm.h> + + +/* The following architectures are known to be CORTEX_A9 */ +#if defined(CONFIG_ARCH_S5PV310 ) || defined(CONFIG_ARCH_U8500 ) +#define CORTEX_A9 +#else +/* Assume CORTEX_A8 as default */ +#define CORTEX_A8 +#endif
We should use run-time detection of the CPU rather than #ifdef's. We have the ability to build multiple processors support into the same kernel image.
Quoted 7 lines
arch/arm/kernel/hibernate.c new file +7
-0+struct saved_context { +/* +* FIXME: Only support for Cortex A8 and Cortex A9 now +*/ + ? ? ? /* CR0 */ + ? ? ? u32 cssr; ? ? ? /* Cache Size Selection */ + ? ? ? /* CR1 */
arch/arm/kernel/hibernate.c line 40
Quoted 10 lines
arch/arm/kernel/hibernate.c new file +10
-0+#ifdef CORTEX_A8 + ? ? ? u32 cr; ? ? ? ? /* Control */ + ? ? ? u32 cacr; ? ? ? /* Coprocessor Access Control */ +#elif defined(CORTEX_A9 ) + ? ? ? u32 cr; + ? ? ? u32 actlr; + ? ? ? u32 cacr; + ? ? ? u32 sder; + ? ? ? u32 vcr; +#endif
We could follow the ARM ARM and define a save_context structure which has architected registers and implementation-defined ones. For the latter you could use a union inside this structure to differentiate between A8, A9 and other registers for different implementations.
Quoted 4 lines
arch/arm/kernel/hibernate.c new file +4
-0+ ? ? ? /* CR2 */ + ? ? ? u32 ttb_0r; ? ? /* Translation Table Base 0 */ + ? ? ? u32 ttb_1r; ? ? /* Translation Table Base 1 */ + ? ? ? u32 ttbcr; ? ? ?/* Translation Talbe Base Control */
arch/arm/kernel/hibernate.c line 54
Quoted 10 lines
arch/arm/kernel/hibernate.c new file +10
-0+ ? ? ? /* CR3 */ + ? ? ? u32 dacr; ? ? ? /* Domain Access Control */ + ? ? ? /* CR5 */ + ? ? ? u32 d_fsr; ? ? ?/* Data Fault Status */ + ? ? ? u32 i_fsr; ? ? ?/* Instruction Fault Status */ + ? ? ? u32 d_afsr; ? ? /* Data Auxilirary Fault Status */ ? ? ? ; + ? ? ? u32 i_afsr; ? ? /* Instruction Auxilirary Fault Status */; +/* CR6 */ +u32 d_far;/* Data Fault Address */ +u32 i_far;/* Instruction Fault Address */
I haven't checked the ARM ARM but some registers may be read-only and not really needing saving/restoring. Some of them also don't have any information that is essential when coming back from hibernation (like the FSR/FAR ones).
Quoted 5 lines
arch/arm/kernel/hibernate.c new file +5
-0+static inline void __save_processor_state (struct saved_context *ctxt) +{ + ? ? ? /* CR0 */ + ? ? ? asm volatile ("mrc p15, 2, %0, c0, c0, 0" : "=r"(ctxt->cssr)); + ? ? ? /* CR1 */
arch/arm/kernel/hibernate.c line 69
Quoted 10 lines
arch/arm/kernel/hibernate.c new file +10
-0+#ifdef CORTEX_A8 + ? ? ? asm volatile ("mrc p15, 0, %0, c1, c0, 0" : "=r"(ctxt->cr)); + ? ? ? asm volatile ("mrc p15, 0, %0, c1, c0, 2" : "=r"(ctxt->cacr)); +#elif defined(CORTEX_A9 ) + ? ? ? asm volatile ("mrc p15, 0, %0, c1, c0, 0" : "=r"(ctxt->cr)); + ? ? ? asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r"(ctxt->actlr)); + ? ? ? asm volatile ("mrc p15, 0, %0, c1, c0, 2" : "=r"(ctxt->cacr)); + ? ? ? asm volatile ("mrc p15, 0, %0, c1, c1, 1" : "=r"(ctxt->sder)); + ? ? ? asm volatile ("mrc p15, 0, %0, c1, c1, 3" : "=r"(ctxt->vcr)); +#endif
I think this could be split into a generic state saving function and a per-processor one. You can then do some checks on the CPU ID to and call the corresponding implementation-specific save function.
Quoted 2 lines
arch/arm/kernel/hibernate.c new file +2
-0+static inline void __restore_processor_state (struct saved_context *ctxt) +{
[...]
arch/arm/kernel/hibernate.c line 46
Quoted 3 lines
arch/arm/kernel/hibernate.c new file +3
-0+#ifdef CORTEX_A8 + ? ? ? asm volatile ("mcr p15, 1, %0, c9, c0, 0" : : "r"(ctxt->l2clr)); +#endif
This register (and maybe others) is not always writable in non-secure mode. If running in non-secure mode (which cannot easily be detected at run-time), we should first check the Nonsecure Access Control Register.
Signature · 1 line
Catalin
RFC PATCH 1/1 ARM: Add initial hibernation support for Cortex A8 and A9
Quoted 4 lines · Catalin Marinas
We could follow the ARM ARM and define a
save_contextstructure which has architected registers and implementation-defined ones. For the latter you could use a union inside this structure to differentiate between A8, A9 and other registers for different implementations.
No we shouldn't. The architecture manual will tell you that you need to save the entire universe (eg, IRQ-mode registers, VFP registers, etc.)
What we should have is the individual support files (eg, perf) saving their own state at the appropriate time. And there's two times that subsystems need to save their state:
1. Hot unplug of a CPU.
2. Suspend.
I've recently added the necessary hotplug notifier to VFP.
With some intelligence, we can avoid saving many registers, such as the non-SVC mode registers (by calling cpu_init() which re-sets the non-SVC mode registers up as we want them to be), the VFP registers (which we save into the thread context save structure if they're not already saved there.)
The same should be true of things like perf.
Things like the control register we already have the value cached, so there's little point saving another copy of it.
What we should also have is a callback into the proc-*.S files for them to save the processor specific registers such as the TTB registers.
And then, with non-secure mode, we run into issues about which registers we _can_ sanely read and write.
What I'm saying is that rather than copying stuff verbatim from the ARM ARM, _think_ first and see what is actually necessary.
RFC PATCH 1/1 ARM: Add initial hibernation support for Cortex A8 and A9
Hi!
Quoted 5 lines
The same should be true of things like perf.
Things like the control register we already have the value cached, so there's little point saving another copy of it.
Quoted 8 lines
What we should also have is a callback into the proc-*.S files for them to save the processor specific registers such as the TTB registers.
And then, with non-secure mode, we run into issues about which registers we _can_ sanely read and write.
What I'm saying is that rather than copying stuff verbatim from the ARM ARM, _think_ first and see what is actually necessary.
Well, the patch is not exactly nice, but "simple and stupid" version that just saves everything might be useful baseline for bisect etc... and speed should not really be issue here.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 4 lines · Catalin Marinas
We could follow the ARM ARM and define a
save_contextstructure which has architected registers and implementation-defined ones. For the latter you could use a union inside this structure to differentiate between A8, A9 and other registers for different implementations.
No we shouldn't. The architecture manual will tell you that you need to save the entire universe (eg, IRQ-mode registers, VFP registers, etc.)
What we should have is the individual support files (eg, perf) saving their own state at the appropriate time. And there's two times that subsystems need to save their state:
1. Hot unplug of a CPU.
2. Suspend.
I've recently added the necessary hotplug notifier to VFP.
With some intelligence, we can avoid saving many registers, such as the non-SVC mode registers (by calling cpu_init() which re-sets the non-SVC mode registers up as we want them to be), the VFP registers (which we save into the thread context save structure if they're not already saved there.)
The same should be true of things like perf.
Things like the control register we already have the value cached, so there's little point saving another copy of it.
What we should also have is a callback into the proc-*.S files for them to save the processor specific registers such as the TTB registers.
And then, with non-secure mode, we run into issues about which registers we _can_ sanely read and write.
What I'm saying is that rather than copying stuff verbatim from the ARM ARM, _think_ first and see what is actually necessary.
Quoted 10 lines · MyungJoo Ham
Hibernation (Suspend-To-Disk) support for ARM Cortex A8 and A9.
This patch is based on the work of Hiroshi DOYU at Nokia, which is stated to be based on the original work of Romit and Raghu at TI.
The hibernation support is tested with S5PC210 (ARM Cortex A9 MP2). In order to add support for Cortex A9 on the original patch of Hiroshi DOYU, which support Cortex A8 only, we have edited the list of registers to be saved in the case of A9.
Quoted 6 lines
In the original work of Hiroshi DOYU,
arch/arm/kernel/vmlinux.lds.Swas modified; however, we have reverted it because it only created build failure in our tested system.Signed-off-by MyungJoo Ham <[email protected]>Signed-off-by Kyungmin Park <[email protected]>
Please note that I only had a quick look at the code and I won't have time to do a proper review before the end of the year. But I have a few comments which are consider essential.
Quoted 16 lines
arch/arm/kernel/hibernate.c new file +13
-0@@ -0,0 +1,323 @@ +/* +* Hibernation support specific for ARM +* +* Copyright (C) 2010 Nokia Corporation +* Copyright (C) 2010 Texas Instruments, Inc. +* Copyright (C) 2006 Rafael J. Wysocki <[email protected]> +* +* Contact: Hiroshi DOYU <[email protected]> +* +* License terms: GNU General Public License (GPL) version 2 +*/ + +#include <linux/module.h>
arch/arm/kernel/hibernate.c line 23
Quoted 10 lines
arch/arm/kernel/hibernate.c new file +10
-0+#include <linux/mm.h> + + +/* The following architectures are known to be CORTEX_A9 */ +#if defined(CONFIG_ARCH_S5PV310 ) || defined(CONFIG_ARCH_U8500 ) +#define CORTEX_A9 +#else +/* Assume CORTEX_A8 as default */ +#define CORTEX_A8 +#endif
We should use run-time detection of the CPU rather than #ifdef's. We have the ability to build multiple processors support into the same kernel image.
Quoted 7 lines
arch/arm/kernel/hibernate.c new file +7
-0+struct saved_context { +/* +* FIXME: Only support for Cortex A8 and Cortex A9 now +*/ + /* CR0 */ + u32 cssr; /* Cache Size Selection */ + /* CR1 */
arch/arm/kernel/hibernate.c line 46
Quoted 10 lines
arch/arm/kernel/hibernate.c new file +10
-0+#ifdef CORTEX_A8 + u32 cr; /* Control */ + u32 cacr; /* Coprocessor Access Control */ +#elif defined(CORTEX_A9 ) + u32 cr; + u32 actlr; + u32 cacr; + u32 sder; + u32 vcr; +#endif
We could follow the ARM ARM and define a save_context structure which has architected registers and implementation-defined ones. For the latter you could use a union inside this structure to differentiate between A8, A9 and other registers for different implementations.
Quoted 4 lines
arch/arm/kernel/hibernate.c new file +4
-0+ /* CR2 */ + u32 ttb_0r; /* Translation Table Base 0 */ + u32 ttb_1r; /* Translation Table Base 1 */ + u32 ttbcr; /* Translation Talbe Base Control */
arch/arm/kernel/hibernate.c line 60
Quoted 10 lines
arch/arm/kernel/hibernate.c new file +10
-0+ /* CR3 */ + u32 dacr; /* Domain Access Control */ + /* CR5 */ + u32 d_fsr; /* Data Fault Status */ + u32 i_fsr; /* Instruction Fault Status */ + u32 d_afsr; /* Data Auxilirary Fault Status */ ; + u32 i_afsr; /* Instruction Auxilirary Fault Status */; +/* CR6 */ +u32 d_far;/* Data Fault Address */ +u32 i_far;/* Instruction Fault Address */
I haven't checked the ARM ARM but some registers may be read-only and not really needing saving/restoring. Some of them also don't have any information that is essential when coming back from hibernation (like the FSR/FAR ones).
Quoted 5 lines
arch/arm/kernel/hibernate.c new file +5
-0+static inline void __save_processor_state (struct saved_context *ctxt) +{ + /* CR0 */ + asm volatile ("mrc p15, 2, %0, c0, c0, 0" : "=r"(ctxt->cssr)); + /* CR1 */
arch/arm/kernel/hibernate.c line 157
Quoted 10 lines
arch/arm/kernel/hibernate.c new file +10
-0+#ifdef CORTEX_A8 + asm volatile ("mrc p15, 0, %0, c1, c0, 0" : "=r"(ctxt->cr)); + asm volatile ("mrc p15, 0, %0, c1, c0, 2" : "=r"(ctxt->cacr)); +#elif defined(CORTEX_A9 ) + asm volatile ("mrc p15, 0, %0, c1, c0, 0" : "=r"(ctxt->cr)); + asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r"(ctxt->actlr)); + asm volatile ("mrc p15, 0, %0, c1, c0, 2" : "=r"(ctxt->cacr)); + asm volatile ("mrc p15, 0, %0, c1, c1, 1" : "=r"(ctxt->sder)); + asm volatile ("mrc p15, 0, %0, c1, c1, 3" : "=r"(ctxt->vcr)); +#endif
I think this could be split into a generic state saving function and a per-processor one. You can then do some checks on the CPU ID to and call the corresponding implementation-specific save function.
Quoted 2 lines
arch/arm/kernel/hibernate.c new file +2
-0+static inline void __restore_processor_state (struct saved_context *ctxt) +{
[...]
arch/arm/kernel/hibernate.c line 276
Quoted 3 lines
arch/arm/kernel/hibernate.c new file +3
-0+#ifdef CORTEX_A8 + asm volatile ("mcr p15, 1, %0, c9, c0, 0" : : "r"(ctxt->l2clr)); +#endif
This register (and maybe others) is not always writable in non-secure mode. If running in non-secure mode (which cannot easily be detected at run-time), we should first check the Nonsecure Access Control Register.
Signature · 5 lines
Catalin _______________________________________________ linux-pm mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 10 lines · MyungJoo Ham
Hibernation (Suspend-To-Disk) support for ARM Cortex A8 and A9.
This patch is based on the work of Hiroshi DOYU at Nokia, which is stated to be based on the original work of Romit and Raghu at TI.
The hibernation support is tested with S5PC210 (ARM Cortex A9 MP2). In order to add support for Cortex A9 on the original patch of Hiroshi DOYU, which support Cortex A8 only, we have edited the list of registers to be saved in the case of A9.
Quoted 6 lines
In the original work of Hiroshi DOYU,
arch/arm/kernel/vmlinux.lds.Swas modified; however, we have reverted it because it only created build failure in our tested system.Signed-off-by MyungJoo Ham <[email protected]>Signed-off-by Kyungmin Park <[email protected]>
Please note that I only had a quick look at the code and I won't have time to do a proper review before the end of the year. But I have a few comments which are consider essential.
Quoted 16 lines
arch/arm/kernel/hibernate.c new file +13
-0@@ -0,0 +1,323 @@ +/* +* Hibernation support specific for ARM +* +* Copyright (C) 2010 Nokia Corporation +* Copyright (C) 2010 Texas Instruments, Inc. +* Copyright (C) 2006 Rafael J. Wysocki <[email protected]> +* +* Contact: Hiroshi DOYU <[email protected]> +* +* License terms: GNU General Public License (GPL) version 2 +*/ + +#include <linux/module.h>
arch/arm/kernel/hibernate.c line 23
Quoted 10 lines
arch/arm/kernel/hibernate.c new file +10
-0+#include <linux/mm.h> + + +/* The following architectures are known to be CORTEX_A9 */ +#if defined(CONFIG_ARCH_S5PV310 ) || defined(CONFIG_ARCH_U8500 ) +#define CORTEX_A9 +#else +/* Assume CORTEX_A8 as default */ +#define CORTEX_A8 +#endif
We should use run-time detection of the CPU rather than #ifdef's. We have the ability to build multiple processors support into the same kernel image.
Quoted 7 lines
arch/arm/kernel/hibernate.c new file +7
-0+struct saved_context { +/* +* FIXME: Only support for Cortex A8 and Cortex A9 now +*/ + /* CR0 */ + u32 cssr; /* Cache Size Selection */ + /* CR1 */
arch/arm/kernel/hibernate.c line 46
Quoted 10 lines
arch/arm/kernel/hibernate.c new file +10
-0+#ifdef CORTEX_A8 + u32 cr; /* Control */ + u32 cacr; /* Coprocessor Access Control */ +#elif defined(CORTEX_A9 ) + u32 cr; + u32 actlr; + u32 cacr; + u32 sder; + u32 vcr; +#endif
We could follow the ARM ARM and define a save_context structure which has architected registers and implementation-defined ones. For the latter you could use a union inside this structure to differentiate between A8, A9 and other registers for different implementations.
Quoted 4 lines
arch/arm/kernel/hibernate.c new file +4
-0+ /* CR2 */ + u32 ttb_0r; /* Translation Table Base 0 */ + u32 ttb_1r; /* Translation Table Base 1 */ + u32 ttbcr; /* Translation Talbe Base Control */
arch/arm/kernel/hibernate.c line 60
Quoted 10 lines
arch/arm/kernel/hibernate.c new file +10
-0+ /* CR3 */ + u32 dacr; /* Domain Access Control */ + /* CR5 */ + u32 d_fsr; /* Data Fault Status */ + u32 i_fsr; /* Instruction Fault Status */ + u32 d_afsr; /* Data Auxilirary Fault Status */ ; + u32 i_afsr; /* Instruction Auxilirary Fault Status */; +/* CR6 */ +u32 d_far;/* Data Fault Address */ +u32 i_far;/* Instruction Fault Address */
I haven't checked the ARM ARM but some registers may be read-only and not really needing saving/restoring. Some of them also don't have any information that is essential when coming back from hibernation (like the FSR/FAR ones).
Quoted 5 lines
arch/arm/kernel/hibernate.c new file +5
-0+static inline void __save_processor_state (struct saved_context *ctxt) +{ + /* CR0 */ + asm volatile ("mrc p15, 2, %0, c0, c0, 0" : "=r"(ctxt->cssr)); + /* CR1 */
arch/arm/kernel/hibernate.c line 157
Quoted 10 lines
arch/arm/kernel/hibernate.c new file +10
-0+#ifdef CORTEX_A8 + asm volatile ("mrc p15, 0, %0, c1, c0, 0" : "=r"(ctxt->cr)); + asm volatile ("mrc p15, 0, %0, c1, c0, 2" : "=r"(ctxt->cacr)); +#elif defined(CORTEX_A9 ) + asm volatile ("mrc p15, 0, %0, c1, c0, 0" : "=r"(ctxt->cr)); + asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r"(ctxt->actlr)); + asm volatile ("mrc p15, 0, %0, c1, c0, 2" : "=r"(ctxt->cacr)); + asm volatile ("mrc p15, 0, %0, c1, c1, 1" : "=r"(ctxt->sder)); + asm volatile ("mrc p15, 0, %0, c1, c1, 3" : "=r"(ctxt->vcr)); +#endif
I think this could be split into a generic state saving function and a per-processor one. You can then do some checks on the CPU ID to and call the corresponding implementation-specific save function.
Quoted 2 lines
arch/arm/kernel/hibernate.c new file +2
-0+static inline void __restore_processor_state (struct saved_context *ctxt) +{
[...]
arch/arm/kernel/hibernate.c line 276
Quoted 3 lines
arch/arm/kernel/hibernate.c new file +3
-0+#ifdef CORTEX_A8 + asm volatile ("mcr p15, 1, %0, c9, c0, 0" : : "r"(ctxt->l2clr)); +#endif
This register (and maybe others) is not always writable in non-secure mode. If running in non-secure mode (which cannot easily be detected at run-time), we should first check the Nonsecure Access Control Register.
Signature · 10 lines
Catalin _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel _______________________________________________ linux-pm mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/linux-pm