Skip to contentSkip to conversation

mpc83xx: remove some dead code, saving space

PATCH New Joakim Tjernlund 4 participants 9 messages Nov 23, 2010 – Dec 1, 2010 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mpc83xx: remove some dead code, saving space

---
 arch/powerpc/cpu/mpc83xx/start.S |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
arch/powerpc/cpu/mpc83xx/start.S +0 -7
index f7da14b..121c276 100644
@@ -967,13 +967,6 @@ relocate_code:
 30:	li r3, 0
 	blr
 
-2:	slwi	r0,r0,2 /* re copy in reverse order ... y do we needed it? */
-	add	r8,r4,r0
-	add	r7,r3,r0
-3:	lwzu	r0,-4(r8)
-	stwu	r0,-4(r7)
-	bdnz	3b
-
 /*
  * Now flush the cache: note that we must start from a cache aligned
  * address. Otherwise we might miss one cache line.
Signature · 1 line
1.7.2.2
#2 lore raw

PATCH 1/1 mpc83xx: remove some dead code, saving space

In reply to Joakim Tjernlund

Dear Joakim Tjernlund,

Quoted 11 lines · In message <[email protected]>…
---
 arch/powerpc/cpu/mpc83xx/start.S |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
arch/powerpc/cpu/mpc83xx/start.S +0 -0
index f7da14b..121c276 100644

arch/powerpc/cpu/mpc83xx/start.S relocate_code: · line 976

Quoted 10 lines
arch/powerpc/cpu/mpc83xx/start.S +0 -7
@@ -967,13 +967,6 @@ relocate_code:
 30:	li r3, 0
 	blr
 
-2:	slwi	r0,r0,2 /* re copy in reverse order ... y do we needed it? */
-	add	r8,r4,r0
-	add	r7,r3,r0
-3:	lwzu	r0,-4(r8)
-	stwu	r0,-4(r7)
-	bdnz	3b
-

Why do you think this is dead code?

I see this about 30 lines above:

...

 851         cmplw   cr1,r3,r4
 852         addi    r0,r5,3
 853         srwi.   r0,r0,2
 854         beq     cr1,4f          /* In place copy is not necessary
*/
 855         beq     7f              /* Protect against 0 count
*/
 856         mtctr   r0
 857         bge     cr1,2f

...

With your removal of the code, the "bge cr1,2f" will jump right
into the relocation loop. I don't think this is intended?

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Good manners are the settled  medium  of  social,  as  specie  is  of
commercial, life; returns are equally expected for both.
           - Lord Chesterfield _Letters to his Son_, 25 December 1753
#3 lore raw

PATCH 1/1 mpc83xx: remove some dead code, saving space

Quoted 40 lines

Dear Joakim Tjernlund,

Quoted 11 lines · In message <[email protected]>…
---
 arch/powerpc/cpu/mpc83xx/start.S |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
arch/powerpc/cpu/mpc83xx/start.S +0 -0
index f7da14b..121c276 100644

arch/powerpc/cpu/mpc83xx/start.S relocate_code: · line 976

Quoted 10 lines
arch/powerpc/cpu/mpc83xx/start.S +0 -7
@@ -967,13 +967,6 @@ relocate_code:
 30:   li r3, 0
    blr
 
-2:   slwi   r0,r0,2 /* re copy in reverse order ... y do we needed it? */
-   add   r8,r4,r0
-   add   r7,r3,r0
-3:   lwzu   r0,-4(r8)
-   stwu   r0,-4(r7)
-   bdnz   3b
-

Why do you think this is dead code?

I see this about 30 lines above:

...

 851         cmplw   cr1,r3,r4
 852         addi    r0,r5,3
 853         srwi.   r0,r0,2
 854         beq     cr1,4f          /* In place copy is not necessary
*/
 855         beq     7f              /* Protect against 0 count
*/
 856         mtctr   r0
 857         bge     cr1,2f
Quoted 4 lines

...

With your removal of the code, the "bge cr1,2f" will jump right
into the relocation loop. I don't think this is intended?

Ah, sharp eyes! Didn't notice that branch. I do think that
bge could be removed as well. It will only matter if the src and dst overlap and the distance between them is < 4 bytes.
Anyhow, we don't need to remove this code now.

On a related note, I am not sure why the I and D cache needs to be flushed, aren't they coherent?

Jocke

#4 lore raw

PATCH 1/1 mpc83xx: remove some dead code, saving space

Quoted 2 lines · On Tue, 30 Nov 2010 21:45:19 +0100 Joakim Tjernlund…

On a related note, I am not sure why the I and D cache needs to be flushed, aren't they coherent?

They are not.

-Scott

#5 lore raw

PATCH 1/1 mpc83xx: remove some dead code, saving space

Scott Wood <[email protected]> wrote on 2010/11/30 21:50:52:

Quoted 8 lines
Quoted 2 lines · On Tue, 30 Nov 2010 21:45:19 +0100 Joakim Tjernlund…

On a related note, I am not sure why the I and D cache needs to be flushed, aren't they coherent?

They are not.

Ah, I figured they would be these days.
I doubt one needs to invalidate the icache though? Better safe than sorry I guess, one could probably optimize it a little bit though.

Jocke

#6 lore raw

PATCH 1/1 mpc83xx: remove some dead code, saving space

Quoted 11 lines · On Tue, 30 Nov 2010 22:13:32 +0100 Joakim Tjernlund…

Scott Wood <[email protected]> wrote on 2010/11/30 21:50:52:

Quoted 8 lines
Quoted 2 lines · On Tue, 30 Nov 2010 21:45:19 +0100 Joakim Tjernlund…

On a related note, I am not sure why the I and D cache needs to be flushed, aren't they coherent?

They are not.

Ah, I figured they would be these days.

Nope, I've seen weird stuff happen when I forget to sync the icache even on very recent chips (albeit 85xx and not 83xx).

Quoted 3 lines

I doubt one needs to invalidate the icache though? Better safe than sorry I guess, one could probably optimize it a little bit though.

You need to flush the dcache and then invalidate the icache.

-Scott

#7 lore raw

PATCH 1/1 mpc83xx: remove some dead code, saving space

Scott Wood <[email protected]> wrote on 2010/11/30 22:17:31:

Quoted 16 lines
Quoted 11 lines · On Tue, 30 Nov 2010 22:13:32 +0100 Joakim Tjernlund…

Scott Wood <[email protected]> wrote on 2010/11/30 21:50:52:

Quoted 8 lines
Quoted 2 lines · On Tue, 30 Nov 2010 21:45:19 +0100 Joakim Tjernlund…

On a related note, I am not sure why the I and D cache needs to be flushed, aren't they coherent?

They are not.

Ah, I figured they would be these days.

Quoted 8 lines

Nope, I've seen weird stuff happen when I forget to sync the icache even on very recent chips (albeit 85xx and not 83xx).

Quoted 3 lines

I doubt one needs to invalidate the icache though? Better safe than sorry I guess, one could probably optimize it a little bit though.

You need to flush the dcache and then invalidate the icache.

but if one haven't executed any insn's at the new location yet there should not be any cache lines in the icache that match the new location.

#8 lore raw

PATCH 1/1 mpc83xx: remove some dead code, saving space

Quoted 24 lines · On Tue, 30 Nov 2010 22:25:11 +0100 Joakim Tjernlund…

Scott Wood <[email protected]> wrote on 2010/11/30 22:17:31:

Quoted 23 lines
Quoted 11 lines · On Tue, 30 Nov 2010 22:13:32 +0100 Joakim Tjernlund…

Scott Wood <[email protected]> wrote on 2010/11/30 21:50:52:

Quoted 8 lines
Quoted 2 lines · On Tue, 30 Nov 2010 21:45:19 +0100 Joakim Tjernlund…

On a related note, I am not sure why the I and D cache needs to be flushed, aren't they coherent?

They are not.

Ah, I figured they would be these days.

Nope, I've seen weird stuff happen when I forget to sync the icache even on very recent chips (albeit 85xx and not 83xx).

Quoted 3 lines

I doubt one needs to invalidate the icache though? Better safe than sorry I guess, one could probably optimize it a little bit though.

Quoted 5 lines
Quoted 1 line

You need to flush the dcache and then invalidate the icache.

but if one haven't executed any insn's at the new location yet there should not be any cache lines in the icache that match the new location.

Ah. That's a special case. :-)

Still, better to set a good example.

-Scott