Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hwpmc/hwpmc_amd.c
| Show First 20 Lines • Show All 395 Lines • ▼ Show 20 Lines | amd_allocate_pmc(int cpu __unused, int ri, struct pmc *pm, | ||||
| KASSERT(ri >= 0 && ri < amd_npmcs, | KASSERT(ri >= 0 && ri < amd_npmcs, | ||||
| ("[amd,%d] illegal row index %d", __LINE__, ri)); | ("[amd,%d] illegal row index %d", __LINE__, ri)); | ||||
| pd = &amd_pmcdesc[ri].pm_descr; | pd = &amd_pmcdesc[ri].pm_descr; | ||||
| /* check class match */ | /* check class match */ | ||||
| if (pd->pd_class != a->pm_class) | if (pd->pd_class != a->pm_class) | ||||
| return (EINVAL); | |||||
| if ((a->pm_flags & PMC_F_EV_PMU) == 0) | |||||
| return (EINVAL); | return (EINVAL); | ||||
| caps = pm->pm_caps; | caps = pm->pm_caps; | ||||
| PMCDBG2(MDP, ALL, 1,"amd-allocate ri=%d caps=0x%x", ri, caps); | PMCDBG2(MDP, ALL, 1,"amd-allocate ri=%d caps=0x%x", ri, caps); | ||||
| /* Validate sub-class. */ | /* Validate sub-class. */ | ||||
| if (amd_pmcdesc[ri].pm_subclass != a->pm_md.pm_amd.pm_amd_sub_class) | if (amd_pmcdesc[ri].pm_subclass != a->pm_md.pm_amd.pm_amd_sub_class) | ||||
| return (EINVAL); | return (EINVAL); | ||||
| if (((caps & PMC_CAP_PRECISE) != 0) && | if (((caps & PMC_CAP_PRECISE) != 0) && | ||||
| ((pd->pd_caps & PMC_CAP_PRECISE) == 0)) | ((pd->pd_caps & PMC_CAP_PRECISE) == 0)) | ||||
| return (EINVAL); | return (EINVAL); | ||||
| if (strlen(pmc_cpuid) != 0) { | /* PMC_F_EV_PMU: config comes from pmu-events tables. */ | ||||
| if ((a->pm_flags & PMC_F_EV_PMU) != 0) { | |||||
| config = a->pm_md.pm_amd.pm_amd_config; | config = a->pm_md.pm_amd.pm_amd_config; | ||||
| if ((config & ~amd_config_mask(amd_pmcdesc[ri].pm_subclass, | if ((config & ~amd_config_mask(amd_pmcdesc[ri].pm_subclass, | ||||
| caps)) != 0) | caps)) != 0) | ||||
| return (EXTERROR(EINVAL, | return (EXTERROR(EINVAL, | ||||
| "AMD PMU config has unsupported bits %#jx", | "AMD PMU config has unsupported bits %#jx", | ||||
| (uintmax_t)(config & ~amd_config_mask( | (uintmax_t)(config & ~amd_config_mask( | ||||
| amd_pmcdesc[ri].pm_subclass, caps)))); | amd_pmcdesc[ri].pm_subclass, caps)))); | ||||
| pm->pm_md.pm_amd.pm_amd_evsel = config; | pm->pm_md.pm_amd.pm_amd_evsel = config; | ||||
| ▲ Show 20 Lines • Show All 746 Lines • Show Last 20 Lines | |||||