Re: [PATCH 1/2] v2 476: Set CCR2[DSTI] to prevent isync from flushing shadow TLB

2010-10-12 Thread Dave Kleikamp
Josh,
Please pull this patch.  I just found a bone-headed mistake that makes
the whole patch a no-op.  I'll need to fix it and put it through a bit
of testing before I can re-submit it.

The other patch in this series should be okay.

Thanks,
Shaggy

On Mon, 2010-09-27 at 16:56 -0500, Dave Kleikamp wrote:
 When the DSTI (Disable Shadow TLB Invalidate) bit is set in the CCR2
 register, the isync command does not flush the shadow TLB (iTLB  dTLB).
 
 However, since the shadow TLB does not contain context information, we
 want the shadow TLB flushed in situations where we are switching context.
 In those situations, we explicitly clear the DSTI bit before performing
 isync, and set it again afterward.  We also need to do the same when we
 perform isync after explicitly flushing the TLB.
 
 Signed-off-by: Dave Kleikamp sha...@linux.vnet.ibm.com
 ---
  arch/powerpc/include/asm/reg_booke.h  |4 
  arch/powerpc/kernel/head_44x.S|   25 +
  arch/powerpc/mm/tlb_nohash_low.S  |   14 +-
  arch/powerpc/platforms/44x/misc_44x.S |   26 ++
  4 files changed, 68 insertions(+), 1 deletions(-)
 

   --- snip ---

 --- a/arch/powerpc/kernel/head_44x.S
 +++ b/arch/powerpc/kernel/head_44x.S

Not only is this in the wrong place (non-47x initialization) but ...

 @@ -861,6 +877,15 @@ skpinv:  addir4,r4,1 /* 
 Increment */
   isync
  #endif /* CONFIG_PPC_EARLY_DEBUG_44x */
 
 +BEGIN_MMU_FTR_SECTION
 + mfspr   r3,SPRN_CCR2_476
 + /* With CCR2(DSTI) set, isync does not invalidate the shadow TLB */
 + orisr3,r3,ccr2_476_d...@h
 + rlwinm  r3,r3,0,~CCR2_476_DSTI

^^^ This instruction doesn't belong at all.  It clears the bit right
after setting it.  This one was just introduced removing the config
option, but it was in the wrong place all along.

 + mtspr   SPRN_CCR2_476,r3
 + isync
 +END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_47x)
 +
   /* Establish the interrupt vector offsets */
   SET_IVOR(0,  CriticalInput);
   SET_IVOR(1,  MachineCheck);

I wasn't diligent enough checking a year-old patch that I got back to
work on.  The code is very similar in two places and the patch applied
to the wrong section.

Thanks,
Shaggy
-- 
Dave Kleikamp
IBM Linux Technology Center

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 1/2] v2 476: Set CCR2[DSTI] to prevent isync from flushing shadow TLB

2010-10-12 Thread Josh Boyer
On Tue, Oct 12, 2010 at 02:40:13PM -0500, Dave Kleikamp wrote:
Josh,
Please pull this patch.  I just found a bone-headed mistake that makes
the whole patch a no-op.  I'll need to fix it and put it through a bit
of testing before I can re-submit it.

OK.  I should have looked more closely myself.  I did think it odd that
it was changing head_44x.S but didn't follow up.

Ben, since you haven't pulled my -next branch yet, don't ;).  I'll fix
this up in my tree and resend a request tomorrow.

josh


The other patch in this series should be okay.

Thanks,
Shaggy

On Mon, 2010-09-27 at 16:56 -0500, Dave Kleikamp wrote:
 When the DSTI (Disable Shadow TLB Invalidate) bit is set in the CCR2
 register, the isync command does not flush the shadow TLB (iTLB  dTLB).
 
 However, since the shadow TLB does not contain context information, we
 want the shadow TLB flushed in situations where we are switching context.
 In those situations, we explicitly clear the DSTI bit before performing
 isync, and set it again afterward.  We also need to do the same when we
 perform isync after explicitly flushing the TLB.
 
 Signed-off-by: Dave Kleikamp sha...@linux.vnet.ibm.com
 ---
  arch/powerpc/include/asm/reg_booke.h  |4 
  arch/powerpc/kernel/head_44x.S|   25 +
  arch/powerpc/mm/tlb_nohash_low.S  |   14 +-
  arch/powerpc/platforms/44x/misc_44x.S |   26 ++
  4 files changed, 68 insertions(+), 1 deletions(-)
 

   --- snip ---

 --- a/arch/powerpc/kernel/head_44x.S
 +++ b/arch/powerpc/kernel/head_44x.S

Not only is this in the wrong place (non-47x initialization) but ...

 @@ -861,6 +877,15 @@ skpinv: addir4,r4,1 /* 
 Increment */
  isync
  #endif /* CONFIG_PPC_EARLY_DEBUG_44x */
 
 +BEGIN_MMU_FTR_SECTION
 +mfspr   r3,SPRN_CCR2_476
 +/* With CCR2(DSTI) set, isync does not invalidate the shadow TLB */
 +orisr3,r3,ccr2_476_d...@h
 +rlwinm  r3,r3,0,~CCR2_476_DSTI

^^^ This instruction doesn't belong at all.  It clears the bit right
after setting it.  This one was just introduced removing the config
option, but it was in the wrong place all along.

 +mtspr   SPRN_CCR2_476,r3
 +isync
 +END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_47x)
 +
  /* Establish the interrupt vector offsets */
  SET_IVOR(0,  CriticalInput);
  SET_IVOR(1,  MachineCheck);

I wasn't diligent enough checking a year-old patch that I got back to
work on.  The code is very similar in two places and the patch applied
to the wrong section.

Thanks,
Shaggy
-- 
Dave Kleikamp
IBM Linux Technology Center

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/2] v2 476: Set CCR2[DSTI] to prevent isync from flushing shadow TLB

2010-09-27 Thread Dave Kleikamp
When the DSTI (Disable Shadow TLB Invalidate) bit is set in the CCR2
register, the isync command does not flush the shadow TLB (iTLB  dTLB).

However, since the shadow TLB does not contain context information, we
want the shadow TLB flushed in situations where we are switching context.
In those situations, we explicitly clear the DSTI bit before performing
isync, and set it again afterward.  We also need to do the same when we
perform isync after explicitly flushing the TLB.

Signed-off-by: Dave Kleikamp sha...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/reg_booke.h  |4 
 arch/powerpc/kernel/head_44x.S|   25 +
 arch/powerpc/mm/tlb_nohash_low.S  |   14 +-
 arch/powerpc/platforms/44x/misc_44x.S |   26 ++
 4 files changed, 68 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/include/asm/reg_booke.h 
b/arch/powerpc/include/asm/reg_booke.h
index 667a498..a7ecbfe 100644
--- a/arch/powerpc/include/asm/reg_booke.h
+++ b/arch/powerpc/include/asm/reg_booke.h
@@ -120,6 +120,7 @@
 #define SPRN_TLB3CFG   0x2B3   /* TLB 3 Config Register */
 #define SPRN_EPR   0x2BE   /* External Proxy Register */
 #define SPRN_CCR1  0x378   /* Core Configuration Register 1 */
+#define SPRN_CCR2_476  0x379   /* Core Configuration Register 2 (476)*/
 #define SPRN_ZPR   0x3B0   /* Zone Protection Register (40x) */
 #define SPRN_MAS7  0x3B0   /* MMU Assist Register 7 */
 #define SPRN_MMUCR 0x3B2   /* MMU Control Register */
@@ -188,6 +189,9 @@
 #defineCCR1_DPC0x0100 /* Disable L1 I-Cache/D-Cache parity 
checking */
 #defineCCR1_TCS0x0080 /* Timer Clock Select */
 
+/* Bit definitions for CCR2. */
+#define CCR2_476_DSTI  0x0800 /* Disable Shadow TLB Invalidate */
+
 /* Bit definitions for the MCSR. */
 #define MCSR_MCS   0x8000 /* Machine Check Summary */
 #define MCSR_IB0x4000 /* Instruction PLB Error */
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 562305b..cd34afb 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -38,6 +38,7 @@
 #include asm/ppc_asm.h
 #include asm/asm-offsets.h
 #include asm/synch.h
+#include asm/bug.h
 #include head_booke.h
 
 
@@ -703,8 +704,23 @@ _GLOBAL(set_context)
stw r4, 0x4(r5)
 #endif
mtspr   SPRN_PID,r3
+BEGIN_MMU_FTR_SECTION
+   b   1f
+END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_47x)
isync   /* Force context change */
blr
+1:
+#ifdef CONFIG_PPC_47x
+   mfspr   r10,SPRN_CCR2_476
+   rlwinm  r11,r10,0,~CCR2_476_DSTI
+   mtspr   SPRN_CCR2_476,r11
+   isync   /* Force context change */
+   mtspr   SPRN_CCR2_476,r10
+#else /* CONFIG_PPC_47x */
+2: trap
+   EMIT_BUG_ENTRY 2b,__FILE__,__LINE__,0;
+#endif /* CONFIG_PPC_47x */
+   blr
 
 /*
  * Init CPU state. This is called at boot time or for secondary CPUs
@@ -861,6 +877,15 @@ skpinv:addir4,r4,1 /* 
Increment */
isync
 #endif /* CONFIG_PPC_EARLY_DEBUG_44x */
 
+BEGIN_MMU_FTR_SECTION
+   mfspr   r3,SPRN_CCR2_476
+   /* With CCR2(DSTI) set, isync does not invalidate the shadow TLB */
+   orisr3,r3,ccr2_476_d...@h
+   rlwinm  r3,r3,0,~CCR2_476_DSTI
+   mtspr   SPRN_CCR2_476,r3
+   isync
+END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_47x)
+
/* Establish the interrupt vector offsets */
SET_IVOR(0,  CriticalInput);
SET_IVOR(1,  MachineCheck);
diff --git a/arch/powerpc/mm/tlb_nohash_low.S b/arch/powerpc/mm/tlb_nohash_low.S
index b9d9fed..f28fb52 100644
--- a/arch/powerpc/mm/tlb_nohash_low.S
+++ b/arch/powerpc/mm/tlb_nohash_low.S
@@ -112,7 +112,11 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_47x)
clrrwi  r4,r3,12/* get an EPN for the hashing with V = 0 */
ori r4,r4,PPC47x_TLBE_SIZE
tlbwe   r4,r7,0 /* write it */
+   mfspr   r8,SPRN_CCR2_476
+   rlwinm  r9,r8,0,~CCR2_476_DSTI
+   mtspr   SPRN_CCR2_476,r9
isync
+   mtspr   SPRN_CCR2_476,r8
wrtee   r10
blr
 #else /* CONFIG_PPC_47x */
@@ -180,7 +184,11 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_47x)
lwz r8,0(r10)   /* Load boltmap entry */
addir10,r10,4   /* Next word */
b   1b  /* Then loop */
-1: isync   /* Sync shadows */
+1: mfspr   r9,SPRN_CCR2_476
+   rlwinm  r10,r9,0,~CCR2_476_DSTI
+   mtspr   SPRN_CCR2_476,r10
+   isync   /* Sync shadows */
+   mtspr   SPRN_CCR2_476,r9
wrtee   r11
 #else /* CONFIG_PPC_47x */
 1: trap
@@ -203,7 +211,11 @@ _GLOBAL(_tlbivax_bcast)
isync
 /* tlbivax 0,r3 - use .long to avoid binutils deps */
.long 0x7c000624 | (r3  11)
+   mfspr   r8,SPRN_CCR2_476
+   rlwinm  r9,r8,0,~CCR2_476_DSTI
+   mtspr   SPRN_CCR2_476,r9