static inline void pmu_sbi_stop_hw_ctrs(struct riscv_pmu *pmu)
 {
        struct cpu_hw_events *cpu_hw_evt = this_cpu_ptr(pmu->hw_events);
+       int i;
 
-       /* No need to check the error here as we can't do anything about the error */
-       sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP, 0,
-                 cpu_hw_evt->used_hw_ctrs[0], 0, 0, 0, 0);
+       for (i = 0; i < BITS_TO_LONGS(RISCV_MAX_COUNTERS); i++)
+               /* No need to check the error here as we can't do anything about the error */
+               sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP, i * BITS_PER_LONG,
+                         cpu_hw_evt->used_hw_ctrs[i], 0, 0, 0, 0);
 }
 
 /*
 static inline void pmu_sbi_start_overflow_mask(struct riscv_pmu *pmu,
                                               unsigned long ctr_ovf_mask)
 {
-       int idx = 0;
+       int idx = 0, i;
        struct cpu_hw_events *cpu_hw_evt = this_cpu_ptr(pmu->hw_events);
        struct perf_event *event;
        unsigned long flag = SBI_PMU_START_FLAG_SET_INIT_VALUE;
        struct hw_perf_event *hwc;
        u64 init_val = 0;
 
-       ctr_start_mask = cpu_hw_evt->used_hw_ctrs[0] & ~ctr_ovf_mask;
-
-       /* Start all the counters that did not overflow in a single shot */
-       sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, 0, ctr_start_mask,
-                 0, 0, 0, 0);
+       for (i = 0; i < BITS_TO_LONGS(RISCV_MAX_COUNTERS); i++) {
+               ctr_start_mask = cpu_hw_evt->used_hw_ctrs[i] & ~ctr_ovf_mask;
+               /* Start all the counters that did not overflow in a single shot */
+               sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, i * BITS_PER_LONG, ctr_start_mask,
+                       0, 0, 0, 0);
+       }
 
        /* Reinitialize and start all the counter that overflowed */
        while (ctr_ovf_mask) {