* [PATCH 0/3] a few small irq improvements
@ 2018-02-24 7:15 Nicholas Piggin
2018-02-24 7:15 ` [PATCH 1/3] powerpc/pseries: put cede MSR[EE] check under IRQ_SOFT_MASK_DEBUG Nicholas Piggin
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Nicholas Piggin @ 2018-02-24 7:15 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Nicholas Piggin
Patch 2 is really the main one. Patch 3 assumes we drop POWER4
support as per https://patchwork.ozlabs.org/patch/875852/
Nicholas Piggin (3):
powerpc/pseries: put cede MSR[EE] check under IRQ_SOFT_MASK_DEBUG
powerpc/64s: make PACA_IRQ_HARD_DIS track MSR[EE]
powerpc/64s: micro-optimise __hard_irq_enable() for mtmsrd L=1 support
arch/powerpc/include/asm/hw_irq.h | 14 ++++++++------
arch/powerpc/include/asm/plpar_wrappers.h | 8 ++++----
arch/powerpc/kernel/exceptions-64s.S | 5 ++++-
arch/powerpc/kernel/irq.c | 14 ++++++--------
4 files changed, 22 insertions(+), 19 deletions(-)
--
2.16.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] powerpc/pseries: put cede MSR[EE] check under IRQ_SOFT_MASK_DEBUG
2018-02-24 7:15 [PATCH 0/3] a few small irq improvements Nicholas Piggin
@ 2018-02-24 7:15 ` Nicholas Piggin
2018-02-24 7:15 ` [PATCH 2/3] powerpc/64s: make PACA_IRQ_HARD_DIS track MSR[EE] Nicholas Piggin
2018-02-24 7:15 ` [PATCH 3/3] powerpc/64s: micro-optimise __hard_irq_enable() for mtmsrd L=1 support Nicholas Piggin
2 siblings, 0 replies; 4+ messages in thread
From: Nicholas Piggin @ 2018-02-24 7:15 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Nicholas Piggin
This check does not catch IRQ soft mask bugs, but this option
is slightly more suitable than TRACE_IRQFLAGS.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/include/asm/plpar_wrappers.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/include/asm/plpar_wrappers.h b/arch/powerpc/include/asm/plpar_wrappers.h
index 55eddf50d149..86f220110890 100644
--- a/arch/powerpc/include/asm/plpar_wrappers.h
+++ b/arch/powerpc/include/asm/plpar_wrappers.h
@@ -45,10 +45,10 @@ static inline long extended_cede_processor(unsigned long latency_hint)
set_cede_latency_hint(latency_hint);
rc = cede_processor();
-#ifdef CONFIG_TRACE_IRQFLAGS
- /* Ensure that H_CEDE returns with IRQs on */
- if (WARN_ON(!(mfmsr() & MSR_EE)))
- __hard_irq_enable();
+#ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
+ /* Ensure that H_CEDE returns with IRQs on */
+ if (WARN_ON(!(mfmsr() & MSR_EE)))
+ __hard_irq_enable();
#endif
set_cede_latency_hint(old_latency_hint);
--
2.16.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] powerpc/64s: make PACA_IRQ_HARD_DIS track MSR[EE]
2018-02-24 7:15 [PATCH 0/3] a few small irq improvements Nicholas Piggin
2018-02-24 7:15 ` [PATCH 1/3] powerpc/pseries: put cede MSR[EE] check under IRQ_SOFT_MASK_DEBUG Nicholas Piggin
@ 2018-02-24 7:15 ` Nicholas Piggin
2018-02-24 7:15 ` [PATCH 3/3] powerpc/64s: micro-optimise __hard_irq_enable() for mtmsrd L=1 support Nicholas Piggin
2 siblings, 0 replies; 4+ messages in thread
From: Nicholas Piggin @ 2018-02-24 7:15 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Nicholas Piggin
When the masked interrupt handler clears MSR[EE] for an interrupt in
the PACA_IRQ_MUST_HARD_MASK set, it does not set PACA_IRQ_HARD_DIS.
This makes them get out of synch.
With that taken into account, it's only low level irq manipulation
(and interrupt entry before reconcile) where they can be out of synch.
This makes the code less surprising.
It also allows the IRQ replay code to rely on the IRQ_HARD_DIS value
and not have to mtmsrd again in this case (e.g., for an external
interrupt that has been masked).
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/include/asm/hw_irq.h | 10 ++++++----
arch/powerpc/kernel/exceptions-64s.S | 5 ++++-
arch/powerpc/kernel/irq.c | 14 ++++++--------
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index 855e17d158b1..8004d7887ff6 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -248,14 +248,16 @@ static inline bool lazy_irq_pending(void)
/*
* This is called by asynchronous interrupts to conditionally
- * re-enable hard interrupts when soft-disabled after having
- * cleared the source of the interrupt
+ * re-enable hard interrupts after having cleared the source
+ * of the interrupt. They are kept disabled if there is a different
+ * soft-masked interrupt pending that requires hard masking.
*/
static inline void may_hard_irq_enable(void)
{
- get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS;
- if (!(get_paca()->irq_happened & PACA_IRQ_MUST_HARD_MASK))
+ if (!(get_paca()->irq_happened & PACA_IRQ_MUST_HARD_MASK)) {
+ get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS;
__hard_irq_enable();
+ }
}
static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 3ac87e53b3da..d1b0b0ef6658 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1446,7 +1446,10 @@ masked_##_H##interrupt: \
mfspr r10,SPRN_##_H##SRR1; \
xori r10,r10,MSR_EE; /* clear MSR_EE */ \
mtspr SPRN_##_H##SRR1,r10; \
-2: mtcrf 0x80,r9; \
+ ori r11,r11,PACA_IRQ_HARD_DIS; \
+ stb r11,PACAIRQHAPPENED(r13); \
+2: /* done */ \
+ mtcrf 0x80,r9; \
ld r9,PACA_EXGEN+EX_R9(r13); \
ld r10,PACA_EXGEN+EX_R10(r13); \
ld r11,PACA_EXGEN+EX_R11(r13); \
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index f88038847790..1c9ed0a3ba3f 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -256,16 +256,14 @@ notrace void arch_local_irq_restore(unsigned long mask)
* __check_irq_replay(). We also need to soft-disable
* again to avoid warnings in there due to the use of
* per-cpu variables.
- *
- * We know that if the value in irq_happened is exactly 0x01
- * then we are already hard disabled (there are other less
- * common cases that we'll ignore for now), so we skip the
- * (expensive) mtmsrd.
*/
- if (unlikely(irq_happened != PACA_IRQ_HARD_DIS))
+ if (!(irq_happened & PACA_IRQ_HARD_DIS)) {
+#ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
+ WARN_ON(!(mfmsr() & MSR_EE));
+#endif
__hard_irq_disable();
#ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
- else {
+ } else {
/*
* We should already be hard disabled here. We had bugs
* where that wasn't the case so let's dbl check it and
@@ -274,8 +272,8 @@ notrace void arch_local_irq_restore(unsigned long mask)
*/
if (WARN_ON(mfmsr() & MSR_EE))
__hard_irq_disable();
- }
#endif
+ }
irq_soft_mask_set(IRQS_ALL_DISABLED);
trace_hardirqs_off();
--
2.16.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] powerpc/64s: micro-optimise __hard_irq_enable() for mtmsrd L=1 support
2018-02-24 7:15 [PATCH 0/3] a few small irq improvements Nicholas Piggin
2018-02-24 7:15 ` [PATCH 1/3] powerpc/pseries: put cede MSR[EE] check under IRQ_SOFT_MASK_DEBUG Nicholas Piggin
2018-02-24 7:15 ` [PATCH 2/3] powerpc/64s: make PACA_IRQ_HARD_DIS track MSR[EE] Nicholas Piggin
@ 2018-02-24 7:15 ` Nicholas Piggin
2 siblings, 0 replies; 4+ messages in thread
From: Nicholas Piggin @ 2018-02-24 7:15 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Nicholas Piggin
Book3S minimum supported ISA version now requires mtmsrd L=1. This
instruction does not require bits other than RI and EE to be
supplied, so __hard_irq_enable() and __hard_irq_disable() does not
have to read the kernel_msr from paca.
Interrupt entry code already relies on L=1 support.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/include/asm/hw_irq.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index 8004d7887ff6..fbc2d83808aa 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -228,8 +228,8 @@ static inline bool arch_irqs_disabled(void)
#define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory")
#define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory")
#else
-#define __hard_irq_enable() __mtmsrd(local_paca->kernel_msr | MSR_EE, 1)
-#define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1)
+#define __hard_irq_enable() __mtmsrd(MSR_EE|MSR_RI, 1)
+#define __hard_irq_disable() __mtmsrd(MSR_RI, 1)
#endif
#define hard_irq_disable() do { \
--
2.16.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-02-24 7:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-24 7:15 [PATCH 0/3] a few small irq improvements Nicholas Piggin
2018-02-24 7:15 ` [PATCH 1/3] powerpc/pseries: put cede MSR[EE] check under IRQ_SOFT_MASK_DEBUG Nicholas Piggin
2018-02-24 7:15 ` [PATCH 2/3] powerpc/64s: make PACA_IRQ_HARD_DIS track MSR[EE] Nicholas Piggin
2018-02-24 7:15 ` [PATCH 3/3] powerpc/64s: micro-optimise __hard_irq_enable() for mtmsrd L=1 support Nicholas Piggin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).