Commit b020aa9d authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc: cleanup hw_irq.h

SET_MSR_EE() is just use in this file and doesn't provide
any added value compared to mtmsr(). Drop it.

Add a wrtee() inline function to use wrtee/wrteei insn.

Replace #ifdefs by IS_ENABLED()
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/a28a20514d5f6df9629c1a117b667e48c4272736.1567068137.git.christophe.leroy@c-s.fr
parent 44448640
...@@ -226,8 +226,8 @@ static inline bool arch_irqs_disabled(void) ...@@ -226,8 +226,8 @@ static inline bool arch_irqs_disabled(void)
#endif /* CONFIG_PPC_BOOK3S */ #endif /* CONFIG_PPC_BOOK3S */
#ifdef CONFIG_PPC_BOOK3E #ifdef CONFIG_PPC_BOOK3E
#define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory") #define __hard_irq_enable() wrtee(MSR_EE)
#define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory") #define __hard_irq_disable() wrtee(0)
#else #else
#define __hard_irq_enable() __mtmsrd(MSR_EE|MSR_RI, 1) #define __hard_irq_enable() __mtmsrd(MSR_EE|MSR_RI, 1)
#define __hard_irq_disable() __mtmsrd(MSR_RI, 1) #define __hard_irq_disable() __mtmsrd(MSR_RI, 1)
...@@ -280,8 +280,6 @@ extern void force_external_irq_replay(void); ...@@ -280,8 +280,6 @@ extern void force_external_irq_replay(void);
#else /* CONFIG_PPC64 */ #else /* CONFIG_PPC64 */
#define SET_MSR_EE(x) mtmsr(x)
static inline unsigned long arch_local_save_flags(void) static inline unsigned long arch_local_save_flags(void)
{ {
return mfmsr(); return mfmsr();
...@@ -289,47 +287,44 @@ static inline unsigned long arch_local_save_flags(void) ...@@ -289,47 +287,44 @@ static inline unsigned long arch_local_save_flags(void)
static inline void arch_local_irq_restore(unsigned long flags) static inline void arch_local_irq_restore(unsigned long flags)
{ {
#if defined(CONFIG_BOOKE) if (IS_ENABLED(CONFIG_BOOKE))
asm volatile("wrtee %0" : : "r" (flags) : "memory"); wrtee(flags);
#else else
mtmsr(flags); mtmsr(flags);
#endif
} }
static inline unsigned long arch_local_irq_save(void) static inline unsigned long arch_local_irq_save(void)
{ {
unsigned long flags = arch_local_save_flags(); unsigned long flags = arch_local_save_flags();
#ifdef CONFIG_BOOKE
asm volatile("wrteei 0" : : : "memory"); if (IS_ENABLED(CONFIG_BOOKE))
#elif defined(CONFIG_PPC_8xx) wrtee(0);
wrtspr(SPRN_EID); else if (IS_ENABLED(CONFIG_PPC_8xx))
#else wrtspr(SPRN_EID);
SET_MSR_EE(flags & ~MSR_EE); else
#endif mtmsr(flags & ~MSR_EE);
return flags; return flags;
} }
static inline void arch_local_irq_disable(void) static inline void arch_local_irq_disable(void)
{ {
#ifdef CONFIG_BOOKE if (IS_ENABLED(CONFIG_BOOKE))
asm volatile("wrteei 0" : : : "memory"); wrtee(0);
#elif defined(CONFIG_PPC_8xx) else if (IS_ENABLED(CONFIG_PPC_8xx))
wrtspr(SPRN_EID); wrtspr(SPRN_EID);
#else else
arch_local_irq_save(); mtmsr(mfmsr() & ~MSR_EE);
#endif
} }
static inline void arch_local_irq_enable(void) static inline void arch_local_irq_enable(void)
{ {
#ifdef CONFIG_BOOKE if (IS_ENABLED(CONFIG_BOOKE))
asm volatile("wrteei 1" : : : "memory"); wrtee(MSR_EE);
#elif defined(CONFIG_PPC_8xx) else if (IS_ENABLED(CONFIG_PPC_8xx))
wrtspr(SPRN_EIE); wrtspr(SPRN_EIE);
#else else
unsigned long msr = mfmsr(); mtmsr(mfmsr() | MSR_EE);
SET_MSR_EE(msr | MSR_EE);
#endif
} }
static inline bool arch_irqs_disabled_flags(unsigned long flags) static inline bool arch_irqs_disabled_flags(unsigned long flags)
......
...@@ -1368,6 +1368,14 @@ static inline void mtmsr_isync(unsigned long val) ...@@ -1368,6 +1368,14 @@ static inline void mtmsr_isync(unsigned long val)
#define wrtspr(rn) asm volatile("mtspr " __stringify(rn) ",0" : \ #define wrtspr(rn) asm volatile("mtspr " __stringify(rn) ",0" : \
: : "memory") : : "memory")
static inline void wrtee(unsigned long val)
{
if (__builtin_constant_p(val))
asm volatile("wrteei %0" : : "i" ((val & MSR_EE) ? 1 : 0) : "memory");
else
asm volatile("wrtee %0" : : "r" (val) : "memory");
}
extern unsigned long msr_check_and_set(unsigned long bits); extern unsigned long msr_check_and_set(unsigned long bits);
extern bool strict_msr_control; extern bool strict_msr_control;
extern void __msr_check_and_clear(unsigned long bits); extern void __msr_check_and_clear(unsigned long bits);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment