diff mbox

[U-Boot] armv7: Fix to mistake clean the memory space

Message ID 1341498915-19127-1-git-send-email-bocui107@gmail.com
State Superseded
Delegated to: Albert ARIBAUD
Headers show

Commit Message

seedshope July 5, 2012, 2:35 p.m. UTC
From: Zhong Hongbo <bocui107@gmail.com>

In currently, when __bss_start is equal to __bss_end__,
The bss loop will clear all the things in memory space.

But just only when __bss_end__ greater than __bss_start__,
we do the clear bss section operation.

Signed-off-by: Hongbo Zhong <bocui107@gmail.com>
---
 arch/arm/cpu/armv7/start.S |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

Comments

Andreas Bießmann July 5, 2012, 3:38 p.m. UTC | #1
Dear Zhong Hongbo,

this is arm related and should therefore apply to all the different
arch/arm/cpu/*/start.S (as long as they have SPL support).

On 05.07.2012 16:35, Zhong Hongbo wrote:
> From: Zhong Hongbo <bocui107@gmail.com>
> 
> In currently, when __bss_start is equal to __bss_end__,
> The bss loop will clear all the things in memory space.

I ask myself why there is no bss at all. Have you just initialized data
in your spl code?

> 
> But just only when __bss_end__ greater than __bss_start__,
> we do the clear bss section operation.
> 
> Signed-off-by: Hongbo Zhong <bocui107@gmail.com>
> ---
>  arch/arm/cpu/armv7/start.S |    9 ++++++---
>  1 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
> index 22a3ced..2e583ee 100644
> --- a/arch/arm/cpu/armv7/start.S
> +++ b/arch/arm/cpu/armv7/start.S
> @@ -259,10 +259,13 @@ clear_bss:
>  #endif
>  	mov	r2, #0x00000000		/* clear			    */
>  
> -clbss_l:str	r2, [r0]		/* clear loop...		    */
> +clbss_l:
> +	cmp	r1, r0
> +	bls	clbss_end
> +	str	r2, [r0]		/* clear loop...		    */
>  	add	r0, r0, #4
> -	cmp	r0, r1
> -	bne	clbss_l
> +	b	clbss_l
> +clbss_end:

Looks sane, I maybe had checked before clbss_l, jumped over clear loop
if r0 and r1 equal (to emphasize the fact that this is a check for entry
correctness) and wouldn't change the loop at all. To be more precise we
could also check if end is after start.

>  
>  /*
>   * We are done. Do not return, instead branch to second part of board
> 

Best regards

Andreas Bießmann
Andreas Bießmann July 5, 2012, 3:52 p.m. UTC | #2
On 05.07.2012 17:38, Andreas Bießmann wrote:

<snip>

>> -clbss_l:str	r2, [r0]		/* clear loop...		    */
>> +clbss_l:
>> +	cmp	r1, r0
>> +	bls	clbss_end
>> +	str	r2, [r0]		/* clear loop...		    */
>>  	add	r0, r0, #4
>> -	cmp	r0, r1
>> -	bne	clbss_l
>> +	b	clbss_l
>> +clbss_end:
> 
> Looks sane, I maybe had checked before clbss_l, jumped over clear loop
> if r0 and r1 equal (to emphasize the fact that this is a check for entry
> correctness) and wouldn't change the loop at all. To be more precise we
> could also check if end is after start.

Well, I just realized you do check for less ;)
Albert ARIBAUD July 6, 2012, 5:44 a.m. UTC | #3
Hi Zhong,

On Thu,  5 Jul 2012 22:35:15 +0800, Zhong Hongbo <bocui107@gmail.com> wrote:
> From: Zhong Hongbo <bocui107@gmail.com>
> 
> In currently, when __bss_start is equal to __bss_end__,
> The bss loop will clear all the things in memory space.
> 
> But just only when __bss_end__ greater than __bss_start__,
> we do the clear bss section operation.
> 
> Signed-off-by: Hongbo Zhong <bocui107@gmail.com>
> ---
>  arch/arm/cpu/armv7/start.S |    9 ++++++---
>  1 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
> index 22a3ced..2e583ee 100644
> --- a/arch/arm/cpu/armv7/start.S
> +++ b/arch/arm/cpu/armv7/start.S
> @@ -259,10 +259,13 @@ clear_bss:
>  #endif
>  	mov	r2, #0x00000000		/* clear			    */
>  
> -clbss_l:str	r2, [r0]		/* clear loop...		    */
> +clbss_l:
> +	cmp	r1, r0
> +	bls	clbss_end
> +	str	r2, [r0]		/* clear loop...		    */
>  	add	r0, r0, #4
> -	cmp	r0, r1
> -	bne	clbss_l
> +	b	clbss_l
> +clbss_end:
>  
>  /*
>   * We are done. Do not return, instead branch to second part of board

Just checking: that's the same as your 'infinite' patch, right?

Amicalement,
seedshope July 6, 2012, 11:31 a.m. UTC | #4
On 07/05/2012 11:52 PM, Andreas Bießmann wrote:
> On 05.07.2012 17:38, Andreas Bießmann wrote:
> 
> <snip>
> 
>>> -clbss_l:str	r2, [r0]		/* clear loop...		    */
>>> +clbss_l:
>>> +	cmp	r1, r0
>>> +	bls	clbss_end
>>> +	str	r2, [r0]		/* clear loop...		    */
>>>  	add	r0, r0, #4
>>> -	cmp	r0, r1
>>> -	bne	clbss_l
>>> +	b	clbss_l
>>> +clbss_end:
>>
>> Looks sane, I maybe had checked before clbss_l, jumped over clear loop
>> if r0 and r1 equal (to emphasize the fact that this is a check for entry
>> correctness) and wouldn't change the loop at all. To be more precise we
>> could also check if end is after start.
> 
> Well, I just realized you do check for less ;)
> 
Yes,

Thanks,
hongbo
seedshope July 6, 2012, 11:35 a.m. UTC | #5
On 07/06/2012 01:44 PM, Albert ARIBAUD wrote:
> Hi Zhong,
> 
> On Thu,  5 Jul 2012 22:35:15 +0800, Zhong Hongbo <bocui107@gmail.com> wrote:
>> From: Zhong Hongbo <bocui107@gmail.com>
>>
>> In currently, when __bss_start is equal to __bss_end__,
>> The bss loop will clear all the things in memory space.
>>
>> But just only when __bss_end__ greater than __bss_start__,
>> we do the clear bss section operation.
>>
>> Signed-off-by: Hongbo Zhong <bocui107@gmail.com>
>> ---
>>  arch/arm/cpu/armv7/start.S |    9 ++++++---
>>  1 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
>> index 22a3ced..2e583ee 100644
>> --- a/arch/arm/cpu/armv7/start.S
>> +++ b/arch/arm/cpu/armv7/start.S
>> @@ -259,10 +259,13 @@ clear_bss:
>>  #endif
>>  	mov	r2, #0x00000000		/* clear			    */
>>  
>> -clbss_l:str	r2, [r0]		/* clear loop...		    */
>> +clbss_l:
>> +	cmp	r1, r0
>> +	bls	clbss_end
>> +	str	r2, [r0]		/* clear loop...		    */
>>  	add	r0, r0, #4
>> -	cmp	r0, r1
>> -	bne	clbss_l
>> +	b	clbss_l
>> +clbss_end:
>>  
>>  /*
>>   * We are done. Do not return, instead branch to second part of board
> 
> Just checking: that's the same as your 'infinite' patch, right?
You are right. I think the description(V1 patch) have not very clear, So
I modify it.

Thanks,
hongbo
> 
> Amicalement,
>
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index 22a3ced..2e583ee 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -259,10 +259,13 @@  clear_bss:
 #endif
 	mov	r2, #0x00000000		/* clear			    */
 
-clbss_l:str	r2, [r0]		/* clear loop...		    */
+clbss_l:
+	cmp	r1, r0
+	bls	clbss_end
+	str	r2, [r0]		/* clear loop...		    */
 	add	r0, r0, #4
-	cmp	r0, r1
-	bne	clbss_l
+	b	clbss_l
+clbss_end:
 
 /*
  * We are done. Do not return, instead branch to second part of board