Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hwpmc/hwpmc_uncore.c
Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
return (1ULL << uncore_ucf_width) - rlc; | return (1ULL << uncore_ucf_width) - rlc; | ||||
} | } | ||||
static int | static int | ||||
ucf_allocate_pmc(int cpu, int ri, struct pmc *pm, | ucf_allocate_pmc(int cpu, int ri, struct pmc *pm, | ||||
const struct pmc_op_pmcallocate *a) | const struct pmc_op_pmcallocate *a) | ||||
{ | { | ||||
uint32_t caps, flags; | uint32_t flags; | ||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), | KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), | ||||
("[uncore,%d] illegal CPU %d", __LINE__, cpu)); | ("[uncore,%d] illegal CPU %d", __LINE__, cpu)); | ||||
PMCDBG2(MDP,ALL,1, "ucf-allocate ri=%d reqcaps=0x%x", ri, pm->pm_caps); | PMCDBG2(MDP,ALL,1, "ucf-allocate ri=%d reqcaps=0x%x", ri, pm->pm_caps); | ||||
if (ri < 0 || ri > uncore_ucf_npmc) | if (ri < 0 || ri > uncore_ucf_npmc) | ||||
return (EINVAL); | return (EINVAL); | ||||
caps = a->pm_caps; | if (a->pm_class != PMC_CLASS_UCF) | ||||
if (a->pm_class != PMC_CLASS_UCF || | |||||
(caps & UCF_PMC_CAPS) != caps) | |||||
return (EINVAL); | return (EINVAL); | ||||
flags = UCF_EN; | flags = UCF_EN; | ||||
pm->pm_md.pm_ucf.pm_ucf_ctrl = (flags << (ri * 4)); | pm->pm_md.pm_ucf.pm_ucf_ctrl = (flags << (ri * 4)); | ||||
PMCDBG1(MDP,ALL,2, "ucf-allocate config=0x%jx", | PMCDBG1(MDP,ALL,2, "ucf-allocate config=0x%jx", | ||||
(uintmax_t) pm->pm_md.pm_ucf.pm_ucf_ctrl); | (uintmax_t) pm->pm_md.pm_ucf.pm_ucf_ctrl); | ||||
▲ Show 20 Lines • Show All 303 Lines • ▼ Show 20 Lines | ucp_event_sb_hw_ok_on_counter(uint8_t ev, int ri) | ||||
return (mask & (1 << ri)); | return (mask & (1 << ri)); | ||||
} | } | ||||
static int | static int | ||||
ucp_allocate_pmc(int cpu, int ri, struct pmc *pm, | ucp_allocate_pmc(int cpu, int ri, struct pmc *pm, | ||||
const struct pmc_op_pmcallocate *a) | const struct pmc_op_pmcallocate *a) | ||||
{ | { | ||||
uint8_t ev; | uint8_t ev; | ||||
uint32_t caps; | |||||
const struct pmc_md_ucp_op_pmcallocate *ucp; | const struct pmc_md_ucp_op_pmcallocate *ucp; | ||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), | KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), | ||||
("[uncore,%d] illegal CPU %d", __LINE__, cpu)); | ("[uncore,%d] illegal CPU %d", __LINE__, cpu)); | ||||
KASSERT(ri >= 0 && ri < uncore_ucp_npmc, | KASSERT(ri >= 0 && ri < uncore_ucp_npmc, | ||||
("[uncore,%d] illegal row-index value %d", __LINE__, ri)); | ("[uncore,%d] illegal row-index value %d", __LINE__, ri)); | ||||
if (a->pm_class != PMC_CLASS_UCP) | if (a->pm_class != PMC_CLASS_UCP) | ||||
return (EINVAL); | return (EINVAL); | ||||
/* check requested capabilities */ | |||||
caps = a->pm_caps; | |||||
if ((UCP_PMC_CAPS & caps) != caps) | |||||
return (EPERM); | |||||
ucp = &a->pm_md.pm_ucp; | ucp = &a->pm_md.pm_ucp; | ||||
ev = UCP_EVSEL(ucp->pm_ucp_config); | ev = UCP_EVSEL(ucp->pm_ucp_config); | ||||
switch (uncore_cputype) { | switch (uncore_cputype) { | ||||
case PMC_CPU_INTEL_HASWELL: | case PMC_CPU_INTEL_HASWELL: | ||||
case PMC_CPU_INTEL_SANDYBRIDGE: | case PMC_CPU_INTEL_SANDYBRIDGE: | ||||
if (ucp_event_sb_hw_ok_on_counter(ev, ri) == 0) | if (ucp_event_sb_hw_ok_on_counter(ev, ri) == 0) | ||||
return (EINVAL); | return (EINVAL); | ||||
▲ Show 20 Lines • Show All 315 Lines • Show Last 20 Lines |