Deleted Added
full compact
hwpmc_mpc7xxx.c (263122) hwpmc_mpc7xxx.c (283884)
1/*-
2 * Copyright (c) 2011 Justin Hibbits
3 * Copyright (c) 2005, Joseph Koshy
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2011 Justin Hibbits
3 * Copyright (c) 2005, Joseph Koshy
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: stable/10/sys/dev/hwpmc/hwpmc_mpc7xxx.c 263122 2014-03-14 00:12:53Z jhibbits $");
30__FBSDID("$FreeBSD: stable/10/sys/dev/hwpmc/hwpmc_mpc7xxx.c 283884 2015-06-01 17:57:05Z jhb $");
31
32#include <sys/param.h>
33#include <sys/pmc.h>
34#include <sys/pmckern.h>
35#include <sys/systm.h>
36
37#include <machine/pmc_mdep.h>
38#include <machine/spr.h>

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

379 ("[powerpc,%d] illegal row index %d", __LINE__, ri));
380
381 pm = powerpc_pcpu[cpu]->pc_ppcpmcs[ri].phw_pmc;
382 KASSERT(pm,
383 ("[core,%d] cpu %d ri %d pmc not configured", __LINE__, cpu,
384 ri));
385
386 tmp = mpc7xxx_pmcn_read(ri);
31
32#include <sys/param.h>
33#include <sys/pmc.h>
34#include <sys/pmckern.h>
35#include <sys/systm.h>
36
37#include <machine/pmc_mdep.h>
38#include <machine/spr.h>

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

379 ("[powerpc,%d] illegal row index %d", __LINE__, ri));
380
381 pm = powerpc_pcpu[cpu]->pc_ppcpmcs[ri].phw_pmc;
382 KASSERT(pm,
383 ("[core,%d] cpu %d ri %d pmc not configured", __LINE__, cpu,
384 ri));
385
386 tmp = mpc7xxx_pmcn_read(ri);
387 PMCDBG(MDP,REA,2,"ppc-read id=%d -> %jd", ri, tmp);
387 PMCDBG2(MDP,REA,2,"ppc-read id=%d -> %jd", ri, tmp);
388 if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
389 *v = POWERPC_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp);
390 else
391 *v = tmp;
392
393 return 0;
394}
395

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

403 KASSERT(ri >= 0 && ri < MPC7XXX_MAX_PMCS,
404 ("[powerpc,%d] illegal row-index %d", __LINE__, ri));
405
406 pm = powerpc_pcpu[cpu]->pc_ppcpmcs[ri].phw_pmc;
407
408 if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
409 v = POWERPC_RELOAD_COUNT_TO_PERFCTR_VALUE(v);
410
388 if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
389 *v = POWERPC_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp);
390 else
391 *v = tmp;
392
393 return 0;
394}
395

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

403 KASSERT(ri >= 0 && ri < MPC7XXX_MAX_PMCS,
404 ("[powerpc,%d] illegal row-index %d", __LINE__, ri));
405
406 pm = powerpc_pcpu[cpu]->pc_ppcpmcs[ri].phw_pmc;
407
408 if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
409 v = POWERPC_RELOAD_COUNT_TO_PERFCTR_VALUE(v);
410
411 PMCDBG(MDP,WRI,1,"powerpc-write cpu=%d ri=%d v=%jx", cpu, ri, v);
411 PMCDBG3(MDP,WRI,1,"powerpc-write cpu=%d ri=%d v=%jx", cpu, ri, v);
412
413 mpc7xxx_pmcn_write(ri, v);
414
415 return 0;
416}
417
418static int
419mpc7xxx_config_pmc(int cpu, int ri, struct pmc *pm)
420{
421 struct pmc_hw *phw;
422
412
413 mpc7xxx_pmcn_write(ri, v);
414
415 return 0;
416}
417
418static int
419mpc7xxx_config_pmc(int cpu, int ri, struct pmc *pm)
420{
421 struct pmc_hw *phw;
422
423 PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
423 PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
424
425 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
426 ("[powerpc,%d] illegal CPU value %d", __LINE__, cpu));
427 KASSERT(ri >= 0 && ri < MPC7XXX_MAX_PMCS,
428 ("[powerpc,%d] illegal row-index %d", __LINE__, ri));
429
430 phw = &powerpc_pcpu[cpu]->pc_ppcpmcs[ri];
431

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

554{
555 int first_ri, i;
556 struct pmc_cpu *pc;
557 struct powerpc_cpu *pac;
558 struct pmc_hw *phw;
559
560 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
561 ("[powerpc,%d] wrong cpu number %d", __LINE__, cpu));
424
425 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
426 ("[powerpc,%d] illegal CPU value %d", __LINE__, cpu));
427 KASSERT(ri >= 0 && ri < MPC7XXX_MAX_PMCS,
428 ("[powerpc,%d] illegal row-index %d", __LINE__, ri));
429
430 phw = &powerpc_pcpu[cpu]->pc_ppcpmcs[ri];
431

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

554{
555 int first_ri, i;
556 struct pmc_cpu *pc;
557 struct powerpc_cpu *pac;
558 struct pmc_hw *phw;
559
560 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
561 ("[powerpc,%d] wrong cpu number %d", __LINE__, cpu));
562 PMCDBG(MDP,INI,1,"powerpc-init cpu=%d", cpu);
562 PMCDBG1(MDP,INI,1,"powerpc-init cpu=%d", cpu);
563
564 powerpc_pcpu[cpu] = pac = malloc(sizeof(struct powerpc_cpu), M_PMC,
565 M_WAITOK|M_ZERO);
566 pac->pc_ppcpmcs = malloc(sizeof(struct pmc_hw) * MPC7XXX_MAX_PMCS,
567 M_PMC, M_WAITOK|M_ZERO);
568 pac->pc_class = PMC_CLASS_PPC7450;
569 pc = pmc_pcpu[cpu];
570 first_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_PPC7450].pcd_ri;

--- 58 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
563
564 powerpc_pcpu[cpu] = pac = malloc(sizeof(struct powerpc_cpu), M_PMC,
565 M_WAITOK|M_ZERO);
566 pac->pc_ppcpmcs = malloc(sizeof(struct pmc_hw) * MPC7XXX_MAX_PMCS,
567 M_PMC, M_WAITOK|M_ZERO);
568 pac->pc_class = PMC_CLASS_PPC7450;
569 pc = pmc_pcpu[cpu];
570 first_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_PPC7450].pcd_ri;

--- 58 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
643mpc7xxx_release_pmc(int cpu, int ri, struct pmc *pmc)
644{
645 struct pmc_hw *phw;

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

663 uint32_t config;
664 struct pmc *pm;
665 struct powerpc_cpu *pac;
666 pmc_value_t v;
667
668 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
669 ("[powerpc,%d] out of range CPU %d", __LINE__, cpu));
670
638
639 return 0;
640}
641
642static int
643mpc7xxx_release_pmc(int cpu, int ri, struct pmc *pmc)
644{
645 struct pmc_hw *phw;

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

663 uint32_t config;
664 struct pmc *pm;
665 struct powerpc_cpu *pac;
666 pmc_value_t v;
667
668 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
669 ("[powerpc,%d] out of range CPU %d", __LINE__, cpu));
670
671 PMCDBG(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf,
671 PMCDBG3(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf,
672 TRAPF_USERMODE(tf));
673
674 retval = 0;
675
676 pac = powerpc_pcpu[cpu];
677
678 config = mfspr(SPR_MMCR0);
679 mtspr(SPR_MMCR0, config | SPR_MMCR0_FC);

--- 74 unchanged lines hidden ---
672 TRAPF_USERMODE(tf));
673
674 retval = 0;
675
676 pac = powerpc_pcpu[cpu];
677
678 config = mfspr(SPR_MMCR0);
679 mtspr(SPR_MMCR0, config | SPR_MMCR0_FC);

--- 74 unchanged lines hidden ---