@@ -345,17 +345,54 @@ static inline bool lazy_irq_pending_nocheck(void)
345345bool power_pmu_wants_prompt_pmi (void );
346346
347347/*
348- * This is called by asynchronous interrupts to conditionally
349- * re-enable hard interrupts after having cleared the source
350- * of the interrupt. They are kept disabled if there is a different
351- * soft-masked interrupt pending that requires hard masking.
348+ * This is called by asynchronous interrupts to check whether to
349+ * conditionally re-enable hard interrupts after having cleared
350+ * the source of the interrupt. They are kept disabled if there
351+ * is a different soft-masked interrupt pending that requires hard
352+ * masking.
352353 */
353- static inline void may_hard_irq_enable (void )
354+ static inline bool should_hard_irq_enable (void )
354355{
355- if (!(get_paca ()-> irq_happened & PACA_IRQ_MUST_HARD_MASK )) {
356- get_paca ()-> irq_happened &= ~PACA_IRQ_HARD_DIS ;
357- __hard_irq_enable ();
358- }
356+ #ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
357+ WARN_ON (irq_soft_mask_return () == IRQS_ENABLED );
358+ WARN_ON (mfmsr () & MSR_EE );
359+ #endif
360+ #ifdef CONFIG_PERF_EVENTS
361+ /*
362+ * If the PMU is not running, there is not much reason to enable
363+ * MSR[EE] in irq handlers because any interrupts would just be
364+ * soft-masked.
365+ *
366+ * TODO: Add test for 64e
367+ */
368+ if (IS_ENABLED (CONFIG_PPC_BOOK3S_64 ) && !power_pmu_wants_prompt_pmi ())
369+ return false;
370+
371+ if (get_paca ()-> irq_happened & PACA_IRQ_MUST_HARD_MASK )
372+ return false;
373+
374+ return true;
375+ #else
376+ return false;
377+ #endif
378+ }
379+
380+ /*
381+ * Do the hard enabling, only call this if should_hard_irq_enable is true.
382+ */
383+ static inline void do_hard_irq_enable (void )
384+ {
385+ #ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
386+ WARN_ON (irq_soft_mask_return () == IRQS_ENABLED );
387+ WARN_ON (get_paca ()-> irq_happened & PACA_IRQ_MUST_HARD_MASK );
388+ WARN_ON (mfmsr () & MSR_EE );
389+ #endif
390+ /*
391+ * This allows PMI interrupts (and watchdog soft-NMIs) through.
392+ * There is no other reason to enable this way.
393+ */
394+ get_paca ()-> irq_happened &= ~PACA_IRQ_HARD_DIS ;
395+ __hard_irq_enable ();
359396}
360397
361398static inline bool arch_irq_disabled_regs (struct pt_regs * regs )
@@ -436,7 +473,7 @@ static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
436473 return !(regs -> msr & MSR_EE );
437474}
438475
439- static inline bool may_hard_irq_enable (void )
476+ static inline bool should_hard_irq_enable (void )
440477{
441478 return false;
442479}
0 commit comments