Generic CPU save/restore PM support
Subsystems (5)
The following patch series implements infrastructure to save/restore CPU state on suspend/resume PM events, and updates SA11x0, PXA and Samsung platforms to use this.
Not all CPU support files are updated with the necessary changes - currently only ARM920, ARM926, SA11x0, XScale, XScale3, V6 and V7 CPUs are supported.
I've build-tested this for Assabet, PXA, and S3C2410, but not boot tested it yet.
PATCH 1/5 ARM: move cache/processor/fault glue to separate include files
This allows the cache/processor/fault glue to be more easily used from assembler code.
--- arch/arm/include/asm/cacheflush.h | 133 +---------------- arch/arm/include/asm/cpu-multi32.h | 69 -------- arch/arm/include/asm/cpu-single.h | 44 ------ arch/arm/include/asm/glue-cache.h | 146 ++++++++++++++++++ arch/arm/include/asm/glue-df.h | 110 +++++++++++++ arch/arm/include/asm/glue-pf.h | 57 +++++++ arch/arm/include/asm/glue-proc.h | 261 +++++++++++++++++++++++++++++++ arch/arm/include/asm/glue.h | 138 ----------------- arch/arm/include/asm/proc-fns.h | 299 ++++++++---------------------------- arch/arm/kernel/asm-offsets.c | 2 + arch/arm/kernel/entry-armv.S | 3 +- 11 files changed, 644 insertions(+), 618 deletions(-) delete mode 100644 arch/arm/include/asm/cpu-multi32.h delete mode 100644 arch/arm/include/asm/cpu-single.h create mode 100644 arch/arm/include/asm/glue-cache.h create mode 100644 arch/arm/include/asm/glue-df.h create mode 100644 arch/arm/include/asm/glue-pf.h create mode 100644 arch/arm/include/asm/glue-proc.h
arch/arm/include/asm/cacheflush.h +2 -131
@@ -12,7 +12,7 @@#include <linux/mm.h> -#include <asm/glue.h> +#include <asm/glue-cache.h> #include <asm/shmparam.h> #include <asm/cachetype.h> #include <asm/outercache.h>
@@ -20,123 +20,6 @@#define CACHE_COLOUR (vaddr) ((vaddr & (SHMLBA - 1)) >> PAGE_SHIFT)/* -* Cache Model -* =========== -*/ -#undef _CACHE -#undef MULTI_CACHE - -#if defined(CONFIG_CPU_CACHE_V3 ) -# ifdef _CACHE -# define MULTI_CACHE 1 -# else -# define _CACHE v3 -# endif -#endif - -#if defined(CONFIG_CPU_CACHE_V4 ) -# ifdef _CACHE -# define MULTI_CACHE 1 -# else -# define _CACHE v4 -# endif -#endif - -#if defined(CONFIG_CPU_ARM920T ) || defined(CONFIG_CPU_ARM922T ) || \ - defined(CONFIG_CPU_ARM925T ) || defined(CONFIG_CPU_ARM1020 ) || \ - defined(CONFIG_CPU_ARM1026 ) -# define MULTI_CACHE 1 -#endif - -#if defined(CONFIG_CPU_FA526 ) -# ifdef _CACHE -# define MULTI_CACHE 1 -# else -# define _CACHE fa -# endif -#endif - -#if defined(CONFIG_CPU_ARM926T ) -# ifdef _CACHE -# define MULTI_CACHE 1 -# else -# define _CACHE arm926 -# endif -#endif - -#if defined(CONFIG_CPU_ARM940T ) -# ifdef _CACHE -# define MULTI_CACHE 1 -# else -# define _CACHE arm940 -# endif -#endif - -#if defined(CONFIG_CPU_ARM946E ) -# ifdef _CACHE -# define MULTI_CACHE 1 -# else -# define _CACHE arm946 -# endif -#endif - -#if defined(CONFIG_CPU_CACHE_V4WB ) -# ifdef _CACHE -# define MULTI_CACHE 1 -# else -# define _CACHE v4wb -# endif -#endif - -#if defined(CONFIG_CPU_XSCALE ) -# ifdef _CACHE -# define MULTI_CACHE 1 -# else -# define _CACHE xscale -# endif -#endif - -#if defined(CONFIG_CPU_XSC3 ) -# ifdef _CACHE -# define MULTI_CACHE 1 -# else -# define _CACHE xsc3 -# endif -#endif - -#if defined(CONFIG_CPU_MOHAWK ) -# ifdef _CACHE -# define MULTI_CACHE 1 -# else -# define _CACHE mohawk -# endif -#endif - -#if defined(CONFIG_CPU_FEROCEON ) -# define MULTI_CACHE 1 -#endif - -#if defined(CONFIG_CPU_V6 ) -//# ifdef _CACHE -# define MULTI_CACHE 1 -//# else -//# define _CACHE v6 -//# endif -#endif - -#if defined(CONFIG_CPU_V7 ) -//# ifdef _CACHE -# define MULTI_CACHE 1 -//# else -//# define _CACHE v7 -//# endif -#endif - -#if !defined(_CACHE) && !defined(MULTI_CACHE ) -#error Unknown cache maintainence model -#endif - -/* * This flag is used to indicate that the page pointed to by a pte is clean * and does not require cleaning before returning it to the user. */
@@ -249,19 +132,11 @@ extern struct cpu_cache_fns cpu_cache;* visible to the CPU. */ #define dmac_map_area cpu_cache.dma_map_area -#define dmac_unmap_area cpu_cache.dma_unmap_area +#define dmac_unmap_area cpu_cache.dma_unmap_area#define dmac_flush_range cpu_cache.dma_flush_range#else -#define __cpuc_flush_icache_all __glue(_CACHE,_flush_icache_all) -#define __cpuc_flush_kern_all __glue(_CACHE,_flush_kern_cache_all) -#define __cpuc_flush_user_all __glue(_CACHE,_flush_user_cache_all) -#define __cpuc_flush_user_range __glue(_CACHE,_flush_user_cache_range) -#define __cpuc_coherent_kern_range __glue(_CACHE,_coherent_kern_range) -#define __cpuc_coherent_user_range __glue(_CACHE,_coherent_user_range) -#define __cpuc_flush_dcache_area __glue(_CACHE,_flush_kern_dcache_area) -extern void __cpuc_flush_icache_all (void );extern void __cpuc_flush_kern_all (void );extern void __cpuc_flush_user_all (void );
@@ -276,10 +151,6 @@ extern void __cpuc_flush_dcache_area(void *, size_t);* is visible to DMA, or data written by DMA to system memory is * visible to the CPU. */ -#define dmac_map_area __glue(_CACHE,_dma_map_area) -#define dmac_unmap_area __glue(_CACHE,_dma_unmap_area) -#define dmac_flush_range __glue(_CACHE,_dma_flush_range) -extern void dmac_map_area (const void *,size_t ,int );extern void dmac_unmap_area (const void *,size_t ,int );extern void dmac_flush_range (const void *,const void *);
arch/arm/include/asm/cpu-multi32.h deleted +0 -69
69 lines not on this page · raw message
arch/arm/include/asm/cpu-single.h deleted +0 -44
44 lines not on this page · raw message
arch/arm/include/asm/glue-cache.h new file +146 -0
146 lines not on this page · raw message
arch/arm/include/asm/glue-df.h new file +110 -0
110 lines not on this page · raw message
arch/arm/include/asm/glue-pf.h new file +57 -0
57 lines not on this page · raw message
arch/arm/include/asm/glue-proc.h new file +261 -0
261 lines not on this page · raw message
arch/arm/include/asm/glue.h +0 -138
148 lines not on this page · raw message
arch/arm/include/asm/proc-fns.h +64 -235
312 lines not on this page · raw message
arch/arm/kernel/asm-offsets.c +2 -0
@@ -13,6 +13,8 @@#include <linux/sched.h> #include <linux/mm.h> #include <linux/dma-mapping.h> +#include <asm/glue-df.h> +#include <asm/glue-pf.h> #include <asm/mach/arch.h> #include <asm/thread_info.h> #include <asm/memory.h>
arch/arm/kernel/entry-armv.S +2 -1
@@ -16,7 +16,8 @@ */ #include <asm/memory.h> -#include <asm/glue.h> +#include <asm/glue-df.h> +#include <asm/glue-pf.h> #include <asm/vfpmacros.h> #include <mach/entry-macro.S> #include <asm/thread_notify.h>
Signature · 1 line
1.6.2.5
PATCH 2/5 ARM: pm: add generic CPU suspend/resume support
In reply to Russell King - ARM LinuxThis adds core support for saving and restoring CPU coprocessor registers for suspend/resume support. This contains support for suspend with ARM920, ARM926, SA11x0, PXA25x, PXA27x, PXA3xx and V6 CPUs.
--- arch/arm/include/asm/glue-proc.h | 3 + arch/arm/include/asm/proc-fns.h | 7 ++ arch/arm/kernel/Makefile | 1 + arch/arm/kernel/asm-offsets.c | 9 +++ arch/arm/kernel/sleep.S | 76 +++++++++++++++++++++++ arch/arm/mm/proc-arm1020.S | 3 + arch/arm/mm/proc-arm1020e.S | 3 + arch/arm/mm/proc-arm1022.S | 3 + arch/arm/mm/proc-arm1026.S | 3 + arch/arm/mm/proc-arm6_7.S | 6 ++ arch/arm/mm/proc-arm720.S | 3 + arch/arm/mm/proc-arm740.S | 3 + arch/arm/mm/proc-arm7tdmi.S | 3 + arch/arm/mm/proc-arm920.S | 34 ++++++++++ arch/arm/mm/proc-arm922.S | 3 + arch/arm/mm/proc-arm925.S | 3 + arch/arm/mm/proc-arm926.S | 34 ++++++++++ arch/arm/mm/proc-arm940.S | 3 + arch/arm/mm/proc-arm946.S | 3 + arch/arm/mm/proc-arm9tdmi.S | 3 + arch/arm/mm/proc-fa526.S | 3 + arch/arm/mm/proc-feroceon.S | 3 + arch/arm/mm/proc-mohawk.S | 3 + arch/arm/mm/proc-sa110.S | 3 + arch/arm/mm/proc-sa1100.S | 43 +++++++++++++ arch/arm/mm/proc-v6.S | 43 +++++++++++++ arch/arm/mm/proc-v7.S | 124 ++++++++++++++++++++++++++++--------- arch/arm/mm/proc-xsc3.S | 78 +++++++++++++++++++++++- arch/arm/mm/proc-xscale.S | 51 +++++++++++++++- 29 files changed, 524 insertions(+), 33 deletions(-) create mode 100644 arch/arm/kernel/sleep.S
arch/arm/include/asm/glue-proc.h +3 -0
@@ -256,6 +256,9 @@#define cpu_dcache_clean_area __glue(CPU_NAME,_dcache_clean_area)#define cpu_do_switch_mm __glue(CPU_NAME,_switch_mm)#define cpu_set_pte_ext __glue(CPU_NAME,_set_pte_ext) +#define cpu_suspend_size __glue(CPU_NAME,_suspend_size) +#define cpu_do_suspend __glue(CPU_NAME,_do_suspend) +#define cpu_do_resume __glue(CPU_NAME,_do_resume)#endif #endif
arch/arm/include/asm/proc-fns.h +7 -0
@@ -66,6 +66,11 @@ extern struct processor {* ignore 'ext'. */ void (*set_pte_ext)(pte_t *ptep,pte_t pte,unsigned int ext); + +/* Suspend/resume */ +unsigned int suspend_size; +void (*do_suspend)(void *); +void (*do_resume)(void *); } processor;#ifndef MULTI_CPU
@@ -86,6 +91,8 @@ extern void cpu_reset(unsigned long addr) __attribute__((noreturn));#define cpu_do_switch_mm (pgd,mm) processor.switch_mm(pgd,mm)#endif +extern void cpu_resume (void ); +#include <asm/memory.h> #ifdef CONFIG_MMU
arch/arm/kernel/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_MODULES) += armksyms.o module.o obj-$(CONFIG_ARTHUR) += arthur.o obj-$(CONFIG_ISA_DMA) += dma-isa.o obj-$(CONFIG_PCI) += bios32.o isa.o +obj-$(CONFIG_PM) += sleep.o obj-$(CONFIG_HAVE_SCHED_CLOCK) += sched_clock.o obj-$(CONFIG_SMP) += smp.o smp_tlb.o obj-$(CONFIG_HAVE_ARM_SCU) += smp_scu.o
arch/arm/kernel/asm-offsets.c +9 -0
@@ -13,6 +13,7 @@#include <linux/sched.h> #include <linux/mm.h> #include <linux/dma-mapping.h> +#include <asm/cacheflush.h> #include <asm/glue-df.h> #include <asm/glue-pf.h> #include <asm/mach/arch.h>
@@ -116,6 +117,14 @@ int main(void)#ifdef MULTI_PABORT DEFINE (PROCESSOR_PABT_FUNC , offsetof(struct processor , _prefetch_abort));#endif +#ifdef MULTI_CPU +DEFINE (CPU_SLEEP_SIZE , offsetof(struct processor , suspend_size)); +DEFINE (CPU_DO_SUSPEND , offsetof(struct processor , do_suspend)); +DEFINE (CPU_DO_RESUME , offsetof(struct processor , do_resume)); +#endif +#ifdef MULTI_CACHE +DEFINE (CACHE_FLUSH_KERN_ALL , offsetof(struct cpu_cache_fns , flush_kern_all)); +#endif BLANK ();DEFINE (DMA_BIDIRECTIONAL ,DMA_BIDIRECTIONAL );DEFINE (DMA_TO_DEVICE ,DMA_TO_DEVICE );
arch/arm/kernel/sleep.S new file +76 -0
76 lines not on this page · raw message
arch/arm/mm/proc-arm1020.S +3 -0
@@ -493,6 +493,9 @@ arm1020_processor_functions: .word cpu_arm1020_dcache_clean_area .word cpu_arm1020_switch_mm .word cpu_arm1020_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1020_processor_functions, . - arm1020_processor_functions .section ".rodata"
arch/arm/mm/proc-arm1020e.S +3 -0
@@ -474,6 +474,9 @@ arm1020e_processor_functions: .word cpu_arm1020e_dcache_clean_area .word cpu_arm1020e_switch_mm .word cpu_arm1020e_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1020e_processor_functions, . - arm1020e_processor_functions .section ".rodata"
arch/arm/mm/proc-arm1022.S +3 -0
@@ -457,6 +457,9 @@ arm1022_processor_functions: .word cpu_arm1022_dcache_clean_area .word cpu_arm1022_switch_mm .word cpu_arm1022_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1022_processor_functions, . - arm1022_processor_functions .section ".rodata"
arch/arm/mm/proc-arm1026.S +3 -0
@@ -452,6 +452,9 @@ arm1026_processor_functions: .word cpu_arm1026_dcache_clean_area .word cpu_arm1026_switch_mm .word cpu_arm1026_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1026_processor_functions, . - arm1026_processor_functions .section .rodata
arch/arm/mm/proc-arm6_7.S +6 -0
@@ -284,6 +284,9 @@ ENTRY(arm6_processor_functions) .word cpu_arm6_dcache_clean_area .word cpu_arm6_switch_mm .word cpu_arm6_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm6_processor_functions, . - arm6_processor_functions /*
@@ -301,6 +304,9 @@ ENTRY(arm7_processor_functions) .word cpu_arm7_dcache_clean_area .word cpu_arm7_switch_mm .word cpu_arm7_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm7_processor_functions, . - arm7_processor_functions .section ".rodata"
arch/arm/mm/proc-arm720.S +3 -0
@@ -185,6 +185,9 @@ ENTRY(arm720_processor_functions) .word cpu_arm720_dcache_clean_area .word cpu_arm720_switch_mm .word cpu_arm720_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm720_processor_functions, . - arm720_processor_functions .section ".rodata"
arch/arm/mm/proc-arm740.S +3 -0
@@ -130,6 +130,9 @@ ENTRY(arm740_processor_functions) .word cpu_arm740_dcache_clean_area .word cpu_arm740_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm740_processor_functions, . - arm740_processor_functions .section ".rodata"
arch/arm/mm/proc-arm7tdmi.S +3 -0
@@ -70,6 +70,9 @@ ENTRY(arm7tdmi_processor_functions) .word cpu_arm7tdmi_dcache_clean_area .word cpu_arm7tdmi_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm7tdmi_processor_functions, . - arm7tdmi_processor_functions .section ".rodata"
arch/arm/mm/proc-arm920.S +34 -0
@@ -387,6 +387,37 @@ ENTRY(cpu_arm920_set_pte_ext) #endif mov pc, lr +/* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ +.globl arm920_suspend_size +.equ arm920_suspend_size, 4 * 3 +#ifdef CONFIG_PM +ENTRY(arm920_do_suspend) + stmfd sp!, {r4 - r7, lr} + mrc p15, 0, r4, c13, c0, 0 @ PID + mrc p15, 0, r5, c3, c0, 0 @ Domain ID + mrc p15, 0, r6, c2, c0, 0 @ TTB address + mrc p15, 0, r7, c1, c0, 0 @ Control register + stmia r0, {r4 - r7} + ldmfd sp!, {r4 - r7, pc} +ENDPROC(arm920_do_suspend) + +ENTRY(arm920_do_resume) + mov ip, #0 + mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs + mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches + ldmia r0, {r4 - r7} + mcr p15, 0, r4, c13, c0, 0 @ PID + mcr p15, 0, r5, c3, c0, 0 @ Domain ID + mcr p15, 0, r6, c2, c0, 0 @ TTB address + mcr p15, 0, r7, c1, c0, 0 @ Control register + nop + mov pc, lr +ENDPROC(arm920_do_resume) +#else +#define arm920_do_suspend 0 +#define arm920_do_resume 0 +#endif + __CPUINIT .type __arm920_setup, #function
@@ -432,6 +463,9 @@ arm920_processor_functions: .word cpu_arm920_dcache_clean_area .word cpu_arm920_switch_mm .word cpu_arm920_set_pte_ext + .word arm920_suspend_size + .word arm920_do_suspend + .word arm920_do_resume .size arm920_processor_functions, . - arm920_processor_functions .section ".rodata"
arch/arm/mm/proc-arm922.S +3 -0
@@ -436,6 +436,9 @@ arm922_processor_functions: .word cpu_arm922_dcache_clean_area .word cpu_arm922_switch_mm .word cpu_arm922_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm922_processor_functions, . - arm922_processor_functions .section ".rodata"
arch/arm/mm/proc-arm925.S +3 -0
@@ -503,6 +503,9 @@ arm925_processor_functions: .word cpu_arm925_dcache_clean_area .word cpu_arm925_switch_mm .word cpu_arm925_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm925_processor_functions, . - arm925_processor_functions .section ".rodata"
arch/arm/mm/proc-arm926.S +34 -0
@@ -401,6 +401,37 @@ ENTRY(cpu_arm926_set_pte_ext) #endif mov pc, lr +/* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ +.globl arm926_suspend_size +.equ arm926_suspend_size, 4 * 3 +#ifdef CONFIG_PM +ENTRY(arm926_do_suspend) + stmfd sp!, {r4 - r7, lr} + mrc p15, 0, r4, c13, c0, 0 @ PID + mrc p15, 0, r5, c3, c0, 0 @ Domain ID + mrc p15, 0, r6, c2, c0, 0 @ TTB address + mrc p15, 0, r7, c1, c0, 0 @ Control register + stmia r0, {r4 - r7} + ldmfd sp!, {r4 - r7, pc} +ENDPROC(arm926_do_suspend) + +ENTRY(arm926_do_resume) + mov ip, #0 + mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs + mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches + ldmia r0, {r4 - r7} + mcr p15, 0, r4, c13, c0, 0 @ PID + mcr p15, 0, r5, c3, c0, 0 @ Domain ID + mcr p15, 0, r6, c2, c0, 0 @ TTB address + mcr p15, 0, r7, c1, c0, 0 @ Control register + nop + mov pc, lr +ENDPROC(arm926_do_resume) +#else +#define arm926_do_suspend 0 +#define arm926_do_resume 0 +#endif + __CPUINIT .type __arm926_setup, #function
@@ -456,6 +487,9 @@ arm926_processor_functions: .word cpu_arm926_dcache_clean_area .word cpu_arm926_switch_mm .word cpu_arm926_set_pte_ext + .word arm926_suspend_size + .word arm926_do_suspend + .word arm926_do_resume .size arm926_processor_functions, . - arm926_processor_functions .section ".rodata"
arch/arm/mm/proc-arm940.S +3 -0
@@ -363,6 +363,9 @@ ENTRY(arm940_processor_functions) .word cpu_arm940_dcache_clean_area .word cpu_arm940_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm940_processor_functions, . - arm940_processor_functions .section ".rodata"
arch/arm/mm/proc-arm946.S +3 -0
@@ -419,6 +419,9 @@ ENTRY(arm946_processor_functions) .word cpu_arm946_dcache_clean_area .word cpu_arm946_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm946_processor_functions, . - arm946_processor_functions .section ".rodata"
arch/arm/mm/proc-arm9tdmi.S +3 -0
@@ -70,6 +70,9 @@ ENTRY(arm9tdmi_processor_functions) .word cpu_arm9tdmi_dcache_clean_area .word cpu_arm9tdmi_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm9tdmi_processor_functions, . - arm9tdmi_processor_functions .section ".rodata"
arch/arm/mm/proc-fa526.S +3 -0
@@ -195,6 +195,9 @@ fa526_processor_functions: .word cpu_fa526_dcache_clean_area .word cpu_fa526_switch_mm .word cpu_fa526_set_pte_ext + .word 0 + .word 0 + .word 0 .size fa526_processor_functions, . - fa526_processor_functions .section ".rodata"
arch/arm/mm/proc-feroceon.S +3 -0
@@ -554,6 +554,9 @@ feroceon_processor_functions: .word cpu_feroceon_dcache_clean_area .word cpu_feroceon_switch_mm .word cpu_feroceon_set_pte_ext + .word 0 + .word 0 + .word 0 .size feroceon_processor_functions, . - feroceon_processor_functions .section ".rodata"
arch/arm/mm/proc-mohawk.S +3 -0
@@ -388,6 +388,9 @@ mohawk_processor_functions: .word cpu_mohawk_dcache_clean_area .word cpu_mohawk_switch_mm .word cpu_mohawk_set_pte_ext + .word 0 + .word 0 + .word 0 .size mohawk_processor_functions, . - mohawk_processor_functions .section ".rodata"
arch/arm/mm/proc-sa110.S +3 -0
@@ -203,6 +203,9 @@ ENTRY(sa110_processor_functions) .word cpu_sa110_dcache_clean_area .word cpu_sa110_switch_mm .word cpu_sa110_set_pte_ext + .word 0 + .word 0 + .word 0 .size sa110_processor_functions, . - sa110_processor_functions .section ".rodata"
arch/arm/mm/proc-sa1100.S +43 -0
55 lines not on this page · raw message
arch/arm/mm/proc-v6.S +43 -0
55 lines not on this page · raw message
arch/arm/mm/proc-v7.S +94 -30
142 lines not on this page · raw message
arch/arm/mm/proc-xsc3.S +77 -1
92 lines not on this page · raw message
arch/arm/mm/proc-xscale.S +49 -2
66 lines not on this page · raw message
Signature · 1 line
1.6.2.5
PATCH v2 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 6 lines · Russell King - ARM Linux
This adds core support for saving and restoring CPU coprocessor registers for suspend/resume support. This contains support for suspend with ARM920, ARM926, SA11x0, PXA25x, PXA27x, PXA3xx and V6 CPUs.
Signed-off-by Russell King <[email protected]>---
Here's v2 of this patch. I've moved the MMU handling code into arch/arm/kernel/sleep.S, so everyone can benefit from having this handled in the same way, much like we do in head.S. I've also added a full cache flush after the MMU is turned on to ensure that we don't leak any cache lines into userspace for the MMU resume code. This should make things a little more robust.
arch/arm/include/asm/glue-proc.h | 3 + arch/arm/include/asm/proc-fns.h | 7 ++ arch/arm/kernel/Makefile | 1 + arch/arm/kernel/asm-offsets.c | 9 +++ arch/arm/kernel/sleep.S | 109 ++++++++++++++++++++++++++++++++++++ arch/arm/mm/proc-arm1020.S | 3 + arch/arm/mm/proc-arm1020e.S | 3 + arch/arm/mm/proc-arm1022.S | 3 + arch/arm/mm/proc-arm1026.S | 3 + arch/arm/mm/proc-arm6_7.S | 6 ++ arch/arm/mm/proc-arm720.S | 3 + arch/arm/mm/proc-arm740.S | 3 + arch/arm/mm/proc-arm7tdmi.S | 3 + arch/arm/mm/proc-arm920.S | 37 ++++++++++++ arch/arm/mm/proc-arm922.S | 3 + arch/arm/mm/proc-arm925.S | 3 + arch/arm/mm/proc-arm926.S | 37 ++++++++++++ arch/arm/mm/proc-arm940.S | 3 + arch/arm/mm/proc-arm946.S | 3 + arch/arm/mm/proc-arm9tdmi.S | 3 + arch/arm/mm/proc-fa526.S | 3 + arch/arm/mm/proc-feroceon.S | 3 + arch/arm/mm/proc-mohawk.S | 3 + arch/arm/mm/proc-sa110.S | 3 + arch/arm/mm/proc-sa1100.S | 39 +++++++++++++ arch/arm/mm/proc-v6.S | 48 ++++++++++++++++ arch/arm/mm/proc-v7.S | 114 ++++++++++++++++++++++++++++---------- arch/arm/mm/proc-xsc3.S | 48 ++++++++++++++++- arch/arm/mm/proc-xscale.S | 45 ++++++++++++++- 29 files changed, 518 insertions(+), 33 deletions(-)
arch/arm/include/asm/glue-proc.h +3 -0
@@ -256,6 +256,9 @@#define cpu_dcache_clean_area __glue(CPU_NAME,_dcache_clean_area)#define cpu_do_switch_mm __glue(CPU_NAME,_switch_mm)#define cpu_set_pte_ext __glue(CPU_NAME,_set_pte_ext) +#define cpu_suspend_size __glue(CPU_NAME,_suspend_size) +#define cpu_do_suspend __glue(CPU_NAME,_do_suspend) +#define cpu_do_resume __glue(CPU_NAME,_do_resume)#endif #endif
arch/arm/include/asm/proc-fns.h +7 -0
@@ -66,6 +66,11 @@ extern struct processor {* ignore 'ext'. */ void (*set_pte_ext)(pte_t *ptep,pte_t pte,unsigned int ext); + +/* Suspend/resume */ +unsigned int suspend_size; +void (*do_suspend)(void *); +void (*do_resume)(void *); } processor;#ifndef MULTI_CPU
@@ -86,6 +91,8 @@ extern void cpu_reset(unsigned long addr) __attribute__((noreturn));#define cpu_do_switch_mm (pgd,mm) processor.switch_mm(pgd,mm)#endif +extern void cpu_resume (void ); +#include <asm/memory.h> #ifdef CONFIG_MMU
arch/arm/kernel/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_MODULES) += armksyms.o module.o obj-$(CONFIG_ARTHUR) += arthur.o obj-$(CONFIG_ISA_DMA) += dma-isa.o obj-$(CONFIG_PCI) += bios32.o isa.o +obj-$(CONFIG_PM) += sleep.o obj-$(CONFIG_HAVE_SCHED_CLOCK) += sched_clock.o obj-$(CONFIG_SMP) += smp.o smp_tlb.o obj-$(CONFIG_HAVE_ARM_SCU) += smp_scu.o
arch/arm/kernel/asm-offsets.c +9 -0
@@ -13,6 +13,7 @@#include <linux/sched.h> #include <linux/mm.h> #include <linux/dma-mapping.h> +#include <asm/cacheflush.h> #include <asm/glue-df.h> #include <asm/glue-pf.h> #include <asm/mach/arch.h>
@@ -116,6 +117,14 @@ int main(void)#ifdef MULTI_PABORT DEFINE (PROCESSOR_PABT_FUNC , offsetof(struct processor , _prefetch_abort));#endif +#ifdef MULTI_CPU +DEFINE (CPU_SLEEP_SIZE , offsetof(struct processor , suspend_size)); +DEFINE (CPU_DO_SUSPEND , offsetof(struct processor , do_suspend)); +DEFINE (CPU_DO_RESUME , offsetof(struct processor , do_resume)); +#endif +#ifdef MULTI_CACHE +DEFINE (CACHE_FLUSH_KERN_ALL , offsetof(struct cpu_cache_fns , flush_kern_all)); +#endif BLANK ();DEFINE (DMA_BIDIRECTIONAL ,DMA_BIDIRECTIONAL );DEFINE (DMA_TO_DEVICE ,DMA_TO_DEVICE );
arch/arm/kernel/sleep.S new file +109 -0
109 lines not on this page · raw message
arch/arm/mm/proc-arm1020.S +3 -0
@@ -493,6 +493,9 @@ arm1020_processor_functions: .word cpu_arm1020_dcache_clean_area .word cpu_arm1020_switch_mm .word cpu_arm1020_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1020_processor_functions, . - arm1020_processor_functions .section ".rodata"
arch/arm/mm/proc-arm1020e.S +3 -0
@@ -474,6 +474,9 @@ arm1020e_processor_functions: .word cpu_arm1020e_dcache_clean_area .word cpu_arm1020e_switch_mm .word cpu_arm1020e_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1020e_processor_functions, . - arm1020e_processor_functions .section ".rodata"
arch/arm/mm/proc-arm1022.S +3 -0
@@ -457,6 +457,9 @@ arm1022_processor_functions: .word cpu_arm1022_dcache_clean_area .word cpu_arm1022_switch_mm .word cpu_arm1022_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1022_processor_functions, . - arm1022_processor_functions .section ".rodata"
arch/arm/mm/proc-arm1026.S +3 -0
@@ -452,6 +452,9 @@ arm1026_processor_functions: .word cpu_arm1026_dcache_clean_area .word cpu_arm1026_switch_mm .word cpu_arm1026_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1026_processor_functions, . - arm1026_processor_functions .section .rodata
arch/arm/mm/proc-arm6_7.S +6 -0
@@ -284,6 +284,9 @@ ENTRY(arm6_processor_functions) .word cpu_arm6_dcache_clean_area .word cpu_arm6_switch_mm .word cpu_arm6_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm6_processor_functions, . - arm6_processor_functions /*
@@ -301,6 +304,9 @@ ENTRY(arm7_processor_functions) .word cpu_arm7_dcache_clean_area .word cpu_arm7_switch_mm .word cpu_arm7_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm7_processor_functions, . - arm7_processor_functions .section ".rodata"
arch/arm/mm/proc-arm720.S +3 -0
@@ -185,6 +185,9 @@ ENTRY(arm720_processor_functions) .word cpu_arm720_dcache_clean_area .word cpu_arm720_switch_mm .word cpu_arm720_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm720_processor_functions, . - arm720_processor_functions .section ".rodata"
arch/arm/mm/proc-arm740.S +3 -0
@@ -130,6 +130,9 @@ ENTRY(arm740_processor_functions) .word cpu_arm740_dcache_clean_area .word cpu_arm740_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm740_processor_functions, . - arm740_processor_functions .section ".rodata"
arch/arm/mm/proc-arm7tdmi.S +3 -0
@@ -70,6 +70,9 @@ ENTRY(arm7tdmi_processor_functions) .word cpu_arm7tdmi_dcache_clean_area .word cpu_arm7tdmi_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm7tdmi_processor_functions, . - arm7tdmi_processor_functions .section ".rodata"
arch/arm/mm/proc-arm920.S +37 -0
@@ -387,6 +387,40 @@ ENTRY(cpu_arm920_set_pte_ext) #endif mov pc, lr +/* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ +.globl arm920_suspend_size +.equ arm920_suspend_size, 4 * 3 +#ifdef CONFIG_PM +ENTRY(arm920_do_suspend) + stmfd sp!, {r4 - r7, lr} + mrc p15, 0, r4, c13, c0, 0 @ PID + mrc p15, 0, r5, c3, c0, 0 @ Domain ID + mrc p15, 0, r6, c2, c0, 0 @ TTB address + mrc p15, 0, r7, c1, c0, 0 @ Control register + stmia r0, {r4 - r7} + ldmfd sp!, {r4 - r7, pc} +ENDPROC(arm920_do_suspend) + +ENTRY(arm920_do_resume) + mov ip, #0 + mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs + mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches + ldmia r0, {r4 - r7} + mcr p15, 0, r4, c13, c0, 0 @ PID + mcr p15, 0, r5, c3, c0, 0 @ Domain ID + mcr p15, 0, r6, c2, c0, 0 @ TTB address + mov r0, r7 @ control register + mov r2, r6, lsr #14 @ get TTB0 base + mov r2, r2, lsl #14 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + PMD_SECT_CACHEABLE | PMD_BIT4 | PMD_SECT_AP_WRITE + b cpu_resume_mmu +ENDPROC(arm920_do_resume) +#else +#define arm920_do_suspend 0 +#define arm920_do_resume 0 +#endif + __CPUINIT .type __arm920_setup, #function
@@ -432,6 +466,9 @@ arm920_processor_functions: .word cpu_arm920_dcache_clean_area .word cpu_arm920_switch_mm .word cpu_arm920_set_pte_ext + .word arm920_suspend_size + .word arm920_do_suspend + .word arm920_do_resume .size arm920_processor_functions, . - arm920_processor_functions .section ".rodata"
arch/arm/mm/proc-arm922.S +3 -0
@@ -436,6 +436,9 @@ arm922_processor_functions: .word cpu_arm922_dcache_clean_area .word cpu_arm922_switch_mm .word cpu_arm922_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm922_processor_functions, . - arm922_processor_functions .section ".rodata"
arch/arm/mm/proc-arm925.S +3 -0
@@ -503,6 +503,9 @@ arm925_processor_functions: .word cpu_arm925_dcache_clean_area .word cpu_arm925_switch_mm .word cpu_arm925_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm925_processor_functions, . - arm925_processor_functions .section ".rodata"
arch/arm/mm/proc-arm926.S +37 -0
@@ -401,6 +401,40 @@ ENTRY(cpu_arm926_set_pte_ext) #endif mov pc, lr +/* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ +.globl arm926_suspend_size +.equ arm926_suspend_size, 4 * 3 +#ifdef CONFIG_PM +ENTRY(arm926_do_suspend) + stmfd sp!, {r4 - r7, lr} + mrc p15, 0, r4, c13, c0, 0 @ PID + mrc p15, 0, r5, c3, c0, 0 @ Domain ID + mrc p15, 0, r6, c2, c0, 0 @ TTB address + mrc p15, 0, r7, c1, c0, 0 @ Control register + stmia r0, {r4 - r7} + ldmfd sp!, {r4 - r7, pc} +ENDPROC(arm926_do_suspend) + +ENTRY(arm926_do_resume) + mov ip, #0 + mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs + mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches + ldmia r0, {r4 - r7} + mcr p15, 0, r4, c13, c0, 0 @ PID + mcr p15, 0, r5, c3, c0, 0 @ Domain ID + mcr p15, 0, r6, c2, c0, 0 @ TTB address + mov r0, r7 @ control register + mov r2, r6, lsr #14 @ get TTB0 base + mov r2, r2, lsl #14 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + PMD_SECT_CACHEABLE | PMD_BIT4 | PMD_SECT_AP_WRITE + b cpu_resume_mmu +ENDPROC(arm926_do_resume) +#else +#define arm926_do_suspend 0 +#define arm926_do_resume 0 +#endif + __CPUINIT .type __arm926_setup, #function
@@ -456,6 +490,9 @@ arm926_processor_functions: .word cpu_arm926_dcache_clean_area .word cpu_arm926_switch_mm .word cpu_arm926_set_pte_ext + .word arm926_suspend_size + .word arm926_do_suspend + .word arm926_do_resume .size arm926_processor_functions, . - arm926_processor_functions .section ".rodata"
arch/arm/mm/proc-arm940.S +3 -0
@@ -363,6 +363,9 @@ ENTRY(arm940_processor_functions) .word cpu_arm940_dcache_clean_area .word cpu_arm940_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm940_processor_functions, . - arm940_processor_functions .section ".rodata"
arch/arm/mm/proc-arm946.S +3 -0
@@ -419,6 +419,9 @@ ENTRY(arm946_processor_functions) .word cpu_arm946_dcache_clean_area .word cpu_arm946_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm946_processor_functions, . - arm946_processor_functions .section ".rodata"
arch/arm/mm/proc-arm9tdmi.S +3 -0
@@ -70,6 +70,9 @@ ENTRY(arm9tdmi_processor_functions) .word cpu_arm9tdmi_dcache_clean_area .word cpu_arm9tdmi_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm9tdmi_processor_functions, . - arm9tdmi_processor_functions .section ".rodata"
arch/arm/mm/proc-fa526.S +3 -0
@@ -195,6 +195,9 @@ fa526_processor_functions: .word cpu_fa526_dcache_clean_area .word cpu_fa526_switch_mm .word cpu_fa526_set_pte_ext + .word 0 + .word 0 + .word 0 .size fa526_processor_functions, . - fa526_processor_functions .section ".rodata"
arch/arm/mm/proc-feroceon.S +3 -0
@@ -554,6 +554,9 @@ feroceon_processor_functions: .word cpu_feroceon_dcache_clean_area .word cpu_feroceon_switch_mm .word cpu_feroceon_set_pte_ext + .word 0 + .word 0 + .word 0 .size feroceon_processor_functions, . - feroceon_processor_functions .section ".rodata"
arch/arm/mm/proc-mohawk.S +3 -0
@@ -388,6 +388,9 @@ mohawk_processor_functions: .word cpu_mohawk_dcache_clean_area .word cpu_mohawk_switch_mm .word cpu_mohawk_set_pte_ext + .word 0 + .word 0 + .word 0 .size mohawk_processor_functions, . - mohawk_processor_functions .section ".rodata"
arch/arm/mm/proc-sa110.S +3 -0
@@ -203,6 +203,9 @@ ENTRY(sa110_processor_functions) .word cpu_sa110_dcache_clean_area .word cpu_sa110_switch_mm .word cpu_sa110_set_pte_ext + .word 0 + .word 0 + .word 0 .size sa110_processor_functions, . - sa110_processor_functions .section ".rodata"
arch/arm/mm/proc-sa1100.S +39 -0
@@ -169,6 +169,42 @@ ENTRY(cpu_sa1100_set_pte_ext) #endif mov pc, lr +.globl cpu_sa1100_suspend_size +.equ cpu_sa1100_suspend_size, 4*4 +#ifdef CONFIG_PM +ENTRY(cpu_sa1100_do_suspend) + stmfd sp!, {r4 - r7, lr} + mrc p15, 0, r4, c3, c0, 0 @ domain ID + mrc p15, 0, r5, c2, c0, 0 @ translation table base addr + mrc p15, 0, r6, c13, c0, 0 @ PID + mrc p15, 0, r7, c1, c0, 0 @ control reg + stmia r0, {r4 - r7} @ store cp regs + ldmfd sp!, {r4 - r7, pc} +ENDPROC(cpu_sa1100_do_suspend) + +ENTRY(cpu_sa1100_do_resume) + ldmia r0, {r4 - r7} @ load cp regs + mov r1, #0 + mcr p15, 0, r1, c8, c7, 0 @ flush I+D TLBs + mcr p15, 0, r1, c7, c7, 0 @ flush I&D cache + mcr p15, 0, r1, c9, c0, 0 @ invalidate RB + mcr p15, 0, r1, c9, c0, 5 @ allow user space to use RB + + mcr p15, 0, r4, c3, c0, 0 @ domain ID + mcr p15, 0, r5, c2, c0, 0 @ translation table base addr + mcr p15, 0, r6, c13, c0, 0 @ PID + mov r0, r7 @ control register + mov r2, r5, lsr #14 @ get TTB0 base + mov r2, r2, lsl #14 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + PMD_SECT_CACHEABLE | PMD_SECT_AP_WRITE + b cpu_resume_mmu +ENDPROC(cpu_sa1100_do_resume) +#else +#define cpu_sa1100_do_suspend 0 +#define cpu_sa1100_do_resume 0 +#endif + __CPUINIT .type __sa1100_setup, #function
@@ -218,6 +254,9 @@ ENTRY(sa1100_processor_functions) .word cpu_sa1100_dcache_clean_area .word cpu_sa1100_switch_mm .word cpu_sa1100_set_pte_ext + .word cpu_sa1100_suspend_size + .word cpu_sa1100_do_suspend + .word cpu_sa1100_do_resume .size sa1100_processor_functions, . - sa1100_processor_functions .section ".rodata"
arch/arm/mm/proc-v6.S +48 -0
60 lines not on this page · raw message
arch/arm/mm/proc-v7.S +84 -30
132 lines not on this page · raw message
arch/arm/mm/proc-xsc3.S +47 -1
62 lines not on this page · raw message
arch/arm/mm/proc-xscale.S +43 -2
60 lines not on this page · raw message
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 7 lines · Russell King - ARM Linux
Quoted 6 lines · Russell King - ARM Linux
This adds core support for saving and restoring CPU coprocessor registers for suspend/resume support. This contains support for suspend with ARM920, ARM926, SA11x0, PXA25x, PXA27x, PXA3xx and V6 CPUs.
Signed-off-by Russell King <[email protected]>---
Gah. No sooner than v2, than there's a v3 of this patch, replacing a typo'd sub rather than mov instruction, and adding a .ltorg to avoid .text wastage.
arch/arm/include/asm/glue-proc.h | 3 + arch/arm/include/asm/proc-fns.h | 7 ++ arch/arm/kernel/Makefile | 1 + arch/arm/kernel/asm-offsets.c | 9 +++ arch/arm/kernel/sleep.S | 110 ++++++++++++++++++++++++++++++++++++ arch/arm/mm/proc-arm1020.S | 3 + arch/arm/mm/proc-arm1020e.S | 3 + arch/arm/mm/proc-arm1022.S | 3 + arch/arm/mm/proc-arm1026.S | 3 + arch/arm/mm/proc-arm6_7.S | 6 ++ arch/arm/mm/proc-arm720.S | 3 + arch/arm/mm/proc-arm740.S | 3 + arch/arm/mm/proc-arm7tdmi.S | 3 + arch/arm/mm/proc-arm920.S | 37 ++++++++++++ arch/arm/mm/proc-arm922.S | 3 + arch/arm/mm/proc-arm925.S | 3 + arch/arm/mm/proc-arm926.S | 37 ++++++++++++ arch/arm/mm/proc-arm940.S | 3 + arch/arm/mm/proc-arm946.S | 3 + arch/arm/mm/proc-arm9tdmi.S | 3 + arch/arm/mm/proc-fa526.S | 3 + arch/arm/mm/proc-feroceon.S | 3 + arch/arm/mm/proc-mohawk.S | 3 + arch/arm/mm/proc-sa110.S | 3 + arch/arm/mm/proc-sa1100.S | 39 +++++++++++++ arch/arm/mm/proc-v6.S | 48 ++++++++++++++++ arch/arm/mm/proc-v7.S | 114 ++++++++++++++++++++++++++++---------- arch/arm/mm/proc-xsc3.S | 48 ++++++++++++++++- arch/arm/mm/proc-xscale.S | 45 ++++++++++++++- 29 files changed, 519 insertions(+), 33 deletions(-)
arch/arm/include/asm/glue-proc.h +3 -0
@@ -256,6 +256,9 @@#define cpu_dcache_clean_area __glue(CPU_NAME,_dcache_clean_area)#define cpu_do_switch_mm __glue(CPU_NAME,_switch_mm)#define cpu_set_pte_ext __glue(CPU_NAME,_set_pte_ext) +#define cpu_suspend_size __glue(CPU_NAME,_suspend_size) +#define cpu_do_suspend __glue(CPU_NAME,_do_suspend) +#define cpu_do_resume __glue(CPU_NAME,_do_resume)#endif #endif
arch/arm/include/asm/proc-fns.h +7 -0
@@ -66,6 +66,11 @@ extern struct processor {* ignore 'ext'. */ void (*set_pte_ext)(pte_t *ptep,pte_t pte,unsigned int ext); + +/* Suspend/resume */ +unsigned int suspend_size; +void (*do_suspend)(void *); +void (*do_resume)(void *); } processor;#ifndef MULTI_CPU
@@ -86,6 +91,8 @@ extern void cpu_reset(unsigned long addr) __attribute__((noreturn));#define cpu_do_switch_mm (pgd,mm) processor.switch_mm(pgd,mm)#endif +extern void cpu_resume (void ); +#include <asm/memory.h> #ifdef CONFIG_MMU
arch/arm/kernel/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_MODULES) += armksyms.o module.o obj-$(CONFIG_ARTHUR) += arthur.o obj-$(CONFIG_ISA_DMA) += dma-isa.o obj-$(CONFIG_PCI) += bios32.o isa.o +obj-$(CONFIG_PM) += sleep.o obj-$(CONFIG_HAVE_SCHED_CLOCK) += sched_clock.o obj-$(CONFIG_SMP) += smp.o smp_tlb.o obj-$(CONFIG_HAVE_ARM_SCU) += smp_scu.o
arch/arm/kernel/asm-offsets.c +9 -0
@@ -13,6 +13,7 @@#include <linux/sched.h> #include <linux/mm.h> #include <linux/dma-mapping.h> +#include <asm/cacheflush.h> #include <asm/glue-df.h> #include <asm/glue-pf.h> #include <asm/mach/arch.h>
@@ -116,6 +117,14 @@ int main(void)#ifdef MULTI_PABORT DEFINE (PROCESSOR_PABT_FUNC , offsetof(struct processor , _prefetch_abort));#endif +#ifdef MULTI_CPU +DEFINE (CPU_SLEEP_SIZE , offsetof(struct processor , suspend_size)); +DEFINE (CPU_DO_SUSPEND , offsetof(struct processor , do_suspend)); +DEFINE (CPU_DO_RESUME , offsetof(struct processor , do_resume)); +#endif +#ifdef MULTI_CACHE +DEFINE (CACHE_FLUSH_KERN_ALL , offsetof(struct cpu_cache_fns , flush_kern_all)); +#endif BLANK ();DEFINE (DMA_BIDIRECTIONAL ,DMA_BIDIRECTIONAL );DEFINE (DMA_TO_DEVICE ,DMA_TO_DEVICE );
arch/arm/kernel/sleep.S new file +110 -0
110 lines not on this page · raw message
arch/arm/mm/proc-arm1020.S +3 -0
@@ -493,6 +493,9 @@ arm1020_processor_functions: .word cpu_arm1020_dcache_clean_area .word cpu_arm1020_switch_mm .word cpu_arm1020_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1020_processor_functions, . - arm1020_processor_functions .section ".rodata"
arch/arm/mm/proc-arm1020e.S +3 -0
@@ -474,6 +474,9 @@ arm1020e_processor_functions: .word cpu_arm1020e_dcache_clean_area .word cpu_arm1020e_switch_mm .word cpu_arm1020e_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1020e_processor_functions, . - arm1020e_processor_functions .section ".rodata"
arch/arm/mm/proc-arm1022.S +3 -0
@@ -457,6 +457,9 @@ arm1022_processor_functions: .word cpu_arm1022_dcache_clean_area .word cpu_arm1022_switch_mm .word cpu_arm1022_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1022_processor_functions, . - arm1022_processor_functions .section ".rodata"
arch/arm/mm/proc-arm1026.S +3 -0
@@ -452,6 +452,9 @@ arm1026_processor_functions: .word cpu_arm1026_dcache_clean_area .word cpu_arm1026_switch_mm .word cpu_arm1026_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1026_processor_functions, . - arm1026_processor_functions .section .rodata
arch/arm/mm/proc-arm6_7.S +6 -0
@@ -284,6 +284,9 @@ ENTRY(arm6_processor_functions) .word cpu_arm6_dcache_clean_area .word cpu_arm6_switch_mm .word cpu_arm6_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm6_processor_functions, . - arm6_processor_functions /*
@@ -301,6 +304,9 @@ ENTRY(arm7_processor_functions) .word cpu_arm7_dcache_clean_area .word cpu_arm7_switch_mm .word cpu_arm7_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm7_processor_functions, . - arm7_processor_functions .section ".rodata"
arch/arm/mm/proc-arm720.S +3 -0
@@ -185,6 +185,9 @@ ENTRY(arm720_processor_functions) .word cpu_arm720_dcache_clean_area .word cpu_arm720_switch_mm .word cpu_arm720_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm720_processor_functions, . - arm720_processor_functions .section ".rodata"
arch/arm/mm/proc-arm740.S +3 -0
@@ -130,6 +130,9 @@ ENTRY(arm740_processor_functions) .word cpu_arm740_dcache_clean_area .word cpu_arm740_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm740_processor_functions, . - arm740_processor_functions .section ".rodata"
arch/arm/mm/proc-arm7tdmi.S +3 -0
@@ -70,6 +70,9 @@ ENTRY(arm7tdmi_processor_functions) .word cpu_arm7tdmi_dcache_clean_area .word cpu_arm7tdmi_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm7tdmi_processor_functions, . - arm7tdmi_processor_functions .section ".rodata"
arch/arm/mm/proc-arm920.S +37 -0
@@ -387,6 +387,40 @@ ENTRY(cpu_arm920_set_pte_ext) #endif mov pc, lr +/* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ +.globl arm920_suspend_size +.equ arm920_suspend_size, 4 * 3 +#ifdef CONFIG_PM +ENTRY(arm920_do_suspend) + stmfd sp!, {r4 - r7, lr} + mrc p15, 0, r4, c13, c0, 0 @ PID + mrc p15, 0, r5, c3, c0, 0 @ Domain ID + mrc p15, 0, r6, c2, c0, 0 @ TTB address + mrc p15, 0, r7, c1, c0, 0 @ Control register + stmia r0, {r4 - r7} + ldmfd sp!, {r4 - r7, pc} +ENDPROC(arm920_do_suspend) + +ENTRY(arm920_do_resume) + mov ip, #0 + mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs + mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches + ldmia r0, {r4 - r7} + mcr p15, 0, r4, c13, c0, 0 @ PID + mcr p15, 0, r5, c3, c0, 0 @ Domain ID + mcr p15, 0, r6, c2, c0, 0 @ TTB address + mov r0, r7 @ control register + mov r2, r6, lsr #14 @ get TTB0 base + mov r2, r2, lsl #14 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + PMD_SECT_CACHEABLE | PMD_BIT4 | PMD_SECT_AP_WRITE + b cpu_resume_mmu +ENDPROC(arm920_do_resume) +#else +#define arm920_do_suspend 0 +#define arm920_do_resume 0 +#endif + __CPUINIT .type __arm920_setup, #function
@@ -432,6 +466,9 @@ arm920_processor_functions: .word cpu_arm920_dcache_clean_area .word cpu_arm920_switch_mm .word cpu_arm920_set_pte_ext + .word arm920_suspend_size + .word arm920_do_suspend + .word arm920_do_resume .size arm920_processor_functions, . - arm920_processor_functions .section ".rodata"
arch/arm/mm/proc-arm922.S +3 -0
@@ -436,6 +436,9 @@ arm922_processor_functions: .word cpu_arm922_dcache_clean_area .word cpu_arm922_switch_mm .word cpu_arm922_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm922_processor_functions, . - arm922_processor_functions .section ".rodata"
arch/arm/mm/proc-arm925.S +3 -0
@@ -503,6 +503,9 @@ arm925_processor_functions: .word cpu_arm925_dcache_clean_area .word cpu_arm925_switch_mm .word cpu_arm925_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm925_processor_functions, . - arm925_processor_functions .section ".rodata"
arch/arm/mm/proc-arm926.S +37 -0
@@ -401,6 +401,40 @@ ENTRY(cpu_arm926_set_pte_ext) #endif mov pc, lr +/* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ +.globl arm926_suspend_size +.equ arm926_suspend_size, 4 * 3 +#ifdef CONFIG_PM +ENTRY(arm926_do_suspend) + stmfd sp!, {r4 - r7, lr} + mrc p15, 0, r4, c13, c0, 0 @ PID + mrc p15, 0, r5, c3, c0, 0 @ Domain ID + mrc p15, 0, r6, c2, c0, 0 @ TTB address + mrc p15, 0, r7, c1, c0, 0 @ Control register + stmia r0, {r4 - r7} + ldmfd sp!, {r4 - r7, pc} +ENDPROC(arm926_do_suspend) + +ENTRY(arm926_do_resume) + mov ip, #0 + mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs + mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches + ldmia r0, {r4 - r7} + mcr p15, 0, r4, c13, c0, 0 @ PID + mcr p15, 0, r5, c3, c0, 0 @ Domain ID + mcr p15, 0, r6, c2, c0, 0 @ TTB address + mov r0, r7 @ control register + mov r2, r6, lsr #14 @ get TTB0 base + mov r2, r2, lsl #14 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + PMD_SECT_CACHEABLE | PMD_BIT4 | PMD_SECT_AP_WRITE + b cpu_resume_mmu +ENDPROC(arm926_do_resume) +#else +#define arm926_do_suspend 0 +#define arm926_do_resume 0 +#endif + __CPUINIT .type __arm926_setup, #function
@@ -456,6 +490,9 @@ arm926_processor_functions: .word cpu_arm926_dcache_clean_area .word cpu_arm926_switch_mm .word cpu_arm926_set_pte_ext + .word arm926_suspend_size + .word arm926_do_suspend + .word arm926_do_resume .size arm926_processor_functions, . - arm926_processor_functions .section ".rodata"
arch/arm/mm/proc-arm940.S +3 -0
@@ -363,6 +363,9 @@ ENTRY(arm940_processor_functions) .word cpu_arm940_dcache_clean_area .word cpu_arm940_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm940_processor_functions, . - arm940_processor_functions .section ".rodata"
arch/arm/mm/proc-arm946.S +3 -0
@@ -419,6 +419,9 @@ ENTRY(arm946_processor_functions) .word cpu_arm946_dcache_clean_area .word cpu_arm946_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm946_processor_functions, . - arm946_processor_functions .section ".rodata"
arch/arm/mm/proc-arm9tdmi.S +3 -0
@@ -70,6 +70,9 @@ ENTRY(arm9tdmi_processor_functions) .word cpu_arm9tdmi_dcache_clean_area .word cpu_arm9tdmi_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm9tdmi_processor_functions, . - arm9tdmi_processor_functions .section ".rodata"
arch/arm/mm/proc-fa526.S +3 -0
@@ -195,6 +195,9 @@ fa526_processor_functions: .word cpu_fa526_dcache_clean_area .word cpu_fa526_switch_mm .word cpu_fa526_set_pte_ext + .word 0 + .word 0 + .word 0 .size fa526_processor_functions, . - fa526_processor_functions .section ".rodata"
arch/arm/mm/proc-feroceon.S +3 -0
@@ -554,6 +554,9 @@ feroceon_processor_functions: .word cpu_feroceon_dcache_clean_area .word cpu_feroceon_switch_mm .word cpu_feroceon_set_pte_ext + .word 0 + .word 0 + .word 0 .size feroceon_processor_functions, . - feroceon_processor_functions .section ".rodata"
arch/arm/mm/proc-mohawk.S +3 -0
@@ -388,6 +388,9 @@ mohawk_processor_functions: .word cpu_mohawk_dcache_clean_area .word cpu_mohawk_switch_mm .word cpu_mohawk_set_pte_ext + .word 0 + .word 0 + .word 0 .size mohawk_processor_functions, . - mohawk_processor_functions .section ".rodata"
arch/arm/mm/proc-sa110.S +3 -0
@@ -203,6 +203,9 @@ ENTRY(sa110_processor_functions) .word cpu_sa110_dcache_clean_area .word cpu_sa110_switch_mm .word cpu_sa110_set_pte_ext + .word 0 + .word 0 + .word 0 .size sa110_processor_functions, . - sa110_processor_functions .section ".rodata"
arch/arm/mm/proc-sa1100.S +39 -0
@@ -169,6 +169,42 @@ ENTRY(cpu_sa1100_set_pte_ext) #endif mov pc, lr +.globl cpu_sa1100_suspend_size +.equ cpu_sa1100_suspend_size, 4*4 +#ifdef CONFIG_PM +ENTRY(cpu_sa1100_do_suspend) + stmfd sp!, {r4 - r7, lr} + mrc p15, 0, r4, c3, c0, 0 @ domain ID + mrc p15, 0, r5, c2, c0, 0 @ translation table base addr + mrc p15, 0, r6, c13, c0, 0 @ PID + mrc p15, 0, r7, c1, c0, 0 @ control reg + stmia r0, {r4 - r7} @ store cp regs + ldmfd sp!, {r4 - r7, pc} +ENDPROC(cpu_sa1100_do_suspend) + +ENTRY(cpu_sa1100_do_resume) + ldmia r0, {r4 - r7} @ load cp regs + mov r1, #0 + mcr p15, 0, r1, c8, c7, 0 @ flush I+D TLBs + mcr p15, 0, r1, c7, c7, 0 @ flush I&D cache + mcr p15, 0, r1, c9, c0, 0 @ invalidate RB + mcr p15, 0, r1, c9, c0, 5 @ allow user space to use RB + + mcr p15, 0, r4, c3, c0, 0 @ domain ID + mcr p15, 0, r5, c2, c0, 0 @ translation table base addr + mcr p15, 0, r6, c13, c0, 0 @ PID + mov r0, r7 @ control register + mov r2, r5, lsr #14 @ get TTB0 base + mov r2, r2, lsl #14 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + PMD_SECT_CACHEABLE | PMD_SECT_AP_WRITE + b cpu_resume_mmu +ENDPROC(cpu_sa1100_do_resume) +#else +#define cpu_sa1100_do_suspend 0 +#define cpu_sa1100_do_resume 0 +#endif + __CPUINIT .type __sa1100_setup, #function
@@ -218,6 +254,9 @@ ENTRY(sa1100_processor_functions) .word cpu_sa1100_dcache_clean_area .word cpu_sa1100_switch_mm .word cpu_sa1100_set_pte_ext + .word cpu_sa1100_suspend_size + .word cpu_sa1100_do_suspend + .word cpu_sa1100_do_resume .size sa1100_processor_functions, . - sa1100_processor_functions .section ".rodata"
arch/arm/mm/proc-v6.S +48 -0
60 lines not on this page · raw message
arch/arm/mm/proc-v7.S +84 -30
132 lines not on this page · raw message
arch/arm/mm/proc-xsc3.S +47 -1
62 lines not on this page · raw message
arch/arm/mm/proc-xscale.S +43 -2
60 lines not on this page · raw message
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 184 lines · Russell King - ARM Linux
Quoted 7 lines · Russell King - ARM Linux
Quoted 6 lines · Russell King - ARM Linux
This adds core support for saving and restoring CPU coprocessor registers for suspend/resume support. ?This contains support for suspend with ARM920, ARM926, SA11x0, PXA25x, PXA27x, PXA3xx and V6 CPUs.
Signed-off-by Russell King <[email protected]>---
Gah. ?No sooner than v2, than there's a v3 of this patch, replacing a typo'd sub rather than mov instruction, and adding a .ltorg to avoid .text wastage.
?arch/arm/include/asm/glue-proc.h | ? ?3 + ?arch/arm/include/asm/proc-fns.h ?| ? ?7 ++ ?arch/arm/kernel/Makefile ? ? ? ? | ? ?1 + ?arch/arm/kernel/asm-offsets.c ? ?| ? ?9 +++ ?arch/arm/kernel/sleep.S ? ? ? ? ?| ?110 ++++++++++++++++++++++++++++++++++++ ?arch/arm/mm/proc-arm1020.S ? ? ? | ? ?3 + ?arch/arm/mm/proc-arm1020e.S ? ? ?| ? ?3 + ?arch/arm/mm/proc-arm1022.S ? ? ? | ? ?3 + ?arch/arm/mm/proc-arm1026.S ? ? ? | ? ?3 + ?arch/arm/mm/proc-arm6_7.S ? ? ? ?| ? ?6 ++ ?arch/arm/mm/proc-arm720.S ? ? ? ?| ? ?3 + ?arch/arm/mm/proc-arm740.S ? ? ? ?| ? ?3 + ?arch/arm/mm/proc-arm7tdmi.S ? ? ?| ? ?3 + ?arch/arm/mm/proc-arm920.S ? ? ? ?| ? 37 ++++++++++++ ?arch/arm/mm/proc-arm922.S ? ? ? ?| ? ?3 + ?arch/arm/mm/proc-arm925.S ? ? ? ?| ? ?3 + ?arch/arm/mm/proc-arm926.S ? ? ? ?| ? 37 ++++++++++++ ?arch/arm/mm/proc-arm940.S ? ? ? ?| ? ?3 + ?arch/arm/mm/proc-arm946.S ? ? ? ?| ? ?3 + ?arch/arm/mm/proc-arm9tdmi.S ? ? ?| ? ?3 + ?arch/arm/mm/proc-fa526.S ? ? ? ? | ? ?3 + ?arch/arm/mm/proc-feroceon.S ? ? ?| ? ?3 + ?arch/arm/mm/proc-mohawk.S ? ? ? ?| ? ?3 + ?arch/arm/mm/proc-sa110.S ? ? ? ? | ? ?3 + ?arch/arm/mm/proc-sa1100.S ? ? ? ?| ? 39 +++++++++++++ ?arch/arm/mm/proc-v6.S ? ? ? ? ? ?| ? 48 ++++++++++++++++ ?arch/arm/mm/proc-v7.S ? ? ? ? ? ?| ?114 ++++++++++++++++++++++++++++---------- ?arch/arm/mm/proc-xsc3.S ? ? ? ? ?| ? 48 ++++++++++++++++- ?arch/arm/mm/proc-xscale.S ? ? ? ?| ? 45 ++++++++++++++-?29 files changed, 519 insertions(+), 33 deletions(-)
arch/arm/include/asm/glue-proc.h +3
-0@@ -256,6 +256,9 @@ ?#define cpu_dcache_clean_area ? ? ? ? ?__glue(CPU_NAME,_dcache_clean_area) ?#define cpu_do_switch_mm ? ? ? ? ? ? ? __glue(CPU_NAME,_switch_mm) ?#define cpu_set_pte_ext ? ? ? ? ? ? ? ? ? ? ? ?__glue(CPU_NAME,_set_pte_ext) +#define cpu_suspend_size ? ? ? ? ? ? ? __glue(CPU_NAME,_suspend_size) +#define cpu_do_suspend ? ? ? ? ? ? ? ? __glue(CPU_NAME,_do_suspend) +#define cpu_do_resume ? ? ? ? ? ? ? ? ?__glue(CPU_NAME,_do_resume)?#endif
?#endif
arch/arm/include/asm/proc-fns.h +0
-0@@ -66,6 +66,11 @@ extern struct processor {? ? ? ? * ignore 'ext'.
? ? ? ? */
? ? ? ?void (*set_pte_ext)(pte_t *ptep,pte_tpte, unsigned int ext); +
+ ? ? ? /* Suspend/resume */
+ ? ? ? unsigned intsuspend_size;
+ ? ? ? void (*do_suspend)(void *);
+ ? ? ? void (*do_resume)(void *);
?} processor;?#ifndef
MULTI_CPUarch/arm/include/asm/proc-fns.h +0
-0@@ -86,6 +91,8 @@ extern void cpu_reset(unsigned long addr) __attribute__((noreturn)); ?#define cpu_do_switch_mm(pgd,mm) ? ? ? processor.switch_mm(pgd,mm)?#endif
arch/arm/include/asm/proc-fns.h +2
-0+extern void cpu_resume (void ); +?#include <
asm/memory.h>?#ifdef
CONFIG_MMUarch/arm/kernel/Makefile +0
-0@@ -29,6 +29,7 @@ obj-$(CONFIG_MODULES) ? ? ? ? += armksyms.o module.o?obj-$(CONFIG_ARTHUR) ? ? ? ? ? += arthur.o ?obj-$(CONFIG_ISA_DMA) ? ? ? ? ?+= dma-isa.o ?obj-$(CONFIG_PCI) ? ? ? ? ? ? ?+= bios32.o isa.o +obj-$(CONFIG_PM) ? ? ? ? ? ? ? += sleep.o ?obj-$(CONFIG_HAVE_SCHED_CLOCK) += sched_clock.o ?obj-$(CONFIG_SMP) ? ? ? ? ? ? ?+= smp.o smp_tlb.o ?obj-$(CONFIG_HAVE_ARM_SCU) ? ? += smp_scu.o
arch/arm/kernel/asm-offsets.c +0
-0@@ -13,6 +13,7 @@?#include <
linux/sched.h>
?#include <linux/mm.h>
?#include <linux/dma-mapping.h>
+#include <asm/cacheflush.h>
?#include <asm/glue-df.h>
?#include <asm/glue-pf.h>
?#include <asm/mach/arch.h>arch/arm/kernel/asm-offsets.c +0
-0@@ -116,6 +117,14 @@ int main(void)?#ifdef
MULTI_PABORT
?DEFINE(PROCESSOR_PABT_FUNC, ?offsetof(struct processor, _prefetch_abort)); ?#endifarch/arm/kernel/asm-offsets.c +8
-0+#ifdef MULTI_CPU + ?DEFINE(CPU_SLEEP_SIZE, ? ? ? offsetof(struct processor, suspend_size)); + ?DEFINE(CPU_DO_SUSPEND, ? ? ? offsetof(struct processor, do_suspend)); + ?DEFINE(CPU_DO_RESUME, ? ? ? ? ? ? ? ?offsetof(struct processor, do_resume)); +#endif +#ifdef MULTI_CACHE + ?DEFINE(CACHE_FLUSH_KERN_ALL, offsetof(struct cpu_cache_fns, flush_kern_all)); +#endif ?
BLANK();
?DEFINE(DMA_BIDIRECTIONAL, ? ?DMA_BIDIRECTIONAL); ?DEFINE(DMA_TO_DEVICE, ? ? ? ? ? ? ? ?DMA_TO_DEVICE);arch/arm/kernel/sleep.S new file +56
-0@@ -0,0 +1,110 @@ +#include <linux/linkage.h> +#include <asm/asm-offsets.h> +#include <asm/assembler.h> +#include <asm/glue-cache.h> +#include <asm/glue-proc.h> + ? ? ? .text + +/* + * Save CPU state for a suspend + * ?r1 = v:p offset + * ?r3 = virtual return function + * Note: sp is decremented to allocate space for CPU state on stack + * r0-r3,r9,r10,lr corrupted + */ +ENTRY(cpu_suspend) + ? ? ? mov ? ? r9, lr +#ifdef MULTI_CPU + ? ? ? ldr ? ? r10, =processor + ? ? ? mov ? ? r2, sp ? ? ? ? ? ? ? ? ?@ current virtual SP + ? ? ? ldr ? ? r0, [r10, #CPU_SLEEP_SIZE] @ size of CPU sleep state + ? ? ? ldr ? ? ip, [r10, #CPU_DO_RESUME] @ virtual resume function + ? ? ? sub ? ? sp, sp, r0 ? ? ? ? ? ? ?@ allocate CPU state on stack + ? ? ? mov ? ? r0, sp ? ? ? ? ? ? ? ? ?@ save pointer + ? ? ? add ? ? ip, ip, r1 ? ? ? ? ? ? ?@ convert resume fn to phys + ? ? ? stmfd ? sp!, {r1, r2, r3, ip} ? @ save v:p, virt SP, retfn, phys resume fn + ? ? ? ldr ? ? r3, =sleep_save_sp + ? ? ? add ? ? r2, sp, r1 ? ? ? ? ? ? ?@ convert SP to phys + ? ? ? str ? ? r2, [r3] ? ? ? ? ? ? ? ?@ save phys SP + ? ? ? mov ? ? lr, pc + ? ? ? ldr ? ? pc, [r10, #CPU_DO_SUSPEND] @ save CPU state +#else + ? ? ? mov ? ? r2, sp ? ? ? ? ? ? ? ? ?@ current virtual SP + ? ? ? ldr ? ? r0, =cpu_suspend_size + ? ? ? sub ? ? sp, sp, r0 ? ? ? ? ? ? ?@ allocate CPU state on stack + ? ? ? mov ? ? r0, sp ? ? ? ? ? ? ? ? ?@ save pointer + ? ? ? stmfd ? sp!, {r1, r2, r3} ? ? ? @ save v:p, virt SP, return fn + ? ? ? ldr ? ? r3, =sleep_save_sp + ? ? ? add ? ? r2, sp, r1 ? ? ? ? ? ? ?@ convert SP to phys + ? ? ? str ? ? r2, [r3] ? ? ? ? ? ? ? ?@ save phys SP + ? ? ? bl ? ? ?cpu_do_suspend +#endif + + ? ? ? @ flush data cache +#ifdef MULTI_CACHE + ? ? ? ldr ? ? r10, =cpu_cache + ? ? ? mov ? ? lr, r9 + ? ? ? ldr ? ? pc, [r10, #CACHE_FLUSH_KERN_ALL] +#else + ? ? ? mov ? ? lr, r9 + ? ? ? b ? ? ? __cpuc_flush_kern_all +#endif +ENDPROC(cpu_suspend) + ? ? ? .ltorg + +/* + * r0 = control register value
arch/arm/kernel/sleep.S line 66
Quoted 10 lines
arch/arm/kernel/sleep.S new file +10
-0+ * r1 = v:p offset (preserved by cpu_do_resume) + * r2 = phys page table base + * r3 = L1 section flags + */ +ENTRY(cpu_resume_mmu) + ? ? ? adr ? ? r4, cpu_resume_turn_mmu_on + ? ? ? mov ? ? r4, r4, lsr #20 + ? ? ? orr ? ? r3, r3, r4, lsl #20 + ? ? ? ldr ? ? r5, [r2, r4, lsl #2] ? ?@ save old mapping + ? ? ? str ? ? r3, [r2, r4, lsl #2] ? ?@ setup 1:1 mapping for mmu code
this code doesn't look smp save, it modifies page table that could be used by another cpu. I suggest to create (at boot time) identity page table and use it in order to do mmu on.
saeed
Quoted 804 lines
arch/arm/kernel/sleep.S new file +44
-0+ ? ? ? sub ? ? r2, r2, r1 + ? ? ? ldr ? ? r3, =cpu_resume_after_mmu + ? ? ? b ? ? ? cpu_resume_turn_mmu_on +ENDPROC(cpu_resume_mmu) + ? ? ? .ltorg + ? ? ? .align ?5 +cpu_resume_turn_mmu_on: + ? ? ? mcr ? ? p15, 0, r0, c1, c0, 0 ? @ turn on MMU, caches, etc + ? ? ? mrc ? ? p15, 0, r0, c0, c0, 0 ? @ read id reg + ? ? ? mov ? ? r0, r0 + ? ? ? mov ? ? r0, r0 + ? ? ? mov ? ? pc, r3 ? ? ? ? ? ? ? ? ?@ jump to virtual address +ENDPROC(cpu_resume_turn_mmu_on) +cpu_resume_after_mmu: + ? ? ? str ? ? r5, [r2, r4, lsl #2] ? ?@ restore old mapping +#ifdef MULTI_CACHE + ? ? ? ldr ? ? r10, =cpu_cache + ? ? ? ldr ? ? pc, [r10, #CACHE_FLUSH_KERN_ALL] +#else + ? ? ? b ? ? ? __cpuc_flush_kern_all +#endif + +/* + * Note: Yes, part of the following code is located into the .data section. + * ? ? ? This is to allow sleep_save_sp to be accessed with a relative load + * ? ? ? while we can't rely on any MMU translation. ?We could have put + * ? ? ? sleep_save_sp in the .text section as well, but some setups might + * ? ? ? insist on it to be truly read-only. + */ + ? ? ? .data + ? ? ? .align +ENTRY(cpu_resume) + ? ? ? ldr ? ? r0, sleep_save_sp ? ? ? @ stack phys addr + ? ? ? msr ? ? cpsr_c, #PSR_I_BIT | PSR_F_BIT | SVC_MODE @ set SVC, irqs off +#ifdef MULTI_CPU + ? ? ? ldmia ? r0!, {r1, sp, lr, pc} ? @ load v:p, stack, return fn, resume fn +#else + ? ? ? ldmia ? r0!, {r1, sp, lr} ? ? ? @ load v:p, stack, return fn + ? ? ? b ? ? ? cpu_do_resume +#endif +ENDPROC(cpu_resume) + +sleep_save_sp: + ? ? ? .word ? 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? @ preserve stack phys ptr herearch/arm/mm/proc-arm1020.S +0
-0@@ -493,6 +493,9 @@ arm1020_processor_functions:? ? ? ?.word ?
cpu_arm1020_dcache_clean_area
? ? ? ?.word ?cpu_arm1020_switch_mm
? ? ? ?.word ?cpu_arm1020_set_pte_ext
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?arm1020_processor_functions, . -arm1020_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm1020e.S +0
-0@@ -474,6 +474,9 @@ arm1020e_processor_functions:? ? ? ?.word ?
cpu_arm1020e_dcache_clean_area
? ? ? ?.word ?cpu_arm1020e_switch_mm
? ? ? ?.word ?cpu_arm1020e_set_pte_ext
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?arm1020e_processor_functions, . -arm1020e_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm1022.S +0
-0@@ -457,6 +457,9 @@ arm1022_processor_functions:? ? ? ?.word ?
cpu_arm1022_dcache_clean_area
? ? ? ?.word ?cpu_arm1022_switch_mm
? ? ? ?.word ?cpu_arm1022_set_pte_ext
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?arm1022_processor_functions, . -arm1022_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm1026.S +0
-0@@ -452,6 +452,9 @@ arm1026_processor_functions:? ? ? ?.word ?
cpu_arm1026_dcache_clean_area
? ? ? ?.word ?cpu_arm1026_switch_mm
? ? ? ?.word ?cpu_arm1026_set_pte_ext
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?arm1026_processor_functions, . -arm1026_processor_functions? ? ? ?.section .rodata
arch/arm/mm/proc-arm6_7.S +0
-0@@ -284,6 +284,9 @@ ENTRY(arm6_processor_functions)? ? ? ? ? ? ? ?.word ?
cpu_arm6_dcache_clean_area
? ? ? ? ? ? ? ?.word ?cpu_arm6_switch_mm
? ? ? ? ? ? ? ?.word ?cpu_arm6_set_pte_ext
+ ? ? ? ? ? ? ? .word ? 0
+ ? ? ? ? ? ? ? .word ? 0
+ ? ? ? ? ? ? ? .word ? 0
? ? ? ? ? ? ? ?.size ?arm6_processor_functions, . -arm6_processor_functions?/*
arch/arm/mm/proc-arm6_7.S +0
-0@@ -301,6 +304,9 @@ ENTRY(arm7_processor_functions)? ? ? ? ? ? ? ?.word ?
cpu_arm7_dcache_clean_area
? ? ? ? ? ? ? ?.word ?cpu_arm7_switch_mm
? ? ? ? ? ? ? ?.word ?cpu_arm7_set_pte_ext
+ ? ? ? ? ? ? ? .word ? 0
+ ? ? ? ? ? ? ? .word ? 0
+ ? ? ? ? ? ? ? .word ? 0
? ? ? ? ? ? ? ?.size ?arm7_processor_functions, . -arm7_processor_functions? ? ? ? ? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm720.S +0
-0@@ -185,6 +185,9 @@ ENTRY(arm720_processor_functions)? ? ? ? ? ? ? ?.word ?
cpu_arm720_dcache_clean_area
? ? ? ? ? ? ? ?.word ?cpu_arm720_switch_mm
? ? ? ? ? ? ? ?.word ?cpu_arm720_set_pte_ext
+ ? ? ? ? ? ? ? .word ? 0
+ ? ? ? ? ? ? ? .word ? 0
+ ? ? ? ? ? ? ? .word ? 0
? ? ? ? ? ? ? ?.size ?arm720_processor_functions, . -arm720_processor_functions? ? ? ? ? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm740.S +0
-0@@ -130,6 +130,9 @@ ENTRY(arm740_processor_functions)? ? ? ?.word ?
cpu_arm740_dcache_clean_area
? ? ? ?.word ?cpu_arm740_switch_mm
? ? ? ?.word ? 0 ? ? ? ? ? ? ? ? ? ? ? @ cpu_*_set_pte
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?arm740_processor_functions, . -arm740_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm7tdmi.S +0
-0@@ -70,6 +70,9 @@ ENTRY(arm7tdmi_processor_functions)? ? ? ? ? ? ? ?.word ?
cpu_arm7tdmi_dcache_clean_area
? ? ? ? ? ? ? ?.word ?cpu_arm7tdmi_switch_mm
? ? ? ? ? ? ? ?.word ? 0 ? ? ? ? ? ? ? @ cpu_*_set_pte
+ ? ? ? ? ? ? ? .word ? 0
+ ? ? ? ? ? ? ? .word ? 0
+ ? ? ? ? ? ? ? .word ? 0
? ? ? ? ? ? ? ?.size ?arm7tdmi_processor_functions, . -arm7tdmi_processor_functions? ? ? ? ? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm920.S +0
-0@@ -387,6 +387,40 @@ ENTRY(cpu_arm920_set_pte_ext)?#endif
? ? ? ?mov ? ? pc, lrarch/arm/mm/proc-arm920.S +34
-0+/* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ +.globl arm920_suspend_size +.equ ? arm920_suspend_size, 4 * 3 +#ifdef CONFIG_PM +ENTRY(arm920_do_suspend) + ? ? ? stmfd ? sp!, {r4 - r7, lr} + ? ? ? mrc ? ? p15, 0, r4, c13, c0, 0 ?@ PID + ? ? ? mrc ? ? p15, 0, r5, c3, c0, 0 ? @ Domain ID + ? ? ? mrc ? ? p15, 0, r6, c2, c0, 0 ? @ TTB address + ? ? ? mrc ? ? p15, 0, r7, c1, c0, 0 ? @ Control register + ? ? ? stmia ? r0, {r4 - r7} + ? ? ? ldmfd ? sp!, {r4 - r7, pc} +ENDPROC(arm920_do_suspend) + +ENTRY(arm920_do_resume) + ? ? ? mov ? ? ip, #0 + ? ? ? mcr ? ? p15, 0, ip, c8, c7, 0 ? @ invalidate I+D TLBs + ? ? ? mcr ? ? p15, 0, ip, c7, c7, 0 ? @ invalidate I+D caches + ? ? ? ldmia ? r0, {r4 - r7} + ? ? ? mcr ? ? p15, 0, r4, c13, c0, 0 ?@ PID + ? ? ? mcr ? ? p15, 0, r5, c3, c0, 0 ? @ Domain ID + ? ? ? mcr ? ? p15, 0, r6, c2, c0, 0 ? @ TTB address + ? ? ? mov ? ? r0, r7 ? ? ? ? ? ? ? ? ?@ control register + ? ? ? mov ? ? r2, r6, lsr #14 ? ? ? ? @ get TTB0 base + ? ? ? mov ? ? r2, r2, lsl #14 + ? ? ? ldr ? ? r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + ? ? ? ? ? ? ? ? ? ?PMD_SECT_CACHEABLE | PMD_BIT4 | PMD_SECT_AP_WRITE + ? ? ? b ? ? ? cpu_resume_mmu +ENDPROC(arm920_do_resume) +#else +#define arm920_do_suspend ? ? ?0 +#define arm920_do_resume ? ? ? 0 +#endif +? ? ? ?__CPUINIT
? ? ? ?.type ?
__arm920_setup, #functionarch/arm/mm/proc-arm920.S +0
-0@@ -432,6 +466,9 @@ arm920_processor_functions:? ? ? ?.word ?
cpu_arm920_dcache_clean_area
? ? ? ?.word ?cpu_arm920_switch_mm
? ? ? ?.word ?cpu_arm920_set_pte_ext
+ ? ? ? .word ?arm920_suspend_size
+ ? ? ? .word ?arm920_do_suspend
+ ? ? ? .word ?arm920_do_resume
? ? ? ?.size ?arm920_processor_functions, . -arm920_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm922.S +0
-0@@ -436,6 +436,9 @@ arm922_processor_functions:? ? ? ?.word ?
cpu_arm922_dcache_clean_area
? ? ? ?.word ?cpu_arm922_switch_mm
? ? ? ?.word ?cpu_arm922_set_pte_ext
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?arm922_processor_functions, . -arm922_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm925.S +0
-0@@ -503,6 +503,9 @@ arm925_processor_functions:? ? ? ?.word ?
cpu_arm925_dcache_clean_area
? ? ? ?.word ?cpu_arm925_switch_mm
? ? ? ?.word ?cpu_arm925_set_pte_ext
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?arm925_processor_functions, . -arm925_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm926.S +0
-0@@ -401,6 +401,40 @@ ENTRY(cpu_arm926_set_pte_ext)?#endif
? ? ? ?mov ? ? pc, lrarch/arm/mm/proc-arm926.S +34
-0+/* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ +.globl arm926_suspend_size +.equ ? arm926_suspend_size, 4 * 3 +#ifdef CONFIG_PM +ENTRY(arm926_do_suspend) + ? ? ? stmfd ? sp!, {r4 - r7, lr} + ? ? ? mrc ? ? p15, 0, r4, c13, c0, 0 ?@ PID + ? ? ? mrc ? ? p15, 0, r5, c3, c0, 0 ? @ Domain ID + ? ? ? mrc ? ? p15, 0, r6, c2, c0, 0 ? @ TTB address + ? ? ? mrc ? ? p15, 0, r7, c1, c0, 0 ? @ Control register + ? ? ? stmia ? r0, {r4 - r7} + ? ? ? ldmfd ? sp!, {r4 - r7, pc} +ENDPROC(arm926_do_suspend) + +ENTRY(arm926_do_resume) + ? ? ? mov ? ? ip, #0 + ? ? ? mcr ? ? p15, 0, ip, c8, c7, 0 ? @ invalidate I+D TLBs + ? ? ? mcr ? ? p15, 0, ip, c7, c7, 0 ? @ invalidate I+D caches + ? ? ? ldmia ? r0, {r4 - r7} + ? ? ? mcr ? ? p15, 0, r4, c13, c0, 0 ?@ PID + ? ? ? mcr ? ? p15, 0, r5, c3, c0, 0 ? @ Domain ID + ? ? ? mcr ? ? p15, 0, r6, c2, c0, 0 ? @ TTB address + ? ? ? mov ? ? r0, r7 ? ? ? ? ? ? ? ? ?@ control register + ? ? ? mov ? ? r2, r6, lsr #14 ? ? ? ? @ get TTB0 base + ? ? ? mov ? ? r2, r2, lsl #14 + ? ? ? ldr ? ? r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + ? ? ? ? ? ? ? ? ? ?PMD_SECT_CACHEABLE | PMD_BIT4 | PMD_SECT_AP_WRITE + ? ? ? b ? ? ? cpu_resume_mmu +ENDPROC(arm926_do_resume) +#else +#define arm926_do_suspend ? ? ?0 +#define arm926_do_resume ? ? ? 0 +#endif +? ? ? ?__CPUINIT
? ? ? ?.type ?
__arm926_setup, #functionarch/arm/mm/proc-arm926.S +0
-0@@ -456,6 +490,9 @@ arm926_processor_functions:? ? ? ?.word ?
cpu_arm926_dcache_clean_area
? ? ? ?.word ?cpu_arm926_switch_mm
? ? ? ?.word ?cpu_arm926_set_pte_ext
+ ? ? ? .word ?arm926_suspend_size
+ ? ? ? .word ?arm926_do_suspend
+ ? ? ? .word ?arm926_do_resume
? ? ? ?.size ?arm926_processor_functions, . -arm926_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm940.S +0
-0@@ -363,6 +363,9 @@ ENTRY(arm940_processor_functions)? ? ? ?.word ?
cpu_arm940_dcache_clean_area
? ? ? ?.word ?cpu_arm940_switch_mm
? ? ? ?.word ? 0 ? ? ? ? ? ? ? @ cpu_*_set_pte
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?arm940_processor_functions, . -arm940_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm946.S +0
-0@@ -419,6 +419,9 @@ ENTRY(arm946_processor_functions)? ? ? ?.word ?
cpu_arm946_dcache_clean_area
? ? ? ?.word ?cpu_arm946_switch_mm
? ? ? ?.word ? 0 ? ? ? ? ? ? ? @ cpu_*_set_pte
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?arm946_processor_functions, . -arm946_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-arm9tdmi.S +0
-0@@ -70,6 +70,9 @@ ENTRY(arm9tdmi_processor_functions)? ? ? ? ? ? ? ?.word ?
cpu_arm9tdmi_dcache_clean_area
? ? ? ? ? ? ? ?.word ?cpu_arm9tdmi_switch_mm
? ? ? ? ? ? ? ?.word ? 0 ? ? ? ? ? ? ? @ cpu_*_set_pte
+ ? ? ? ? ? ? ? .word ? 0
+ ? ? ? ? ? ? ? .word ? 0
+ ? ? ? ? ? ? ? .word ? 0
? ? ? ? ? ? ? ?.size ?arm9tdmi_processor_functions, . -arm9tdmi_processor_functions? ? ? ? ? ? ? ?.section ".rodata"
arch/arm/mm/proc-fa526.S +0
-0@@ -195,6 +195,9 @@ fa526_processor_functions:? ? ? ?.word ?
cpu_fa526_dcache_clean_area
? ? ? ?.word ?cpu_fa526_switch_mm
? ? ? ?.word ?cpu_fa526_set_pte_ext
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?fa526_processor_functions, . -fa526_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-feroceon.S +0
-0@@ -554,6 +554,9 @@ feroceon_processor_functions:? ? ? ?.word ?
cpu_feroceon_dcache_clean_area
? ? ? ?.word ?cpu_feroceon_switch_mm
? ? ? ?.word ?cpu_feroceon_set_pte_ext
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?feroceon_processor_functions, . -feroceon_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-mohawk.S +0
-0@@ -388,6 +388,9 @@ mohawk_processor_functions:? ? ? ?.word ?
cpu_mohawk_dcache_clean_area
? ? ? ?.word ?cpu_mohawk_switch_mm
? ? ? ?.word ?cpu_mohawk_set_pte_ext
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?mohawk_processor_functions, . -mohawk_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-sa110.S +0
-0@@ -203,6 +203,9 @@ ENTRY(sa110_processor_functions)? ? ? ?.word ?
cpu_sa110_dcache_clean_area
? ? ? ?.word ?cpu_sa110_switch_mm
? ? ? ?.word ?cpu_sa110_set_pte_ext
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?sa110_processor_functions, . -sa110_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-sa1100.S +0
-0@@ -169,6 +169,42 @@ ENTRY(cpu_sa1100_set_pte_ext)?#endif
? ? ? ?mov ? ? pc, lr+.globl
cpu_sa1100_suspend_size
+.equ ?cpu_sa1100_suspend_size, 4*4arch/arm/mm/proc-sa1100.S +34
-0+#ifdef CONFIG_PM +ENTRY(cpu_sa1100_do_suspend) + ? ? ? stmfd ? sp!, {r4 - r7, lr} + ? ? ? mrc ? ? p15, 0, r4, c3, c0, 0 ? ? ? ? ? @ domain ID + ? ? ? mrc ? ? p15, 0, r5, c2, c0, 0 ? ? ? ? ? @ translation table base addr + ? ? ? mrc ? ? p15, 0, r6, c13, c0, 0 ? ? ? ? ?@ PID + ? ? ? mrc ? ? p15, 0, r7, c1, c0, 0 ? ? ? ? ? @ control reg + ? ? ? stmia ? r0, {r4 - r7} ? ? ? ? ? ? ? ? ? @ store cp regs + ? ? ? ldmfd ? sp!, {r4 - r7, pc} +ENDPROC(cpu_sa1100_do_suspend) + +ENTRY(cpu_sa1100_do_resume) + ? ? ? ldmia ? r0, {r4 - r7} ? ? ? ? ? ? ? ? ? @ load cp regs + ? ? ? mov ? ? r1, #0 + ? ? ? mcr ? ? p15, 0, r1, c8, c7, 0 ? ? ? ? ? @ flush I+D TLBs + ? ? ? mcr ? ? p15, 0, r1, c7, c7, 0 ? ? ? ? ? @ flush I&D cache + ? ? ? mcr ? ? p15, 0, r1, c9, c0, 0 ? ? ? ? ? @ invalidate RB + ? ? ? mcr ? ? p15, 0, r1, c9, c0, 5 ? ? ? ? ? @ allow user space to use RB + + ? ? ? mcr ? ? p15, 0, r4, c3, c0, 0 ? ? ? ? ? @ domain ID + ? ? ? mcr ? ? p15, 0, r5, c2, c0, 0 ? ? ? ? ? @ translation table base addr + ? ? ? mcr ? ? p15, 0, r6, c13, c0, 0 ? ? ? ? ?@ PID + ? ? ? mov ? ? r0, r7 ? ? ? ? ? ? ? ? ? ? ? ? ?@ control register + ? ? ? mov ? ? r2, r5, lsr #14 ? ? ? ? ? ? ? ? @ get TTB0 base + ? ? ? mov ? ? r2, r2, lsl #14 + ? ? ? ldr ? ? r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + ? ? ? ? ? ? ? ? ? ?PMD_SECT_CACHEABLE | PMD_SECT_AP_WRITE + ? ? ? b ? ? ? cpu_resume_mmu +ENDPROC(cpu_sa1100_do_resume) +#else +#define cpu_sa1100_do_suspend ?0 +#define cpu_sa1100_do_resume ? 0 +#endif +? ? ? ?__CPUINIT
? ? ? ?.type ?
__sa1100_setup, #functionarch/arm/mm/proc-sa1100.S +0
-0@@ -218,6 +254,9 @@ ENTRY(sa1100_processor_functions)? ? ? ?.word ?
cpu_sa1100_dcache_clean_area
? ? ? ?.word ?cpu_sa1100_switch_mm
? ? ? ?.word ?cpu_sa1100_set_pte_ext
+ ? ? ? .word ?cpu_sa1100_suspend_size
+ ? ? ? .word ?cpu_sa1100_do_suspend
+ ? ? ? .word ?cpu_sa1100_do_resume
? ? ? ?.size ?sa1100_processor_functions, . -sa1100_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-v6.S +0
-0@@ -121,6 +121,51 @@ ENTRY(cpu_v6_set_pte_ext)?#endif
? ? ? ?mov ? ? pc, lrarch/arm/mm/proc-v6.S +45
-0+/* Suspend/resume support: taken from arch/arm/mach-s3c64xx/sleep.S */ +.globl cpu_v6_suspend_size +.equ ? cpu_v6_suspend_size, 4 * 7 +#ifdef CONFIG_PM +ENTRY(cpu_v6_do_suspend) + ? ? ? stmfd ? sp!, {r4 - r10, lr} + ? ? ? mrc ? ? p15, 0, r4, c13, c0, 0 ?@ FCSE/PID + ? ? ? mrc ? ? p15, 0, r5, c3, c0, 0 ? @ Domain ID + ? ? ? mrc ? ? p15, 0, r6, c2, c0, 0 ? @ Translation table base 0 + ? ? ? mrc ? ? p15, 0, r7, c2, c0, 1 ? @ Translation table base 1 + ? ? ? mrc ? ? p15, 0, r8, c1, c0, 1 ? @ auxillary control register + ? ? ? mrc ? ? p15, 0, r9, c1, c0, 2 ? @ co-processor access control + ? ? ? mrc ? ? p15, 0, r10, c1, c0, 0 ?@ control register + ? ? ? stmia ? r0, {r4 - r10} + ? ? ? ldmfd ? sp!, {r4- r10, pc} +ENDPROC(cpu_v6_do_suspend) + +ENTRY(cpu_v6_do_resume) + ? ? ? mov ? ? ip, #0 + ? ? ? mcr ? ? p15, 0, ip, c7, c14, 0 ?@ clean+invalidate D cache + ? ? ? mcr ? ? p15, 0, ip, c7, c5, 0 ? @ invalidate I cache + ? ? ? mcr ? ? p15, 0, ip, c7, c15, 0 ?@ clean+invalidate cache + ? ? ? mcr ? ? p15, 0, ip, c7, c10, 4 ?@ drain write buffer + ? ? ? ldmia ? r0, {r4 - r10} + ? ? ? mcr ? ? p15, 0, r4, c13, c0, 0 ?@ FCSE/PID + ? ? ? mcr ? ? p15, 0, r5, c3, c0, 0 ? @ Domain ID + ? ? ? mcr ? ? p15, 0, r6, c2, c0, 0 ? @ Translation table base 0 + ? ? ? mcr ? ? p15, 0, r7, c2, c0, 1 ? @ Translation table base 1 + ? ? ? mcr ? ? p15, 0, r8, c1, c0, 1 ? @ auxillary control register + ? ? ? mcr ? ? p15, 0, r9, c1, c0, 2 ? @ co-processor access control + ? ? ? mcr ? ? p15, 0, ip, c2, c0, 2 ? @ TTB control register + ? ? ? mcr ? ? p15, 0, ip, c7, c5, 4 ? @ ISB + ? ? ? mov ? ? r0, r10 ? ? ? ? ? ? ? ? @ control register + ? ? ? mov ? ? r2, r6, lsr #14 ? ? ? ? @ get TTB0 base + ? ? ? mov ? ? r2, r2, lsl #14 + ? ? ? ldr ? ? r3, cpu_resume_l1_flags + ? ? ? b ? ? ? cpu_resume_mmu +ENDPROC(cpu_v6_do_resume) +cpu_resume_l1_flags: + ? ? ? ALT_SMP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_FLAGS_SMP) + ? ? ? ALT_UP(.long ?PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_FLAGS_UP) +#else +#define cpu_v6_do_suspend 0 +#define cpu_v6_do_resume 0 +#endif? ? ? ?.type ?
cpu_v6_name, #objectarch/arm/mm/proc-v6.S +0
-0@@ -206,6 +251,9 @@ ENTRY(v6_processor_functions)? ? ? ?.word ?
cpu_v6_dcache_clean_area
? ? ? ?.word ?cpu_v6_switch_mm
? ? ? ?.word ?cpu_v6_set_pte_ext
+ ? ? ? .word ?cpu_v6_suspend_size
+ ? ? ? .word ?cpu_v6_do_suspend
+ ? ? ? .word ?cpu_v6_do_resume
? ? ? ?.size ?v6_processor_functions, . -v6_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-v7.S +0
-0@@ -171,6 +171,85 @@ cpu_v7_name:? ? ? ?.ascii ?"ARMv7 Processor"
? ? ? ?.align+ ? ? ? /*
+ ? ? ? ?* Memory region attributes with SCTLR.TRE=1
+ ? ? ? ?*
+ ? ? ? ?* ? n = TEX[0],C,B
+ ? ? ? ?* ? TR = PRRR[2n+1:2n] ? ? ? ? - memory type
+ ? ? ? ?* ? IR = NMRR[2n+1:2n] ? ? ? ? - inner cacheable property
+ ? ? ? ?* ? OR = NMRR[2n+17:2n+16] ? ? - outer cacheable property
+ ? ? ? ?*
+ ? ? ? ?* ? ? ? ? ? ? ? ? ? ? ?n ? ? ? TR ? ? ?IR ? ? ?OR
+ ? ? ? ?* ? UNCACHED ? ? ? ? ? 000 ? ? 00
+ ? ? ? ?* ? BUFFERABLE ? ? ? ? 001 ? ? 10 ? ? ?00 ? ? ?00
+ ? ? ? ?* ? WRITETHROUGH ? ? ? 010 ? ? 10 ? ? ?10 ? ? ?10
+ ? ? ? ?* ? WRITEBACK ? ? ? ? ?011 ? ? 10 ? ? ?11 ? ? ?11
+ ? ? ? ?* ? reserved ? ? ? ? ? 110
+ ? ? ? ?* ? WRITEALLOC ? ? ? ? 111 ? ? 10 ? ? ?01 ? ? ?01
+ ? ? ? ?* ?DEV_SHARED? ? ? ? 100 ? ? 01
+ ? ? ? ?* ?DEV_NONSHARED? ? ?100 ? ? 01
+ ? ? ? ?* ?DEV_WC? ? ? ? ? ? 001 ? ? 10
+ ? ? ? ?* ?DEV_CACHED? ? ? ? 011 ? ? 10
+ ? ? ? ?*
+ ? ? ? ?* Other attributes:
+ ? ? ? ?*
+ ? ? ? ?* ? DS0 = PRRR[16] = 0 ? ? ? ? - device shareable property
+ ? ? ? ?* ? DS1 = PRRR[17] = 1 ? ? ? ? - device shareable property
+ ? ? ? ?* ? NS0 = PRRR[18] = 0 ? ? ? ? - normal shareable property
+ ? ? ? ?* ? NS1 = PRRR[19] = 1 ? ? ? ? - normal shareable property
+ ? ? ? ?* ? NOS = PRRR[24+n] = 1 ? ? ? - not outer shareable
+ ? ? ? ?*/
+.equ ? PRRR, ?0xff0a81a8
+.equ ? NMRR, ?0x40e040e0arch/arm/mm/proc-v7.S +49
-0+ +/* Suspend/resume support: derived from arch/arm/mach-s5pv210/sleep.S */ +.globl cpu_v7_suspend_size +.equ ? cpu_v7_suspend_size, 4 * 7 +#ifdef CONFIG_PM +ENTRY(cpu_v7_do_suspend) + ? ? ? stmfd ? sp!, {r4 - r10, lr} + ? ? ? mrc ? ? p15, 0, r4, c13, c0, 0 ?@ FCSE/PID + ? ? ? mrc ? ? p15, 0, r5, c3, c0, 0 ? @ Domain ID + ? ? ? mrc ? ? p15, 0, r6, c2, c0, 0 ? @ TTB 0 + ? ? ? mrc ? ? p15, 0, r7, c2, c0, 1 ? @ TTB 1 + ? ? ? mrc ? ? p15, 0, r8, c1, c0, 0 ? @ Control register + ? ? ? mrc ? ? p15, 0, r9, c1, c0, 1 ? @ Auxiliary control register + ? ? ? mrc ? ? p15, 0, r10, c1, c0, 2 ?@ Co-processor access control + ? ? ? stmia ? r0, {r4 - r10} + ? ? ? ldmfd ? sp!, {r4 - r10, pc} +ENDPROC(cpu_v7_do_suspend) + +ENTRY(cpu_v7_do_resume) + ? ? ? mov ? ? ip, #0 + ? ? ? mcr ? ? p15, 0, ip, c8, c7, 0 ? @ invalidate TLBs + ? ? ? mcr ? ? p15, 0, ip, c7, c5, 0 ? @ invalidate I cache + ? ? ? ldmia ? r0, {r4 - r10} + ? ? ? mcr ? ? p15, 0, r4, c13, c0, 0 ?@ FCSE/PID + ? ? ? mcr ? ? p15, 0, r5, c3, c0, 0 ? @ Domain ID + ? ? ? mcr ? ? p15, 0, r6, c2, c0, 0 ? @ TTB 0 + ? ? ? mcr ? ? p15, 0, r7, c2, c0, 1 ? @ TTB 1 + ? ? ? mcr ? ? p15, 0, ip, c2, c0, 2 ? @ TTB control register + ? ? ? mcr ? ? p15, 0, r9, c1, c0, 1 ? @ Auxillary control register + ? ? ? mcr ? ? p15, 0, r10, c1, c0, 2 ?@ Co-processor access control + ? ? ? ldr ? ? r4, =PRRR ? ? ? ? ? ? ? @ PRRR + ? ? ? ldr ? ? r5, =NMRR ? ? ? ? ? ? ? @ NMRR + ? ? ? mcr ? ? p15, 0, r4, c10, c2, 0 ?@ write PRRR + ? ? ? mcr ? ? p15, 0, r5, c10, c2, 1 ?@ write NMRR + ? ? ? isb + ? ? ? mov ? ? r0, r8 ? ? ? ? ? ? ? ? ?@ control register + ? ? ? mov ? ? r2, r6, lsr #14 ? ? ? ? @ get TTB0 base + ? ? ? mov ? ? r2, r2, lsl #14 + ? ? ? ldr ? ? r3, cpu_resume_l1_flags + ? ? ? b ? ? ? cpu_resume_mmu +ENDPROC(cpu_v7_do_resume) +cpu_resume_l1_flags: + ? ? ? ALT_SMP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_FLAGS_SMP) + ? ? ? ALT_UP(.long ?PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_FLAGS_UP) +#else +#define cpu_v7_do_suspend ? ? ?0 +#define cpu_v7_do_resume ? ? ? 0 +#endif +? ? ? ?__CPUINIT
?/*
arch/arm/mm/proc-v7.S +0
-0@@ -276,36 +355,8 @@ __v7_setup: ? ? ? ?ALT_SMP(orr ? ? r4, r4, #TTB_FLAGS_SMP) ? ? ? ?ALT_UP(orr ? ? ?r4, r4, #TTB_FLAGS_UP)? ? ? ?mcr ? ? p15, 0, r4, c2, c0, 1 ? ? ? ? ? @ load TTB1
- ? ? ? /*
- ? ? ? ?* Memory region attributes with SCTLR.TRE=1
- ? ? ? ?*
- ? ? ? ?* ? n = TEX[0],C,B
- ? ? ? ?* ? TR = PRRR[2n+1:2n] ? ? ? ? - memory type
- ? ? ? ?* ? IR = NMRR[2n+1:2n] ? ? ? ? - inner cacheable property
- ? ? ? ?* ? OR = NMRR[2n+17:2n+16] ? ? - outer cacheable property
- ? ? ? ?*
- ? ? ? ?* ? ? ? ? ? ? ? ? ? ? ?n ? ? ? TR ? ? ?IR ? ? ?OR
- ? ? ? ?* ? UNCACHED ? ? ? ? ? 000 ? ? 00
- ? ? ? ?* ? BUFFERABLE ? ? ? ? 001 ? ? 10 ? ? ?00 ? ? ?00
- ? ? ? ?* ? WRITETHROUGH ? ? ? 010 ? ? 10 ? ? ?10 ? ? ?10
- ? ? ? ?* ? WRITEBACK ? ? ? ? ?011 ? ? 10 ? ? ?11 ? ? ?11
- ? ? ? ?* ? reserved ? ? ? ? ? 110
- ? ? ? ?* ? WRITEALLOC ? ? ? ? 111 ? ? 10 ? ? ?01 ? ? ?01
- ? ? ? ?* ?DEV_SHARED? ? ? ? 100 ? ? 01
- ? ? ? ?* ?DEV_NONSHARED? ? ?100 ? ? 01
- ? ? ? ?* ?DEV_WC? ? ? ? ? ? 001 ? ? 10
- ? ? ? ?* ?DEV_CACHED? ? ? ? 011 ? ? 10
- ? ? ? ?*
- ? ? ? ?* Other attributes:
- ? ? ? ?*
- ? ? ? ?* ? DS0 = PRRR[16] = 0 ? ? ? ? - device shareable property
- ? ? ? ?* ? DS1 = PRRR[17] = 1 ? ? ? ? - device shareable property
- ? ? ? ?* ? NS0 = PRRR[18] = 0 ? ? ? ? - normal shareable property
- ? ? ? ?* ? NS1 = PRRR[19] = 1 ? ? ? ? - normal shareable property
- ? ? ? ?* ? NOS = PRRR[24+n] = 1 ? ? ? - not outer shareable
- ? ? ? ?*/
- ? ? ? ldr ? ? r5, =0xff0a81a8 ? ? ? ? ? ? ? ? @ PRRR
- ? ? ? ldr ? ? r6, =0x40e040e0 ? ? ? ? ? ? ? ? @ NMRR
+ ? ? ? ldr ? ? r5, =PRRR ? ? ? ? ? ? ? ? ? ? ? @ PRRR
+ ? ? ? ldr ? ? r6, =NMRR ? ? ? ? ? ? ? ? ? ? ? @ NMRR
? ? ? ?mcr ? ? p15, 0, r5, c10, c2, 0 ? ? ? ? ?@ write PRRR ? ? ? ?mcr ? ? p15, 0, r6, c10, c2, 1 ? ? ? ? ?@ write NMRR ?#endifarch/arm/mm/proc-v7.S +0
-0@@ -351,6 +402,9 @@ ENTRY(v7_processor_functions)? ? ? ?.word ?
cpu_v7_dcache_clean_area
? ? ? ?.word ?cpu_v7_switch_mm
? ? ? ?.word ?cpu_v7_set_pte_ext
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
+ ? ? ? .word ? 0
? ? ? ?.size ?v7_processor_functions, . -v7_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-xsc3.S +0
-0@@ -413,9 +413,52 @@ ENTRY(cpu_xsc3_set_pte_ext)? ? ? ?mov ? ? pc, lr
? ? ? ?.ltorg
-
? ? ? ?.align+.globl
cpu_xsc3_suspend_size
+.equ ?cpu_xsc3_suspend_size, 4 * 8arch/arm/mm/proc-xsc3.S +42
-0+#ifdef CONFIG_PM +ENTRY(cpu_xsc3_do_suspend) + ? ? ? stmfd ? sp!, {r4 - r10, lr} + ? ? ? mrc ? ? p14, 0, r4, c6, c0, 0 ? @ clock configuration, for turbo mode + ? ? ? mrc ? ? p15, 0, r5, c15, c1, 0 ?@ CP access reg + ? ? ? mrc ? ? p15, 0, r6, c13, c0, 0 ?@ PID + ? ? ? mrc ? ? p15, 0, r7, c3, c0, 0 ? @ domain ID + ? ? ? mrc ? ? p15, 0, r8, c2, c0, 0 ? @ translation table base addr + ? ? ? mrc ? ? p15, 0, r9, c1, c0, 1 ? @ auxiliary control reg + ? ? ? mrc ? ? p15, 0, r10, c1, c0, 0 ?@ control reg + ? ? ? bic ? ? r4, r4, #2 ? ? ? ? ? ? ?@ clear frequency change bit + ? ? ? stmia ? r0, {r1, r4 - r10} ? ? ?@ store v:p offset + cp regs + ? ? ? ldmia ? sp!, {r4 - r10, pc} +ENDPROC(cpu_xsc3_do_suspend) + +ENTRY(cpu_xsc3_do_resume) + ? ? ? ldmia ? r0, {r1, r4 - r10} ? ? ?@ load v:p offset + cp regs + ? ? ? mov ? ? ip, #0 + ? ? ? mcr ? ? p15, 0, ip, c7, c7, 0 ? @ invalidate I & D caches, BTB + ? ? ? mcr ? ? p15, 0, ip, c7, c10, 4 ?@ drain write (&fill) buffer + ? ? ? mcr ? ? p15, 0, ip, c7, c5, 4 ? @ flush prefetch buffer + ? ? ? mcr ? ? p15, 0, ip, c8, c7, 0 ? @ invalidate I & D TLBs + ? ? ? mcr ? ? p14, 0, r4, c6, c0, 0 ? @ clock configuration, turbo mode. + ? ? ? mcr ? ? p15, 0, r5, c15, c1, 0 ?@ CP access reg + ? ? ? mcr ? ? p15, 0, r6, c13, c0, 0 ?@ PID + ? ? ? mcr ? ? p15, 0, r7, c3, c0, 0 ? @ domain ID + ? ? ? mcr ? ? p15, 0, r8, c2, c0, 0 ? @ translation table base addr + ? ? ? mcr ? ? p15, 0, r9, c1, c0, 1 ? @ auxiliary control reg + + ? ? ? @ temporarily map resume_turn_on_mmu into the page table, + ? ? ? @ otherwise prefetch abort occurs after MMU is turned on + ? ? ? mov ? ? r0, r10 ? ? ? ? ? ? ? ? @ control register + ? ? ? mov ? ? r2, r8, lsr #14 ? ? ? ? @ get TTB0 base + ? ? ? mov ? ? r2, r2, lsl #14 + ? ? ? ldr ? ? r3, =0x542e ? ? ? ? ? ? @ section flags + ? ? ? b ? ? ? cpu_resume_mmu +ENDPROC(cpu_xsc3_do_resume) +#else +#define cpu_xsc3_do_suspend ? ?0 +#define cpu_xsc3_do_resume ? ? 0 +#endif +? ? ? ?__CPUINIT
? ? ? ?.type ?
__xsc3_setup, #functionarch/arm/mm/proc-xsc3.S +0
-0@@ -476,6 +519,9 @@ ENTRY(xsc3_processor_functions)? ? ? ?.word ?
cpu_xsc3_dcache_clean_area
? ? ? ?.word ?cpu_xsc3_switch_mm
? ? ? ?.word ?cpu_xsc3_set_pte_ext
+ ? ? ? .word ?cpu_xsc3_suspend_size
+ ? ? ? .word ?cpu_xsc3_do_suspend
+ ? ? ? .word ?cpu_xsc3_do_resume
? ? ? ?.size ?xsc3_processor_functions, . -xsc3_processor_functions? ? ? ?.section ".rodata"
arch/arm/mm/proc-xscale.S +0
-0@@ -513,11 +513,49 @@ ENTRY(cpu_xscale_set_pte_ext)? ? ? ?xscale_set_pte_ext_epilogue
? ? ? ?mov ? ? pc, lr-
? ? ? ?.ltorg
-
? ? ? ?.align+.globl
cpu_xscale_suspend_size
+.equ ?cpu_xscale_suspend_size, 4 * 7arch/arm/mm/proc-xscale.S +38
-0+#ifdef CONFIG_PM +ENTRY(cpu_xscale_do_suspend) + ? ? ? stmfd ? sp!, {r4 - r10, lr} + ? ? ? mrc ? ? p14, 0, r4, c6, c0, 0 ? @ clock configuration, for turbo mode + ? ? ? mrc ? ? p15, 0, r5, c15, c1, 0 ?@ CP access reg + ? ? ? mrc ? ? p15, 0, r6, c13, c0, 0 ?@ PID + ? ? ? mrc ? ? p15, 0, r7, c3, c0, 0 ? @ domain ID + ? ? ? mrc ? ? p15, 0, r8, c2, c0, 0 ? @ translation table base addr + ? ? ? mrc ? ? p15, 0, r9, c1, c1, 0 ? @ auxiliary control reg + ? ? ? mrc ? ? p15, 0, r10, c1, c0, 0 ?@ control reg + ? ? ? bic ? ? r4, r4, #2 ? ? ? ? ? ? ?@ clear frequency change bit + ? ? ? stmia ? r0, {r4 - r10} ? ? ? ? ?@ store cp regs + ? ? ? ldmfd ? sp!, {r4 - r10, pc} +ENDPROC(cpu_xscale_do_suspend) + +ENTRY(cpu_xscale_do_resume) + ? ? ? ldmia ? r0, {r4 - r10} ? ? ? ? ?@ load cp regs + ? ? ? mov ? ? ip, #0 + ? ? ? mcr ? ? p15, 0, ip, c8, c7, 0 ? @ invalidate I & D TLBs + ? ? ? mcr ? ? p15, 0, ip, c7, c7, 0 ? @ invalidate I & D caches, BTB + ? ? ? mcr ? ? p14, 0, r4, c6, c0, 0 ? @ clock configuration, turbo mode. + ? ? ? mcr ? ? p15, 0, r5, c15, c1, 0 ?@ CP access reg + ? ? ? mcr ? ? p15, 0, r6, c13, c0, 0 ?@ PID + ? ? ? mcr ? ? p15, 0, r7, c3, c0, 0 ? @ domain ID + ? ? ? mcr ? ? p15, 0, r8, c2, c0, 0 ? @ translation table base addr + ? ? ? mcr ? ? p15, 0, r9, c1, c1, 0 ? @ auxiliary control reg + ? ? ? mov ? ? r0, r10 ? ? ? ? ? ? ? ? @ control register + ? ? ? mov ? ? r2, r8, lsr #14 ? ? ? ? @ get TTB0 base + ? ? ? mov ? ? r2, r2, lsl #14 + ? ? ? ldr ? ? r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + ? ? ? ? ? ? ? ? ? ?PMD_SECT_CACHEABLE | PMD_SECT_AP_WRITE + ? ? ? b ? ? ? cpu_resume_mmu +ENDPROC(cpu_xscale_do_resume) +#else +#define cpu_xscale_do_suspend ?0 +#define cpu_xscale_do_resume ? 0 +#endif +? ? ? ?__CPUINIT
? ? ? ?.type ?
__xscale_setup, #functionarch/arm/mm/proc-xscale.S +0
-0@@ -565,6 +603,9 @@ ENTRY(xscale_processor_functions)? ? ? ?.word ?
cpu_xscale_dcache_clean_area
? ? ? ?.word ?cpu_xscale_switch_mm
? ? ? ?.word ?cpu_xscale_set_pte_ext
+ ? ? ? .word ?cpu_xscale_suspend_size
+ ? ? ? .word ?cpu_xscale_do_suspend
+ ? ? ? .word ?cpu_xscale_do_resume
? ? ? ?.size ?xscale_processor_functions, . -xscale_processor_functions? ? ? ?.section ".rodata"
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
http://en.wikipedia.org/wiki/Posting_style#Trimming_and_reformatting
It's really not nice to page down and down and down to find out the one or two lines that actually contain something useful - or in my case scroll through the first three pages, then go to the bottom and start scrolling up. It wastes time.
Please *always* trim the quoted text down to the context that's relevant for your reply, like this:
Quoted 11 lines · saeed bishara
Quoted 6 lines · Russell King - ARM Linux
+ENTRY(cpu_resume_mmu)
+ ? ? ? adr ? ? r4,cpu_resume_turn_mmu_on
+ ? ? ? mov ? ? r4, r4, lsr #20
+ ? ? ? orr ? ? r3, r3, r4, lsl #20
+ ? ? ? ldr ? ? r5, [r2, r4, lsl #2] ? ?@ save old mapping
+ ? ? ? str ? ? r3, [r2, r4, lsl #2] ? ?@ setup 1:1 mapping for mmu codethis code doesn't look smp save, it modifies page table that could be used by another cpu. I suggest to create (at boot time) identity page table and use it in order to do mmu on.
When you suspend/resume, the other CPUs will be hot-unplugged before suspend, and hot-plugged after resume. SMP issues really don't come in here, and there's not really many other ways to solve the inherent races involved with turning on the MMU.
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 4 lines
It's really not nice to page down and down and down to find out the one or two lines that actually contain something useful - or in my case scroll through the first three pages, then go to the bottom and start scrolling up. ?It wastes time.
sorry
Quoted 9 lines
Quoted 4 lines
this code doesn't look smp save, it modifies page table that could be used by another cpu. I suggest to create (at ?boot time) identity page table and use it in order to do mmu on.
When you suspend/resume, the other CPUs will be hot-unplugged before suspend, and hot-plugged after resume. ?SMP issues really don't come in here, and there's not really many other ways to solve the inherent races involved with turning on the MMU.
that's right, but in the future this code can be used also for cpuidle, so please take that into account.
also, I think cpu_resume_after_mmu needs to invalidates the TLB after restoring the old mapping.
one more comment, don't you need to restore the context ID cp15 register? saeed
Quoted 1 line
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 10 lines · saeed bishara
Quoted 4 lines
It's really not nice to page down and down and down to find out the one or two lines that actually contain something useful - or in my case scroll through the first three pages, then go to the bottom and start scrolling up. ?It wastes time.
sorry
Quoted 5 lines
Quoted 4 lines
this code doesn't look smp save, it modifies page table that could be used by another cpu. I suggest to create (at ?boot time) identity page table and use it in order to do mmu on.
Quoted 6 lines
Quoted 4 lines
When you suspend/resume, the other CPUs will be hot-unplugged before suspend, and hot-plugged after resume. ?SMP issues really don't come in here, and there's not really many other ways to solve the inherent races involved with turning on the MMU.
that's right, but in the future this code can be used also for cpuidle, so please take that into account.
As I've said, there's not much other choice here. We _have_ to have an identity mapping in place to bring the MMU back online, or we'll crash. That's non-optional. So if this is a problem for cpuidle, cpuidle needs to ensure that a page table switch has happened prior to the CPU going down which _can_ be safely modified.
Quoted 2 lines
also, I think
cpu_resume_after_mmuneeds to invalidates the TLB after restoring the old mapping.
Probably - and that's not going to be soo easy to work into this... I'll see later this afternoon about adding that.
Quoted 1 line
one more comment, don't you need to restore the context ID cp15 register?
Yes it does, and I wonder why the Samsung folk aren't doing so. Here's v4 with that added.
arch/arm/include/asm/glue-proc.h | 3 + arch/arm/include/asm/proc-fns.h | 7 ++ arch/arm/kernel/Makefile | 1 + arch/arm/kernel/asm-offsets.c | 9 +++ arch/arm/kernel/sleep.S | 110 ++++++++++++++++++++++++++++++++++++ arch/arm/mm/proc-arm1020.S | 3 + arch/arm/mm/proc-arm1020e.S | 3 + arch/arm/mm/proc-arm1022.S | 3 + arch/arm/mm/proc-arm1026.S | 3 + arch/arm/mm/proc-arm6_7.S | 6 ++ arch/arm/mm/proc-arm720.S | 3 + arch/arm/mm/proc-arm740.S | 3 + arch/arm/mm/proc-arm7tdmi.S | 3 + arch/arm/mm/proc-arm920.S | 37 ++++++++++++ arch/arm/mm/proc-arm922.S | 3 + arch/arm/mm/proc-arm925.S | 3 + arch/arm/mm/proc-arm926.S | 37 ++++++++++++ arch/arm/mm/proc-arm940.S | 3 + arch/arm/mm/proc-arm946.S | 3 + arch/arm/mm/proc-arm9tdmi.S | 3 + arch/arm/mm/proc-fa526.S | 3 + arch/arm/mm/proc-feroceon.S | 3 + arch/arm/mm/proc-mohawk.S | 3 + arch/arm/mm/proc-sa110.S | 3 + arch/arm/mm/proc-sa1100.S | 39 +++++++++++++ arch/arm/mm/proc-v6.S | 50 ++++++++++++++++ arch/arm/mm/proc-v7.S | 116 ++++++++++++++++++++++++++++---------- arch/arm/mm/proc-xsc3.S | 48 +++++++++++++++- arch/arm/mm/proc-xscale.S | 45 ++++++++++++++- 29 files changed, 523 insertions(+), 33 deletions(-)
arch/arm/include/asm/glue-proc.h +3 -0
@@ -256,6 +256,9 @@#define cpu_dcache_clean_area __glue(CPU_NAME,_dcache_clean_area)#define cpu_do_switch_mm __glue(CPU_NAME,_switch_mm)#define cpu_set_pte_ext __glue(CPU_NAME,_set_pte_ext) +#define cpu_suspend_size __glue(CPU_NAME,_suspend_size) +#define cpu_do_suspend __glue(CPU_NAME,_do_suspend) +#define cpu_do_resume __glue(CPU_NAME,_do_resume)#endif #endif
arch/arm/include/asm/proc-fns.h +7 -0
@@ -66,6 +66,11 @@ extern struct processor {* ignore 'ext'. */ void (*set_pte_ext)(pte_t *ptep,pte_t pte,unsigned int ext); + +/* Suspend/resume */ +unsigned int suspend_size; +void (*do_suspend)(void *); +void (*do_resume)(void *); } processor;#ifndef MULTI_CPU
@@ -86,6 +91,8 @@ extern void cpu_reset(unsigned long addr) __attribute__((noreturn));#define cpu_do_switch_mm (pgd,mm) processor.switch_mm(pgd,mm)#endif +extern void cpu_resume (void ); +#include <asm/memory.h> #ifdef CONFIG_MMU
arch/arm/kernel/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_MODULES) += armksyms.o module.o obj-$(CONFIG_ARTHUR) += arthur.o obj-$(CONFIG_ISA_DMA) += dma-isa.o obj-$(CONFIG_PCI) += bios32.o isa.o +obj-$(CONFIG_PM) += sleep.o obj-$(CONFIG_HAVE_SCHED_CLOCK) += sched_clock.o obj-$(CONFIG_SMP) += smp.o smp_tlb.o obj-$(CONFIG_HAVE_ARM_SCU) += smp_scu.o
arch/arm/kernel/asm-offsets.c +9 -0
@@ -13,6 +13,7 @@#include <linux/sched.h> #include <linux/mm.h> #include <linux/dma-mapping.h> +#include <asm/cacheflush.h> #include <asm/glue-df.h> #include <asm/glue-pf.h> #include <asm/mach/arch.h>
@@ -116,6 +117,14 @@ int main(void)#ifdef MULTI_PABORT DEFINE (PROCESSOR_PABT_FUNC , offsetof(struct processor , _prefetch_abort));#endif +#ifdef MULTI_CPU +DEFINE (CPU_SLEEP_SIZE , offsetof(struct processor , suspend_size)); +DEFINE (CPU_DO_SUSPEND , offsetof(struct processor , do_suspend)); +DEFINE (CPU_DO_RESUME , offsetof(struct processor , do_resume)); +#endif +#ifdef MULTI_CACHE +DEFINE (CACHE_FLUSH_KERN_ALL , offsetof(struct cpu_cache_fns , flush_kern_all)); +#endif BLANK ();DEFINE (DMA_BIDIRECTIONAL ,DMA_BIDIRECTIONAL );DEFINE (DMA_TO_DEVICE ,DMA_TO_DEVICE );
arch/arm/kernel/sleep.S new file +110 -0
110 lines not on this page · raw message
arch/arm/mm/proc-arm1020.S +3 -0
@@ -493,6 +493,9 @@ arm1020_processor_functions: .word cpu_arm1020_dcache_clean_area .word cpu_arm1020_switch_mm .word cpu_arm1020_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1020_processor_functions, . - arm1020_processor_functions .section ".rodata"
arch/arm/mm/proc-arm1020e.S +3 -0
@@ -474,6 +474,9 @@ arm1020e_processor_functions: .word cpu_arm1020e_dcache_clean_area .word cpu_arm1020e_switch_mm .word cpu_arm1020e_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1020e_processor_functions, . - arm1020e_processor_functions .section ".rodata"
arch/arm/mm/proc-arm1022.S +3 -0
@@ -457,6 +457,9 @@ arm1022_processor_functions: .word cpu_arm1022_dcache_clean_area .word cpu_arm1022_switch_mm .word cpu_arm1022_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1022_processor_functions, . - arm1022_processor_functions .section ".rodata"
arch/arm/mm/proc-arm1026.S +3 -0
@@ -452,6 +452,9 @@ arm1026_processor_functions: .word cpu_arm1026_dcache_clean_area .word cpu_arm1026_switch_mm .word cpu_arm1026_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm1026_processor_functions, . - arm1026_processor_functions .section .rodata
arch/arm/mm/proc-arm6_7.S +6 -0
@@ -284,6 +284,9 @@ ENTRY(arm6_processor_functions) .word cpu_arm6_dcache_clean_area .word cpu_arm6_switch_mm .word cpu_arm6_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm6_processor_functions, . - arm6_processor_functions /*
@@ -301,6 +304,9 @@ ENTRY(arm7_processor_functions) .word cpu_arm7_dcache_clean_area .word cpu_arm7_switch_mm .word cpu_arm7_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm7_processor_functions, . - arm7_processor_functions .section ".rodata"
arch/arm/mm/proc-arm720.S +3 -0
@@ -185,6 +185,9 @@ ENTRY(arm720_processor_functions) .word cpu_arm720_dcache_clean_area .word cpu_arm720_switch_mm .word cpu_arm720_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm720_processor_functions, . - arm720_processor_functions .section ".rodata"
arch/arm/mm/proc-arm740.S +3 -0
@@ -130,6 +130,9 @@ ENTRY(arm740_processor_functions) .word cpu_arm740_dcache_clean_area .word cpu_arm740_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm740_processor_functions, . - arm740_processor_functions .section ".rodata"
arch/arm/mm/proc-arm7tdmi.S +3 -0
@@ -70,6 +70,9 @@ ENTRY(arm7tdmi_processor_functions) .word cpu_arm7tdmi_dcache_clean_area .word cpu_arm7tdmi_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm7tdmi_processor_functions, . - arm7tdmi_processor_functions .section ".rodata"
arch/arm/mm/proc-arm920.S +37 -0
@@ -387,6 +387,40 @@ ENTRY(cpu_arm920_set_pte_ext) #endif mov pc, lr +/* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ +.globl arm920_suspend_size +.equ arm920_suspend_size, 4 * 3 +#ifdef CONFIG_PM +ENTRY(arm920_do_suspend) + stmfd sp!, {r4 - r7, lr} + mrc p15, 0, r4, c13, c0, 0 @ PID + mrc p15, 0, r5, c3, c0, 0 @ Domain ID + mrc p15, 0, r6, c2, c0, 0 @ TTB address + mrc p15, 0, r7, c1, c0, 0 @ Control register + stmia r0, {r4 - r7} + ldmfd sp!, {r4 - r7, pc} +ENDPROC(arm920_do_suspend) + +ENTRY(arm920_do_resume) + mov ip, #0 + mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs + mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches + ldmia r0, {r4 - r7} + mcr p15, 0, r4, c13, c0, 0 @ PID + mcr p15, 0, r5, c3, c0, 0 @ Domain ID + mcr p15, 0, r6, c2, c0, 0 @ TTB address + mov r0, r7 @ control register + mov r2, r6, lsr #14 @ get TTB0 base + mov r2, r2, lsl #14 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + PMD_SECT_CACHEABLE | PMD_BIT4 | PMD_SECT_AP_WRITE + b cpu_resume_mmu +ENDPROC(arm920_do_resume) +#else +#define arm920_do_suspend 0 +#define arm920_do_resume 0 +#endif + __CPUINIT .type __arm920_setup, #function
@@ -432,6 +466,9 @@ arm920_processor_functions: .word cpu_arm920_dcache_clean_area .word cpu_arm920_switch_mm .word cpu_arm920_set_pte_ext + .word arm920_suspend_size + .word arm920_do_suspend + .word arm920_do_resume .size arm920_processor_functions, . - arm920_processor_functions .section ".rodata"
arch/arm/mm/proc-arm922.S +3 -0
@@ -436,6 +436,9 @@ arm922_processor_functions: .word cpu_arm922_dcache_clean_area .word cpu_arm922_switch_mm .word cpu_arm922_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm922_processor_functions, . - arm922_processor_functions .section ".rodata"
arch/arm/mm/proc-arm925.S +3 -0
@@ -503,6 +503,9 @@ arm925_processor_functions: .word cpu_arm925_dcache_clean_area .word cpu_arm925_switch_mm .word cpu_arm925_set_pte_ext + .word 0 + .word 0 + .word 0 .size arm925_processor_functions, . - arm925_processor_functions .section ".rodata"
arch/arm/mm/proc-arm926.S +37 -0
@@ -401,6 +401,40 @@ ENTRY(cpu_arm926_set_pte_ext) #endif mov pc, lr +/* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ +.globl arm926_suspend_size +.equ arm926_suspend_size, 4 * 3 +#ifdef CONFIG_PM +ENTRY(arm926_do_suspend) + stmfd sp!, {r4 - r7, lr} + mrc p15, 0, r4, c13, c0, 0 @ PID + mrc p15, 0, r5, c3, c0, 0 @ Domain ID + mrc p15, 0, r6, c2, c0, 0 @ TTB address + mrc p15, 0, r7, c1, c0, 0 @ Control register + stmia r0, {r4 - r7} + ldmfd sp!, {r4 - r7, pc} +ENDPROC(arm926_do_suspend) + +ENTRY(arm926_do_resume) + mov ip, #0 + mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs + mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches + ldmia r0, {r4 - r7} + mcr p15, 0, r4, c13, c0, 0 @ PID + mcr p15, 0, r5, c3, c0, 0 @ Domain ID + mcr p15, 0, r6, c2, c0, 0 @ TTB address + mov r0, r7 @ control register + mov r2, r6, lsr #14 @ get TTB0 base + mov r2, r2, lsl #14 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + PMD_SECT_CACHEABLE | PMD_BIT4 | PMD_SECT_AP_WRITE + b cpu_resume_mmu +ENDPROC(arm926_do_resume) +#else +#define arm926_do_suspend 0 +#define arm926_do_resume 0 +#endif + __CPUINIT .type __arm926_setup, #function
@@ -456,6 +490,9 @@ arm926_processor_functions: .word cpu_arm926_dcache_clean_area .word cpu_arm926_switch_mm .word cpu_arm926_set_pte_ext + .word arm926_suspend_size + .word arm926_do_suspend + .word arm926_do_resume .size arm926_processor_functions, . - arm926_processor_functions .section ".rodata"
arch/arm/mm/proc-arm940.S +3 -0
@@ -363,6 +363,9 @@ ENTRY(arm940_processor_functions) .word cpu_arm940_dcache_clean_area .word cpu_arm940_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm940_processor_functions, . - arm940_processor_functions .section ".rodata"
arch/arm/mm/proc-arm946.S +3 -0
@@ -419,6 +419,9 @@ ENTRY(arm946_processor_functions) .word cpu_arm946_dcache_clean_area .word cpu_arm946_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm946_processor_functions, . - arm946_processor_functions .section ".rodata"
arch/arm/mm/proc-arm9tdmi.S +3 -0
@@ -70,6 +70,9 @@ ENTRY(arm9tdmi_processor_functions) .word cpu_arm9tdmi_dcache_clean_area .word cpu_arm9tdmi_switch_mm .word 0 @ cpu_*_set_pte + .word 0 + .word 0 + .word 0 .size arm9tdmi_processor_functions, . - arm9tdmi_processor_functions .section ".rodata"
arch/arm/mm/proc-fa526.S +3 -0
@@ -195,6 +195,9 @@ fa526_processor_functions: .word cpu_fa526_dcache_clean_area .word cpu_fa526_switch_mm .word cpu_fa526_set_pte_ext + .word 0 + .word 0 + .word 0 .size fa526_processor_functions, . - fa526_processor_functions .section ".rodata"
arch/arm/mm/proc-feroceon.S +3 -0
@@ -554,6 +554,9 @@ feroceon_processor_functions: .word cpu_feroceon_dcache_clean_area .word cpu_feroceon_switch_mm .word cpu_feroceon_set_pte_ext + .word 0 + .word 0 + .word 0 .size feroceon_processor_functions, . - feroceon_processor_functions .section ".rodata"
arch/arm/mm/proc-mohawk.S +3 -0
@@ -388,6 +388,9 @@ mohawk_processor_functions: .word cpu_mohawk_dcache_clean_area .word cpu_mohawk_switch_mm .word cpu_mohawk_set_pte_ext + .word 0 + .word 0 + .word 0 .size mohawk_processor_functions, . - mohawk_processor_functions .section ".rodata"
arch/arm/mm/proc-sa110.S +3 -0
@@ -203,6 +203,9 @@ ENTRY(sa110_processor_functions) .word cpu_sa110_dcache_clean_area .word cpu_sa110_switch_mm .word cpu_sa110_set_pte_ext + .word 0 + .word 0 + .word 0 .size sa110_processor_functions, . - sa110_processor_functions .section ".rodata"
arch/arm/mm/proc-sa1100.S +39 -0
@@ -169,6 +169,42 @@ ENTRY(cpu_sa1100_set_pte_ext) #endif mov pc, lr +.globl cpu_sa1100_suspend_size +.equ cpu_sa1100_suspend_size, 4*4 +#ifdef CONFIG_PM +ENTRY(cpu_sa1100_do_suspend) + stmfd sp!, {r4 - r7, lr} + mrc p15, 0, r4, c3, c0, 0 @ domain ID + mrc p15, 0, r5, c2, c0, 0 @ translation table base addr + mrc p15, 0, r6, c13, c0, 0 @ PID + mrc p15, 0, r7, c1, c0, 0 @ control reg + stmia r0, {r4 - r7} @ store cp regs + ldmfd sp!, {r4 - r7, pc} +ENDPROC(cpu_sa1100_do_suspend) + +ENTRY(cpu_sa1100_do_resume) + ldmia r0, {r4 - r7} @ load cp regs + mov r1, #0 + mcr p15, 0, r1, c8, c7, 0 @ flush I+D TLBs + mcr p15, 0, r1, c7, c7, 0 @ flush I&D cache + mcr p15, 0, r1, c9, c0, 0 @ invalidate RB + mcr p15, 0, r1, c9, c0, 5 @ allow user space to use RB + + mcr p15, 0, r4, c3, c0, 0 @ domain ID + mcr p15, 0, r5, c2, c0, 0 @ translation table base addr + mcr p15, 0, r6, c13, c0, 0 @ PID + mov r0, r7 @ control register + mov r2, r5, lsr #14 @ get TTB0 base + mov r2, r2, lsl #14 + ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \ + PMD_SECT_CACHEABLE | PMD_SECT_AP_WRITE + b cpu_resume_mmu +ENDPROC(cpu_sa1100_do_resume) +#else +#define cpu_sa1100_do_suspend 0 +#define cpu_sa1100_do_resume 0 +#endif + __CPUINIT .type __sa1100_setup, #function
@@ -218,6 +254,9 @@ ENTRY(sa1100_processor_functions) .word cpu_sa1100_dcache_clean_area .word cpu_sa1100_switch_mm .word cpu_sa1100_set_pte_ext + .word cpu_sa1100_suspend_size + .word cpu_sa1100_do_suspend + .word cpu_sa1100_do_resume .size sa1100_processor_functions, . - sa1100_processor_functions .section ".rodata"
arch/arm/mm/proc-v6.S +50 -0
62 lines not on this page · raw message
arch/arm/mm/proc-v7.S +86 -30
134 lines not on this page · raw message
arch/arm/mm/proc-xsc3.S +47 -1
62 lines not on this page · raw message
arch/arm/mm/proc-xscale.S +43 -2
60 lines not on this page · raw message
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 5 lines
As I've said, there's not much other choice here. ?We _have_ to have an identity mapping in place to bring the MMU back online, or we'll crash. That's non-optional. ?So if this is a problem for cpuidle, cpuidle needs to ensure that a page table switch has happened prior to the CPU going down which _can_ be safely modified.
I fully agree with you, but what I was suggesting is to create temporary identity page table at boot time, the resume code will load that page table (Context ID will be loaded with unique ASID), enable mmu, then the original page table and Context ID will be restored.
saeed
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 9 lines · saeed bishara
Quoted 5 lines
As I've said, there's not much other choice here. ?We _have_ to have an identity mapping in place to bring the MMU back online, or we'll crash. That's non-optional. ?So if this is a problem for cpuidle, cpuidle needs to ensure that a page table switch has happened prior to the CPU going down which _can_ be safely modified.
I fully agree with you, but what I was suggesting is to create temporary identity page table at boot time, the resume code will load that page table (Context ID will be loaded with unique ASID), enable mmu, then the original page table and Context ID will be restored.
That's much easier to do in C code than in the assembly code. Let's keep the assembly code as simple as possible...
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 7 lines
Quoted 4 lines
I fully agree with you, but what I was suggesting is to create temporary identity page table at boot time, the resume code will load that page table (Context ID will be loaded with unique ASID), enable mmu, then the original page table and Context ID will be restored.
That's much easier to do in C code than in the assembly code. ?Let's keep the assembly code as simple as possible...
well, the allocation of the identity page table doesn't need to be done in assembly code. this is the similar to what you did in __cpu_up.
for example, this allocation can be done in arch/arm/kernel/setup.c. the assembly code only need to know the offset of this page table. looks that there are several usages for the identity page table (smp boot, kexec, pm), maybe all those clients can share the same one.
you may also consider loading this identity page table before calling suspend flow, thus saving all the v:p stuff, and the resume code will take care for restoring the original page table after enabling the mmu.
saeed
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 7 lines · saeed bishara
well, the allocation of the identity page table doesn't need to be done in assembly code. this is the similar to what you did in
__cpu_up.
for example, this allocation can be done inarch/arm/kernel/setup.c. the assembly code only need to know the offset of this page table. looks that there are several usages for the identity page table (smp boot, kexec, pm), maybe all those clients can share the same one.
We don't want to allocate this at boot time, because it will require additional maintainence when L1 page tables are added for ioremap() etc.
I feel that it's best to leave it as-is, as this is the method everyone has been using to date. When it becomes a problem, we can then look at resolving it.
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Hi Russell,
Quoted 9 lines · Russell King - ARM Linux
Quoted 7 lines · saeed bishara
well, the allocation of the identity page table doesn't need to be done in assembly code. this is the similar to what you did in
__cpu_up.
for example, this allocation can be done inarch/arm/kernel/setup.c. the assembly code only need to know the offset of this page table. looks that there are several usages for the identity page table (smp boot, kexec, pm), maybe all those clients can share the same one.
Quoted 7 lines
We don't want to allocate this at boot time, because it will require additional maintainence when L1 page tables are added for
ioremap()etc.I feel that it's best to leave it as-is, as this is the method everyone has been using to date. When it becomes a problem, we can then look at resolving it.
For v7 MP cpuidle it is already critical, we do need to have a page table copy for the resume path to be MP safe. The same goes for the stack pointer global variable which should be per cpu. Maybe we can just provide an API to pass the page table pointer, then see how to allocate it and when.
In which branch do these patches live in order to test them and provide feedback ?
Many thanks,
Lorenzo
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 20 lines · Lorenzo Pieralisi
Hi Russell,
Quoted 9 lines · Russell King - ARM Linux
Quoted 7 lines · saeed bishara
well, the allocation of the identity page table doesn't need to be done in assembly code. this is the similar to what you did in
__cpu_up.
for example, this allocation can be done inarch/arm/kernel/setup.c. the assembly code only need to know the offset of this page table. looks that there are several usages for the identity page table (smp boot, kexec, pm), maybe all those clients can share the same one.Quoted 7 lines
We don't want to allocate this at boot time, because it will require additional maintainence when L1 page tables are added for
ioremap()etc.I feel that it's best to leave it as-is, as this is the method everyone has been using to date. When it becomes a problem, we can then look at resolving it.
Quoted 4 lines
For v7 MP cpuidle it is already critical, we do need to have a page table copy for the resume path to be MP safe.
Maybe we can just provide an API to pass the page table pointer, then see how to allocate it and when.
As I already said - allocate a page table before hand and switch to it, free it afterwards. This code does not need to have the complexities of page table allocation mixed into it.
Quoted 2 lines
The same goes for the stack pointer global variable which should be per cpu.
Yes, but this is what is currently done, so at the present time I'm just sorting out what's already in the kernel. If we need further changes, then that needs to be built on top of this.
Quoted 2 lines
In which branch do these patches live in order to test them and provide feedback ?
They're not published yet as I'm waiting for feedback on them, etc. They're still receiving the odd tweak as comments are received.
Let's get this so that the current suspend/resume code can use it, and has been tested with it, and then think about adding other uses to it.
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 6 lines · Russell King - ARM Linux
Quoted 2 lines
The same goes for the stack pointer global variable which should be per cpu.
Yes, but this is what is currently done, so at the present time I'm just sorting out what's already in the kernel. If we need further changes, then that needs to be built on top of this.
Like this:
arch/arm/kernel/sleep.S | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-)
arch/arm/kernel/sleep.S +25 -1
@@ -25,7 +25,14 @@ ENTRY(cpu_suspend) stmfd sp!, {r1, r2, r3, ip} @ save v:p, virt SP, retfn, phys resume fn ldr r3, =sleep_save_sp add r2, sp, r1 @ convert SP to phys +#ifdef CONFIG_SMP + ALT_SMP(mrc p15, 0, lr, c0, c0, 5) + ALT_UP(mov lr, #0) + and lr, lr, #15 + str r2, [r3, lr, lsl #2] @ save phys SP +#else str r2, [r3] @ save phys SP +#endif mov lr, pc ldr pc, [r10, #CPU_DO_SUSPEND] @ save CPU state #else
@@ -36,7 +43,14 @@ ENTRY(cpu_suspend) stmfd sp!, {r1, r2, r3} @ save v:p, virt SP, return fn ldr r3, =sleep_save_sp add r2, sp, r1 @ convert SP to phys +#ifdef CONFIG_SMP + ALT_SMP(mrc p15, 0, lr, c0, c0, 5) + ALT_UP(mov lr, #0) + and lr, lr, #15 + str r2, [r3, lr, lsl #2] @ save phys SP +#else str r2, [r3] @ save phys SP +#endif bl cpu_do_suspend #endif
@@ -96,7 +110,15 @@ cpu_resume_after_mmu: .data .align ENTRY(cpu_resume) +#ifdef CONFIG_SMP + adr r0, sleep_save_sp + ALT_SMP(mrc p15, 0, r1, c0, c0, 5) + ALT_UP(mov r1, #0) + and r1, r1, #15 + ldr r0, [r0, r1, lsl #2] @ stack phys addr +#else ldr r0, sleep_save_sp @ stack phys addr +#endif msr cpsr_c, #PSR_I_BIT | PSR_F_BIT | SVC_MODE @ set SVC, irqs off #ifdef MULTI_CPU ldmia r0!, {r1, sp, lr, pc} @ load v:p, stack, return fn, resume fn
@@ -107,4 +129,6 @@ ENTRY(cpu_resume) ENDPROC(cpu_resume) sleep_save_sp: - .word 0 @ preserve stack phys ptr here + .rept CONFIG_NR_CPUS + .long 0 @ preserve stack phys ptr here + .endr
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
On Tue, 2011-02-08 at 12:33 +0000, Russell King - ARM Linux wrote:
<snip>
Quoted 25 lines
Quoted 3 lines
Yes, but this is what is currently done, so at the present time I'm just sorting out what's already in the kernel. If we need further changes, then that needs to be built on top of this.
Like this:
arch/arm/kernel/sleep.S | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-)arch/arm/kernel/sleep.S +7
-0@@ -25,7 +25,14 @@ ENTRY(cpu_suspend) stmfd sp!, {r1, r2, r3, ip} @ save v:p, virt SP, retfn, phys resume fn ldr r3, =sleep_save_sp add r2, sp, r1 @ convert SP to phys +#ifdef CONFIG_SMP + ALT_SMP(mrc p15, 0, lr, c0, c0, 5) + ALT_UP(mov lr, #0) + and lr, lr, #15 + str r2, [r3, lr, lsl #2] @ save phys SP +#else str r2, [r3] @ save phys SP +#endif
<snip>
arch/arm/kernel/sleep.S ENTRY(cpu_resume) · line 134
Quoted 6 lines
sleep_save_sp:arch/arm/kernel/sleep.S +3
-1- .word 0 @ preserve stack phys ptr here + .rept CONFIG_NR_CPUS + .long 0 @ preserve stack phys ptr here + .endr
Yes Russell, thanks that's what we are currently doing for MP, it looks ok. As for the page tables, I know you already replied and I took your point. It is on the cpuidle path so page tables should be created in C, beforehand as you pointed out (with the 1:1 map required), once for all. I just wanted to say, maybe we can save the pgd pointer (with the required 1:1 for MMU on) in a pc-relative addressable location that you can retrieve on resume, eliminating the code changing the original page table and replacing it with pgd switching.
But again it is just a suggestion, I understand your point, no need to comment further.
Many thanks,
Lorenzo
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
In reply to Russell King - ARM LinuxOn Mon, Feb 7, 2011 at 8:17 AM, Russell King - ARM Linux <[email protected]> wrote:
<snip>
Quoted 22 lines
arch/arm/kernel/sleep.S new file +16
-0@@ -0,0 +1,110 @@ +#include <linux/linkage.h> +#include <asm/asm-offsets.h> +#include <asm/assembler.h> +#include <asm/glue-cache.h> +#include <asm/glue-proc.h> + ? ? ? .text + +/* + * Save CPU state for a suspend + * ?r1 = v:p offset + * ?r3 = virtual return function + * Note: sp is decremented to allocate space for CPU state on stack + * r0-r3,r9,r10,lr corrupted + */ +ENTRY(cpu_suspend) + ? ? ? mov ? ? r9, lr
arch/arm/kernel/sleep.S line 26
Quoted 10 lines
arch/arm/kernel/sleep.S new file +10
-0+#ifdef MULTI_CPU + ? ? ? ldr ? ? r10, =processor + ? ? ? mov ? ? r2, sp ? ? ? ? ? ? ? ? ?@ current virtual SP + ? ? ? ldr ? ? r0, [r10, #CPU_SLEEP_SIZE] @ size of CPU sleep state + ? ? ? ldr ? ? ip, [r10, #CPU_DO_RESUME] @ virtual resume function + ? ? ? sub ? ? sp, sp, r0 ? ? ? ? ? ? ?@ allocate CPU state on stack + ? ? ? mov ? ? r0, sp ? ? ? ? ? ? ? ? ?@ save pointer + ? ? ? add ? ? ip, ip, r1 ? ? ? ? ? ? ?@ convert resume fn to phys + ? ? ? stmfd ? sp!, {r1, r2, r3, ip} ? @ save v:p, virt SP, retfn, phys resume fn + ? ? ? ldr ? ? r3, =sleep_save_sp
The global variable will prevent using this function to save the state of multiple CPUs during idle.
<snip>
Quoted 4 lines
arch/arm/mm/proc-v7.S +0
-0
<snip>
Quoted 7 lines
arch/arm/mm/proc-v7.S +7
-0+/* Suspend/resume support: derived from arch/arm/mach-s5pv210/sleep.S */ +.globl cpu_v7_suspend_size +.equ ? cpu_v7_suspend_size, 4 * 8 +#ifdef CONFIG_PM +ENTRY(cpu_v7_do_suspend) + ? ? ? stmfd ? sp!, {r4 - r11, lr} + ? ? ? mrc ? ? p15, 0, r4, c13, c0, 0 ?@ FCSE/PID
arch/arm/mm/proc-v7.S
Quoted 10 lines
arch/arm/mm/proc-v7.S +10
-0+ ? ? ? mrc ? ? p15, 0, r5, c13, c0, 1 ?@ Context ID + ? ? ? mrc ? ? p15, 0, r6, c3, c0, 0 ? @ Domain ID + ? ? ? mrc ? ? p15, 0, r7, c2, c0, 0 ? @ TTB 0 + ? ? ? mrc ? ? p15, 0, r8, c2, c0, 1 ? @ TTB 1 + ? ? ? mrc ? ? p15, 0, r9, c1, c0, 0 ? @ Control register + ? ? ? mrc ? ? p15, 0, r10, c1, c0, 1 ?@ Auxiliary control register + ? ? ? mrc ? ? p15, 0, r11, c1, c0, 2 ?@ Co-processor access control + ? ? ? stmia ? r0, {r4 - r11} + ? ? ? ldmfd ? sp!, {r4 - r11, pc} +ENDPROC(cpu_v7_do_suspend)
Should the FIQ banked registers be saved in here, or by the driver that set them?
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
In reply to Russell King - ARM LinuxQuoted 4 lines · Russell King - ARM Linux
arch/arm/mm/proc-v7.S +0
-0
arch/arm/mm/proc-v7.S
Quoted 10 lines
arch/arm/mm/proc-v7.S +10
-0+ENTRY(cpu_v7_do_suspend) + ? ? ? stmfd ? sp!, {r4 - r11, lr} + ? ? ? mrc ? ? p15, 0, r4, c13, c0, 0 ?@ FCSE/PID + ? ? ? mrc ? ? p15, 0, r5, c13, c0, 1 ?@ Context ID + ? ? ? mrc ? ? p15, 0, r6, c3, c0, 0 ? @ Domain ID + ? ? ? mrc ? ? p15, 0, r7, c2, c0, 0 ? @ TTB 0 + ? ? ? mrc ? ? p15, 0, r8, c2, c0, 1 ? @ TTB 1 + ? ? ? mrc ? ? p15, 0, r9, c1, c0, 0 ? @ Control register + ? ? ? mrc ? ? p15, 0, r10, c1, c0, 1 ?@ Auxiliary control register + ? ? ? mrc ? ? p15, 0, r11, c1, c0, 2 ?@ Co-processor access control
The diagnostic register also needs to be saved to keep the errata bits set in __v7_setup.
arch/arm/mm/proc-v7.S cpu_v7_name:
Quoted 8 lines
+ ? ? ? stmia ? r0, {r4 - r11}
+ ? ? ? ldmfd ? sp!, {r4 - r11, pc}arch/arm/mm/proc-v7.S +6
-0+ENDPROC(cpu_v7_do_suspend) + +ENTRY(cpu_v7_do_resume) + ? ? ? mov ? ? ip, #0 + ? ? ? mcr ? ? p15, 0, ip, c8, c7, 0 ? @ invalidate TLBs + ? ? ? mcr ? ? p15, 0, ip, c7, c5, 0 ? @ invalidate I cache
Does this need the same ALT_SMP/ALT_UP combo as v7_flush_icache_all?
<snip>
Tegra2 suspend and cpuidle works on top of this patch and the patch that adds SMP support to sleep_save_sp. Tegra seems to need to invalidate the entire l1 data cache before enabling it, so I'm using a custom reset vector that branches to cpu_resume, and I'm handling the TLB invalidate in the function cpu_resume returns to.
Are you targeting 2.6.39 with these patches? They replace a few hundred lines of code in the Tegra2 suspend, hotplug, and idle patches, so I'd like to wait until this is in before pushing mine.
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 2 lines · Colin Cross
The diagnostic register also needs to be saved to keep the errata bits set in
__v7_setup.
Saving I've no problem with. Restoring gets hairy with kernels running in non-secure mode, as we can't just write the register - we don't know whether we are running in secure or non-secure mode. A write to the register in NS mode will crash.
Santosh: is the diagnostic register on OMAP4 re-initialized by the secure code on OMAP?
Quoted 10 lines
arch/arm/mm/proc-v7.S cpu_v7_name:
Quoted 8 lines
+ ? ? ? stmia ? r0, {r4 - r11}
+ ? ? ? ldmfd ? sp!, {r4 - r11, pc}arch/arm/mm/proc-v7.S +6
-0+ENDPROC(cpu_v7_do_suspend) + +ENTRY(cpu_v7_do_resume) + ? ? ? mov ? ? ip, #0 + ? ? ? mcr ? ? p15, 0, ip, c8, c7, 0 ? @ invalidate TLBs + ? ? ? mcr ? ? p15, 0, ip, c7, c5, 0 ? @ invalidate I cacheDoes this need the same ALT_SMP/ALT_UP combo as
v7_flush_icache_all?
That depends whether you the CPU which is resuming is part of a coherent SMP system at that point. This instruction will invalidate the I-cache for the local CPU only, whereas the c7, c1 variant will invalidate the instruction caches of all CPUs within the inner sharable domain.
Has anything changed in the other CPUs as a result of this CPU resuming at this point? I don't think so, so I think we just need to ensure that the local CPU instruction cache is invalidated at this point.
Quoted 3 lines
Tegra2 suspend and cpuidle works on top of this patch and the patch that adds SMP support to
sleep_save_sp. Tegra seems to need to invalidate the entire l1 data cache before enabling it,
As it's undefined what state the data cache is in on resume, I'm surprised the s5pv210 code doesn't also need a D-cache invalidate too. Maybe Samsung folk can answer that.
Quoted 9 lines
so I'm using a
custom reset vector that branches tocpu_resume, and I'm handling the TLB invalidate in the functioncpu_resumereturns to.Tested-by Colin Cross <[email protected]>Are you targeting 2.6.39 with these patches? They replace a few hundred lines of code in the Tegra2 suspend, hotplug, and idle patches, so I'd like to wait until this is in before pushing mine.
Undecided at the moment. It's great that you've tested it, and I've also tested it on Assabet, but PXA and Samsung stuff hasn't been tested yet. I guess I could just push the generic and sa1100 bits for 2.6.39, unless the remainder gets tested.
Once the above issues have answers, I'll see about posting a new set of patches.
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 22 lines
-----Original Message-----
From: linux-arm-kernel-bounces at lists.infradead.org [mailto:linux- arm-kernel-bounces at lists.infradead.org] On Behalf Of Russell King - ARM Linux
Sent: Friday, February 11, 2011 5:29 PM
To: Colin Cross; Santosh Shilimkar; Kukjin Kim
Cc: saeed bishara; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH v3 2/5] ARM: pm: add generic CPU suspend/resume supportQuoted 1 line · Colin Cross
The diagnostic register also needs to be saved to keep the errata
bits
Quoted 1 line
set in
__v7_setup.Saving I've no problem with. Restoring gets hairy with kernels running
in non-secure mode, as we can't just write the register - we don't know
whether we are running in secure or non-secure mode. A write to the register in NS mode will crash.
Quoted 3 lines
Santosh: is the diagnostic register on OMAP4 re-initialized by the secure code on OMAP?
There is a Monitor secure API, needs to be called from non-secure software to set this diagnostic registers in resume path.
Regards,
Santosh
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 2 lines · Santosh Shilimkar
There is a Monitor secure API, needs to be called from non-secure software to set this diagnostic registers in resume path.
It would be an idea to get the OMAP sleep code up to date so that I can look at OMAPs requirements for this to be useful.
As the current code stands, I don't see any reason why the sleep34xx code can't use this infrastructure, but I'm loathed to start modifying that if there's outstanding code changes in that area.
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
Quoted 13 lines
-----Original Message-----
From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk]
Sent: Saturday, February 12, 2011 8:20 PM
To: Santosh Shilimkar
Cc: Colin Cross; Kukjin Kim; saeed bishara; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH v3 2/5] ARM: pm: add generic CPU suspend/resume supportQuoted 2 lines · Santosh Shilimkar
There is a Monitor secure API, needs to be called from non-secure software to set this diagnostic registers in resume path.
Quoted 8 lines
It would be an idea to get the OMAP sleep code up to date so that I can
look at OMAPs requirements for this to be useful.As the current code stands, I don't see any reason why the sleep34xx code
can't use this infrastructure, but I'm loathed to start modifying that if there's outstanding code changes in that area.
Yep. There are few issues out there with sleep34xx code.
- Secure APIs
- Current code needs to be cleaned up to remove unwanted registers save restore
- Some part of the code on OMAP3 must be run from SRAM. It can't run from DDR
- AUXCTLR, Diagnostic registers aren't accessible in secure mode.
- L2 cache needs to be handled with secure APIs.
- Code sequence needs to handle errata's handling which accesses OMAP PM registers.
Few of the above are getting addressed for this merge window.
So my plan was to take a look at generic suspend after the merge window. By that time your generic stuff and omap cleanup would have got merged hopefully.
Regards,
Santosh
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
+ linux-omap on this thread.
Quoted 55 lines
-----Original Message-----
From: Santosh Shilimkar [mailto:santosh.shilimkar at ti.com]
Sent: Saturday, February 12, 2011 8:40 PM
To: Russell King - ARM Linux
Cc: Colin Cross; Kukjin Kim; saeed bishara; linux-arm- kernel at lists.infradead.org
Subject: RE: [PATCH v3 2/5] ARM: pm: add generic CPU suspend/resume supportQuoted 7 lines
-----Original Message-----
From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk]
Sent: Saturday, February 12, 2011 8:20 PM
To: Santosh Shilimkar
Cc: Colin Cross; Kukjin Kim; saeed bishara; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH v3 2/5] ARM: pm: add generic CPUsuspend/resume
Quoted 4 lines
support
Quoted 1 line · Santosh Shilimkar
There is a Monitor secure API, needs to be called from non-
secure
Quoted 3 lines
Quoted 1 line
software to set this diagnostic registers in resume path.
It would be an idea to get the OMAP sleep code up to date so that
I
Quoted 4 lines
can
look at OMAPs requirements for this to be useful.As the current code stands, I don't see any reason why the
sleep34xx
Quoted 3 lines
code
can't use this infrastructure, but I'm loathed to start modifying that if there's outstanding code changes in that area.Yep. There are few issues out there with sleep34xx code.
- Secure APIs
- Current code needs to be cleaned up to remove unwanted registers save restore
- Some part of the code on OMAP3 must be run from SRAM. It can't run from DDR
- AUXCTLR, Diagnostic registers aren't accessible in secure mode.
- L2 cache needs to be handled with secure APIs.
- Code sequence needs to handle errata's handling which accesses OMAP PM registers.Few of the above are getting addressed for this merge window.
So my plan was to take a look at generic suspend after the merge window. By that time your generic stuff and omap cleanup would have got merged hopefully.
Regards,
Santosh
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
In reply to Santosh ShilimkarQuoted 22 lines · Santosh Shilimkar
Quoted 13 lines
-----Original Message-----
From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk]
Sent: Saturday, February 12, 2011 8:20 PM
To: Santosh Shilimkar
Cc: Colin Cross; Kukjin Kim; saeed bishara; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH v3 2/5] ARM: pm: add generic CPU suspend/resume supportQuoted 2 lines · Santosh Shilimkar
There is a Monitor secure API, needs to be called from non-secure software to set this diagnostic registers in resume path.
Quoted 8 lines
It would be an idea to get the OMAP sleep code up to date so that I can
look at OMAPs requirements for this to be useful.As the current code stands, I don't see any reason why the sleep34xx code
can't use this infrastructure, but I'm loathed to start modifying that if there's outstanding code changes in that area.
Quoted 6 lines
Yep. There are few issues out there with sleep34xx code. ? ? ? ?- Secure APIs
? ? ? ?- Current code needs to be cleaned up to remove ? ? ? ?unwanted registers save restore
? ? ? ?- Some part of the code on OMAP3 must be run from ? ? ? ?SRAM. It can't run from DDR
This is not the highest priority for now, I will have to come back later on this.
Quoted 5 lines
? ? ? ?- AUXCTLR, Diagnostic registers aren't accessible ? ? ? ?in secure mode.
? ? ? ?- L2 cache needs to be handled with secure APIs. ? ? ? ?- Code sequence needs to handle errata's handling ? ? ? ?which accesses OMAP PM registers.
Also there is some on-going work to support Thumb-2, adding Dave.
Quoted 6 lines
Few of the above are getting addressed for this merge window.
So my plan was to take a look at generic suspend after the merge window. By that time your generic stuff and omap cleanup would have got merged hopefully.
Agree!
Quoted 3 lines
Regards,
Santosh
Regards,
Jean
Quoted 6 lines
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 2/5 ARM: pm: add generic CPU suspend/resume support
In reply to Russell King - ARM LinuxQuoted 33 lines · Russell King - ARM Linux
Quoted 2 lines · Colin Cross
The diagnostic register also needs to be saved to keep the errata bits set in
__v7_setup.Saving I've no problem with. Restoring gets hairy with kernels running in non-secure mode, as we can't just write the register - we don't know whether we are running in secure or non-secure mode. A write to the register in NS mode will crash.
Santosh: is the diagnostic register on OMAP4 re-initialized by the secure code on OMAP?
Quoted 10 lines
arch/arm/mm/proc-v7.S cpu_v7_name: · line 226
Quoted 8 lines
arch/arm/mm/proc-v7.S +8
-0+ stmia r0, {r4 - r11} + ldmfd sp!, {r4 - r11, pc} +ENDPROC(cpu_v7_do_suspend) + +ENTRY(cpu_v7_do_resume) + mov ip, #0 + mcr p15, 0, ip, c8, c7, 0 @ invalidate TLBs + mcr p15, 0, ip, c7, c5, 0 @ invalidate I cacheDoes this need the same ALT_SMP/ALT_UP combo as
v7_flush_icache_all?That depends whether you the CPU which is resuming is part of a coherent SMP system at that point. This instruction will invalidate the I-cache for the local CPU only, whereas the c7, c1 variant will invalidate the instruction caches of all CPUs within the inner sharable domain.
Has anything changed in the other CPUs as a result of this CPU resuming at this point? I don't think so, so I think we just need to ensure that the local CPU instruction cache is invalidated at this point.
Quoted 8 lines
Quoted 3 lines
Tegra2 suspend and cpuidle works on top of this patch and the patch that adds SMP support to
sleep_save_sp. Tegra seems to need to invalidate the entire l1 data cache before enabling it,As it's undefined what state the data cache is in on resume, I'm surprised the s5pv210 code doesn't also need a D-cache invalidate too. Maybe Samsung folk can answer that.
Now, it works fine with omission D-cache invalidate on S5PV210. Basically, Samsung S5P SoCs have some kind of hardware initialization code. So I'm not sure it has something for it, will/need to check it to hardware guys soon :) Then let you know about that ;)
As a note, I will test your updated generic CPU suspend/resume support on Samsung SoCs also, if any available branch which has p2v patches for it, please let me know. Anyway sorry for late testing on board.
Have a nice weekend.
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH 3/5 ARM: pm: convert PXA to generic suspend/resume support
In reply to Russell King - ARM Linux--- arch/arm/mach-pxa/include/mach/pm.h | 5 +- arch/arm/mach-pxa/palmz72.c | 2 +- arch/arm/mach-pxa/pm.c | 5 - arch/arm/mach-pxa/pxa25x.c | 4 +- arch/arm/mach-pxa/pxa27x.c | 4 +- arch/arm/mach-pxa/pxa3xx.c | 7 +- arch/arm/mach-pxa/sleep.S | 184 +++-------------------------------- arch/arm/mach-pxa/zeus.c | 2 +- 8 files changed, 24 insertions(+), 189 deletions(-)
arch/arm/mach-pxa/include/mach/pm.h +2 -3
@@ -22,9 +22,8 @@ struct pxa_cpu_pm_fns {extern struct pxa_cpu_pm_fns *pxa_cpu_pm_fns;/* sleep.S */ -extern void pxa25x_cpu_suspend (unsigned int ); -extern void pxa27x_cpu_suspend (unsigned int ); -extern void pxa_cpu_resume (void ); +extern void pxa25x_cpu_suspend (unsigned int ,long ); +extern void pxa27x_cpu_suspend (unsigned int ,long );extern int pxa_pm_enter (suspend_state_t state);extern int pxa_pm_prepare (void );
arch/arm/mach-pxa/palmz72.c +1 -1
@@ -212,7 +212,7 @@ static unsigned long store_ptr;static int palmz72_pm_suspend (struct sys_device *dev,pm_message_t msg) {/* setup the resume_info struct for the original bootloader */ - palmz72_resume_info.resume_addr = (u32 ) pxa_cpu_resume; + palmz72_resume_info.resume_addr = (u32 ) cpu_resume;/* Storing memory touched by ROM */ store_ptr = *PALMZ72_SAVE_DWORD ;
arch/arm/mach-pxa/pm.c +0 -5
@@ -67,11 +67,6 @@ int pxa_pm_enter(suspend_state_t state)EXPORT_SYMBOL_GPL (pxa_pm_enter); -unsigned long sleep_phys_sp (void *sp) -{ -return virt_to_phys (sp); -} -static int pxa_pm_valid (suspend_state_t state) {if (pxa_cpu_pm_fns)
arch/arm/mach-pxa/pxa25x.c +2 -2
@@ -244,7 +244,7 @@ static void pxa25x_cpu_pm_enter(suspend_state_t state)switch (state) {case PM_SUSPEND_MEM : -pxa25x_cpu_suspend (PWRMODE_SLEEP ); +pxa25x_cpu_suspend (PWRMODE_SLEEP ,PHYS_OFFSET -PAGE_OFFSET );break ; } }
@@ -252,7 +252,7 @@ static void pxa25x_cpu_pm_enter(suspend_state_t state)static int pxa25x_cpu_pm_prepare (void ) {/* set resume return address */ -PSPR =virt_to_phys (pxa_cpu_resume); +PSPR =virt_to_phys (cpu_resume);return 0 ; }
arch/arm/mach-pxa/pxa27x.c +2 -2
@@ -300,7 +300,7 @@ void pxa27x_cpu_pm_enter(suspend_state_t state)pxa_cpu_standby ();break ;case PM_SUSPEND_MEM : -pxa27x_cpu_suspend (pwrmode); +pxa27x_cpu_suspend (pwrmode,PHYS_OFFSET -PAGE_OFFSET );break ; } }
@@ -313,7 +313,7 @@ static int pxa27x_cpu_pm_valid(suspend_state_t state)static int pxa27x_cpu_pm_prepare (void ) {/* set resume return address */ -PSPR =virt_to_phys (pxa_cpu_resume); +PSPR =virt_to_phys (cpu_resume);return 0 ; }
arch/arm/mach-pxa/pxa3xx.c +3 -4
@@ -142,8 +142,7 @@ static void pxa3xx_cpu_pm_suspend(void)volatile unsigned long *p = (volatile void *)0xc0000000 ;unsigned long saved_data = *p; -extern void pxa3xx_cpu_suspend (void ); -extern void pxa3xx_cpu_resume (void ); +extern void pxa3xx_cpu_suspend (long );/* resuming from D2 requires the HSIO2/BOOT/TPM clocks enabled */ CKENA |= (1 <<CKEN_BOOT ) | (1 <<CKEN_TPM );
@@ -161,9 +160,9 @@ static void pxa3xx_cpu_pm_suspend(void)PSPR =0x5c014000 ;/* overwrite with the resume address */ - *p =virt_to_phys (pxa3xx_cpu_resume); + *p =virt_to_phys (cpu_resume); -pxa3xx_cpu_suspend (); +pxa3xx_cpu_suspend (PHYS_OFFSET -PAGE_OFFSET ); *p = saved_data;
arch/arm/mach-pxa/sleep.S +13 -171
231 lines not on this page · raw message
arch/arm/mach-pxa/zeus.c +1 -1
@@ -676,7 +676,7 @@ static struct pxa2xx_udc_mach_info zeus_udc_info = {static void zeus_power_off (void ) {local_irq_disable (); -pxa27x_cpu_suspend (PWRMODE_DEEPSLEEP ); +pxa27x_cpu_suspend (PWRMODE_DEEPSLEEP ,PHYS_OFFSET -PAGE_OFFSET ); }#else #define zeus_power_off NULL
Signature · 1 line
1.6.2.5
PATCH 4/5 ARM: pm: convert sa11x0 to generic suspend/resume support
In reply to Russell King - ARM Linux--- arch/arm/mach-sa1100/pm.c | 12 ++----- arch/arm/mach-sa1100/sleep.S | 72 ++--------------------------------------- 2 files changed, 7 insertions(+), 77 deletions(-)
arch/arm/mach-sa1100/pm.c +3 -9
@@ -32,8 +32,7 @@#include <asm/system.h> #include <asm/mach/time.h> -extern void sa1100_cpu_suspend (void ); -extern void sa1100_cpu_resume (void ); +extern void sa1100_cpu_suspend (long );#define SAVE (x) sleep_save[SLEEP_SAVE_##x] = x#define RESTORE (x) x = sleep_save[SLEEP_SAVE_##x]
@@ -73,10 +72,10 @@ static int sa11x0_pm_enter(suspend_state_t state)RCSR =RCSR_HWR |RCSR_SWR |RCSR_WDR |RCSR_SMR ;/* set resume return address */ -PSPR =virt_to_phys (sa1100_cpu_resume); +PSPR =virt_to_phys (cpu_resume);/* go zzz */ -sa1100_cpu_suspend (); +sa1100_cpu_suspend (PHYS_OFFSET -PAGE_OFFSET );cpu_init ();
@@ -115,11 +114,6 @@ static int sa11x0_pm_enter(suspend_state_t state)return 0 ; } -unsigned long sleep_phys_sp (void *sp) -{ -return virt_to_phys (sp); -} -static const struct platform_suspend_ops sa11x0_pm_ops = { .enter = sa11x0_pm_enter, .valid = suspend_valid_only_mem,
arch/arm/mach-sa1100/sleep.S +4 -68
93 lines not on this page · raw message
Signature · 1 line
1.6.2.5
PATCH 4/5 ARM: pm: convert sa11x0 to generic suspend/resume support
Quoted 1 line · Russell King - ARM Linux
Signed-off-by Russell King <[email protected]>
Now tested this on Assabet, and it works fine there.
PATCH 5/5 ARM: pm: convert samsung platforms to generic suspend/resume support
In reply to Russell King - ARM Linux--- arch/arm/mach-s3c64xx/sleep.S | 63 +----------------- arch/arm/mach-s5pv210/sleep.S | 104 +------------------------------ arch/arm/plat-s3c24xx/sleep.S | 57 +---------------- arch/arm/plat-samsung/include/plat/pm.h | 12 +--- arch/arm/plat-samsung/pm.c | 16 +----- 5 files changed, 13 insertions(+), 239 deletions(-)
arch/arm/mach-s3c64xx/sleep.S +4 -59
@@ -32,25 +32,13 @@ * code after resume. * * entry: - * r0 = pointer to the save block + * r1 = v:p offset */ ENTRY(s3c_cpu_save) stmfd sp!, { r4 - r12, lr } - - mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID - mrc p15, 0, r5, c3, c0, 0 @ Domain ID - mrc p15, 0, r6, c2, c0, 0 @ Translation Table BASE0 - mrc p15, 0, r7, c2, c0, 1 @ Translation Table BASE1 - mrc p15, 0, r8, c2, c0, 2 @ Translation Table Control - mrc p15, 0, r9, c1, c0, 0 @ Control register - mrc p15, 0, r10, c1, c0, 1 @ Auxiliary control register - mrc p15, 0, r11, c1, c0, 2 @ Co-processor access controls - - stmia r0, { r4 - r13 } @ Save CP registers and SP - - @@ save our state to ram - bl s3c_pm_cb_flushcache + ldr r3, =resume_with_mmu + bl cpu_suspend @@ call final suspend code ldr r0, =pm_cpu_sleep
@@ -61,18 +49,6 @@ ENTRY(s3c_cpu_save) resume_with_mmu: ldmfd sp!, { r4 - r12, pc } @ return, from sp from s3c_cpu_save - .data - - /* the next bit is code, but it requires easy access to the - * s3c_sleep_save_phys data before the MMU is switched on, so - * we store the code that needs this variable in the .data where - * the value can be written to (the .text segment is RO). - */ - - .global s3c_sleep_save_phys -s3c_sleep_save_phys: - .word 0 - /* Sleep magic, the word before the resume entry point so that the * bootloader can check for a resumeable image. */
@@ -110,35 +86,4 @@ ENTRY(s3c_cpu_resume) orr r0, r0, #1 << 15 @ GPN15 str r0, [ r3, #S3C64XX_GPNDAT ] #endif - - /* __v6_setup from arch/arm/mm/proc-v6.S, ensure that the caches - * are thoroughly cleaned just in case the bootloader didn't do it - * for us. */ - mov r0, #0 - mcr p15, 0, r0, c7, c14, 0 @ clean+invalidate D cache - mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache - mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache - mcr p15, 0, r0, c7, c10, 4 @ drain write buffer - @@mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs - @@mcr p15, 0, r0, c7, c7, 0 @ Invalidate I + D caches - - ldr r0, s3c_sleep_save_phys - ldmia r0, { r4 - r13 } - - mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID - mcr p15, 0, r5, c3, c0, 0 @ Domain ID - mcr p15, 0, r6, c2, c0, 0 @ Translation Table BASE0 - mcr p15, 0, r7, c2, c0, 1 @ Translation Table BASE1 - mcr p15, 0, r8, c2, c0, 2 @ Translation Table Control - mcr p15, 0, r10, c1, c0, 1 @ Auxiliary control register - - mov r0, #0 @ restore copro access controls - mcr p15, 0, r11, c1, c0, 2 @ Co-processor access controls - mcr p15, 0, r0, c7, c5, 4 - - ldr r2, =resume_with_mmu - mcr p15, 0, r9, c1, c0, 0 /* turn mmu back on */ - nop - mov pc, r2 /* jump back */ - - .end + b cpu_resume
arch/arm/mach-s5pv210/sleep.S +3 -101
128 lines not on this page · raw message
arch/arm/plat-s3c24xx/sleep.S +4 -53
82 lines not on this page · raw message
arch/arm/plat-samsung/include/plat/pm.h +1 -11
@@ -50,13 +50,11 @@ extern unsigned char pm_uart_udivslot; /* true to save UART UDIVSLOT *//* from sleep.S */ -extern int s3c_cpu_save (unsigned long *saveblk); +extern int s3c_cpu_save (unsigned long *saveblk,long );extern void s3c_cpu_resume (void );extern void s3c2410_cpu_suspend (void ); -extern unsigned long s3c_sleep_save_phys; -/* sleep save info */ /**
@@ -179,13 +177,5 @@ extern void s3c_pm_restore_gpios(void);*/ extern void s3c_pm_save_gpios (void ); -/** -* s3c_pm_cb_flushcache - callback for assembly code -* -* Callback to issue flush_cache_all() as this call is -* not a directly callable object. -*/ -extern void s3c_pm_cb_flushcache (void ); -extern void s3c_pm_save_core (void );extern void s3c_pm_restore_core (void );
arch/arm/plat-samsung/pm.c +1 -15
@@ -241,8 +241,6 @@ void (*pm_cpu_sleep)(void);static int s3c_pm_enter (suspend_state_t state) { -static unsigned long regs_save[16 ]; -/* ensure the debug is initialised (if enabled) */ s3c_pm_debug_init ();
@@ -266,12 +264,6 @@ static int s3c_pm_enter(suspend_state_t state)return -EINVAL ; } -/* store the physical address of the register recovery block */ - - s3c_sleep_save_phys =virt_to_phys (regs_save); - -S3C_PMDBG ("s3c_sleep_save_phys=0x%08lx\n" , s3c_sleep_save_phys); -/* save all necessary core registers not covered by the drivers */ s3c_pm_save_gpios ();
@@ -305,7 +297,7 @@ static int s3c_pm_enter(suspend_state_t state)* we resume as it saves its own register state and restores it * during the resume. */ -s3c_cpu_save (regs_save); +s3c_cpu_save (0 ,PHYS_OFFSET -PAGE_OFFSET );/* restore the cpu state using the kernel's cpu init code. */
@@ -336,12 +328,6 @@ static int s3c_pm_enter(suspend_state_t state)return 0 ; } -/* callback from assembly code */ -void s3c_pm_cb_flushcache (void ) -{ -flush_cache_all (); -} -static int s3c_pm_prepare (void ) {/* prepare check area if configured */
Signature · 1 line
1.6.2.5
Quoted 5 lines · Russell King - ARM Linux
The following patch series implements infrastructure to save/restore CPU state on suspend/resume PM events, and updates SA11x0, PXA and Samsung platforms to use this.
Quoted 7 lines
Not all CPU support files are updated with the necessary changes - currently only ARM920, ARM926, SA11x0, XScale, XScale3, V6 and V7 CPUs are supported.
I've build-tested this for Assabet, PXA, and S3C2410, but not boot tested it yet.
Hi Russell,
Occurs following build error with s5pv210_defconfig.
(I applied your patches into my some branch which is based on 38-rc3 for test)
arch/arm/mm/proc-v7.S:207: error: unterminated #ifdef
Let you know the test result on my board after fixing it.
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
RFC 1/1 Generic CPU save/restore PM support
Quoted 15 lines · Kukjin Kim
Quoted 5 lines · Russell King - ARM Linux
The following patch series implements infrastructure to save/restore CPU state on suspend/resume PM events, and updates SA11x0, PXA and Samsung platforms to use this.
Quoted 7 lines
Not all CPU support files are updated with the necessary changes - currently only ARM920, ARM926, SA11x0, XScale, XScale3, V6 and V7 CPUs are supported.
I've build-tested this for Assabet, PXA, and S3C2410, but not boot tested it yet.
Hi Russell,
Quoted 7 lines
Occurs following build error with
s5pv210_defconfig.
(I applied your patches into my some branch which is based on 38-rc3 for test)
arch/arm/mm/proc-v7.S:207: error: unterminated #ifdefLet you know the test result on my board after fixing it.
There is an issue here which I missed when pulling the code out of s5pv210, so you'll also need this. This also fixes Xscale3 to operate in the same manner.
arch/arm/mm/proc-v7.S +4 -3
@@ -203,7 +203,7 @@ cpu_v7_name: .equ NMRR, 0x40e040e0 .globl cpu_v7_suspend_size -.equ cpu_v7_suspend_size, 4 * 7 +.equ cpu_v7_suspend_size, 4 * 8 #ifdef CONFIG_PM ENTRY(cpu_v7_do_suspend) stmfd sp!, {r4 - r10, lr}
@@ -214,7 +214,7 @@ ENTRY(cpu_v7_do_suspend) mrc p15, 0, r8, c1, c0, 0 @ Control register mrc p15, 0, r9, c1, c0, 1 @ Auxiliary control register mrc p15, 0, r10, c1, c0, 2 @ Co-processor access control - stmia r0, {r4 - r10} + stmia r0, {r1, r4 - r10} ldmfd sp!, {r4 - r10, pc} ENDPROC(cpu_v7_do_suspend)
@@ -222,7 +222,7 @@ ENTRY(cpu_v7_do_resume) mov ip, #0 mcr p15, 0, ip, c8, c7, 0 @ invalidate TLBs mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache - ldmia r0, {r4 - r10} + ldmia r0, {r1, r4 - r10} mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID mcr p15, 0, r5, c3, c0, 0 @ Domain ID mcr p15, 0, r6, c2, c0, 0 @ TTB 0
@@ -245,6 +245,7 @@ ENTRY(cpu_v7_do_resume) orr r3, r2, r4, lsl #20 @ phys addr ldr r5, [r6, r4, lsl #2] @ save old translation str r3, [r6, r4, lsl #2] @ virt index + sub r6, r6, r1 @ convert to virt translation base ldr r2, =cpu_v7_resume_after_mmu b cpu_v7_turn_mmu_on
arch/arm/mm/proc-xsc3.S +9 -15
@@ -416,7 +416,7 @@ ENTRY(cpu_xsc3_set_pte_ext) .align .globl cpu_xsc3_suspend_size -.equ cpu_xsc3_suspend_size, 4 * 7 +.equ cpu_xsc3_suspend_size, 4 * 8 #ifdef CONFIG_PM ENTRY(cpu_xsc3_do_suspend) stmfd sp!, {r4 - r10, lr}
@@ -428,17 +428,17 @@ ENTRY(cpu_xsc3_do_suspend) mrc p15, 0, r9, c1, c0, 1 @ auxiliary control reg mrc p15, 0, r10, c1, c0, 0 @ control reg bic r4, r4, #2 @ clear frequency change bit - stmia r0, {r4 - r10} @ store cp regs + stmia r0, {r1, r4 - r10} @ store v:p offset + cp regs ldmia sp!, {r4 - r10, pc} ENDPROC(cpu_xsc3_do_suspend) ENTRY(cpu_xsc3_do_resume) - ldmia r0, {r4 - r10} @ load cp regs - mov r1, #0 - mcr p15, 0, r1, c7, c7, 0 @ invalidate I & D caches, BTB - mcr p15, 0, r1, c7, c10, 4 @ drain write (&fill) buffer - mcr p15, 0, r1, c7, c5, 4 @ flush prefetch buffer - mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs + ldmia r0, {r1, r4 - r10} @ load v:p offset + cp regs + mov ip, #0 + mcr p15, 0, ip, c7, c7, 0 @ invalidate I & D caches, BTB + mcr p15, 0, ip, c7, c10, 4 @ drain write (&fill) buffer + mcr p15, 0, ip, c7, c5, 4 @ flush prefetch buffer + mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs mcr p14, 0, r4, c6, c0, 0 @ clock configuration, turbo mode. mcr p15, 0, r5, c15, c1, 0 @ CP access reg mcr p15, 0, r6, c13, c0, 0 @ PID
@@ -457,12 +457,7 @@ ENTRY(cpu_xsc3_do_resume) orr r3, r2, r4, lsl #20 ldr r5, [r8, r4, lsl #2] str r3, [r8, r4, lsl #2] - - @ Mapping page table address in the page table - mov r6, r8, lsr #20 - orr r3, r2, r6, lsl #20 - ldr r7, [r8, r6, lsl #2] - str r3, [r8, r6, lsl #2] + sub r8, r8, r1 @ convert to virt table base ldr r2, =cpu_xsc3_resume_after_mmu @ absolute virtual address b cpu_xsc3_turn_on_mmu @ cache align execution
@@ -481,7 +476,6 @@ ENDPROC(cpu_xsc3_mmu_on) cpu_xsc3_resume_after_mmu: /* restore the temporary mapping */ str r5, [r8, r4, lsl #2] - str r7, [r8, r6, lsl #2] mov pc, lr ENDPROC(cpu_xsc3_resume_after_mmu) #else