Skip to contentSkip to conversation

MPC5121 TLB errata workaround

RFC PATCH In review David Jander 5 participants 10 messages Mar 16, 2009 – Jun 8, 2009 PowerPC

lore
Share & tools
lore
#0 lore raw

RFC PATCH v5 1/1 MPC5121 TLB errata workaround

Complete workaround for DTLB errata in e300c2/c3/c4 processors.

Due to the bug, the hardware-implemented LRU algorythm always goes to way 1 of the TLB. This fix implements the proposed software workaround in form of a LRW table for chosing the TLB-way.

---

arch/powerpc/kernel/head_32.S +28 -4
index 0f4fac5..3971ee4 100644
@@ -578,9 +578,21 @@ DataLoadTLBMiss:
 	andc	r1,r3,r1		/* PP = user? (rw&dirty? 2: 3): 0 */
 	mtspr	SPRN_RPA,r1
 	mfspr	r3,SPRN_DMISS
+	mfspr	r2,SPRN_SRR1		/* Need to restore CR0 */
+	mtcrf	0x80,r2
+#ifdef CONFIG_PPC_MPC512x
+	li	r0,1
+	mfspr	r1,SPRN_SPRG6
+	rlwinm	r2,r3,17,27,31		/* Get Address bits 19:15 */
+	slw	r0,r0,r2
+	xor	r1,r0,r1
+	srw	r0,r1,r2
+	mtspr   SPRN_SPRG6,r1
+	mfspr	r2,SPRN_SRR1
+	rlwimi	r2,r0,31-14,14,14
+	mtspr   SPRN_SRR1,r2
+#endif
 	tlbld	r3
-	mfspr	r3,SPRN_SRR1		/* Need to restore CR0 */
-	mtcrf	0x80,r3
 	rfi
 DataAddressInvalid:
 	mfspr	r3,SPRN_SRR1
@@ -646,9 +658,21 @@ DataStoreTLBMiss:
 	andc	r1,r3,r1		/* PP = user? 2: 0 */
 	mtspr	SPRN_RPA,r1
 	mfspr	r3,SPRN_DMISS
+	mfspr	r2,SPRN_SRR1		/* Need to restore CR0 */
+	mtcrf	0x80,r2
+#ifdef CONFIG_PPC_MPC512x
+	li	r0,1
+	mfspr	r1,SPRN_SPRG6
+	rlwinm	r2,r3,17,27,31		/* Get Address bits 19:15 */
+	slw	r0,r0,r2
+	xor	r1,r0,r1
+	srw	r0,r1,r2
+	mtspr   SPRN_SPRG6,r1
+	mfspr	r2,SPRN_SRR1
+	rlwimi	r2,r0,31-14,14,14
+	mtspr   SPRN_SRR1,r2
+#endif
 	tlbld	r3
-	mfspr	r3,SPRN_SRR1		/* Need to restore CR0 */
-	mtcrf	0x80,r3
 	rfi
 
 #ifndef CONFIG_ALTIVEC
#1 lore raw

In this patch, I placed the LRW table in SPRG6 like before, but Kumar's code seems a little more compact, so I decided to use that one and fix it ;-)

It's a pity we seem to have one register short in the handler, so we need to load SPRN_SRR1 twice :-(

Allthough the code-path now has 1 instruction less than my previous version most of the time (and 2 instructions more when way is not adjusted), benchmark results are barely affected by this:

1.- mplayer: Total time: 50.392s (50.316s previous patch)

2.- prboom timedemo: 20.1 fps (19.9 fps previous patch)

3.- memcpy speed: 179 MByte/s (180 Mbyte/s previous patch)

Conclusion: difference not measurable between v4 and v5.

Best regards,

Signature · 2 lines
David Jander
Protonic Holland.
#2 lore raw
Quoted 11 lines · David Jander

In this patch, I placed the LRW table in SPRG6 like before, but Kumar's code seems a little more compact, so I decided to use that one and fix it ;-)

It's a pity we seem to have one register short in the handler, so we need to load SPRN_SRR1 twice :-(

Allthough the code-path now has 1 instruction less than my previous version most of the time (and 2 instructions more when way is not adjusted), benchmark results are barely affected by this:

Quoted 7 lines

1.- mplayer: Total time: 50.392s (50.316s previous patch)

2.- prboom timedemo: 20.1 fps (19.9 fps previous patch)

3.- memcpy speed: 179 MByte/s (180 Mbyte/s previous patch)

Conclusion: difference not measurable between v4 and v5.

Can we try this memory instead of the SPRG to see if any noticeable difference?

- k

Acked-by on v5 1/1
#3 lore raw
In reply to David Jander
Quoted 8 lines · David Jander

Complete workaround for DTLB errata in e300c2/c3/c4 processors.

Due to the bug, the hardware-implemented LRU algorythm always goes to way 1 of the TLB. This fix implements the proposed software workaround in form of a LRW table for chosing the TLB-way.

I think we have a winner. with one instruction slot left :) I tried your V4 and V5 and could not see any difference in speed.

#4 lore raw
In reply to David Jander
Quoted 15 lines · David Jander

Complete workaround for DTLB errata in e300c2/c3/c4 processors.

Due to the bug, the hardware-implemented LRU algorythm always goes to way 1 of the TLB. This fix implements the proposed software workaround in form of a LRW table for chosing the TLB-way.

---

arch/powerpc/kernel/head_32.S +0 -0
index 0f4fac5..3971ee4 100644

arch/powerpc/kernel/head_32.S DataLoadTLBMiss: · line 586

Quoted 9 lines
arch/powerpc/kernel/head_32.S +6 -0
@@ -578,9 +578,21 @@ DataLoadTLBMiss:
 	andc	r1,r3,r1		/* PP = user? (rw&dirty? 2: 3): 0 */
 	mtspr	SPRN_RPA,r1
 	mfspr	r3,SPRN_DMISS
+	mfspr	r2,SPRN_SRR1		/* Need to restore CR0 */
+	mtcrf	0x80,r2
+#ifdef CONFIG_PPC_MPC512x
+	li	r0,1
+	mfspr	r1,SPRN_SPRG6
+	rlwinm	r2,r3,17,27,31		/* Get Address bits 19:15 */

Don't we want:

	rlwinm	r2,r3,20,27,31		/* Get address bits 15:19 */

arch/powerpc/kernel/head_32.S DataLoadTLBMiss: · line 596

Quoted 12 lines
arch/powerpc/kernel/head_32.S +8 -2
+	slw	r0,r0,r2
+	xor	r1,r0,r1
+	srw	r0,r1,r2
+	mtspr   SPRN_SPRG6,r1
+	mfspr	r2,SPRN_SRR1
+	rlwimi	r2,r0,31-14,14,14
+	mtspr   SPRN_SRR1,r2
+#endif
 	tlbld	r3
-	mfspr	r3,SPRN_SRR1		/* Need to restore CR0 */
-	mtcrf	0x80,r3
 	rfi

- k

#5 lore raw
Quoted 29 lines · On Monday 16 March 2009 19:05:00 Kumar Gala wrote:
Quoted 17 lines · David Jander

Complete workaround for DTLB errata in e300c2/c3/c4 processors.

Due to the bug, the hardware-implemented LRU algorythm always goes to way
1 of the TLB. This fix implements the proposed software workaround in form of a LRW table for chosing the TLB-way.

---

arch/powerpc/kernel/ renamed from arch/powerpc/kernel/head_32.S +0 -0

head_32.S
index 0f4fac5..3971ee4 100644

arch/powerpc/kernel/head_32.S DataLoadTLBMiss: · line 586

Quoted 9 lines
arch/powerpc/kernel/head_32.S +6 -0
@@ -578,9 +578,21 @@ DataLoadTLBMiss:
 	andc	r1,r3,r1		/* PP = user? (rw&dirty? 2: 3): 0 */
 	mtspr	SPRN_RPA,r1
 	mfspr	r3,SPRN_DMISS
+	mfspr	r2,SPRN_SRR1		/* Need to restore CR0 */
+	mtcrf	0x80,r2
+#ifdef CONFIG_PPC_MPC512x
+	li	r0,1
+	mfspr	r1,SPRN_SPRG6
+	rlwinm	r2,r3,17,27,31		/* Get Address bits 19:15 */

Don't we want:

Quoted 1 line
	rlwinm	r2,r3,20,27,31		/* Get address bits 15:19 */

Hmm, you are right, I must have accidentally counted LE bit-ordering ;-) Only funny part is, that I don't measure any performance difference after fixing this.... *sigh*.

Regards,

Signature · 2 lines
David Jander
Protonic Holland.
#6 lore raw
Quoted 32 lines · David Jander
Quoted 29 lines · On Monday 16 March 2009 19:05:00 Kumar Gala wrote:
Quoted 17 lines · David Jander

Complete workaround for DTLB errata in e300c2/c3/c4 processors.

Due to the bug, the hardware-implemented LRU algorythm always goes to way
1 of the TLB. This fix implements the proposed software workaround in form of a LRW table for chosing the TLB-way.

---

arch/powerpc/kernel/ renamed from arch/powerpc/kernel/head_32.S +0 -0

head_32.S
index 0f4fac5..3971ee4 100644

arch/powerpc/kernel/head_32.S DataLoadTLBMiss: · line 586

Quoted 9 lines
arch/powerpc/kernel/head_32.S +6 -0
@@ -578,9 +578,21 @@ DataLoadTLBMiss:
 	andc	r1,r3,r1		/* PP = user? (rw&dirty? 2: 3): 0 */
 	mtspr	SPRN_RPA,r1
 	mfspr	r3,SPRN_DMISS
+	mfspr	r2,SPRN_SRR1		/* Need to restore CR0 */
+	mtcrf	0x80,r2
+#ifdef CONFIG_PPC_MPC512x
+	li	r0,1
+	mfspr	r1,SPRN_SPRG6
+	rlwinm	r2,r3,17,27,31		/* Get Address bits 19:15 */

Don't we want:

Quoted 1 line
	rlwinm	r2,r3,20,27,31		/* Get address bits 15:19 */
Quoted 3 lines

Hmm, you are right, I must have accidentally counted LE bit-ordering ;-) Only funny part is, that I don't measure any performance difference after fixing this.... *sigh*.

I wouldn't expect it to. You are picking some bits to hash on. You picked some different bits but the distribution of addresses was probably similiar.

- k

#7 lore raw
In reply to David Jander

Dear David Jander,

Quoted 8 lines · In message <[email protected]> you wrote:

Complete workaround for DTLB errata in e300c2/c3/c4 processors.

Due to the bug, the hardware-implemented LRU algorythm always goes to way 1 of the TLB. This fix implements the proposed software workaround in form of a LRW table for chosing the TLB-way.

What is the actual status of this patch?

Patchwork (http://patchwork.ozlabs.org/patch/24502/) says it's "superseded" - but by what?

I can't see such code in mainline - what happened to it?

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: [email protected]
One essential to success is that you desire be an all-obsessing  one,
your thoughts and aims be co-ordinated, and your energy be concentra-
ted and applied without letup.
#8 lore raw
Quoted 12 lines · Wolfgang Denk

Dear David Jander,

Quoted 8 lines · In message <[email protected]> you wrote:

Complete workaround for DTLB errata in e300c2/c3/c4 processors.

Due to the bug, the hardware-implemented LRU algorythm always goes to way 1 of the TLB. This fix implements the proposed software workaround in form of a LRW table for chosing the TLB-way.

Quoted 6 lines

What is the actual status of this patch?

Patchwork (http://patchwork.ozlabs.org/patch/24502/) says it's "superseded" - but by what?

I can't see such code in mainline - what happened to it?

I can see the code in mainline ... but only in the -data- TLB miss handler, not the instruction one...

Kumar ? Shouldn't we have the workaround in both ?

Cheers,
Ben.

#9 lore raw
Quoted 18 lines · Benjamin Herrenschmidt
Quoted 17 lines · Wolfgang Denk

Dear David Jander,

Quoted 8 lines · In message <[email protected]> you wrote:

Complete workaround for DTLB errata in e300c2/c3/c4 processors.

Due to the bug, the hardware-implemented LRU algorythm always goes to way 1 of the TLB. This fix implements the proposed software workaround in form of a LRW table for chosing the TLB-way.

What is the actual status of this patch?

Patchwork (http://patchwork.ozlabs.org/patch/24502/) says it's "superseded" - but by what?

Quoted 6 lines
Quoted 1 line

I can't see such code in mainline - what happened to it?

I can see the code in mainline ... but only in the -data- TLB miss handler, not the instruction one...

Kumar ? Shouldn't we have the workaround in both ?

The errata was only for the d-side. The patch is in the mainline kernel.

- k