Lines Matching refs:cpuhw
128 static unsigned long ebb_switch_in(bool ebb, struct cpu_hw_events *cpuhw) in ebb_switch_in() argument
130 return cpuhw->mmcr.mmcr0; in ebb_switch_in()
136 static inline void power_pmu_bhrb_read(struct perf_event *event, struct cpu_hw_events *cpuhw) {} in power_pmu_bhrb_read() argument
157 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events); in get_pmcs_ext_regs() local
159 return cpuhw->pmcs[idx]; in get_pmcs_ext_regs()
409 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events); in power_pmu_bhrb_enable() local
415 if (event->ctx->task && cpuhw->bhrb_context != event->ctx) { in power_pmu_bhrb_enable()
417 cpuhw->bhrb_context = event->ctx; in power_pmu_bhrb_enable()
419 cpuhw->bhrb_users++; in power_pmu_bhrb_enable()
425 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events); in power_pmu_bhrb_disable() local
430 WARN_ON_ONCE(!cpuhw->bhrb_users); in power_pmu_bhrb_disable()
431 cpuhw->bhrb_users--; in power_pmu_bhrb_disable()
434 if (!cpuhw->disabled && !cpuhw->bhrb_users) { in power_pmu_bhrb_disable()
440 cpuhw->bhrb_context = NULL; in power_pmu_bhrb_disable()
483 static void power_pmu_bhrb_read(struct perf_event *event, struct cpu_hw_events *cpuhw) in power_pmu_bhrb_read() argument
539 cpuhw->bhrb_entries[u_index].to = addr; in power_pmu_bhrb_read()
540 cpuhw->bhrb_entries[u_index].mispred = pred; in power_pmu_bhrb_read()
541 cpuhw->bhrb_entries[u_index].predicted = ~pred; in power_pmu_bhrb_read()
552 cpuhw->bhrb_entries[u_index].from = addr; in power_pmu_bhrb_read()
556 cpuhw->bhrb_entries[u_index].from = addr; in power_pmu_bhrb_read()
557 cpuhw->bhrb_entries[u_index].to = in power_pmu_bhrb_read()
559 cpuhw->bhrb_entries[u_index].mispred = pred; in power_pmu_bhrb_read()
560 cpuhw->bhrb_entries[u_index].predicted = ~pred; in power_pmu_bhrb_read()
566 cpuhw->bhrb_stack.nr = u_index; in power_pmu_bhrb_read()
567 cpuhw->bhrb_stack.hw_idx = -1ULL; in power_pmu_bhrb_read()
640 static unsigned long ebb_switch_in(bool ebb, struct cpu_hw_events *cpuhw) in ebb_switch_in() argument
642 unsigned long mmcr0 = cpuhw->mmcr.mmcr0; in ebb_switch_in()
676 mtspr(SPRN_MMCR2, cpuhw->mmcr.mmcr2 | current->thread.mmcr2); in ebb_switch_in()
788 struct cpu_hw_events *cpuhw; in power_pmu_wants_prompt_pmi() local
797 cpuhw = this_cpu_ptr(&cpu_hw_events); in power_pmu_wants_prompt_pmi()
798 return cpuhw->n_events; in power_pmu_wants_prompt_pmi()
882 static int any_pmc_overflown(struct cpu_hw_events *cpuhw) in any_pmc_overflown() argument
886 for (i = 0; i < cpuhw->n_events; i++) { in any_pmc_overflown()
887 idx = cpuhw->event[i]->hw.idx; in any_pmc_overflown()
962 static int power_check_constraints(struct cpu_hw_events *cpuhw, in power_check_constraints() argument
983 cpuhw->alternatives[i]); in power_check_constraints()
984 event_id[i] = cpuhw->alternatives[i][0]; in power_check_constraints()
986 if (ppmu->get_constraint(event_id[i], &cpuhw->amasks[i][0], in power_check_constraints()
987 &cpuhw->avalues[i][0], event[i]->attr.config1)) in power_check_constraints()
992 nv = (value | cpuhw->avalues[i][0]) + in power_check_constraints()
993 (value & cpuhw->avalues[i][0] & addf); in power_check_constraints()
998 if (((((nv + tadd) ^ cpuhw->avalues[i][0]) & cpuhw->amasks[i][0]) in power_check_constraints()
1003 mask |= cpuhw->amasks[i][0]; in power_check_constraints()
1018 cpuhw->alternatives[i]); in power_check_constraints()
1020 ppmu->get_constraint(cpuhw->alternatives[i][j], in power_check_constraints()
1021 &cpuhw->amasks[i][j], in power_check_constraints()
1022 &cpuhw->avalues[i][j], in power_check_constraints()
1042 nv = (value | cpuhw->avalues[i][j]) + in power_check_constraints()
1043 (value & cpuhw->avalues[i][j] & addf); in power_check_constraints()
1045 (((nv + tadd) ^ cpuhw->avalues[i][j]) in power_check_constraints()
1046 & cpuhw->amasks[i][j]) == 0) in power_check_constraints()
1068 mask |= cpuhw->amasks[i][j]; in power_check_constraints()
1076 event_id[i] = cpuhw->alternatives[i][choice[i]]; in power_check_constraints()
1210 static void freeze_limited_counters(struct cpu_hw_events *cpuhw, in freeze_limited_counters() argument
1217 for (i = 0; i < cpuhw->n_limited; ++i) { in freeze_limited_counters()
1218 event = cpuhw->limited_counter[i]; in freeze_limited_counters()
1230 static void thaw_limited_counters(struct cpu_hw_events *cpuhw, in thaw_limited_counters() argument
1237 for (i = 0; i < cpuhw->n_limited; ++i) { in thaw_limited_counters()
1238 event = cpuhw->limited_counter[i]; in thaw_limited_counters()
1239 event->hw.idx = cpuhw->limited_hwidx[i]; in thaw_limited_counters()
1259 static void write_mmcr0(struct cpu_hw_events *cpuhw, unsigned long mmcr0) in write_mmcr0() argument
1263 if (!cpuhw->n_limited) { in write_mmcr0()
1282 freeze_limited_counters(cpuhw, pmc5, pmc6); in write_mmcr0()
1284 thaw_limited_counters(cpuhw, pmc5, pmc6); in write_mmcr0()
1300 struct cpu_hw_events *cpuhw; in power_pmu_disable() local
1306 cpuhw = this_cpu_ptr(&cpu_hw_events); in power_pmu_disable()
1308 if (!cpuhw->disabled) { in power_pmu_disable()
1312 if (!cpuhw->pmcs_enabled) { in power_pmu_disable()
1314 cpuhw->pmcs_enabled = 1; in power_pmu_disable()
1335 write_mmcr0(cpuhw, val); in power_pmu_disable()
1362 val = mmcra = cpuhw->mmcr.mmcra; in power_pmu_disable()
1383 cpuhw->disabled = 1; in power_pmu_disable()
1384 cpuhw->n_added = 0; in power_pmu_disable()
1413 struct cpu_hw_events *cpuhw; in power_pmu_enable() local
1427 cpuhw = this_cpu_ptr(&cpu_hw_events); in power_pmu_enable()
1428 if (!cpuhw->disabled) in power_pmu_enable()
1431 if (cpuhw->n_events == 0) { in power_pmu_enable()
1436 cpuhw->disabled = 0; in power_pmu_enable()
1443 ebb = is_ebb_event(cpuhw->event[0]); in power_pmu_enable()
1451 if (!cpuhw->n_added) { in power_pmu_enable()
1458 if (any_pmc_overflown(cpuhw)) in power_pmu_enable()
1461 mtspr(SPRN_MMCRA, cpuhw->mmcr.mmcra & ~MMCRA_SAMPLE_ENABLE); in power_pmu_enable()
1462 mtspr(SPRN_MMCR1, cpuhw->mmcr.mmcr1); in power_pmu_enable()
1464 mtspr(SPRN_MMCR3, cpuhw->mmcr.mmcr3); in power_pmu_enable()
1471 memset(&cpuhw->mmcr, 0, sizeof(cpuhw->mmcr)); in power_pmu_enable()
1473 if (ppmu->compute_mmcr(cpuhw->events, cpuhw->n_events, hwc_index, in power_pmu_enable()
1474 &cpuhw->mmcr, cpuhw->event, ppmu->flags)) { in power_pmu_enable()
1486 event = cpuhw->event[0]; in power_pmu_enable()
1488 cpuhw->mmcr.mmcr0 |= MMCR0_FCP; in power_pmu_enable()
1490 cpuhw->mmcr.mmcr0 |= freeze_events_kernel; in power_pmu_enable()
1492 cpuhw->mmcr.mmcr0 |= MMCR0_FCHV; in power_pmu_enable()
1501 mtspr(SPRN_MMCRA, cpuhw->mmcr.mmcra & ~MMCRA_SAMPLE_ENABLE); in power_pmu_enable()
1502 mtspr(SPRN_MMCR1, cpuhw->mmcr.mmcr1); in power_pmu_enable()
1503 mtspr(SPRN_MMCR0, (cpuhw->mmcr.mmcr0 & ~(MMCR0_PMC1CE | MMCR0_PMCjCE)) in power_pmu_enable()
1506 mtspr(SPRN_MMCR2, cpuhw->mmcr.mmcr2); in power_pmu_enable()
1509 mtspr(SPRN_MMCR3, cpuhw->mmcr.mmcr3); in power_pmu_enable()
1515 for (i = 0; i < cpuhw->n_events; ++i) { in power_pmu_enable()
1516 event = cpuhw->event[i]; in power_pmu_enable()
1527 cpuhw->n_limited = n_lim = 0; in power_pmu_enable()
1528 for (i = 0; i < cpuhw->n_events; ++i) { in power_pmu_enable()
1529 event = cpuhw->event[i]; in power_pmu_enable()
1534 cpuhw->limited_counter[n_lim] = event; in power_pmu_enable()
1535 cpuhw->limited_hwidx[n_lim] = idx; in power_pmu_enable()
1559 cpuhw->n_limited = n_lim; in power_pmu_enable()
1560 cpuhw->mmcr.mmcr0 |= MMCR0_PMXE | MMCR0_FCECE; in power_pmu_enable()
1565 mmcr0 = ebb_switch_in(ebb, cpuhw); in power_pmu_enable()
1568 if (cpuhw->bhrb_users) in power_pmu_enable()
1569 ppmu->config_bhrb(cpuhw->bhrb_filter); in power_pmu_enable()
1571 write_mmcr0(cpuhw, mmcr0); in power_pmu_enable()
1576 if (cpuhw->mmcr.mmcra & MMCRA_SAMPLE_ENABLE) { in power_pmu_enable()
1578 mtspr(SPRN_MMCRA, cpuhw->mmcr.mmcra); in power_pmu_enable()
1621 struct cpu_hw_events *cpuhw; in power_pmu_add() local
1633 cpuhw = this_cpu_ptr(&cpu_hw_events); in power_pmu_add()
1634 n0 = cpuhw->n_events; in power_pmu_add()
1637 cpuhw->event[n0] = event; in power_pmu_add()
1638 cpuhw->events[n0] = event->hw.config; in power_pmu_add()
1639 cpuhw->flags[n0] = event->hw.event_base; in power_pmu_add()
1657 if (cpuhw->txn_flags & PERF_PMU_TXN_ADD) in power_pmu_add()
1660 if (check_excludes(cpuhw->event, cpuhw->flags, n0, 1)) in power_pmu_add()
1662 if (power_check_constraints(cpuhw, cpuhw->events, cpuhw->flags, n0 + 1, cpuhw->event)) in power_pmu_add()
1664 event->hw.config = cpuhw->events[n0]; in power_pmu_add()
1669 ++cpuhw->n_events; in power_pmu_add()
1670 ++cpuhw->n_added; in power_pmu_add()
1682 cpuhw->bhrb_filter = bhrb_filter; in power_pmu_add()
1697 struct cpu_hw_events *cpuhw; in power_pmu_del() local
1706 cpuhw = this_cpu_ptr(&cpu_hw_events); in power_pmu_del()
1707 for (i = 0; i < cpuhw->n_events; ++i) { in power_pmu_del()
1708 if (event == cpuhw->event[i]) { in power_pmu_del()
1709 while (++i < cpuhw->n_events) { in power_pmu_del()
1710 cpuhw->event[i-1] = cpuhw->event[i]; in power_pmu_del()
1711 cpuhw->events[i-1] = cpuhw->events[i]; in power_pmu_del()
1712 cpuhw->flags[i-1] = cpuhw->flags[i]; in power_pmu_del()
1714 --cpuhw->n_events; in power_pmu_del()
1715 ppmu->disable_pmc(event->hw.idx - 1, &cpuhw->mmcr); in power_pmu_del()
1724 for (i = 0; i < cpuhw->n_limited; ++i) in power_pmu_del()
1725 if (event == cpuhw->limited_counter[i]) in power_pmu_del()
1727 if (i < cpuhw->n_limited) { in power_pmu_del()
1728 while (++i < cpuhw->n_limited) { in power_pmu_del()
1729 cpuhw->limited_counter[i-1] = cpuhw->limited_counter[i]; in power_pmu_del()
1730 cpuhw->limited_hwidx[i-1] = cpuhw->limited_hwidx[i]; in power_pmu_del()
1732 --cpuhw->n_limited; in power_pmu_del()
1734 if (cpuhw->n_events == 0) { in power_pmu_del()
1736 cpuhw->mmcr.mmcr0 &= ~(MMCR0_PMXE | MMCR0_FCECE); in power_pmu_del()
1816 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events); in power_pmu_start_txn() local
1818 WARN_ON_ONCE(cpuhw->txn_flags); /* txn already in flight */ in power_pmu_start_txn()
1820 cpuhw->txn_flags = txn_flags; in power_pmu_start_txn()
1825 cpuhw->n_txn_start = cpuhw->n_events; in power_pmu_start_txn()
1835 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events); in power_pmu_cancel_txn() local
1838 WARN_ON_ONCE(!cpuhw->txn_flags); /* no txn in flight */ in power_pmu_cancel_txn()
1840 txn_flags = cpuhw->txn_flags; in power_pmu_cancel_txn()
1841 cpuhw->txn_flags = 0; in power_pmu_cancel_txn()
1855 struct cpu_hw_events *cpuhw; in power_pmu_commit_txn() local
1861 cpuhw = this_cpu_ptr(&cpu_hw_events); in power_pmu_commit_txn()
1862 WARN_ON_ONCE(!cpuhw->txn_flags); /* no txn in flight */ in power_pmu_commit_txn()
1864 if (cpuhw->txn_flags & ~PERF_PMU_TXN_ADD) { in power_pmu_commit_txn()
1865 cpuhw->txn_flags = 0; in power_pmu_commit_txn()
1869 n = cpuhw->n_events; in power_pmu_commit_txn()
1870 if (check_excludes(cpuhw->event, cpuhw->flags, 0, n)) in power_pmu_commit_txn()
1872 i = power_check_constraints(cpuhw, cpuhw->events, cpuhw->flags, n, cpuhw->event); in power_pmu_commit_txn()
1876 for (i = cpuhw->n_txn_start; i < n; ++i) in power_pmu_commit_txn()
1877 cpuhw->event[i]->hw.config = cpuhw->events[i]; in power_pmu_commit_txn()
1879 cpuhw->txn_flags = 0; in power_pmu_commit_txn()
2005 struct cpu_hw_events *cpuhw; in power_pmu_event_init() local
2119 cpuhw = this_cpu_ptr(&cpu_hw_events); in power_pmu_event_init()
2121 err = power_check_constraints(cpuhw, events, cflags, n + 1, ctrs); in power_pmu_event_init()
2151 cpuhw->bhrb_filter = bhrb_filter; in power_pmu_event_init()
2305 struct cpu_hw_events *cpuhw; in record_and_restart() local
2306 cpuhw = this_cpu_ptr(&cpu_hw_events); in record_and_restart()
2307 power_pmu_bhrb_read(event, cpuhw); in record_and_restart()
2308 perf_sample_save_brstack(&data, event, &cpuhw->bhrb_stack, NULL); in record_and_restart()
2392 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events); in __perf_event_interrupt() local
2396 if (cpuhw->n_limited) in __perf_event_interrupt()
2397 freeze_limited_counters(cpuhw, mfspr(SPRN_PMC5), in __perf_event_interrupt()
2404 cpuhw->pmcs[i] = read_pmc(i + 1); in __perf_event_interrupt()
2409 if (!pmc_overflow(cpuhw->pmcs[i])) in __perf_event_interrupt()
2420 for (j = 0; j < cpuhw->n_events; ++j) { in __perf_event_interrupt()
2421 event = cpuhw->event[j]; in __perf_event_interrupt()
2424 record_and_restart(event, cpuhw->pmcs[i], regs); in __perf_event_interrupt()
2442 for (i = 0; i < cpuhw->n_events; ++i) { in __perf_event_interrupt()
2443 event = cpuhw->event[i]; in __perf_event_interrupt()
2446 if (pmc_overflow_power7(cpuhw->pmcs[event->hw.idx - 1])) { in __perf_event_interrupt()
2450 cpuhw->pmcs[event->hw.idx - 1], in __perf_event_interrupt()
2472 write_mmcr0(cpuhw, cpuhw->mmcr.mmcr0); in __perf_event_interrupt()
2475 memset(&cpuhw->pmcs, 0, sizeof(cpuhw->pmcs)); in __perf_event_interrupt()
2489 struct cpu_hw_events *cpuhw = &per_cpu(cpu_hw_events, cpu); in power_pmu_prepare_cpu() local
2492 memset(cpuhw, 0, sizeof(*cpuhw)); in power_pmu_prepare_cpu()
2493 cpuhw->mmcr.mmcr0 = MMCR0_FC; in power_pmu_prepare_cpu()