Skip to contentSkip to conversation

arm: armv7: omap3: Fix restore sequence in lowlevel_init

PATCH New Albert ARIBAUD 3 participants 3 messages Oct 7, 2012 – Oct 8, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 arm: armv7: omap3: Fix restore sequence in lowlevel_init

The restore sequence in lowlevel_init was in the wrong order, causing lr to lose its original value and be set equal to ip instead. Also, its use of the stack clashes with that of s_init, so move the s_init call after the restore and turn it into a tail-optimized branch.

---
V2: move s_init call after restore and tail-optimize it into a branch
V1: fix order of restores

 arch/arm/cpu/armv7/omap3/lowlevel_init.S |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
arch/arm/cpu/armv7/omap3/lowlevel_init.S +4 -5
index ebf69fa..eacfef8 100644
@@ -214,7 +214,7 @@ pll_div_val5:
 
 ENTRY(lowlevel_init)
 	ldr	sp, SRAM_STACK
-	str	ip, [sp]	/* stash old link register */
+	str	ip, [sp]	/* stash ip register */
 	mov	ip, lr		/* save link reg across call */
 #if !defined(CONFIG_SYS_NAND_BOOT) && !defined(CONFIG_SYS_ONENAND_BOOT)
 /*
@@ -224,12 +224,11 @@ ENTRY(lowlevel_init)
 	ldr	r1, =SRAM_CLK_CODE
 	bl	cpy_clk_code
 #endif /* NAND Boot */
-	bl	s_init		/* go setup pll, mux, memory */
-	ldr	ip, [sp]	/* restore save ip */
 	mov	lr, ip		/* restore link reg */
+	ldr	ip, [sp]	/* restore save ip */
+	/* tail-call s_init to setup pll, mux, memory */
+	b	s_init
 
-	/* back to arch calling code */
-	mov	pc, lr
 ENDPROC(lowlevel_init)
 
 	/* the literal pools origin */
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/1 arm: armv7: omap3: Fix restore sequence in lowlevel_init

Quoted 33 lines · Albert ARIBAUD

The restore sequence in lowlevel_init was in the wrong order, causing lr to lose its original value and be set equal to ip instead. Also, its use of the stack clashes with that of s_init, so move the s_init call after the restore and turn it into a tail-optimized branch.

---
V2: move s_init call after restore and tail-optimize it into a branch
V1: fix order of restores

  arch/arm/cpu/armv7/omap3/lowlevel_init.S |    9 ++++-----
  1 file changed, 4 insertions(+), 5 deletions(-)
arch/arm/cpu/armv7/omap3/lowlevel_init.S +1 -3
index ebf69fa..eacfef8 100644
@@ -214,7 +214,7 @@ pll_div_val5:
 
  ENTRY(lowlevel_init)
  	ldr	sp, SRAM_STACK
-	str	ip, [sp]	/* stash old link register */
+	str	ip, [sp]	/* stash ip register */
  	mov	ip, lr		/* save link reg across call */
  #if !defined(CONFIG_SYS_NAND_BOOT) && !defined(CONFIG_SYS_ONENAND_BOOT)
  /*
@@ -224,12 +224,11 @@ ENTRY(lowlevel_init)
  	ldr	r1, =SRAM_CLK_CODE
  	bl	cpy_clk_code
  #endif /* NAND Boot */
-	bl	s_init		/* go setup pll, mux, memory */
-	ldr	ip, [sp]	/* restore save ip */

arch/arm/cpu/armv7/omap3/lowlevel_init.S ENTRY(lowlevel_init) · line 234

Quoted 10 lines
arch/arm/cpu/armv7/omap3/lowlevel_init.S +3 -2
  	mov	lr, ip		/* restore link reg */
+	ldr	ip, [sp]	/* restore save ip */
+	/* tail-call s_init to setup pll, mux, memory */
+	b	s_init
 
-	/* back to arch calling code */
-	mov	pc, lr
  ENDPROC(lowlevel_init)
 
  	/* the literal pools origin */

on a tam3517 SOM (am3517 mcu) derived board.

Regards,
Jeroen

#2 lore raw

PATCH v2 1/1 arm: armv7: omap3: Fix restore sequence in lowlevel_init

In reply to Albert ARIBAUD
Quoted 8 lines · Albert ARIBAUD

The restore sequence in lowlevel_init was in the wrong order, causing lr to lose its original value and be set equal to ip instead. Also, its use of the stack clashes with that of s_init, so move the s_init call after the restore and turn it into a tail-optimized branch.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121008/096afbcb/attachment.pgp>