aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/hwpmc/hwpmc_core.c
diff options
context:
space:
mode:
authorMatt Macy <mmacy@FreeBSD.org>2018-06-04 02:05:48 +0000
committerMatt Macy <mmacy@FreeBSD.org>2018-06-04 02:05:48 +0000
commit07d80fd8dc996a84b1f135dc11c6a4b07de6b12b (patch)
tree5f5838ed23dff81ae5b9e3a16c17b2021b12beae /sys/dev/hwpmc/hwpmc_core.c
parent5de96e33d68b091cd1c8d682799606e2a3d8f6fa (diff)
downloadsrc-07d80fd8dc996a84b1f135dc11c6a4b07de6b12b.tar.gz
src-07d80fd8dc996a84b1f135dc11c6a4b07de6b12b.zip
Notes
Diffstat (limited to 'sys/dev/hwpmc/hwpmc_core.c')
-rw-r--r--sys/dev/hwpmc/hwpmc_core.c34
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;