diff options
author | Matt Macy <mmacy@FreeBSD.org> | 2018-06-04 02:05:48 +0000 |
---|---|---|
committer | Matt Macy <mmacy@FreeBSD.org> | 2018-06-04 02:05:48 +0000 |
commit | 07d80fd8dc996a84b1f135dc11c6a4b07de6b12b (patch) | |
tree | 5f5838ed23dff81ae5b9e3a16c17b2021b12beae /sys/dev/hwpmc/hwpmc_core.c | |
parent | 5de96e33d68b091cd1c8d682799606e2a3d8f6fa (diff) | |
download | src-07d80fd8dc996a84b1f135dc11c6a4b07de6b12b.tar.gz src-07d80fd8dc996a84b1f135dc11c6a4b07de6b12b.zip |
Notes
Diffstat (limited to 'sys/dev/hwpmc/hwpmc_core.c')
-rw-r--r-- | sys/dev/hwpmc/hwpmc_core.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c index cf2e17955a15..7f5aab42595b 100644 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -224,8 +224,9 @@ static int iaf_allocate_pmc(int cpu, int ri, struct pmc *pm, const struct pmc_op_pmcallocate *a) { - enum pmc_event ev; - uint32_t caps, flags, validflags; + uint8_t ev, umask; + uint32_t caps, flags, config; + const struct pmc_md_iap_op_pmcallocate *iap; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[core,%d] illegal CPU %d", __LINE__, cpu)); @@ -241,19 +242,32 @@ iaf_allocate_pmc(int cpu, int ri, struct pmc *pm, (caps & IAF_PMC_CAPS) != caps) return (EINVAL); - ev = pm->pm_event; - + iap = &a->pm_md.pm_iap; + config = iap->pm_iap_config; + ev = IAP_EVSEL_GET(config); + umask = IAP_UMASK_GET(config); - if (ev == PMC_EV_IAF_INSTR_RETIRED_ANY && ri != 0) + /* INST_RETIRED.ANY */ + if (ev == 0xC0 && ri != 0) return (EINVAL); - if (ev == PMC_EV_IAF_CPU_CLK_UNHALTED_CORE && ri != 1) + /* CPU_CLK_UNHALTED.THREAD */ + else if (ev == 0x3C && ri != 1) return (EINVAL); - if (ev == PMC_EV_IAF_CPU_CLK_UNHALTED_REF && ri != 2) + /* CPU_CLK_UNHALTED.REF */ + else if (ev == 0x0 && umask == 0x3 && ri != 2) + return (EINVAL); + else return (EINVAL); - flags = a->pm_md.pm_iaf.pm_iaf_flags; - - validflags = IAF_MASK; + flags = 0; + if (config & IAP_OS) + flags |= IAF_OS; + if (config & IAP_USR) + flags |= IAF_USR; + if (config & IAP_ANY) + flags |= IAF_ANY; + if (config & IAP_INT) + flags |= IAF_PMI; if (caps & PMC_CAP_INTERRUPT) flags |= IAF_PMI; |