From 8cc3815f02be9fa2a96e47713ad989e6d787e12a Mon Sep 17 00:00:00 2001 From: Mitchell Horne Date: Wed, 19 May 2021 13:11:33 -0300 Subject: 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 --- sys/arm64/include/pmc_mdep.h | 5 ++++- sys/dev/hwpmc/hwpmc_arm64.c | 11 +++++++---- 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 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); -- cgit v1.2.3