[U-Boot] [PATCH] MPC512x: workaround data corruption forunaligned local bus accesses

Steve Deiters SteveDeiters at BASLER.com
Tue Jun 29 18:19:00 CEST 2010


> -----Original Message-----
> From: u-boot-bounces at lists.denx.de 
> [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Wolfgang Denk
> Sent: Tuesday, June 29, 2010 7:56 AM
> To: Joakim Tjernlund
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH] MPC512x: workaround data 
> corruption forunaligned local bus accesses
> 
> Dear Joakim Tjernlund,
> 
> In message 
> <OFEB4E68BC.F6B8C9D0-ONC1257751.0045AE08-C1257751.0045DA56 at tra
> nsmode.se> you wrote:
> >
> > > I could not come up with a better name... What is "align32wrap"
> > > supposed to mean?
> > 
> > mpc5200_memcpy_fromio() resp. mpc5200_memcpy_toio()?
> 
> No. It's not only MPC5200, but also MPC521x. It's not I/O in 
> general, but only I/O from the Local Bus. And even then only 
> unaliged read access.
> 
> But memcpy_for_unaligned_read_from_local_bus() was too long 
> for me, and memcpy_furflb() too cryptic ;-)
> 
> Best regards,
> 
> Wolfgang Denk

I just posted a patch on the linuxppc-dev list that simply uses a
slightly modified version of memcpy to always keep the source address
aligned.  I had conditionals in that one so it only used it for MPC512x
or MPC52xx but you should be able to replace the regular memcpy with
this version.  This way you can avoid the wrappers and extra checks.  It
is a simple enough change in that case:


diff --git a/arch/powerpc/lib/ppcstring.S b/arch/powerpc/lib/ppcstring.S
index 97023a0..4e17265 100644
--- a/arch/powerpc/lib/ppcstring.S
+++ b/arch/powerpc/lib/ppcstring.S
@@ -114,7 +114,7 @@ memcpy:
 	addi	r6,r3,-4
 	addi	r4,r4,-4
 	beq	2f			/* if less than 8 bytes to do */
-	andi.	r0,r6,3			/* get dest word aligned */
+	andi.	r0,r4,3			/* get src word aligned */
 	mtctr	r7
 	bne	5f
 1:	lwz	r7,4(r4)
@@ -125,6 +125,8 @@ memcpy:
 	andi.	r5,r5,7
 2:	cmplwi	0,r5,4
 	blt	3f
+	andi.	r0,r4,3
+	bne	3f
 	lwzu	r0,4(r4)
 	addi	r5,r5,-4
 	stwu	r0,4(r6)


More information about the U-Boot mailing list