Skip to contentSkip to conversation

powerpc/8xx: use SPRN_EIE and SPRN_EID to enable/disable interrupts

PATCH Superseded Christophe Leroy 2 participants 5 messages Aug 18, 2016 – Aug 19, 2016 PowerPC

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/8xx: use SPRN_EIE and SPRN_EID to enable/disable interrupts

The 8xx has two special registers called EID (External Interrupt Disable) and EIE (External Interrupt Enable) for clearing/setting EE in MSR. It avoids the three instructions set mfmsr/ori/mtmsr or mfmsr/rlwinm/mtmsr.

We just have to write something in the register to change MSR EE bit. So we write r0 into the register, regardless of r0 value.

---
 arch/powerpc/include/asm/hw_irq.h  | 6 ++++++
 arch/powerpc/include/asm/reg.h     | 2 ++
 arch/powerpc/include/asm/reg_8xx.h | 5 +++++
 3 files changed, 13 insertions(+)
arch/powerpc/include/asm/hw_irq.h +6 -0
index c7d82ff..7ffb392 100644
@@ -155,6 +155,8 @@ static inline unsigned long arch_local_irq_save(void)
 	unsigned long flags = arch_local_save_flags();
 #ifdef CONFIG_BOOKE
 	asm volatile("wrteei 0" : : : "memory");
+#elif defined(CONFIG_PPC_8xx)
+	wrtspr(SPRN_EID);
 #else
 	SET_MSR_EE(flags & ~MSR_EE);
 #endif
@@ -165,6 +167,8 @@ static inline void arch_local_irq_disable(void)
 {
 #ifdef CONFIG_BOOKE
 	asm volatile("wrteei 0" : : : "memory");
+#elif defined(CONFIG_PPC_8xx)
+	wrtspr(SPRN_EID);
 #else
 	arch_local_irq_save();
 #endif
@@ -174,6 +178,8 @@ static inline void arch_local_irq_enable(void)
 {
 #ifdef CONFIG_BOOKE
 	asm volatile("wrteei 1" : : : "memory");
+#elif defined(CONFIG_PPC_8xx)
+	wrtspr(SPRN_EIE);
 #else
 	unsigned long msr = mfmsr();
 	SET_MSR_EE(msr | MSR_EE);
arch/powerpc/include/asm/reg.h +2 -0
index f69f40f..4bbd9be 100644
@@ -1246,6 +1246,8 @@ static inline void mtmsr_isync(unsigned long val)
 				     : "r" ((unsigned long)(v)) \
 				     : "memory")
 #endif
+#define wrtspr(rn)	asm volatile("mtspr " __stringify(rn) ",0" : \
+				     : : "memory")
 
 extern void msr_check_and_set(unsigned long bits);
 extern bool strict_msr_control;
arch/powerpc/include/asm/reg_8xx.h +5 -0
index 6dae71f..d4bca3de 100644
@@ -6,6 +6,11 @@
 
 #include <asm/mmu.h>
 
+/* Special MSR manipulation registers */
+#define SPRN_EIE	80	/* External interrupt enable (EE=1, RI=1) */
+#define SPRN_EID	81	/* External interrupt disable (EE=0, RI=1) */
+#define SPRN_NRI	81	/* Non Recoverable interrupt (EE=0, RI=0) */
+
 /* Cache control on the MPC8xx is provided through some additional
  * special purpose registers.
  */
Signature · 1 line
2.1.0
#1 lore raw
Quoted 4 lines · Christophe Leroy

The 8xx has two special registers called EID (External Interrupt Disable) and EIE (External Interrupt Enable) for clearing/setting EE in MSR. It avoids the three instructions set mfmsr/ori/mtmsr or mfmsr/rlwinm/mtmsr.

All 8xx? What other models? (5xx for example).

arch/powerpc/include/asm/reg_8xx.h line 12

Quoted 4 lines
arch/powerpc/include/asm/reg_8xx.h +4 -0
+/* Special MSR manipulation registers */
+#define SPRN_EIE	80	/* External interrupt enable (EE=1, RI=1) */
+#define SPRN_EID	81	/* External interrupt disable (EE=0, RI=1) */
+#define SPRN_NRI	81	/* Non Recoverable interrupt (EE=0, RI=0) */

This is wrong (NRI is 82). Don't write code you cannot test / don't submit code you haven't tested? :-)

Segher

#2 lore raw
Quoted 7 lines · Segher Boessenkool
Quoted 4 lines · Christophe Leroy

The 8xx has two special registers called EID (External Interrupt Disable) and EIE (External Interrupt Enable) for clearing/setting EE in MSR. It avoids the three instructions set mfmsr/ori/mtmsr or mfmsr/rlwinm/mtmsr.

All 8xx? What other models? (5xx for example).

At least 823, 860, 866 and 885 have it.

Looks like the 5xx have it too (at least the 565). Does Linux supports that one at all ?

8272 and 8323 don't have it.

Quoted 8 lines

arch/powerpc/include/asm/reg_8xx.h line 12

Quoted 5 lines
arch/powerpc/include/asm/reg_8xx.h +4 -0
+/* Special MSR manipulation registers */
+#define SPRN_EIE	80	/* External interrupt enable (EE=1, RI=1) */
+#define SPRN_EID	81	/* External interrupt disable (EE=0, RI=1) */
+#define SPRN_NRI	81	/* Non Recoverable interrupt (EE=0, RI=0) */

This is wrong (NRI is 82). Don't write code you cannot test / don't submit code you haven't tested? :-)

Oops. You're right, copy/paste failure.
Was tested on an 885. Unfortunatly SPRN_NRI is not used (yet) :-(

Christophe

#3 lore raw
Quoted 10 lines · Christophe Leroy
Quoted 7 lines · Segher Boessenkool
Quoted 4 lines · Christophe Leroy

The 8xx has two special registers called EID (External Interrupt Disable) and EIE (External Interrupt Enable) for clearing/setting EE in MSR. It avoids the three instructions set mfmsr/ori/mtmsr or mfmsr/rlwinm/mtmsr.

All 8xx? What other models? (5xx for example).

At least 823, 860, 866 and 885 have it.

I haven't been able to find a manual for all 8xx. But there is AN2055, which suggests EIE etc. is for all 8xx indeed.

Quoted 2 lines

Looks like the 5xx have it too (at least the 565). Does Linux supports that one at all ?

All 5xx have it, there is a manual for *that* ("RCPU") :-)

Quoted 4 lines
Quoted 4 lines

arch/powerpc/include/asm/reg_8xx.h line 12

Quoted 4 lines
arch/powerpc/include/asm/reg_8xx.h +4 -0
+/* Special MSR manipulation registers */
+#define SPRN_EIE	80	/* External interrupt enable (EE=1, RI=1) */
+#define SPRN_EID	81	/* External interrupt disable (EE=0, RI=1) */
+#define SPRN_NRI	81	/* Non Recoverable interrupt (EE=0, RI=0) */

Is it correct to set RI in all places you do now?

Quoted 5 lines
Quoted 2 lines

This is wrong (NRI is 82). Don't write code you cannot test / don't submit code you haven't tested? :-)

Oops. You're right, copy/paste failure.
Was tested on an 885. Unfortunatly SPRN_NRI is not used (yet) :-(

Well, that was my point!

Segher

#4 lore raw
Quoted 18 lines · Segher Boessenkool
Quoted 10 lines · Christophe Leroy
Quoted 7 lines · Segher Boessenkool
Quoted 4 lines · Christophe Leroy

The 8xx has two special registers called EID (External Interrupt Disable) and EIE (External Interrupt Enable) for clearing/setting EE in MSR. It avoids the three instructions set mfmsr/ori/mtmsr or mfmsr/rlwinm/mtmsr.

All 8xx? What other models? (5xx for example).

At least 823, 860, 866 and 885 have it.

I haven't been able to find a manual for all 8xx. But there is AN2055, which suggests EIE etc. is for all 8xx indeed.

Quoted 2 lines

Looks like the 5xx have it too (at least the 565). Does Linux supports that one at all ?

Quoted 8 lines

All 5xx have it, there is a manual for *that* ("RCPU") :-)

Quoted 4 lines
Quoted 4 lines

arch/powerpc/include/asm/reg_8xx.h line 12

Quoted 4 lines
arch/powerpc/include/asm/reg_8xx.h +4 -0
+/* Special MSR manipulation registers */
+#define SPRN_EIE	80	/* External interrupt enable (EE=1, RI=1) */
+#define SPRN_EID	81	/* External interrupt disable (EE=0, RI=1) */
+#define SPRN_NRI	81	/* Non Recoverable interrupt (EE=0, RI=0) */

Is it correct to set RI in all places you do now?

MSR_KERNEL contains the RI bit.
MSR_KERNEL less MSR_IR and MSR_DR is loaded into MSR in EXCEPTION_PROLOG_2() in head_8xx.S Then reloaded with MSR_KERNEL in some places in entry_32.S

And MSR_RI is cleared in restore: in entry_32.S a few insns before the RFI.

So in all C functions, MSR_RI is set.

Christophe

Quoted 12 lines
Quoted 6 lines
Quoted 3 lines

This is wrong (NRI is 82). Don't write code you cannot test / don't submit code you haven't tested? :-)

Oops. You're right, copy/paste failure.
Was tested on an 885. Unfortunatly SPRN_NRI is not used (yet) :-(

Well, that was my point!

Segher