linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Simplify the code in arch/arm/kernel/sleep.S a bit
@ 2011-05-31 16:08 Eric Miao
  0 siblings, 0 replies; only message in thread
From: Eric Miao @ 2011-05-31 16:08 UTC (permalink / raw)
  To: linux-arm-kernel

Russell,

While reading arch/arm/kernel/sleep.S, actually felt a bit redundancy
of the code handling MULTI_CPU and otherwise. Will something like
below be a bit simpler, though I didn't test it and I know the performance
will be worse (yet I'd argue here it's on the path of suspend/resume, not
really a hotspot).

And further more, does it even make sense to make MULTI_CPU always
true, even when handling a kernel supporting only one core? I believe
we can get rid of many lines and still keep the code generic. Although
I don't have a sense of how it's going to impact the performance.

diff --git a/arch/arm/kernel/sleep.S b/arch/arm/kernel/sleep.S
index 6398ead..ab47c95 100644
--- a/arch/arm/kernel/sleep.S
+++ b/arch/arm/kernel/sleep.S
@@ -12,15 +12,22 @@
  *  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
+ * r0-r3,r8,r9,r10,lr corrupted
  */
 ENTRY(cpu_suspend)
 	mov	r9, lr
 #ifdef MULTI_CPU
 	ldr	r10, =processor
+	ldr	r0, [r10, #CPU_SLEEP_SIZE]
+	ldr	r8, [r10, #CPU_DO_SUSPEND]
+	ldr	ip, [r10, #CPU_DO_RESUME]
+#else
+	ldr	r0, =cpu_suspend_size
+	ldr	r8, =cpu_do_suspend
+	ldr	ip, =cpu_do_resume
+#endif
+
 	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
@@ -36,25 +43,7 @@ ENTRY(cpu_suspend)
 	str	r2, [r3]		@ save phys SP
 #endif
 	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
-#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
+	mov	pc, r8			@ cpu_do_suspend

 	@ flush data cache
 #ifdef MULTI_CACHE
@@ -120,20 +109,12 @@ ENTRY(cpu_resume)
 	ldr	r0, sleep_save_sp	@ stack phys addr
 #endif
 	setmode	PSR_I_BIT | PSR_F_BIT | SVC_MODE, r1  @ set SVC, irqs off
-#ifdef MULTI_CPU
 	@ load v:p, stack, return fn, resume fn
   ARM(	ldmia	r0!, {r1, sp, lr, pc}	)
 THUMB(	ldmia	r0!, {r1, r2, r3, r4}	)
 THUMB(	mov	sp, r2			)
 THUMB(	mov	lr, r3			)
 THUMB(	bx	r4			)
-#else
-	@ load v:p, stack, return fn
-  ARM(	ldmia	r0!, {r1, sp, lr}	)
-THUMB(	ldmia	r0!, {r1, r2, lr}	)
-THUMB(	mov	sp, r2			)
-	b	cpu_do_resume
-#endif
 ENDPROC(cpu_resume)

 sleep_save_sp:

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-31 16:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-31 16:08 [RFC] Simplify the code in arch/arm/kernel/sleep.S a bit Eric Miao

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).