aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Horne <mhorne@FreeBSD.org>2021-05-19 16:11:33 +0000
committerMitchell Horne <mhorne@FreeBSD.org>2021-06-30 19:47:09 +0000
commit8cc3815f02be9fa2a96e47713ad989e6d787e12a (patch)
tree84103a48ebc00ab41aa60ec1a67da635992026a3
parent5867cccdc49df3e7eb3147d6516b488dd8384afe (diff)
downloadsrc-8cc3815f02be9fa2a96e47713ad989e6d787e12a.tar.gz
src-8cc3815f02be9fa2a96e47713ad989e6d787e12a.zip
hwpmc_arm64: accept raw event codes for PMC_OP_PMCALLOCATE
Make it possible to specify event codes without an offset of PMC_EV_ARMV8_FIRST, by setting a machine-dependent flag. This is required to make use of event definitions from pmu-events. Reviewed by: ray (slightly earlier version) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30602
-rw-r--r--sys/arm64/include/pmc_mdep.h5
-rw-r--r--sys/dev/hwpmc/hwpmc_arm64.c11
2 files changed, 11 insertions, 5 deletions
diff --git a/sys/arm64/include/pmc_mdep.h b/sys/arm64/include/pmc_mdep.h
index bcf08a7f9551..f4f31aba6305 100644
--- a/sys/arm64/include/pmc_mdep.h
+++ b/sys/arm64/include/pmc_mdep.h
@@ -38,7 +38,10 @@
#include <dev/hwpmc/hwpmc_arm64.h>
union pmc_md_op_pmcallocate {
- uint64_t __pad[4];
+ uint32_t pm_md_flags;
+#define PM_MD_RAW_EVENT 0x1
+ uint32_t __pad32;
+ uint64_t __pad[3];
};
/* Logging */
diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c
index be26605bad51..6b98fb46e7f1 100644
--- a/sys/dev/hwpmc/hwpmc_arm64.c
+++ b/sys/dev/hwpmc/hwpmc_arm64.c
@@ -181,11 +181,14 @@ arm64_allocate_pmc(int cpu, int ri, struct pmc *pm,
}
pe = a->pm_ev;
- config = (uint32_t)pe - PMC_EV_ARMV8_FIRST;
- if (config > (PMC_EV_ARMV8_LAST - PMC_EV_ARMV8_FIRST))
- return (EINVAL);
+ /* Adjust the config value if needed. */
+ config = (uint32_t)pe;
+ if ((a->pm_md.pm_md_flags & PM_MD_RAW_EVENT) == 0) {
+ config -= PMC_EV_ARMV8_FIRST;
+ if (config > (PMC_EV_ARMV8_LAST - PMC_EV_ARMV8_FIRST))
+ return (EINVAL);
+ }
pm->pm_md.pm_arm64.pm_arm64_evsel = config;
-
PMCDBG2(MDP, ALL, 2, "arm64-allocate ri=%d -> config=0x%x", ri, config);
return (0);