Skip to content

Commit f442d00

Browse files
Madhavan Srinivasanmpe
authored andcommitted
powerpc/64s: Add support to mask perf interrupts and replay them
Two new bit mask field "IRQ_DISABLE_MASK_PMU" is introduced to support the masking of PMI and "IRQ_DISABLE_MASK_ALL" to aid interrupt masking checking. Couple of new irq #defs "PACA_IRQ_PMI" and "SOFTEN_VALUE_0xf0*" added to use in the exception code to check for PMI interrupts. In the masked_interrupt handler, for PMIs we reset the MSR[EE] and return. In the __check_irq_replay(), replay the PMI interrupt by calling performance_monitor_common handler. Signed-off-by: Madhavan Srinivasan <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent f14e953 commit f442d00

File tree

5 files changed

+31
-11
lines changed

5 files changed

+31
-11
lines changed

arch/powerpc/include/asm/exception-64s.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
518518
#define SOFTEN_VALUE_0xe80 PACA_IRQ_DBELL
519519
#define SOFTEN_VALUE_0xe60 PACA_IRQ_HMI
520520
#define SOFTEN_VALUE_0xea0 PACA_IRQ_EE
521+
#define SOFTEN_VALUE_0xf00 PACA_IRQ_PMI
521522

522523
#define __SOFTEN_TEST(h, vec, bitmask) \
523524
lbz r10,PACAIRQSOFTMASK(r13); \
@@ -582,6 +583,10 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
582583
_MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \
583584
EXC_STD, SOFTEN_NOTEST_PR, bitmask)
584585

586+
#define MASKABLE_RELON_EXCEPTION_PSERIES_OOL(vec, label, bitmask) \
587+
MASKABLE_EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_NOTEST_PR, vec, bitmask);\
588+
EXCEPTION_PROLOG_PSERIES_1(label, EXC_STD);
589+
585590
#define MASKABLE_RELON_EXCEPTION_HV(loc, vec, label, bitmask) \
586591
_MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \
587592
EXC_HV, SOFTEN_TEST_HV, bitmask)

arch/powerpc/include/asm/hw_irq.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@
2727
#define PACA_IRQ_DEC 0x08 /* Or FIT */
2828
#define PACA_IRQ_EE_EDGE 0x10 /* BookE only */
2929
#define PACA_IRQ_HMI 0x20
30+
#define PACA_IRQ_PMI 0x40
3031

3132
/*
3233
* flags for paca->irq_soft_mask
3334
*/
3435
#define IRQS_ENABLED 0
35-
#define IRQS_DISABLED 1
36+
#define IRQS_DISABLED 1 /* local_irq_disable() interrupts */
37+
#define IRQS_PMI_DISABLED 2
38+
#define IRQS_ALL_DISABLED (IRQS_DISABLED | IRQS_PMI_DISABLED)
3639

3740
#endif /* CONFIG_PPC64 */
3841

@@ -152,13 +155,13 @@ static inline bool arch_irqs_disabled(void)
152155
#define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1)
153156
#endif
154157

155-
#define hard_irq_disable() do { \
156-
unsigned long flags; \
157-
__hard_irq_disable(); \
158-
flags = irq_soft_mask_set_return(IRQS_DISABLED); \
159-
local_paca->irq_happened |= PACA_IRQ_HARD_DIS; \
160-
if (!arch_irqs_disabled_flags(flags)) \
161-
trace_hardirqs_off(); \
158+
#define hard_irq_disable() do { \
159+
unsigned long flags; \
160+
__hard_irq_disable(); \
161+
flags = irq_soft_mask_set_return(IRQS_ALL_DISABLED); \
162+
local_paca->irq_happened |= PACA_IRQ_HARD_DIS; \
163+
if (!arch_irqs_disabled_flags(flags)) \
164+
trace_hardirqs_off(); \
162165
} while(0)
163166

164167
static inline bool lazy_irq_pending(void)

arch/powerpc/kernel/entry_64.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
954954
addi r3,r1,STACK_FRAME_OVERHEAD;
955955
bl do_IRQ
956956
b ret_from_except
957+
1: cmpwi cr0,r3,0xf00
958+
bne 1f
959+
addi r3,r1,STACK_FRAME_OVERHEAD;
960+
bl performance_monitor_exception
961+
b ret_from_except
957962
1: cmpwi cr0,r3,0xe60
958963
bne 1f
959964
addi r3,r1,STACK_FRAME_OVERHEAD;

arch/powerpc/kernel/exceptions-64s.S

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,8 +1111,8 @@ EXC_REAL_NONE(0xee0, 0x20)
11111111
EXC_VIRT_NONE(0x4ee0, 0x20)
11121112

11131113

1114-
EXC_REAL_OOL(performance_monitor, 0xf00, 0x20)
1115-
EXC_VIRT_OOL(performance_monitor, 0x4f00, 0x20, 0xf00)
1114+
EXC_REAL_OOL_MASKABLE(performance_monitor, 0xf00, 0x20, IRQS_PMI_DISABLED)
1115+
EXC_VIRT_OOL_MASKABLE(performance_monitor, 0x4f00, 0x20, 0xf00, IRQS_PMI_DISABLED)
11161116
TRAMP_KVM(PACA_EXGEN, 0xf00)
11171117
EXC_COMMON_ASYNC(performance_monitor_common, 0xf00, performance_monitor_exception)
11181118

@@ -1723,6 +1723,8 @@ BEGIN_FTR_SECTION
17231723
FTR_SECTION_ELSE
17241724
beq hardware_interrupt_common
17251725
ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_300)
1726+
cmpwi r3,0xf00
1727+
beq performance_monitor_common
17261728
BEGIN_FTR_SECTION
17271729
cmpwi r3,0xa00
17281730
beq h_doorbell_common_msgclr

arch/powerpc/kernel/irq.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ notrace unsigned int __check_irq_replay(void)
186186
return 0x900;
187187
}
188188

189+
if (happened & PACA_IRQ_PMI) {
190+
local_paca->irq_happened &= ~PACA_IRQ_PMI;
191+
return 0xf00;
192+
}
193+
189194
if (happened & PACA_IRQ_EE) {
190195
local_paca->irq_happened &= ~PACA_IRQ_EE;
191196
return 0x500;
@@ -272,7 +277,7 @@ notrace void arch_local_irq_restore(unsigned long mask)
272277
}
273278
#endif /* CONFIG_TRACE_IRQFLAGS */
274279

275-
irq_soft_mask_set(IRQS_DISABLED);
280+
irq_soft_mask_set(IRQS_ALL_DISABLED);
276281
trace_hardirqs_off();
277282

278283
/*

0 commit comments

Comments
 (0)