hwpmc_xscale.c (256281) | hwpmc_xscale.c (283884) |
---|---|
1/*- 2 * Copyright (c) 2009 Rui Paulo <rpaulo@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009 Rui Paulo <rpaulo@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: stable/10/sys/dev/hwpmc/hwpmc_xscale.c 233628 2012-03-28 20:58:30Z fabient $"); | 29__FBSDID("$FreeBSD: stable/10/sys/dev/hwpmc/hwpmc_xscale.c 283884 2015-06-01 17:57:05Z jhb $"); |
30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/pmc.h> 34#include <sys/pmckern.h> 35 36#include <machine/pmc_mdep.h> 37/* --- 234 unchanged lines hidden (view full) --- 272 } 273 if (i == xscale_event_codes_size) 274 return EINVAL; 275 /* Generation 1 has fewer events */ 276 if (xscale_gen == 1 && i > PMC_EV_XSCALE_PC_CHANGE) 277 return EINVAL; 278 pm->pm_md.pm_xscale.pm_xscale_evsel = config; 279 | 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/pmc.h> 34#include <sys/pmckern.h> 35 36#include <machine/pmc_mdep.h> 37/* --- 234 unchanged lines hidden (view full) --- 272 } 273 if (i == xscale_event_codes_size) 274 return EINVAL; 275 /* Generation 1 has fewer events */ 276 if (xscale_gen == 1 && i > PMC_EV_XSCALE_PC_CHANGE) 277 return EINVAL; 278 pm->pm_md.pm_xscale.pm_xscale_evsel = config; 279 |
280 PMCDBG(MDP,ALL,2,"xscale-allocate ri=%d -> config=0x%x", ri, config); | 280 PMCDBG2(MDP,ALL,2,"xscale-allocate ri=%d -> config=0x%x", ri, config); |
281 282 return 0; 283} 284 285 286static int 287xscale_read_pmc(int cpu, int ri, pmc_value_t *v) 288{ 289 struct pmc *pm; 290 pmc_value_t tmp; 291 292 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), 293 ("[xscale,%d] illegal CPU value %d", __LINE__, cpu)); 294 KASSERT(ri >= 0 && ri < xscale_npmcs, 295 ("[xscale,%d] illegal row index %d", __LINE__, ri)); 296 297 pm = xscale_pcpu[cpu]->pc_xscalepmcs[ri].phw_pmc; 298 tmp = xscale_pmcn_read(ri); | 281 282 return 0; 283} 284 285 286static int 287xscale_read_pmc(int cpu, int ri, pmc_value_t *v) 288{ 289 struct pmc *pm; 290 pmc_value_t tmp; 291 292 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), 293 ("[xscale,%d] illegal CPU value %d", __LINE__, cpu)); 294 KASSERT(ri >= 0 && ri < xscale_npmcs, 295 ("[xscale,%d] illegal row index %d", __LINE__, ri)); 296 297 pm = xscale_pcpu[cpu]->pc_xscalepmcs[ri].phw_pmc; 298 tmp = xscale_pmcn_read(ri); |
299 PMCDBG(MDP,REA,2,"xscale-read id=%d -> %jd", ri, tmp); | 299 PMCDBG2(MDP,REA,2,"xscale-read id=%d -> %jd", ri, tmp); |
300 if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) 301 *v = XSCALE_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp); 302 else 303 *v = tmp; 304 305 return 0; 306} 307 --- 7 unchanged lines hidden (view full) --- 315 KASSERT(ri >= 0 && ri < xscale_npmcs, 316 ("[xscale,%d] illegal row-index %d", __LINE__, ri)); 317 318 pm = xscale_pcpu[cpu]->pc_xscalepmcs[ri].phw_pmc; 319 320 if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) 321 v = XSCALE_RELOAD_COUNT_TO_PERFCTR_VALUE(v); 322 | 300 if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) 301 *v = XSCALE_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp); 302 else 303 *v = tmp; 304 305 return 0; 306} 307 --- 7 unchanged lines hidden (view full) --- 315 KASSERT(ri >= 0 && ri < xscale_npmcs, 316 ("[xscale,%d] illegal row-index %d", __LINE__, ri)); 317 318 pm = xscale_pcpu[cpu]->pc_xscalepmcs[ri].phw_pmc; 319 320 if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) 321 v = XSCALE_RELOAD_COUNT_TO_PERFCTR_VALUE(v); 322 |
323 PMCDBG(MDP,WRI,1,"xscale-write cpu=%d ri=%d v=%jx", cpu, ri, v); | 323 PMCDBG3(MDP,WRI,1,"xscale-write cpu=%d ri=%d v=%jx", cpu, ri, v); |
324 325 xscale_pmcn_write(ri, v); 326 327 return 0; 328} 329 330static int 331xscale_config_pmc(int cpu, int ri, struct pmc *pm) 332{ 333 struct pmc_hw *phw; 334 | 324 325 xscale_pmcn_write(ri, v); 326 327 return 0; 328} 329 330static int 331xscale_config_pmc(int cpu, int ri, struct pmc *pm) 332{ 333 struct pmc_hw *phw; 334 |
335 PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm); | 335 PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm); |
336 337 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), 338 ("[xscale,%d] illegal CPU value %d", __LINE__, cpu)); 339 KASSERT(ri >= 0 && ri < xscale_npmcs, 340 ("[xscale,%d] illegal row-index %d", __LINE__, ri)); 341 342 phw = &xscale_pcpu[cpu]->pc_xscalepmcs[ri]; 343 --- 219 unchanged lines hidden (view full) --- 563{ 564 int first_ri, i; 565 struct pmc_cpu *pc; 566 struct xscale_cpu *pac; 567 struct pmc_hw *phw; 568 569 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), 570 ("[xscale,%d] wrong cpu number %d", __LINE__, cpu)); | 336 337 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), 338 ("[xscale,%d] illegal CPU value %d", __LINE__, cpu)); 339 KASSERT(ri >= 0 && ri < xscale_npmcs, 340 ("[xscale,%d] illegal row-index %d", __LINE__, ri)); 341 342 phw = &xscale_pcpu[cpu]->pc_xscalepmcs[ri]; 343 --- 219 unchanged lines hidden (view full) --- 563{ 564 int first_ri, i; 565 struct pmc_cpu *pc; 566 struct xscale_cpu *pac; 567 struct pmc_hw *phw; 568 569 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), 570 ("[xscale,%d] wrong cpu number %d", __LINE__, cpu)); |
571 PMCDBG(MDP,INI,1,"xscale-init cpu=%d", cpu); | 571 PMCDBG1(MDP,INI,1,"xscale-init cpu=%d", cpu); |
572 573 xscale_pcpu[cpu] = pac = malloc(sizeof(struct xscale_cpu), M_PMC, 574 M_WAITOK|M_ZERO); 575 pac->pc_xscalepmcs = malloc(sizeof(struct pmc_hw) * xscale_npmcs, 576 M_PMC, M_WAITOK|M_ZERO); 577 pc = pmc_pcpu[cpu]; 578 first_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_XSCALE].pcd_ri; 579 KASSERT(pc != NULL, ("[xscale,%d] NULL per-cpu pointer", __LINE__)); --- 43 unchanged lines hidden (view full) --- 623 case 2: 624 case 3: 625 xscale_npmcs = 4; 626 break; 627 default: 628 printf("%s: unknown XScale core generation\n", __func__); 629 return (NULL); 630 } | 572 573 xscale_pcpu[cpu] = pac = malloc(sizeof(struct xscale_cpu), M_PMC, 574 M_WAITOK|M_ZERO); 575 pac->pc_xscalepmcs = malloc(sizeof(struct pmc_hw) * xscale_npmcs, 576 M_PMC, M_WAITOK|M_ZERO); 577 pc = pmc_pcpu[cpu]; 578 first_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_XSCALE].pcd_ri; 579 KASSERT(pc != NULL, ("[xscale,%d] NULL per-cpu pointer", __LINE__)); --- 43 unchanged lines hidden (view full) --- 623 case 2: 624 case 3: 625 xscale_npmcs = 4; 626 break; 627 default: 628 printf("%s: unknown XScale core generation\n", __func__); 629 return (NULL); 630 } |
631 PMCDBG(MDP,INI,1,"xscale-init npmcs=%d", xscale_npmcs); | 631 PMCDBG1(MDP,INI,1,"xscale-init npmcs=%d", xscale_npmcs); |
632 633 /* 634 * Allocate space for pointers to PMC HW descriptors and for 635 * the MDEP structure used by MI code. 636 */ 637 xscale_pcpu = malloc(sizeof(struct xscale_cpu *) * pmc_cpu_max(), M_PMC, 638 M_WAITOK|M_ZERO); 639 --- 37 unchanged lines hidden --- | 632 633 /* 634 * Allocate space for pointers to PMC HW descriptors and for 635 * the MDEP structure used by MI code. 636 */ 637 xscale_pcpu = malloc(sizeof(struct xscale_cpu *) * pmc_cpu_max(), M_PMC, 638 M_WAITOK|M_ZERO); 639 --- 37 unchanged lines hidden --- |