Skip to content

Commit 0209b58

Browse files
atishp04palmer-dabbelt
authored andcommitted
RISC-V: Fix SBI PMU calls for RV32
Some of the SBI PMU calls does not pass 64bit arguments correctly and not under RV32 compile time flags. Currently, this doesn't create any incorrect results as RV64 ignores any value in the additional register and qemu doesn't support raw events. Fix those SBI calls in order to set correct values for RV32. Fixes: e999143 ("RISC-V: Add perf platform driver based on SBI PMU extension") Signed-off-by: Atish Patra <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 133a6d1 commit 0209b58

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/perf/riscv_pmu_sbi.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,13 @@ static int pmu_sbi_ctr_get_idx(struct perf_event *event)
274274
cflags |= SBI_PMU_CFG_FLAG_SET_UINH;
275275

276276
/* retrieve the available counter index */
277+
#if defined(CONFIG_32BIT)
278+
ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, cbase, cmask,
279+
cflags, hwc->event_base, hwc->config, hwc->config >> 32);
280+
#else
277281
ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, cbase, cmask,
278282
cflags, hwc->event_base, hwc->config, 0);
283+
#endif
279284
if (ret.error) {
280285
pr_debug("Not able to find a counter for event %lx config %llx\n",
281286
hwc->event_base, hwc->config);
@@ -417,8 +422,13 @@ static void pmu_sbi_ctr_start(struct perf_event *event, u64 ival)
417422
struct hw_perf_event *hwc = &event->hw;
418423
unsigned long flag = SBI_PMU_START_FLAG_SET_INIT_VALUE;
419424

425+
#if defined(CONFIG_32BIT)
420426
ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, hwc->idx,
421427
1, flag, ival, ival >> 32, 0);
428+
#else
429+
ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, hwc->idx,
430+
1, flag, ival, 0, 0);
431+
#endif
422432
if (ret.error && (ret.error != SBI_ERR_ALREADY_STARTED))
423433
pr_err("Starting counter idx %d failed with error %d\n",
424434
hwc->idx, sbi_err_map_linux_errno(ret.error));

0 commit comments

Comments
 (0)