Deleted Added
full compact
hwpmc_ppro.c (174395) hwpmc_ppro.c (183266)
1/*-
1/*-
2 * Copyright (c) 2003-2005 Joseph Koshy
2 * Copyright (c) 2003-2005,2008 Joseph Koshy
3 * Copyright (c) 2007 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by A. Joseph Koshy under
7 * sponsorship from the FreeBSD Foundation and Google, Inc.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions

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

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
3 * Copyright (c) 2007 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by A. Joseph Koshy under
7 * sponsorship from the FreeBSD Foundation and Google, Inc.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions

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

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/dev/hwpmc/hwpmc_ppro.c 174395 2007-12-07 08:20:17Z jkoshy $");
32__FBSDID("$FreeBSD: head/sys/dev/hwpmc/hwpmc_ppro.c 183266 2008-09-22 10:37:02Z jkoshy $");
33
34#include <sys/param.h>
35#include <sys/lock.h>
36#include <sys/mutex.h>
37#include <sys/pmc.h>
38#include <sys/pmckern.h>
39#include <sys/smp.h>
40#include <sys/systm.h>

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

331
332static int
333p6_init(int cpu)
334{
335 int n;
336 struct p6_cpu *pcs;
337 struct pmc_hw *phw;
338
33
34#include <sys/param.h>
35#include <sys/lock.h>
36#include <sys/mutex.h>
37#include <sys/pmc.h>
38#include <sys/pmckern.h>
39#include <sys/smp.h>
40#include <sys/systm.h>

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

331
332static int
333p6_init(int cpu)
334{
335 int n;
336 struct p6_cpu *pcs;
337 struct pmc_hw *phw;
338
339 KASSERT(cpu >= 0 && cpu < mp_ncpus,
339 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
340 ("[p6,%d] bad cpu %d", __LINE__, cpu));
341
342 PMCDBG(MDP,INI,0,"p6-init cpu=%d", cpu);
343
344 MALLOC(pcs, struct p6_cpu *, sizeof(struct p6_cpu), M_PMC,
345 M_WAITOK|M_ZERO);
346
347 phw = pcs->pc_p6pmcs;

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

361 return 0;
362}
363
364static int
365p6_cleanup(int cpu)
366{
367 struct pmc_cpu *pcs;
368
340 ("[p6,%d] bad cpu %d", __LINE__, cpu));
341
342 PMCDBG(MDP,INI,0,"p6-init cpu=%d", cpu);
343
344 MALLOC(pcs, struct p6_cpu *, sizeof(struct p6_cpu), M_PMC,
345 M_WAITOK|M_ZERO);
346
347 phw = pcs->pc_p6pmcs;

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

361 return 0;
362}
363
364static int
365p6_cleanup(int cpu)
366{
367 struct pmc_cpu *pcs;
368
369 KASSERT(cpu >= 0 && cpu < mp_ncpus,
369 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
370 ("[p6,%d] bad cpu %d", __LINE__, cpu));
371
372 PMCDBG(MDP,INI,0,"p6-cleanup cpu=%d", cpu);
373
374 if ((pcs = pmc_pcpu[cpu]) != NULL)
375 FREE(pcs, M_PMC);
376 pmc_pcpu[cpu] = NULL;
377

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

507{
508 uint32_t allowed_unitmask, caps, config, unitmask;
509 const struct p6pmc_descr *pd;
510 const struct p6_event_descr *pevent;
511 enum pmc_event ev;
512
513 (void) cpu;
514
370 ("[p6,%d] bad cpu %d", __LINE__, cpu));
371
372 PMCDBG(MDP,INI,0,"p6-cleanup cpu=%d", cpu);
373
374 if ((pcs = pmc_pcpu[cpu]) != NULL)
375 FREE(pcs, M_PMC);
376 pmc_pcpu[cpu] = NULL;
377

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

507{
508 uint32_t allowed_unitmask, caps, config, unitmask;
509 const struct p6pmc_descr *pd;
510 const struct p6_event_descr *pevent;
511 enum pmc_event ev;
512
513 (void) cpu;
514
515 KASSERT(cpu >= 0 && cpu < mp_ncpus,
515 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
516 ("[p4,%d] illegal CPU %d", __LINE__, cpu));
517 KASSERT(ri >= 0 && ri < P6_NPMCS,
518 ("[p4,%d] illegal row-index value %d", __LINE__, ri));
519
520 pd = &p6_pmcdesc[ri];
521
522 PMCDBG(MDP,ALL,1, "p6-allocate ri=%d class=%d pmccaps=0x%x "
523 "reqcaps=0x%x", ri, pd->pm_descr.pd_class, pd->pm_descr.pd_caps,

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

611p6_release_pmc(int cpu, int ri, struct pmc *pm)
612{
613 struct pmc_hw *phw;
614
615 (void) pm;
616
617 PMCDBG(MDP,REL,1, "p6-release cpu=%d ri=%d pm=%p", cpu, ri, pm);
618
516 ("[p4,%d] illegal CPU %d", __LINE__, cpu));
517 KASSERT(ri >= 0 && ri < P6_NPMCS,
518 ("[p4,%d] illegal row-index value %d", __LINE__, ri));
519
520 pd = &p6_pmcdesc[ri];
521
522 PMCDBG(MDP,ALL,1, "p6-allocate ri=%d class=%d pmccaps=0x%x "
523 "reqcaps=0x%x", ri, pd->pm_descr.pd_class, pd->pm_descr.pd_caps,

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

611p6_release_pmc(int cpu, int ri, struct pmc *pm)
612{
613 struct pmc_hw *phw;
614
615 (void) pm;
616
617 PMCDBG(MDP,REL,1, "p6-release cpu=%d ri=%d pm=%p", cpu, ri, pm);
618
619 KASSERT(cpu >= 0 && cpu < mp_ncpus,
619 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
620 ("[p6,%d] illegal CPU value %d", __LINE__, cpu));
621 KASSERT(ri >= 0 && ri < P6_NPMCS,
622 ("[p6,%d] illegal row-index %d", __LINE__, ri));
623
624 phw = pmc_pcpu[cpu]->pc_hwpmcs[ri];
625
626 KASSERT(phw->phw_pmc == NULL,
627 ("[p6,%d] PHW pmc %p != pmc %p", __LINE__, phw->phw_pmc, pm));

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

633p6_start_pmc(int cpu, int ri)
634{
635 uint32_t config;
636 struct pmc *pm;
637 struct p6_cpu *pc;
638 struct pmc_hw *phw;
639 const struct p6pmc_descr *pd;
640
620 ("[p6,%d] illegal CPU value %d", __LINE__, cpu));
621 KASSERT(ri >= 0 && ri < P6_NPMCS,
622 ("[p6,%d] illegal row-index %d", __LINE__, ri));
623
624 phw = pmc_pcpu[cpu]->pc_hwpmcs[ri];
625
626 KASSERT(phw->phw_pmc == NULL,
627 ("[p6,%d] PHW pmc %p != pmc %p", __LINE__, phw->phw_pmc, pm));

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

633p6_start_pmc(int cpu, int ri)
634{
635 uint32_t config;
636 struct pmc *pm;
637 struct p6_cpu *pc;
638 struct pmc_hw *phw;
639 const struct p6pmc_descr *pd;
640
641 KASSERT(cpu >= 0 && cpu < mp_ncpus,
641 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
642 ("[p6,%d] illegal CPU value %d", __LINE__, cpu));
643 KASSERT(ri >= 0 && ri < P6_NPMCS,
644 ("[p6,%d] illegal row-index %d", __LINE__, ri));
645
646 pc = (struct p6_cpu *) pmc_pcpu[cpu];
647 phw = pc->pc_common.pc_hwpmcs[ri];
648 pm = phw->phw_pmc;
649 pd = &p6_pmcdesc[ri];

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

677static int
678p6_stop_pmc(int cpu, int ri)
679{
680 struct pmc *pm;
681 struct p6_cpu *pc;
682 struct pmc_hw *phw;
683 struct p6pmc_descr *pd;
684
642 ("[p6,%d] illegal CPU value %d", __LINE__, cpu));
643 KASSERT(ri >= 0 && ri < P6_NPMCS,
644 ("[p6,%d] illegal row-index %d", __LINE__, ri));
645
646 pc = (struct p6_cpu *) pmc_pcpu[cpu];
647 phw = pc->pc_common.pc_hwpmcs[ri];
648 pm = phw->phw_pmc;
649 pd = &p6_pmcdesc[ri];

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

677static int
678p6_stop_pmc(int cpu, int ri)
679{
680 struct pmc *pm;
681 struct p6_cpu *pc;
682 struct pmc_hw *phw;
683 struct p6pmc_descr *pd;
684
685 KASSERT(cpu >= 0 && cpu < mp_ncpus,
685 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
686 ("[p6,%d] illegal cpu value %d", __LINE__, cpu));
687 KASSERT(ri >= 0 && ri < P6_NPMCS,
688 ("[p6,%d] illegal row index %d", __LINE__, ri));
689
690 pc = (struct p6_cpu *) pmc_pcpu[cpu];
691 phw = pc->pc_common.pc_hwpmcs[ri];
692 pm = phw->phw_pmc;
693 pd = &p6_pmcdesc[ri];

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

719{
720 int i, error, retval, ri;
721 uint32_t perf0cfg;
722 struct pmc *pm;
723 struct p6_cpu *pc;
724 struct pmc_hw *phw;
725 pmc_value_t v;
726
686 ("[p6,%d] illegal cpu value %d", __LINE__, cpu));
687 KASSERT(ri >= 0 && ri < P6_NPMCS,
688 ("[p6,%d] illegal row index %d", __LINE__, ri));
689
690 pc = (struct p6_cpu *) pmc_pcpu[cpu];
691 phw = pc->pc_common.pc_hwpmcs[ri];
692 pm = phw->phw_pmc;
693 pd = &p6_pmcdesc[ri];

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

719{
720 int i, error, retval, ri;
721 uint32_t perf0cfg;
722 struct pmc *pm;
723 struct p6_cpu *pc;
724 struct pmc_hw *phw;
725 pmc_value_t v;
726
727 KASSERT(cpu >= 0 && cpu < mp_ncpus,
727 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
728 ("[p6,%d] CPU %d out of range", __LINE__, cpu));
729
730 retval = 0;
731 pc = (struct p6_cpu *) pmc_pcpu[cpu];
732
733 /* stop both PMCs */
734 perf0cfg = rdmsr(P6_MSR_EVSEL0);
735 wrmsr(P6_MSR_EVSEL0, perf0cfg & ~P6_EVSEL_EN);

--- 136 unchanged lines hidden ---
728 ("[p6,%d] CPU %d out of range", __LINE__, cpu));
729
730 retval = 0;
731 pc = (struct p6_cpu *) pmc_pcpu[cpu];
732
733 /* stop both PMCs */
734 perf0cfg = rdmsr(P6_MSR_EVSEL0);
735 wrmsr(P6_MSR_EVSEL0, perf0cfg & ~P6_EVSEL_EN);

--- 136 unchanged lines hidden ---