Deleted Added
full compact
hwpmc_ppc970.c (263122) hwpmc_ppc970.c (283884)
1/*-
2 * Copyright (c) 2013 Justin Hibbits
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) 2013 Justin Hibbits
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_ppc970.c 263122 2014-03-14 00:12:53Z jhibbits $");
29__FBSDID("$FreeBSD: stable/10/sys/dev/hwpmc/hwpmc_ppc970.c 283884 2015-06-01 17:57:05Z jhb $");
30
31#include <sys/param.h>
32#include <sys/pmc.h>
33#include <sys/pmckern.h>
34#include <sys/systm.h>
35
36#include <machine/pmc_mdep.h>
37#include <machine/spr.h>

--- 299 unchanged lines hidden (view full) ---

337 }
338}
339
340static int
341ppc970_config_pmc(int cpu, int ri, struct pmc *pm)
342{
343 struct pmc_hw *phw;
344
30
31#include <sys/param.h>
32#include <sys/pmc.h>
33#include <sys/pmckern.h>
34#include <sys/systm.h>
35
36#include <machine/pmc_mdep.h>
37#include <machine/spr.h>

--- 299 unchanged lines hidden (view full) ---

337 }
338}
339
340static int
341ppc970_config_pmc(int cpu, int ri, struct pmc *pm)
342{
343 struct pmc_hw *phw;
344
345 PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
345 PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
346
347 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
348 ("[powerpc,%d] illegal CPU value %d", __LINE__, cpu));
349 KASSERT(ri >= 0 && ri < PPC970_MAX_PMCS,
350 ("[powerpc,%d] illegal row-index %d", __LINE__, ri));
351
352 phw = &powerpc_pcpu[cpu]->pc_ppcpmcs[ri];
353

--- 86 unchanged lines hidden (view full) ---

440 ("[powerpc,%d] illegal row index %d", __LINE__, ri));
441
442 pm = powerpc_pcpu[cpu]->pc_ppcpmcs[ri].phw_pmc;
443 KASSERT(pm,
444 ("[core,%d] cpu %d ri %d pmc not configured", __LINE__, cpu,
445 ri));
446
447 tmp = ppc970_pmcn_read(ri);
346
347 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
348 ("[powerpc,%d] illegal CPU value %d", __LINE__, cpu));
349 KASSERT(ri >= 0 && ri < PPC970_MAX_PMCS,
350 ("[powerpc,%d] illegal row-index %d", __LINE__, ri));
351
352 phw = &powerpc_pcpu[cpu]->pc_ppcpmcs[ri];
353

--- 86 unchanged lines hidden (view full) ---

440 ("[powerpc,%d] illegal row index %d", __LINE__, ri));
441
442 pm = powerpc_pcpu[cpu]->pc_ppcpmcs[ri].phw_pmc;
443 KASSERT(pm,
444 ("[core,%d] cpu %d ri %d pmc not configured", __LINE__, cpu,
445 ri));
446
447 tmp = ppc970_pmcn_read(ri);
448 PMCDBG(MDP,REA,2,"ppc-read id=%d -> %jd", ri, tmp);
448 PMCDBG2(MDP,REA,2,"ppc-read id=%d -> %jd", ri, tmp);
449 if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
450 *v = POWERPC_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp);
451 else
452 *v = tmp;
453
454 return 0;
455}
456

--- 7 unchanged lines hidden (view full) ---

464 KASSERT(ri >= 0 && ri < PPC970_MAX_PMCS,
465 ("[powerpc,%d] illegal row-index %d", __LINE__, ri));
466
467 pm = powerpc_pcpu[cpu]->pc_ppcpmcs[ri].phw_pmc;
468
469 if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
470 v = POWERPC_RELOAD_COUNT_TO_PERFCTR_VALUE(v);
471
449 if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
450 *v = POWERPC_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp);
451 else
452 *v = tmp;
453
454 return 0;
455}
456

--- 7 unchanged lines hidden (view full) ---

464 KASSERT(ri >= 0 && ri < PPC970_MAX_PMCS,
465 ("[powerpc,%d] illegal row-index %d", __LINE__, ri));
466
467 pm = powerpc_pcpu[cpu]->pc_ppcpmcs[ri].phw_pmc;
468
469 if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
470 v = POWERPC_RELOAD_COUNT_TO_PERFCTR_VALUE(v);
471
472 PMCDBG(MDP,WRI,1,"powerpc-write cpu=%d ri=%d v=%jx", cpu, ri, v);
472 PMCDBG3(MDP,WRI,1,"powerpc-write cpu=%d ri=%d v=%jx", cpu, ri, v);
473
474 ppc970_pmcn_write(ri, v);
475
476 return 0;
477}
478
479static int
480ppc970_intr(int cpu, struct trapframe *tf)
481{
482 struct pmc *pm;
483 struct powerpc_cpu *pac;
484 pmc_value_t v;
485 uint32_t config;
486 int i, error, retval;
487
488 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
489 ("[powerpc,%d] out of range CPU %d", __LINE__, cpu));
490
473
474 ppc970_pmcn_write(ri, v);
475
476 return 0;
477}
478
479static int
480ppc970_intr(int cpu, struct trapframe *tf)
481{
482 struct pmc *pm;
483 struct powerpc_cpu *pac;
484 pmc_value_t v;
485 uint32_t config;
486 int i, error, retval;
487
488 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
489 ("[powerpc,%d] out of range CPU %d", __LINE__, cpu));
490
491 PMCDBG(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf,
491 PMCDBG3(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf,
492 TRAPF_USERMODE(tf));
493
494 retval = 0;
495
496 pac = powerpc_pcpu[cpu];
497
498 /*
499 * look for all PMCs that have interrupted:

--- 46 unchanged lines hidden (view full) ---

546{
547 struct pmc_cpu *pc;
548 struct powerpc_cpu *pac;
549 struct pmc_hw *phw;
550 int first_ri, i;
551
552 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
553 ("[powerpc,%d] wrong cpu number %d", __LINE__, cpu));
492 TRAPF_USERMODE(tf));
493
494 retval = 0;
495
496 pac = powerpc_pcpu[cpu];
497
498 /*
499 * look for all PMCs that have interrupted:

--- 46 unchanged lines hidden (view full) ---

546{
547 struct pmc_cpu *pc;
548 struct powerpc_cpu *pac;
549 struct pmc_hw *phw;
550 int first_ri, i;
551
552 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
553 ("[powerpc,%d] wrong cpu number %d", __LINE__, cpu));
554 PMCDBG(MDP,INI,1,"powerpc-init cpu=%d", cpu);
554 PMCDBG1(MDP,INI,1,"powerpc-init cpu=%d", cpu);
555
556 powerpc_pcpu[cpu] = pac = malloc(sizeof(struct powerpc_cpu), M_PMC,
557 M_WAITOK|M_ZERO);
558 pac->pc_ppcpmcs = malloc(sizeof(struct pmc_hw) * PPC970_MAX_PMCS,
559 M_PMC, M_WAITOK|M_ZERO);
560 pac->pc_class = PMC_CLASS_PPC970;
561
562 pc = pmc_pcpu[cpu];

--- 66 unchanged lines hidden (view full) ---

629 config |= POWERPC_PMC_KERNEL_ENABLE;
630 if (caps & PMC_CAP_USER)
631 config |= POWERPC_PMC_USER_ENABLE;
632 if ((caps & (PMC_CAP_USER | PMC_CAP_SYSTEM)) == 0)
633 config |= POWERPC_PMC_ENABLE;
634
635 pm->pm_md.pm_powerpc.pm_powerpc_evsel = config;
636
555
556 powerpc_pcpu[cpu] = pac = malloc(sizeof(struct powerpc_cpu), M_PMC,
557 M_WAITOK|M_ZERO);
558 pac->pc_ppcpmcs = malloc(sizeof(struct pmc_hw) * PPC970_MAX_PMCS,
559 M_PMC, M_WAITOK|M_ZERO);
560 pac->pc_class = PMC_CLASS_PPC970;
561
562 pc = pmc_pcpu[cpu];

--- 66 unchanged lines hidden (view full) ---

629 config |= POWERPC_PMC_KERNEL_ENABLE;
630 if (caps & PMC_CAP_USER)
631 config |= POWERPC_PMC_USER_ENABLE;
632 if ((caps & (PMC_CAP_USER | PMC_CAP_SYSTEM)) == 0)
633 config |= POWERPC_PMC_ENABLE;
634
635 pm->pm_md.pm_powerpc.pm_powerpc_evsel = config;
636
637 PMCDBG(MDP,ALL,2,"powerpc-allocate ri=%d -> config=0x%x", ri, config);
637 PMCDBG2(MDP,ALL,2,"powerpc-allocate ri=%d -> config=0x%x", ri, config);
638
639 return 0;
640}
641
642static int
643ppc970_release_pmc(int cpu, int ri, struct pmc *pmc)
644{
645 struct pmc_hw *phw;

--- 44 unchanged lines hidden ---
638
639 return 0;
640}
641
642static int
643ppc970_release_pmc(int cpu, int ri, struct pmc *pmc)
644{
645 struct pmc_hw *phw;

--- 44 unchanged lines hidden ---