Skip to contentSkip to conversation

ARM: allocate pre-relocation global_data on pre-relocation stack

PATCH New Reinhard Meyer 3 participants 7 messages Nov 14, 2010 – Nov 28, 2010 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: allocate pre-relocation global_data on pre-relocation stack

That removes the need to reserve memory above the stack and also removes the need for GENERATED_GBL_DATA_SIZE. Alignment is automatically "right" provided stack is aligned.

---
 arch/arm/lib/board.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
arch/arm/lib/board.c +3 -2
index 1fd5f83..53e0f4f 100644
@@ -274,11 +274,12 @@ void board_init_f (ulong bootflag)
 	init_fnc_t **init_fnc_ptr;
 	gd_t *id;
 	ulong addr, addr_sp;
+	gd_t auto_gd;
 
 	/* Pointer is writable since we allocated a register for it */
-	gd = (gd_t *) (CONFIG_SYS_INIT_SP_ADDR);
+	gd = &auto_gd;
 	/* compiler optimization barrier needed for GCC >= 3.4 */
-	__asm__ __volatile__("": : :"memory");
+	/* __asm__ __volatile__("": : :"memory"); */
 
 	memset ((void*)gd, 0, sizeof (gd_t));
 
Signature · 1 line
1.5.6.5
#1 lore raw

PATCH 1/1 ARM: allocate pre-relocation global_data on pre-relocation stack

Dear Reinhard Meyer,

Quoted 6 lines · In message <[email protected]> you…

That removes the need to reserve memory above the stack and also removes the need for GENERATED_GBL_DATA_SIZE. Alignment is automatically "right" provided stack is aligned.

Has this patch been tested? If so, in which way and on which SoCs and boards?

#2 lore raw

PATCH 1/1 ARM: allocate pre-relocation global_data on pre-relocation stack

In reply to Reinhard Meyer
Quoted 19 lines

That removes the need to reserve memory above the stack and also removes the need for GENERATED_GBL_DATA_SIZE. Alignment is automatically "right" provided stack is aligned.

---
 arch/arm/lib/board.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
arch/arm/lib/board.c +1 -0
index 1fd5f83..53e0f4f 100644
@@ -274,11 +274,12 @@ void board_init_f (ulong bootflag)
 	init_fnc_t **init_fnc_ptr;
 	gd_t *id;
 	ulong addr, addr_sp;
+	gd_t auto_gd;

arch/arm/lib/board.c void board_init_f (ulong bootflag) · line 285

Quoted 10 lines
arch/arm/lib/board.c +2 -2
 
 	/* Pointer is writable since we allocated a register for it */
-	gd = (gd_t *) (CONFIG_SYS_INIT_SP_ADDR);
+	gd = &auto_gd;
 	/* compiler optimization barrier needed for GCC >= 3.4 */
-	__asm__ __volatile__("": : :"memory");
+	/* __asm__ __volatile__("": : :"memory"); */
 
 	memset ((void*)gd, 0, sizeof (gd_t));
 

Are there any objections to this patch now?
I can provide a V2 where the "compiler optimization barrier" stuff is completely removed.

Tested on: at91sam9xe / arm926ejs / top9000 and at91sam9xe-ek boards.

Best Regards,
Reinhard

#3 lore raw

PATCH 1/1 ARM: allocate pre-relocation global_data on pre-relocation stack

Le 18/11/2010 14:53, Reinhard Meyer a ?crit :

Quoted 27 lines
Quoted 27 lines

That removes the need to reserve memory above the stack and also removes the need for GENERATED_GBL_DATA_SIZE. Alignment is automatically "right" provided stack is aligned.

---
  arch/arm/lib/board.c |    5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)
arch/arm/lib/board.c +3 -2
index 1fd5f83..53e0f4f 100644
@@ -274,11 +274,12 @@ void board_init_f (ulong bootflag)
  	init_fnc_t **init_fnc_ptr;
  	gd_t *id;
  	ulong addr, addr_sp;
+	gd_t auto_gd;
 
  	/* Pointer is writable since we allocated a register for it */
-	gd = (gd_t *) (CONFIG_SYS_INIT_SP_ADDR);
+	gd =&auto_gd;
  	/* compiler optimization barrier needed for GCC>= 3.4 */
-	__asm__ __volatile__("": : :"memory");
+	/* __asm__ __volatile__("": : :"memory"); */
 
Quoted 8 lines

arch/arm/lib/board.c void board_init_f (ulong bootflag) · line 285

Quoted 2 lines
arch/arm/lib/board.c +0 -0
  	memset ((void*)gd, 0, sizeof (gd_t));
 

Are there any objections to this patch now?
I can provide a V2 where the "compiler optimization barrier" stuff is completely removed.

Tested on: at91sam9xe / arm926ejs / top9000 and at91sam9xe-ek boards.

I'm probably lagging behind... How do you ensure that the pre-relocation GD content ends up in the post-relocation GD (which cannot be that stack variable since the stack is going to be somewhere else)?

Quoted 2 lines

Best Regards,
Reinhard

Amicalement,

Signature · 1 line
Albert.
#4 lore raw

PATCH 1/1 ARM: allocate pre-relocation global_data on pre-relocation stack

Dear Albert ARIBAUD,

Quoted 35 lines

Le 18/11/2010 14:53, Reinhard Meyer a ?crit :

Quoted 34 lines
Quoted 19 lines

That removes the need to reserve memory above the stack and also removes the need for GENERATED_GBL_DATA_SIZE. Alignment is automatically "right" provided stack is aligned.

---
arch/arm/lib/board.c | 5 +++--

1 files changed, 3 insertions(+), 2 deletions(-)
arch/arm/lib/board.c +1 -0
index 1fd5f83..53e0f4f 100644
@@ -274,11 +274,12 @@ void board_init_f (ulong bootflag)
 init_fnc_t **init_fnc_ptr;
 gd_t *id;
 ulong addr, addr_sp;
+ gd_t auto_gd;

arch/arm/lib/board.c void board_init_f (ulong bootflag) · line 285

Quoted 10 lines
arch/arm/lib/board.c +2 -2
 
 /* Pointer is writable since we allocated a register for it */
- gd = (gd_t *) (CONFIG_SYS_INIT_SP_ADDR);
+ gd =&auto_gd;
 /* compiler optimization barrier needed for GCC>= 3.4 */
- __asm__ __volatile__("": : :"memory");
+ /* __asm__ __volatile__("": : :"memory"); */
 
 memset ((void*)gd, 0, sizeof (gd_t));
 

Are there any objections to this patch now?
I can provide a V2 where the "compiler optimization barrier" stuff is completely removed.

Quoted 3 lines
Quoted 1 line

Tested on: at91sam9xe / arm926ejs / top9000 and at91sam9xe-ek boards.

I'm probably lagging behind... How do you ensure that the pre-relocation GD content ends up in the post-relocation GD (which cannot be that stack variable since the stack is going to be somewhere else)?

Check the function yourself:
there is a memcpy of this GD to an area in SDRAM at the end...

Best Regards,
Reinhard

#5 lore raw

PATCH 1/1 ARM: allocate pre-relocation global_data on pre-relocation stack

Le 18/11/2010 21:43, Reinhard Meyer a ?crit :

Quoted 4 lines
Quoted 1 line

I'm probably lagging behind... How do you ensure that the pre-relocation GD content ends up in the post-relocation GD (which cannot be that stack variable since the stack is going to be somewhere else)?

Check the function yourself:
there is a memcpy of this GD to an area in SDRAM at the end...

Apologies: I *was* indeed lagging behind.

Quoted 2 lines

Best Regards,
Reinhard

Amicalement,

Signature · 1 line
Albert.
#6 lore raw

PATCH 1/1 ARM: allocate pre-relocation global_data on pre-relocation stack

Dear Albert ARIBAUD,

Quoted 8 lines

Le 18/11/2010 21:43, Reinhard Meyer a ?crit :

Quoted 4 lines
Quoted 1 line

I'm probably lagging behind... How do you ensure that the pre-relocation GD content ends up in the post-relocation GD (which cannot be that stack variable since the stack is going to be somewhere else)?

Check the function yourself:
there is a memcpy of this GD to an area in SDRAM at the end...

Apologies: I *was* indeed lagging behind.

So what is going to happen about this patch?
I see no objections or complaints anywhere, but I see boards getting fixed using GENERATED_GBL_DATA_SIZE.

Note that using GENERATED_GBL_DATA_SIZE does not break with my patch, it just wastes space.

Best Regards,
Reinhard