lib: sbi: Enable PMU extension for platforms without mcountinhibit
authorAtish Patra <atish.patra@wdc.com>
Mon, 8 Nov 2021 18:53:05 +0000 (10:53 -0800)
committerAnup Patel <anup@brainfault.org>
Thu, 11 Nov 2021 12:24:01 +0000 (17:54 +0530)
commitb28f07005cef03d5eea43a8a7954154b391871fe
treec2fb39ffdc37d5abc6138a5fd51784035edc7afa
parentb628cfd6a0c1e8bf858b33a62d6a6fa16f4db640
lib: sbi: Enable PMU extension for platforms without mcountinhibit

Some platforms such as hifive unmatched doesn't implement mcountinhibit
csr. However, it has hardware events that can be monitored using 2
hpmcounter it has (i.e. mhpmcounter3 & mhpmcounter4).

Currently, PMU extension disabled if mcountinhibit is absent. That's not
really necessary as long as the supervisor OS keeps track of the delta
value of the counters. Without mcountinhibit, the delta value won't be
entirely accurate because the counters are freely running. However, that
should be fine to produce an approximate counter value which can help
performance analysis. Perf sampling won't work though as sscof extension
is not present in hifive unmatched.

Reviewed-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
lib/sbi/sbi_ecall_pmu.c
lib/sbi/sbi_pmu.c
lib/utils/fdt/fdt_pmu.c