linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] omap3: pm: Fixes for low power code
@ 2011-02-21 13:19 Santosh Shilimkar
  2011-02-21 13:19 ` [PATCH 1/6] omap3: pm: Use amrv7 supported instructions instead of legacy cp15 ones Santosh Shilimkar
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Santosh Shilimkar @ 2011-02-21 13:19 UTC (permalink / raw)
  To: linux-arm-kernel

The series does below fixes to the omap3 low power code.
	1. Use supported ARMv7 instructions instead of the legacy ones
	2. Fix the MMU on sequence
	3. Fix the cache flush scenario when only L1 lost.
	4. Remove all un-necessary context save registers
	5. Disable C-bit before cache clean
	6. Use set_cr() exported API instead of custom one. 

It's generated against mainline and tested with OMAP3630 ZOOM3.
	1. Renetion and off-mode mode in suspend - ok.
	2. Retention in idle - ok

The following changes since commit 85e2efbb1db9a18d218006706d6e4fbeb0216213:
  Linus Torvalds (1):
        Linux 2.6.38-rc5

Santosh Shilimkar (6):
  omap3: pm: Use amrv7 supported instructions instead of legacy cp15
    ones
  omap3: pm: Fix the mmu on sequence in the asm code
  omap3: pm: Allow the cache clean when L1 is lost.
  omap3: pm: Remove un-necessary cp15 registers form low power cpu
    context
  omap3: pm: Clear the SCTLR C bit in asm code to prevent data cache
    allocation
  omap3: pm: Use exported set_cr() instead of a custom one.

 arch/arm/mach-omap2/pm34xx.c    |    7 +-
 arch/arm/mach-omap2/sleep34xx.S |  223 ++++++++++++++-------------------------
 2 files changed, 78 insertions(+), 152 deletions(-)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/6] omap3: pm: Use amrv7 supported instructions instead of legacy cp15 ones
  2011-02-21 13:19 [PATCH 0/6] omap3: pm: Fixes for low power code Santosh Shilimkar
@ 2011-02-21 13:19 ` Santosh Shilimkar
  2011-02-21 13:19 ` [PATCH 2/6] omap3: pm: Fix the mmu on sequence in the asm code Santosh Shilimkar
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Santosh Shilimkar @ 2011-02-21 13:19 UTC (permalink / raw)
  To: linux-arm-kernel

On ARMv7 dsb, dmb instructions are supported and can be used directly
instead of their cp15 equivalnet. Also remove the opcodes for smc
and use the available instruction directly in OMAP3 low power asm code

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/sleep34xx.S |   35 +++++++++++++++++------------------
 1 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index 98d8232..db4cc57 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -131,9 +131,9 @@ ENTRY(save_secure_ram_context)
 	mov	r1, #0			@ set task id for ROM code in r1
 	mov	r2, #4			@ set some flags in r2, r6
 	mov	r6, #0xff
-	mcr	p15, 0, r0, c7, c10, 4	@ data write barrier
-	mcr	p15, 0, r0, c7, c10, 5	@ data memory barrier
-	.word	0xE1600071		@ call SMI monitor (smi #1)
+	dsb				@ data write barrier
+	dmb				@ data memory barrier
+	smc	#1			@ call SMI monitor (smi #1)
 	nop
 	nop
 	nop
@@ -289,9 +289,8 @@ omap3_do_wfi:
 	str	r5, [r4]		@ write back to SDRC_POWER register
 
 	/* Data memory barrier and Data sync barrier */
-	mov	r1, #0
-	mcr	p15, 0, r1, c7, c10, 4
-	mcr	p15, 0, r1, c7, c10, 5
+	dsb
+	dmb
 
 /*
  * ===================================
@@ -406,9 +405,9 @@ skipl2dis:
 	mov	r2, #4			@ set some flags in r2, r6
 	mov	r6, #0xff
 	adr	r3, l2_inv_api_params	@ r3 points to dummy parameters
-	mcr	p15, 0, r0, c7, c10, 4	@ data write barrier
-	mcr	p15, 0, r0, c7, c10, 5	@ data memory barrier
-	.word	0xE1600071		@ call SMI monitor (smi #1)
+	dsb				@ data write barrier
+	dmb				@ data memory barrier
+	smc	#1			@ call SMI monitor (smi #1)
 	/* Write to Aux control register to set some bits */
 	mov	r0, #42			@ set service ID for PPA
 	mov	r12, r0			@ copy secure Service ID in r12
@@ -417,9 +416,9 @@ skipl2dis:
 	mov	r6, #0xff
 	ldr	r4, scratchpad_base
 	ldr	r3, [r4, #0xBC]		@ r3 points to parameters
-	mcr	p15, 0, r0, c7, c10, 4	@ data write barrier
-	mcr	p15, 0, r0, c7, c10, 5	@ data memory barrier
-	.word	0xE1600071		@ call SMI monitor (smi #1)
+	dsb				@ data write barrier
+	dmb				@ data memory barrier
+	smc	#1			@ call SMI monitor (smi #1)
 
 #ifdef CONFIG_OMAP3_L2_AUX_SECURE_SAVE_RESTORE
 	/* Restore L2 aux control register */
@@ -432,9 +431,9 @@ skipl2dis:
 	ldr	r4, scratchpad_base
 	ldr	r3, [r4, #0xBC]
 	adds	r3, r3, #8		@ r3 points to parameters
-	mcr	p15, 0, r0, c7, c10, 4	@ data write barrier
-	mcr	p15, 0, r0, c7, c10, 5	@ data memory barrier
-	.word	0xE1600071		@ call SMI monitor (smi #1)
+	dsb				@ data write barrier
+	dmb				@ data memory barrier
+	smc	#1			@ call SMI monitor (smi #1)
 #endif
 	b	logic_l1_restore
 
@@ -443,18 +442,18 @@ l2_inv_api_params:
 l2_inv_gp:
 	/* Execute smi to invalidate L2 cache */
 	mov r12, #0x1			@ set up to invalidate L2
-	.word 0xE1600070		@ Call SMI monitor (smieq)
+	smc	#0			@ Call SMI monitor
 	/* Write to Aux control register to set some bits */
 	ldr	r4, scratchpad_base
 	ldr	r3, [r4,#0xBC]
 	ldr	r0, [r3,#4]
 	mov	r12, #0x3
-	.word	0xE1600070		@ Call SMI monitor (smieq)
+	smc	#0			@ Call SMI monitor
 	ldr	r4, scratchpad_base
 	ldr	r3, [r4,#0xBC]
 	ldr	r0, [r3,#12]
 	mov	r12, #0x2
-	.word	0xE1600070		@ Call SMI monitor (smieq)
+	smc	#0			@ Call SMI monitor
 logic_l1_restore:
 	ldr	r1, l2dis_3630
 	cmp	r1, #0x1		@ Test if L2 re-enable needed on 3630
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/6] omap3: pm: Fix the mmu on sequence in the asm code
  2011-02-21 13:19 [PATCH 0/6] omap3: pm: Fixes for low power code Santosh Shilimkar
  2011-02-21 13:19 ` [PATCH 1/6] omap3: pm: Use amrv7 supported instructions instead of legacy cp15 ones Santosh Shilimkar
@ 2011-02-21 13:19 ` Santosh Shilimkar
  2011-02-21 13:19 ` [PATCH 3/6] omap3: pm: Allow the cache clean when L1 is lost Santosh Shilimkar
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Santosh Shilimkar @ 2011-02-21 13:19 UTC (permalink / raw)
  To: linux-arm-kernel

Add necessary barriers after enabling MMU. Also use the sane way to
load pc and jump to it instead of executing ldma first up.

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/sleep34xx.S |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index db4cc57..4478379 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -591,12 +591,17 @@ usettbr0:
 	ldr	r2, cache_pred_disable_mask
 	and	r4, r2
 	mcr	p15, 0, r4, c1, c0, 0
+	dsb
+	isb
+	ldr     r0, =restoremmu_on
+	bx      r0
 
 /*
  * ==============================
  * == Exit point from OFF mode ==
  * ==============================
  */
+restoremmu_on:
 	ldmfd	sp!, {r0-r12, pc}	@ restore regs and return
 
 
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/6] omap3: pm: Allow the cache clean when L1 is lost.
  2011-02-21 13:19 [PATCH 0/6] omap3: pm: Fixes for low power code Santosh Shilimkar
  2011-02-21 13:19 ` [PATCH 1/6] omap3: pm: Use amrv7 supported instructions instead of legacy cp15 ones Santosh Shilimkar
  2011-02-21 13:19 ` [PATCH 2/6] omap3: pm: Fix the mmu on sequence in the asm code Santosh Shilimkar
@ 2011-02-21 13:19 ` Santosh Shilimkar
  2011-02-21 13:19 ` [PATCH 4/6] omap3: pm: Remove un-necessary cp15 registers form low power cpu context Santosh Shilimkar
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Santosh Shilimkar @ 2011-02-21 13:19 UTC (permalink / raw)
  To: linux-arm-kernel

When L1 cache is suppose to be lost, it needs to be cleaned before
entrering to the low power mode.

While at this, also fix few comments and remove un-necessary
clean_l2 lable.

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/sleep34xx.S |   15 +++------------
 1 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index 4478379..7442431 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -173,12 +173,12 @@ ENTRY(omap34xx_cpu_suspend)
 	stmfd	sp!, {r0-r12, lr}	@ save registers on stack
 
 	/*
-	 * r0 contains restore pointer in sdram
+	 * r0 contains CPU context save/restore pointer in sdram
 	 * r1 contains information about saving context:
 	 *   0 - No context lost
 	 *   1 - Only L1 and logic lost
-	 *   2 - Only L2 lost
-	 *   3 - Both L1 and L2 lost
+	 *   2 - Only L2 lost (Even L1 is retained we clean it along with L2)
+	 *   3 - Both L1 and L2 lost and logic lost
 	 */
 
 	/* Directly jump to WFI is the context save is not required */
@@ -263,15 +263,6 @@ l1_logic_lost:
 
 clean_caches:
 	/*
-	 * Clean Data or unified cache to POU
-	 * How to invalidate only L1 cache???? - #FIX_ME#
-	 * mcr	p15, 0, r11, c7, c11, 1
-	 */
-	cmp	r1, #0x1 		@ Check whether L2 inval is required
-	beq	omap3_do_wfi
-
-clean_l2:
-	/*
 	 * jump out to kernel flush routine
 	 *  - reuse that code is better
 	 *  - it executes in a cached space so is faster than refetch per-block
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/6] omap3: pm: Remove un-necessary cp15 registers form low power cpu context
  2011-02-21 13:19 [PATCH 0/6] omap3: pm: Fixes for low power code Santosh Shilimkar
                   ` (2 preceding siblings ...)
  2011-02-21 13:19 ` [PATCH 3/6] omap3: pm: Allow the cache clean when L1 is lost Santosh Shilimkar
@ 2011-02-21 13:19 ` Santosh Shilimkar
  2011-02-21 13:19 ` [PATCH 5/6] omap3: pm: Clear the SCTLR C bit in asm code to prevent data cache allocation Santosh Shilimkar
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Santosh Shilimkar @ 2011-02-21 13:19 UTC (permalink / raw)
  To: linux-arm-kernel

The current code saves few un-necessary registers which are read-only or
write-only, unused CP15 registers.

Remove them and keep only necessary CP15 registers part of
low power context save/restore.

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/sleep34xx.S |  156 ++++++++++-----------------------------
 1 files changed, 40 insertions(+), 116 deletions(-)

diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index 7442431..28baeb2 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -199,66 +199,29 @@ save_context_wfi:
 	beq	clean_caches
 
 l1_logic_lost:
-	/* Store sp and spsr to SDRAM */
-	mov	r4, sp
-	mrs	r5, spsr
-	mov	r6, lr
+	mov	r4, sp			@ Store sp
+	mrs	r5, spsr		@ Store spsr
+	mov	r6, lr			@ Store lr
 	stmia	r8!, {r4-r6}
-	/* Save all ARM registers */
-	/* Coprocessor access control register */
-	mrc	p15, 0, r6, c1, c0, 2
-	stmia	r8!, {r6}
-	/* TTBR0, TTBR1 and Translation table base control */
-	mrc	p15, 0, r4, c2, c0, 0
-	mrc	p15, 0, r5, c2, c0, 1
-	mrc	p15, 0, r6, c2, c0, 2
-	stmia	r8!, {r4-r6}
-	/*
-	 * Domain access control register, data fault status register,
-	 * and instruction fault status register
-	 */
-	mrc	p15, 0, r4, c3, c0, 0
-	mrc	p15, 0, r5, c5, c0, 0
-	mrc	p15, 0, r6, c5, c0, 1
-	stmia	r8!, {r4-r6}
-	/*
-	 * Data aux fault status register, instruction aux fault status,
-	 * data fault address register and instruction fault address register
-	 */
-	mrc	p15, 0, r4, c5, c1, 0
-	mrc	p15, 0, r5, c5, c1, 1
-	mrc	p15, 0, r6, c6, c0, 0
-	mrc	p15, 0, r7, c6, c0, 2
-	stmia	r8!, {r4-r7}
-	/*
-	 * user r/w thread and process ID, user r/o thread and process ID,
-	 * priv only thread and process ID, cache size selection
-	 */
-	mrc	p15, 0, r4, c13, c0, 2
-	mrc	p15, 0, r5, c13, c0, 3
-	mrc	p15, 0, r6, c13, c0, 4
-	mrc	p15, 2, r7, c0, c0, 0
+
+	mrc	p15, 0, r4, c1, c0, 2	@ Coprocessor access control register
+	mrc	p15, 0, r5, c2, c0, 0	@ TTBR0
+	mrc	p15, 0, r6, c2, c0, 1	@ TTBR1
+	mrc	p15, 0, r7, c2, c0, 2	@ TTBCR
 	stmia	r8!, {r4-r7}
-	/* Data TLB lockdown, instruction TLB lockdown registers */
-	mrc	p15, 0, r5, c10, c0, 0
-	mrc	p15, 0, r6, c10, c0, 1
-	stmia	r8!, {r5-r6}
-	/* Secure or non secure vector base address, FCSE PID, Context PID*/
-	mrc	p15, 0, r4, c12, c0, 0
-	mrc	p15, 0, r5, c13, c0, 0
-	mrc	p15, 0, r6, c13, c0, 1
-	stmia	r8!, {r4-r6}
-	/* Primary remap, normal remap registers */
-	mrc	p15, 0, r4, c10, c2, 0
-	mrc	p15, 0, r5, c10, c2, 1
-	stmia	r8!,{r4-r5}
 
-	/* Store current cpsr*/
-	mrs	r2, cpsr
-	stmia	r8!, {r2}
+	mrc	p15, 0, r4, c3, c0, 0	@ Domain access Control Register
+	mrc	p15, 0, r5, c10, c2, 0	@ PRRR
+	mrc	p15, 0, r6, c10, c2, 1	@ NMRR
+	stmia	r8!,{r4-r6}
+
+	mrc	p15, 0, r4, c13, c0, 1	@ Context ID
+	mrc	p15, 0, r5, c13, c0, 2	@ User r/w thread and process ID
+	mrc	p15, 0, r6, c12, c0, 0	@ Secure or NS vector base address
+	mrs	r7, cpsr		@ Store current cpsr
+	stmia	r8!, {r4-r7}
 
-	mrc	p15, 0, r4, c1, c0, 0
-	/* save control register */
+	mrc	p15, 0, r4, c1, c0, 0	@ save control register
 	stmia	r8!, {r4}
 
 clean_caches:
@@ -463,68 +426,29 @@ skipl2reen:
 	ldr	r4, scratchpad_base
 	ldr	r3, [r4,#0xBC]
 	adds	r3, r3, #16
+
 	ldmia	r3!, {r4-r6}
-	mov	sp, r4
-	msr	spsr_cxsf, r5
-	mov	lr, r6
-
-	ldmia	r3!, {r4-r9}
-	/* Coprocessor access Control Register */
-	mcr p15, 0, r4, c1, c0, 2
-
-	/* TTBR0 */
-	MCR p15, 0, r5, c2, c0, 0
-	/* TTBR1 */
-	MCR p15, 0, r6, c2, c0, 1
-	/* Translation table base control register */
-	MCR p15, 0, r7, c2, c0, 2
-	/* Domain access Control Register */
-	MCR p15, 0, r8, c3, c0, 0
-	/* Data fault status Register */
-	MCR p15, 0, r9, c5, c0, 0
-
-	ldmia	r3!,{r4-r8}
-	/* Instruction fault status Register */
-	MCR p15, 0, r4, c5, c0, 1
-	/* Data Auxiliary Fault Status Register */
-	MCR p15, 0, r5, c5, c1, 0
-	/* Instruction Auxiliary Fault Status Register*/
-	MCR p15, 0, r6, c5, c1, 1
-	/* Data Fault Address Register */
-	MCR p15, 0, r7, c6, c0, 0
-	/* Instruction Fault Address Register*/
-	MCR p15, 0, r8, c6, c0, 2
-	ldmia	r3!,{r4-r7}
+	mov	sp, r4			@ Restore sp
+	msr	spsr_cxsf, r5		@ Restore spsr
+	mov	lr, r6			@ Restore lr
 
-	/* User r/w thread and process ID */
-	MCR p15, 0, r4, c13, c0, 2
-	/* User ro thread and process ID */
-	MCR p15, 0, r5, c13, c0, 3
-	/* Privileged only thread and process ID */
-	MCR p15, 0, r6, c13, c0, 4
-	/* Cache size selection */
-	MCR p15, 2, r7, c0, c0, 0
-	ldmia	r3!,{r4-r8}
-	/* Data TLB lockdown registers */
-	MCR p15, 0, r4, c10, c0, 0
-	/* Instruction TLB lockdown registers */
-	MCR p15, 0, r5, c10, c0, 1
-	/* Secure or Nonsecure Vector Base Address */
-	MCR p15, 0, r6, c12, c0, 0
-	/* FCSE PID */
-	MCR p15, 0, r7, c13, c0, 0
-	/* Context PID */
-	MCR p15, 0, r8, c13, c0, 1
-
-	ldmia	r3!,{r4-r5}
-	/* Primary memory remap register */
-	MCR p15, 0, r4, c10, c2, 0
-	/* Normal memory remap register */
-	MCR p15, 0, r5, c10, c2, 1
-
-	/* Restore cpsr */
-	ldmia	r3!,{r4}		@ load CPSR from SDRAM
-	msr	cpsr, r4		@ store cpsr
+	ldmia	r3!, {r4-r7}
+	mcr	p15, 0, r4, c1, c0, 2	@ Coprocessor access Control Register
+	mcr	p15, 0, r5, c2, c0, 0	@ TTBR0
+	mcr	p15, 0, r6, c2, c0, 1	@ TTBR1
+	mcr	p15, 0, r7, c2, c0, 2	@ TTBCR
+
+	ldmia	r3!,{r4-r6}
+	mcr	p15, 0, r4, c3, c0, 0	@ Domain access Control Register
+	mcr	p15, 0, r5, c10, c2, 0	@ PRRR
+	mcr	p15, 0, r6, c10, c2, 1	@ NMRR
+
+
+	ldmia	r3!,{r4-r7}
+	mcr	p15, 0, r4, c13, c0, 1	@ Context ID
+	mrc	p15, 0, r5, c12, c0, 0	@ Secure or NS vector base address
+	msr	cpsr, r6		@ store cpsr
+	mcr	p15, 0, r7, c13, c0, 2	@ User r/w thread and process ID
 
 	/* Enabling MMU here */
 	mrc	p15, 0, r7, c2, c0, 2 	@ Read TTBRControl
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/6] omap3: pm: Clear the SCTLR C bit in asm code to prevent data cache allocation
  2011-02-21 13:19 [PATCH 0/6] omap3: pm: Fixes for low power code Santosh Shilimkar
                   ` (3 preceding siblings ...)
  2011-02-21 13:19 ` [PATCH 4/6] omap3: pm: Remove un-necessary cp15 registers form low power cpu context Santosh Shilimkar
@ 2011-02-21 13:19 ` Santosh Shilimkar
  2011-02-21 13:19 ` [PATCH 6/6] omap3: pm: Use exported set_cr() instead of a custom one Santosh Shilimkar
  2011-03-03  1:22 ` [PATCH 0/6] omap3: pm: Fixes for low power code Kevin Hilman
  6 siblings, 0 replies; 10+ messages in thread
From: Santosh Shilimkar @ 2011-02-21 13:19 UTC (permalink / raw)
  To: linux-arm-kernel

On the newer ARM processors like CortexA8, CortexA9, the caches can be
speculatively loaded while they are getting flushed.

Clear the SCTLR C bit to prevent further data cache allocation as
part of cache clean routine

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/sleep34xx.S |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index 28baeb2..1e723bb 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -224,6 +224,12 @@ l1_logic_lost:
 	mrc	p15, 0, r4, c1, c0, 0	@ save control register
 	stmia	r8!, {r4}
 
+	/* Clear the SCTLR C bit to prevent further data cache allocation */
+	mrc	p15, 0, r0, c1, c0, 0
+	bic	r0, r0, #(1 << 2)	@ Disable the C bit
+	mcr	p15, 0, r0, c1, c0, 0
+	isb
+
 clean_caches:
 	/*
 	 * jump out to kernel flush routine
@@ -270,6 +276,12 @@ omap3_do_wfi:
 	nop
 	bl wait_sdrc_ok
 
+	mrc	p15, 0, r0, c1, c0, 0
+	tst	r0, #(1 << 2)		@ Check C bit enabled?
+	orreq	r0, r0, #(1 << 2)	@ Enable the C bit if cleared
+	mcreq	p15, 0, r0, c1, c0, 0
+	isb
+
 /*
  * ===================================
  * == Exit point from non-OFF modes ==
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/6] omap3: pm: Use exported set_cr() instead of a custom one.
  2011-02-21 13:19 [PATCH 0/6] omap3: pm: Fixes for low power code Santosh Shilimkar
                   ` (4 preceding siblings ...)
  2011-02-21 13:19 ` [PATCH 5/6] omap3: pm: Clear the SCTLR C bit in asm code to prevent data cache allocation Santosh Shilimkar
@ 2011-02-21 13:19 ` Santosh Shilimkar
  2011-03-03  1:22 ` [PATCH 0/6] omap3: pm: Fixes for low power code Kevin Hilman
  6 siblings, 0 replies; 10+ messages in thread
From: Santosh Shilimkar @ 2011-02-21 13:19 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the custom restore_control_register() and use the exported
set_cr() instead to set the system control register(SCTRL) value.

No functional change.

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/pm34xx.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 2f864e4..63a3e1d 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -311,11 +311,6 @@ static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static void restore_control_register(u32 val)
-{
-	__asm__ __volatile__ ("mcr p15, 0, %0, c1, c0, 0" : : "r" (val));
-}
-
 /* Function to restore the table entry that was modified for enabling MMU */
 static void restore_table_entry(void)
 {
@@ -337,7 +332,7 @@ static void restore_table_entry(void)
 	control_reg_value = __raw_readl(scratchpad_address
 					+ OMAP343X_CONTROL_REG_VALUE_OFFSET);
 	/* This will enable caches and prediction */
-	restore_control_register(control_reg_value);
+	set_cr(control_reg_value);
 }
 
 void omap_sram_idle(void)
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 0/6] omap3: pm: Fixes for low power code
  2011-02-21 13:19 [PATCH 0/6] omap3: pm: Fixes for low power code Santosh Shilimkar
                   ` (5 preceding siblings ...)
  2011-02-21 13:19 ` [PATCH 6/6] omap3: pm: Use exported set_cr() instead of a custom one Santosh Shilimkar
@ 2011-03-03  1:22 ` Kevin Hilman
  2011-03-04  6:54   ` Santosh Shilimkar
  2011-03-08 11:41   ` Santosh Shilimkar
  6 siblings, 2 replies; 10+ messages in thread
From: Kevin Hilman @ 2011-03-03  1:22 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Santosh,

Santosh Shilimkar <santosh.shilimkar@ti.com> writes:

> The series does below fixes to the omap3 low power code.
> 	1. Use supported ARMv7 instructions instead of the legacy ones
> 	2. Fix the MMU on sequence
> 	3. Fix the cache flush scenario when only L1 lost.
> 	4. Remove all un-necessary context save registers
> 	5. Disable C-bit before cache clean
> 	6. Use set_cr() exported API instead of custom one. 

Look like good cleanups, thanks.

> It's generated against mainline and tested with OMAP3630 ZOOM3.
> 	1. Renetion and off-mode mode in suspend - ok.
> 	2. Retention in idle - ok

Testing this series along with other PM changes queued up for mainline
(my pm-core branch), this doesn't work for me on 3630/Zoom3 (but works
fine on 3430/n900.)

Here's what I did using omap2plus_defconfig + enabling CPUidle

First tested suspend:

echo 4 > /debug/pm_debug/wakeup_timer_seconds 
echo mem > /sys/power/state

then, setup UART idle/wakeup:

echo 5 > /sys/devices/platform/omap/omap_uart.0/sleep_timeout 
echo 5 > /sys/devices/platform/omap/omap_uart.1/sleep_timeout 
echo 5 > /sys/devices/platform/omap/omap_uart.2/sleep_timeout 
echo 5 > /sys/devices/platform/omap/omap_uart.3/sleep_timeout 
echo enabled > /sys/devices/platform/serial8250.0/tty/ttyS0/power/wakeup 

then enabled idle:

echo 1 > /debug/pm_debug/sleep_while_idle  

As soon as I do this, it hangs.

Without your series, it's working fine for me.  Only after merging your
series it hangs.

Kevin


> The following changes since commit 85e2efbb1db9a18d218006706d6e4fbeb0216213:
>   Linus Torvalds (1):
>         Linux 2.6.38-rc5
>
> Santosh Shilimkar (6):
>   omap3: pm: Use amrv7 supported instructions instead of legacy cp15
>     ones
>   omap3: pm: Fix the mmu on sequence in the asm code
>   omap3: pm: Allow the cache clean when L1 is lost.
>   omap3: pm: Remove un-necessary cp15 registers form low power cpu
>     context
>   omap3: pm: Clear the SCTLR C bit in asm code to prevent data cache
>     allocation
>   omap3: pm: Use exported set_cr() instead of a custom one.
>
>  arch/arm/mach-omap2/pm34xx.c    |    7 +-
>  arch/arm/mach-omap2/sleep34xx.S |  223 ++++++++++++++-------------------------
>  2 files changed, 78 insertions(+), 152 deletions(-)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 0/6] omap3: pm: Fixes for low power code
  2011-03-03  1:22 ` [PATCH 0/6] omap3: pm: Fixes for low power code Kevin Hilman
@ 2011-03-04  6:54   ` Santosh Shilimkar
  2011-03-08 11:41   ` Santosh Shilimkar
  1 sibling, 0 replies; 10+ messages in thread
From: Santosh Shilimkar @ 2011-03-04  6:54 UTC (permalink / raw)
  To: linux-arm-kernel

> -----Original Message-----
> From: Kevin Hilman [mailto:khilman at ti.com]
> Sent: Thursday, March 03, 2011 6:53 AM
> To: Santosh Shilimkar
> Cc: linux-omap at vger.kernel.org; linux-arm-kernel at lists.infradead.org
> Subject: Re: [PATCH 0/6] omap3: pm: Fixes for low power code
>
> Hi Santosh,
>
> Santosh Shilimkar <santosh.shilimkar@ti.com> writes:
>
> > The series does below fixes to the omap3 low power code.
> > 	1. Use supported ARMv7 instructions instead of the legacy ones
> > 	2. Fix the MMU on sequence
> > 	3. Fix the cache flush scenario when only L1 lost.
> > 	4. Remove all un-necessary context save registers
> > 	5. Disable C-bit before cache clean
> > 	6. Use set_cr() exported API instead of custom one.
>
> Look like good cleanups, thanks.
>
> > It's generated against mainline and tested with OMAP3630 ZOOM3.
> > 	1. Renetion and off-mode mode in suspend - ok.
> > 	2. Retention in idle - ok
>
> Testing this series along with other PM changes queued up for
> mainline
> (my pm-core branch), this doesn't work for me on 3630/Zoom3 (but
> works fine on 3430/n900.)
>
> Here's what I did using omap2plus_defconfig + enabling CPUidle
>
> First tested suspend:
>
> echo 4 > /debug/pm_debug/wakeup_timer_seconds
> echo mem > /sys/power/state
>
> then, setup UART idle/wakeup:
>
> echo 5 > /sys/devices/platform/omap/omap_uart.0/sleep_timeout
> echo 5 > /sys/devices/platform/omap/omap_uart.1/sleep_timeout
> echo 5 > /sys/devices/platform/omap/omap_uart.2/sleep_timeout
> echo 5 > /sys/devices/platform/omap/omap_uart.3/sleep_timeout
> echo enabled >
> /sys/devices/platform/serial8250.0/tty/ttyS0/power/wakeup
>
> then enabled idle:
>
> echo 1 > /debug/pm_debug/sleep_while_idle
>
> As soon as I do this, it hangs.
>
> Without your series, it's working fine for me.  Only after merging
> your series it hangs.
>
Interesting. I was seeing cpuidle hang on my 3630 without this
Series when tested on mainline.
Will rebase this series on your pm-core branch and look
at the issue further.

Regards,
Santosh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 0/6] omap3: pm: Fixes for low power code
  2011-03-03  1:22 ` [PATCH 0/6] omap3: pm: Fixes for low power code Kevin Hilman
  2011-03-04  6:54   ` Santosh Shilimkar
@ 2011-03-08 11:41   ` Santosh Shilimkar
  1 sibling, 0 replies; 10+ messages in thread
From: Santosh Shilimkar @ 2011-03-08 11:41 UTC (permalink / raw)
  To: linux-arm-kernel

Kevin,

> -----Original Message-----
> From: Kevin Hilman [mailto:khilman at ti.com]
> Sent: Thursday, March 03, 2011 6:53 AM
> To: Santosh Shilimkar
> Cc: linux-omap at vger.kernel.org; linux-arm-kernel at lists.infradead.org
> Subject: Re: [PATCH 0/6] omap3: pm: Fixes for low power code
>
> Hi Santosh,
>
> Santosh Shilimkar <santosh.shilimkar@ti.com> writes:
>
> > The series does below fixes to the omap3 low power code.
> > 	1. Use supported ARMv7 instructions instead of the legacy ones
> > 	2. Fix the MMU on sequence
> > 	3. Fix the cache flush scenario when only L1 lost.
> > 	4. Remove all un-necessary context save registers
> > 	5. Disable C-bit before cache clean
> > 	6. Use set_cr() exported API instead of custom one.
>
> Look like good cleanups, thanks.
>
> > It's generated against mainline and tested with OMAP3630 ZOOM3.
> > 	1. Renetion and off-mode mode in suspend - ok.
> > 	2. Retention in idle - ok
>
> Testing this series along with other PM changes queued up for
> mainline
> (my pm-core branch), this doesn't work for me on 3630/Zoom3 (but
> works
> fine on 3430/n900.)
>
> Here's what I did using omap2plus_defconfig + enabling CPUidle
>
> First tested suspend:
>
> echo 4 > /debug/pm_debug/wakeup_timer_seconds
> echo mem > /sys/power/state
>
> then, setup UART idle/wakeup:
>
> echo 5 > /sys/devices/platform/omap/omap_uart.0/sleep_timeout
> echo 5 > /sys/devices/platform/omap/omap_uart.1/sleep_timeout
> echo 5 > /sys/devices/platform/omap/omap_uart.2/sleep_timeout
> echo 5 > /sys/devices/platform/omap/omap_uart.3/sleep_timeout
> echo enabled >
> /sys/devices/platform/serial8250.0/tty/ttyS0/power/wakeup
>
> then enabled idle:
>
> echo 1 > /debug/pm_debug/sleep_while_idle
>
> As soon as I do this, it hangs.
>
> Without your series, it's working fine for me.  Only after merging
> your series it hangs.
>

I rebased this series against latest pm-core branch which also
has Dave's THUMB2 series merged.

After few trials I managed to reproduce the issue. With
above steps it was still working for me but with off mode
enabled, I saw a lock-up in suspend. Further debugging, I
found that one CP15 register save/restore position was
swapped which lead to this. I fixed that.

I have pushed the rebased series on below branch.

git://dev.omapzoom.org/pub/scm/santosh/kernel-omap4-base.git
pm-core-omap3-asm

Regards,
Santosh

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-03-08 11:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-21 13:19 [PATCH 0/6] omap3: pm: Fixes for low power code Santosh Shilimkar
2011-02-21 13:19 ` [PATCH 1/6] omap3: pm: Use amrv7 supported instructions instead of legacy cp15 ones Santosh Shilimkar
2011-02-21 13:19 ` [PATCH 2/6] omap3: pm: Fix the mmu on sequence in the asm code Santosh Shilimkar
2011-02-21 13:19 ` [PATCH 3/6] omap3: pm: Allow the cache clean when L1 is lost Santosh Shilimkar
2011-02-21 13:19 ` [PATCH 4/6] omap3: pm: Remove un-necessary cp15 registers form low power cpu context Santosh Shilimkar
2011-02-21 13:19 ` [PATCH 5/6] omap3: pm: Clear the SCTLR C bit in asm code to prevent data cache allocation Santosh Shilimkar
2011-02-21 13:19 ` [PATCH 6/6] omap3: pm: Use exported set_cr() instead of a custom one Santosh Shilimkar
2011-03-03  1:22 ` [PATCH 0/6] omap3: pm: Fixes for low power code Kevin Hilman
2011-03-04  6:54   ` Santosh Shilimkar
2011-03-08 11:41   ` Santosh Shilimkar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).