lib: sbi_pmu: keep overflow interrupt of stopped hpm counter disabled
authorInochi Amaoto <inochiama@outlook.com>
Tue, 15 Aug 2023 09:40:33 +0000 (17:40 +0800)
committerAnup Patel <anup@brainfault.org>
Sun, 10 Sep 2023 05:35:01 +0000 (11:05 +0530)
After the hardware hpm counter is stopped, it should not raise any new
interrupt as it is already stopped. So add the hw_counter_disable_irq
callback to allow the custom pmu device to control this behavior.

Signed-off-by: Inochi Amaoto <inochiama@outlook.com>
Reviewed-by: Guo Ren <guoren@kernel.org>
Reviewed-by: Anup Patel <anup@brainfault.org>
Tested-by: Samuel Holland <samuel@sholland.org>
lib/sbi/sbi_pmu.c

index c52e8a2935627dea80a08e04137111bca9e5783c..9694aae4fd3a79022d4d31255e2ef82e9f7a4148 100644 (file)
@@ -482,6 +482,9 @@ static int pmu_ctr_stop_hw(uint32_t cidx)
        if (!__test_bit(cidx, &mctr_inhbt)) {
                __set_bit(cidx, &mctr_inhbt);
                csr_write(CSR_MCOUNTINHIBIT, mctr_inhbt);
+               if (pmu_dev && pmu_dev->hw_counter_disable_irq) {
+                       pmu_dev->hw_counter_disable_irq(cidx);
+               }
                return 0;
        } else
                return SBI_EALREADY_STOPPED;