Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hwpmc/hwpmc_xscale.c
Show First 20 Lines • Show All 271 Lines • ▼ Show 20 Lines | xscale_allocate_pmc(int cpu, int ri, struct pmc *pm, | ||||
} | } | ||||
if (i == xscale_event_codes_size) | if (i == xscale_event_codes_size) | ||||
return EINVAL; | return EINVAL; | ||||
/* Generation 1 has fewer events */ | /* Generation 1 has fewer events */ | ||||
if (xscale_gen == 1 && i > PMC_EV_XSCALE_PC_CHANGE) | if (xscale_gen == 1 && i > PMC_EV_XSCALE_PC_CHANGE) | ||||
return EINVAL; | return EINVAL; | ||||
pm->pm_md.pm_xscale.pm_xscale_evsel = config; | pm->pm_md.pm_xscale.pm_xscale_evsel = config; | ||||
PMCDBG(MDP,ALL,2,"xscale-allocate ri=%d -> config=0x%x", ri, config); | PMCDBG2(MDP,ALL,2,"xscale-allocate ri=%d -> config=0x%x", ri, config); | ||||
return 0; | return 0; | ||||
} | } | ||||
static int | static int | ||||
xscale_read_pmc(int cpu, int ri, pmc_value_t *v) | xscale_read_pmc(int cpu, int ri, pmc_value_t *v) | ||||
{ | { | ||||
struct pmc *pm; | struct pmc *pm; | ||||
pmc_value_t tmp; | pmc_value_t tmp; | ||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), | KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), | ||||
("[xscale,%d] illegal CPU value %d", __LINE__, cpu)); | ("[xscale,%d] illegal CPU value %d", __LINE__, cpu)); | ||||
KASSERT(ri >= 0 && ri < xscale_npmcs, | KASSERT(ri >= 0 && ri < xscale_npmcs, | ||||
("[xscale,%d] illegal row index %d", __LINE__, ri)); | ("[xscale,%d] illegal row index %d", __LINE__, ri)); | ||||
pm = xscale_pcpu[cpu]->pc_xscalepmcs[ri].phw_pmc; | pm = xscale_pcpu[cpu]->pc_xscalepmcs[ri].phw_pmc; | ||||
tmp = xscale_pmcn_read(ri); | tmp = xscale_pmcn_read(ri); | ||||
PMCDBG(MDP,REA,2,"xscale-read id=%d -> %jd", ri, tmp); | PMCDBG2(MDP,REA,2,"xscale-read id=%d -> %jd", ri, tmp); | ||||
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) | if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) | ||||
*v = XSCALE_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp); | *v = XSCALE_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp); | ||||
else | else | ||||
*v = tmp; | *v = tmp; | ||||
return 0; | return 0; | ||||
} | } | ||||
static int | static int | ||||
xscale_write_pmc(int cpu, int ri, pmc_value_t v) | xscale_write_pmc(int cpu, int ri, pmc_value_t v) | ||||
{ | { | ||||
struct pmc *pm; | struct pmc *pm; | ||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), | KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), | ||||
("[xscale,%d] illegal CPU value %d", __LINE__, cpu)); | ("[xscale,%d] illegal CPU value %d", __LINE__, cpu)); | ||||
KASSERT(ri >= 0 && ri < xscale_npmcs, | KASSERT(ri >= 0 && ri < xscale_npmcs, | ||||
("[xscale,%d] illegal row-index %d", __LINE__, ri)); | ("[xscale,%d] illegal row-index %d", __LINE__, ri)); | ||||
pm = xscale_pcpu[cpu]->pc_xscalepmcs[ri].phw_pmc; | pm = xscale_pcpu[cpu]->pc_xscalepmcs[ri].phw_pmc; | ||||
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) | if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) | ||||
v = XSCALE_RELOAD_COUNT_TO_PERFCTR_VALUE(v); | v = XSCALE_RELOAD_COUNT_TO_PERFCTR_VALUE(v); | ||||
PMCDBG(MDP,WRI,1,"xscale-write cpu=%d ri=%d v=%jx", cpu, ri, v); | PMCDBG3(MDP,WRI,1,"xscale-write cpu=%d ri=%d v=%jx", cpu, ri, v); | ||||
xscale_pmcn_write(ri, v); | xscale_pmcn_write(ri, v); | ||||
return 0; | return 0; | ||||
} | } | ||||
static int | static int | ||||
xscale_config_pmc(int cpu, int ri, struct pmc *pm) | xscale_config_pmc(int cpu, int ri, struct pmc *pm) | ||||
{ | { | ||||
struct pmc_hw *phw; | struct pmc_hw *phw; | ||||
PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm); | PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm); | ||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), | KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), | ||||
("[xscale,%d] illegal CPU value %d", __LINE__, cpu)); | ("[xscale,%d] illegal CPU value %d", __LINE__, cpu)); | ||||
KASSERT(ri >= 0 && ri < xscale_npmcs, | KASSERT(ri >= 0 && ri < xscale_npmcs, | ||||
("[xscale,%d] illegal row-index %d", __LINE__, ri)); | ("[xscale,%d] illegal row-index %d", __LINE__, ri)); | ||||
phw = &xscale_pcpu[cpu]->pc_xscalepmcs[ri]; | phw = &xscale_pcpu[cpu]->pc_xscalepmcs[ri]; | ||||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
int first_ri, i; | int first_ri, i; | ||||
struct pmc_cpu *pc; | struct pmc_cpu *pc; | ||||
struct xscale_cpu *pac; | struct xscale_cpu *pac; | ||||
struct pmc_hw *phw; | struct pmc_hw *phw; | ||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), | KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), | ||||
("[xscale,%d] wrong cpu number %d", __LINE__, cpu)); | ("[xscale,%d] wrong cpu number %d", __LINE__, cpu)); | ||||
PMCDBG(MDP,INI,1,"xscale-init cpu=%d", cpu); | PMCDBG1(MDP,INI,1,"xscale-init cpu=%d", cpu); | ||||
xscale_pcpu[cpu] = pac = malloc(sizeof(struct xscale_cpu), M_PMC, | xscale_pcpu[cpu] = pac = malloc(sizeof(struct xscale_cpu), M_PMC, | ||||
M_WAITOK|M_ZERO); | M_WAITOK|M_ZERO); | ||||
pac->pc_xscalepmcs = malloc(sizeof(struct pmc_hw) * xscale_npmcs, | pac->pc_xscalepmcs = malloc(sizeof(struct pmc_hw) * xscale_npmcs, | ||||
M_PMC, M_WAITOK|M_ZERO); | M_PMC, M_WAITOK|M_ZERO); | ||||
pc = pmc_pcpu[cpu]; | pc = pmc_pcpu[cpu]; | ||||
first_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_XSCALE].pcd_ri; | first_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_XSCALE].pcd_ri; | ||||
KASSERT(pc != NULL, ("[xscale,%d] NULL per-cpu pointer", __LINE__)); | KASSERT(pc != NULL, ("[xscale,%d] NULL per-cpu pointer", __LINE__)); | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | pmc_xscale_initialize() | ||||
case 2: | case 2: | ||||
case 3: | case 3: | ||||
xscale_npmcs = 4; | xscale_npmcs = 4; | ||||
break; | break; | ||||
default: | default: | ||||
printf("%s: unknown XScale core generation\n", __func__); | printf("%s: unknown XScale core generation\n", __func__); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
PMCDBG(MDP,INI,1,"xscale-init npmcs=%d", xscale_npmcs); | PMCDBG1(MDP,INI,1,"xscale-init npmcs=%d", xscale_npmcs); | ||||
/* | /* | ||||
* Allocate space for pointers to PMC HW descriptors and for | * Allocate space for pointers to PMC HW descriptors and for | ||||
* the MDEP structure used by MI code. | * the MDEP structure used by MI code. | ||||
*/ | */ | ||||
xscale_pcpu = malloc(sizeof(struct xscale_cpu *) * pmc_cpu_max(), M_PMC, | xscale_pcpu = malloc(sizeof(struct xscale_cpu *) * pmc_cpu_max(), M_PMC, | ||||
M_WAITOK|M_ZERO); | M_WAITOK|M_ZERO); | ||||
Show All 37 Lines |