Lines Matching refs:cpuc

827 static inline void sparc_pmu_enable_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc, in…  in sparc_pmu_enable_event()  argument
835 enc = perf_event_get_enc(cpuc->events[idx]); in sparc_pmu_enable_event()
837 val = cpuc->pcr[pcr_index]; in sparc_pmu_enable_event()
840 cpuc->pcr[pcr_index] = val; in sparc_pmu_enable_event()
842 pcr_ops->write_pcr(pcr_index, cpuc->pcr[pcr_index]); in sparc_pmu_enable_event()
845 static inline void sparc_pmu_disable_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc, i… in sparc_pmu_disable_event() argument
855 val = cpuc->pcr[pcr_index]; in sparc_pmu_disable_event()
858 cpuc->pcr[pcr_index] = val; in sparc_pmu_disable_event()
860 pcr_ops->write_pcr(pcr_index, cpuc->pcr[pcr_index]); in sparc_pmu_disable_event()
923 static void read_in_all_counters(struct cpu_hw_events *cpuc) in read_in_all_counters() argument
927 for (i = 0; i < cpuc->n_events; i++) { in read_in_all_counters()
928 struct perf_event *cp = cpuc->event[i]; in read_in_all_counters()
930 if (cpuc->current_idx[i] != PIC_NO_INDEX && in read_in_all_counters()
931 cpuc->current_idx[i] != cp->hw.idx) { in read_in_all_counters()
933 cpuc->current_idx[i]); in read_in_all_counters()
934 cpuc->current_idx[i] = PIC_NO_INDEX; in read_in_all_counters()
947 static void calculate_single_pcr(struct cpu_hw_events *cpuc) in calculate_single_pcr() argument
951 if (!cpuc->n_added) in calculate_single_pcr()
955 for (i = 0; i < cpuc->n_events; i++) { in calculate_single_pcr()
956 struct perf_event *cp = cpuc->event[i]; in calculate_single_pcr()
961 if (cpuc->current_idx[i] != PIC_NO_INDEX) in calculate_single_pcr()
965 cpuc->current_idx[i] = idx; in calculate_single_pcr()
967 enc = perf_event_get_enc(cpuc->events[i]); in calculate_single_pcr()
968 cpuc->pcr[0] &= ~mask_for_index(idx); in calculate_single_pcr()
970 cpuc->pcr[0] |= nop_for_index(idx); in calculate_single_pcr()
972 cpuc->pcr[0] |= event_encoding(enc, idx); in calculate_single_pcr()
977 cpuc->pcr[0] |= cpuc->event[0]->hw.config_base; in calculate_single_pcr()
983 static void calculate_multiple_pcrs(struct cpu_hw_events *cpuc) in calculate_multiple_pcrs() argument
987 if (!cpuc->n_added) in calculate_multiple_pcrs()
990 for (i = 0; i < cpuc->n_events; i++) { in calculate_multiple_pcrs()
991 struct perf_event *cp = cpuc->event[i]; in calculate_multiple_pcrs()
995 if (cpuc->current_idx[i] != PIC_NO_INDEX) in calculate_multiple_pcrs()
998 cpuc->current_idx[i] = idx; in calculate_multiple_pcrs()
1006 for (i = 0; i < cpuc->n_events; i++) { in calculate_multiple_pcrs()
1007 struct perf_event *cp = cpuc->event[i]; in calculate_multiple_pcrs()
1010 cpuc->pcr[idx] |= cp->hw.config_base; in calculate_multiple_pcrs()
1017 static void update_pcrs_for_enable(struct cpu_hw_events *cpuc) in update_pcrs_for_enable() argument
1019 if (cpuc->n_added) in update_pcrs_for_enable()
1020 read_in_all_counters(cpuc); in update_pcrs_for_enable()
1023 calculate_single_pcr(cpuc); in update_pcrs_for_enable()
1025 calculate_multiple_pcrs(cpuc); in update_pcrs_for_enable()
1031 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_enable() local
1034 if (cpuc->enabled) in sparc_pmu_enable()
1037 cpuc->enabled = 1; in sparc_pmu_enable()
1040 if (cpuc->n_events) in sparc_pmu_enable()
1041 update_pcrs_for_enable(cpuc); in sparc_pmu_enable()
1044 pcr_ops->write_pcr(i, cpuc->pcr[i]); in sparc_pmu_enable()
1049 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_disable() local
1052 if (!cpuc->enabled) in sparc_pmu_disable()
1055 cpuc->enabled = 0; in sparc_pmu_disable()
1056 cpuc->n_added = 0; in sparc_pmu_disable()
1059 u64 val = cpuc->pcr[i]; in sparc_pmu_disable()
1063 cpuc->pcr[i] = val; in sparc_pmu_disable()
1064 pcr_ops->write_pcr(i, cpuc->pcr[i]); in sparc_pmu_disable()
1068 static int active_event_index(struct cpu_hw_events *cpuc, in active_event_index() argument
1073 for (i = 0; i < cpuc->n_events; i++) { in active_event_index()
1074 if (cpuc->event[i] == event) in active_event_index()
1077 BUG_ON(i == cpuc->n_events); in active_event_index()
1078 return cpuc->current_idx[i]; in active_event_index()
1083 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_start() local
1084 int idx = active_event_index(cpuc, event); in sparc_pmu_start()
1093 sparc_pmu_enable_event(cpuc, &event->hw, idx); in sparc_pmu_start()
1100 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_stop() local
1101 int idx = active_event_index(cpuc, event); in sparc_pmu_stop()
1104 sparc_pmu_disable_event(cpuc, &event->hw, idx); in sparc_pmu_stop()
1116 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_del() local
1122 for (i = 0; i < cpuc->n_events; i++) { in sparc_pmu_del()
1123 if (event == cpuc->event[i]) { in sparc_pmu_del()
1132 while (++i < cpuc->n_events) { in sparc_pmu_del()
1133 cpuc->event[i - 1] = cpuc->event[i]; in sparc_pmu_del()
1134 cpuc->events[i - 1] = cpuc->events[i]; in sparc_pmu_del()
1135 cpuc->current_idx[i - 1] = in sparc_pmu_del()
1136 cpuc->current_idx[i]; in sparc_pmu_del()
1141 cpuc->n_events--; in sparc_pmu_del()
1151 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_read() local
1152 int idx = active_event_index(cpuc, event); in sparc_pmu_read()
1163 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in perf_stop_nmi_watchdog() local
1168 cpuc->pcr[i] = pcr_ops->read_pcr(i); in perf_stop_nmi_watchdog()
1374 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_add() local
1380 n0 = cpuc->n_events; in sparc_pmu_add()
1384 cpuc->event[n0] = event; in sparc_pmu_add()
1385 cpuc->events[n0] = event->hw.event_base; in sparc_pmu_add()
1386 cpuc->current_idx[n0] = PIC_NO_INDEX; in sparc_pmu_add()
1397 if (cpuc->txn_flags & PERF_PMU_TXN_ADD) in sparc_pmu_add()
1400 if (check_excludes(cpuc->event, n0, 1)) in sparc_pmu_add()
1402 if (sparc_check_constraints(cpuc->event, cpuc->events, n0 + 1)) in sparc_pmu_add()
1406 cpuc->n_events++; in sparc_pmu_add()
1407 cpuc->n_added++; in sparc_pmu_add()
1552 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_commit_txn() local
1558 WARN_ON_ONCE(!cpuc->txn_flags); /* no txn in flight */ in sparc_pmu_commit_txn()
1560 if (cpuc->txn_flags & ~PERF_PMU_TXN_ADD) { in sparc_pmu_commit_txn()
1561 cpuc->txn_flags = 0; in sparc_pmu_commit_txn()
1565 n = cpuc->n_events; in sparc_pmu_commit_txn()
1566 if (check_excludes(cpuc->event, 0, n)) in sparc_pmu_commit_txn()
1568 if (sparc_check_constraints(cpuc->event, cpuc->events, n)) in sparc_pmu_commit_txn()
1571 cpuc->txn_flags = 0; in sparc_pmu_commit_txn()
1618 struct cpu_hw_events *cpuc; in perf_event_nmi_handler() local
1639 cpuc = this_cpu_ptr(&cpu_hw_events); in perf_event_nmi_handler()
1650 pcr_ops->write_pcr(0, cpuc->pcr[0]); in perf_event_nmi_handler()
1652 for (i = 0; i < cpuc->n_events; i++) { in perf_event_nmi_handler()
1653 struct perf_event *event = cpuc->event[i]; in perf_event_nmi_handler()
1654 int idx = cpuc->current_idx[i]; in perf_event_nmi_handler()
1660 pcr_ops->write_pcr(idx, cpuc->pcr[idx]); in perf_event_nmi_handler()