summaryrefslogtreecommitdiff
path: root/lib/utils/fdt
diff options
context:
space:
mode:
authorAtish Patra <atish.patra@wdc.com>2021-11-08 21:53:05 +0300
committerAnup Patel <anup@brainfault.org>2021-11-11 15:24:01 +0300
commitb28f07005cef03d5eea43a8a7954154b391871fe (patch)
treec2fb39ffdc37d5abc6138a5fd51784035edc7afa /lib/utils/fdt
parentb628cfd6a0c1e8bf858b33a62d6a6fa16f4db640 (diff)
downloadopensbi-b28f07005cef03d5eea43a8a7954154b391871fe.tar.xz
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>
Diffstat (limited to 'lib/utils/fdt')
-rw-r--r--lib/utils/fdt/fdt_pmu.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/utils/fdt/fdt_pmu.c b/lib/utils/fdt/fdt_pmu.c
index 9ebf1c2..09c83c8 100644
--- a/lib/utils/fdt/fdt_pmu.c
+++ b/lib/utils/fdt/fdt_pmu.c
@@ -9,6 +9,7 @@
*/
#include <libfdt.h>
+#include <sbi/sbi_hart.h>
#include <sbi/sbi_error.h>
#include <sbi/sbi_pmu.h>
#include <sbi_utils/fdt/fdt_helper.h>
@@ -40,6 +41,7 @@ uint64_t fdt_pmu_get_select_value(uint32_t event_idx)
int fdt_pmu_fixup(void *fdt)
{
int pmu_offset;
+ struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
if (!fdt)
return SBI_EINVAL;
@@ -51,6 +53,8 @@ int fdt_pmu_fixup(void *fdt)
fdt_delprop(fdt, pmu_offset, "pmu,event-to-mhpmcounters");
fdt_delprop(fdt, pmu_offset, "pmu,event-to-mhpmevent");
fdt_delprop(fdt, pmu_offset, "pmu,raw-event-to-mhpmcounters");
+ if (!sbi_hart_has_feature(scratch, SBI_HART_HAS_SSCOFPMF))
+ fdt_delprop(fdt, pmu_offset, "interrupts-extended");
return 0;
}