Merge branches 'clk-range', 'clk-uniphier', 'clk-apple' and 'clk-qcom' into clk-next
[linux-2.6-microblaze.git] / arch / powerpc / perf / core-book3s.c
index 32b98b7..b5b42cf 100644 (file)
@@ -1355,9 +1355,20 @@ static void power_pmu_disable(struct pmu *pmu)
                 * Otherwise provide a warning if there is PMI pending, but
                 * no counter is found overflown.
                 */
-               if (any_pmc_overflown(cpuhw))
-                       clear_pmi_irq_pending();
-               else
+               if (any_pmc_overflown(cpuhw)) {
+                       /*
+                        * Since power_pmu_disable runs under local_irq_save, it
+                        * could happen that code hits a PMC overflow without PMI
+                        * pending in paca. Hence only clear PMI pending if it was
+                        * set.
+                        *
+                        * If a PMI is pending, then MSR[EE] must be disabled (because
+                        * the masked PMI handler disabling EE). So it is safe to
+                        * call clear_pmi_irq_pending().
+                        */
+                       if (pmi_irq_pending())
+                               clear_pmi_irq_pending();
+               } else
                        WARN_ON(pmi_irq_pending());
 
                val = mmcra = cpuhw->mmcr.mmcra;