Deleted Added
full compact
hwpmc_mips24k.c (204635) hwpmc_mips24k.c (227395)
1/*-
2 * Copyright (c) 2010 George V. Neville-Neil <gnn@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) 2010 George V. Neville-Neil <gnn@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: head/sys/dev/hwpmc/hwpmc_mips24k.c 204635 2010-03-03 15:05:58Z gnn $");
29__FBSDID("$FreeBSD: head/sys/dev/hwpmc/hwpmc_mips24k.c 227395 2011-11-09 17:38:27Z adrian $");
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/cpu.h>
37#include <machine/cpufunc.h>

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

249
250 if (caps & PMC_CAP_SYSTEM)
251 config |= (MIPS24K_PMC_SUPER_ENABLE |
252 MIPS24K_PMC_KERNEL_ENABLE);
253 if (caps & PMC_CAP_USER)
254 config |= MIPS24K_PMC_USER_ENABLE;
255 if ((caps & (PMC_CAP_USER | PMC_CAP_SYSTEM)) == 0)
256 config |= MIPS24K_PMC_ENABLE;
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/cpu.h>
37#include <machine/cpufunc.h>

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

249
250 if (caps & PMC_CAP_SYSTEM)
251 config |= (MIPS24K_PMC_SUPER_ENABLE |
252 MIPS24K_PMC_KERNEL_ENABLE);
253 if (caps & PMC_CAP_USER)
254 config |= MIPS24K_PMC_USER_ENABLE;
255 if ((caps & (PMC_CAP_USER | PMC_CAP_SYSTEM)) == 0)
256 config |= MIPS24K_PMC_ENABLE;
257 if (caps & PMC_CAP_INTERRUPT)
258 config |= MIPS24K_PMC_INTERRUPT_ENABLE;
257
258 pm->pm_md.pm_mips24k.pm_mips24k_evsel = config;
259
260 PMCDBG(MDP,ALL,2,"mips-allocate ri=%d -> config=0x%x", ri, config);
261
262 return 0;
263}
264

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

399 ("[mips,%d] PHW pmc %p non-NULL", __LINE__, phw->phw_pmc));
400
401 return 0;
402}
403
404static int
405mips24k_intr(int cpu, struct trapframe *tf)
406{
259
260 pm->pm_md.pm_mips24k.pm_mips24k_evsel = config;
261
262 PMCDBG(MDP,ALL,2,"mips-allocate ri=%d -> config=0x%x", ri, config);
263
264 return 0;
265}
266

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

401 ("[mips,%d] PHW pmc %p non-NULL", __LINE__, phw->phw_pmc));
402
403 return 0;
404}
405
406static int
407mips24k_intr(int cpu, struct trapframe *tf)
408{
407 return 0;
409 int error;
410 int retval, ri;
411 struct pmc *pm;
412 struct mips24k_cpu *pc;
413 uint32_t r, r0, r2;
414
415 KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
416 ("[mips24k,%d] CPU %d out of range", __LINE__, cpu));
417
418 retval = 0;
419 pc = mips24k_pcpu[cpu];
420
421 /* Stop PMCs without clearing the counter */
422 r0 = mips_rd_perfcnt0();
423 mips_wr_perfcnt0(r0 & ~(0x1f));
424 r2 = mips_rd_perfcnt2();
425 mips_wr_perfcnt2(r2 & ~(0x1f));
426
427 for (ri = 0; ri < mips24k_npmcs; ri++) {
428 pm = mips24k_pcpu[cpu]->pc_mipspmcs[ri].phw_pmc;
429 if (pm == NULL)
430 continue;
431 if (! PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
432 continue;
433
434 r = mips24k_pmcn_read(ri);
435
436 /* If bit 31 is set, the counter has overflowed */
437 if ((r & 0x80000000) == 0)
438 continue;
439
440 retval = 1;
441 if (pm->pm_state != PMC_STATE_RUNNING)
442 continue;
443 error = pmc_process_interrupt(cpu, pm, tf,
444 TRAPF_USERMODE(tf));
445 if (error) {
446 /* Clear/disable the relevant counter */
447 if (ri == 0)
448 r0 = 0;
449 else if (ri == 1)
450 r2 = 0;
451 mips24k_stop_pmc(cpu, ri);
452 }
453
454 /* Reload sampling count */
455 mips24k_write_pmc(cpu, ri, pm->pm_sc.pm_reloadcount);
456 }
457
458 /*
459 * Re-enable the PMC counters where they left off.
460 *
461 * Any counter which overflowed will have its sample count
462 * reloaded in the loop above.
463 */
464 mips_wr_perfcnt0(r0);
465 mips_wr_perfcnt2(r2);
466
467 return retval;
408}
409
410static int
411mips24k_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
412{
413 int error;
414 struct pmc_hw *phw;
415 char mips24k_name[PMC_NAME_MAX];

--- 155 unchanged lines hidden ---
468}
469
470static int
471mips24k_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
472{
473 int error;
474 struct pmc_hw *phw;
475 char mips24k_name[PMC_NAME_MAX];

--- 155 unchanged lines hidden ---