Lines Matching refs:cpuc
825 static inline void sparc_pmu_enable_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc, in… in sparc_pmu_enable_event() argument
833 enc = perf_event_get_enc(cpuc->events[idx]); in sparc_pmu_enable_event()
835 val = cpuc->pcr[pcr_index]; in sparc_pmu_enable_event()
838 cpuc->pcr[pcr_index] = val; in sparc_pmu_enable_event()
840 pcr_ops->write_pcr(pcr_index, cpuc->pcr[pcr_index]); in sparc_pmu_enable_event()
843 static inline void sparc_pmu_disable_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc, i… in sparc_pmu_disable_event() argument
853 val = cpuc->pcr[pcr_index]; in sparc_pmu_disable_event()
856 cpuc->pcr[pcr_index] = val; in sparc_pmu_disable_event()
858 pcr_ops->write_pcr(pcr_index, cpuc->pcr[pcr_index]); in sparc_pmu_disable_event()
917 static void read_in_all_counters(struct cpu_hw_events *cpuc) in read_in_all_counters() argument
921 for (i = 0; i < cpuc->n_events; i++) { in read_in_all_counters()
922 struct perf_event *cp = cpuc->event[i]; in read_in_all_counters()
924 if (cpuc->current_idx[i] != PIC_NO_INDEX && in read_in_all_counters()
925 cpuc->current_idx[i] != cp->hw.idx) { in read_in_all_counters()
927 cpuc->current_idx[i]); in read_in_all_counters()
928 cpuc->current_idx[i] = PIC_NO_INDEX; in read_in_all_counters()
939 static void calculate_single_pcr(struct cpu_hw_events *cpuc) in calculate_single_pcr() argument
943 if (!cpuc->n_added) in calculate_single_pcr()
947 for (i = 0; i < cpuc->n_events; i++) { in calculate_single_pcr()
948 struct perf_event *cp = cpuc->event[i]; in calculate_single_pcr()
953 if (cpuc->current_idx[i] != PIC_NO_INDEX) in calculate_single_pcr()
957 cpuc->current_idx[i] = idx; in calculate_single_pcr()
959 enc = perf_event_get_enc(cpuc->events[i]); in calculate_single_pcr()
960 cpuc->pcr[0] &= ~mask_for_index(idx); in calculate_single_pcr()
962 cpuc->pcr[0] |= nop_for_index(idx); in calculate_single_pcr()
964 cpuc->pcr[0] |= event_encoding(enc, idx); in calculate_single_pcr()
967 cpuc->pcr[0] |= cpuc->event[0]->hw.config_base; in calculate_single_pcr()
973 static void calculate_multiple_pcrs(struct cpu_hw_events *cpuc) in calculate_multiple_pcrs() argument
977 if (!cpuc->n_added) in calculate_multiple_pcrs()
980 for (i = 0; i < cpuc->n_events; i++) { in calculate_multiple_pcrs()
981 struct perf_event *cp = cpuc->event[i]; in calculate_multiple_pcrs()
985 if (cpuc->current_idx[i] != PIC_NO_INDEX) in calculate_multiple_pcrs()
988 cpuc->current_idx[i] = idx; in calculate_multiple_pcrs()
993 for (i = 0; i < cpuc->n_events; i++) { in calculate_multiple_pcrs()
994 struct perf_event *cp = cpuc->event[i]; in calculate_multiple_pcrs()
997 cpuc->pcr[idx] |= cp->hw.config_base; in calculate_multiple_pcrs()
1004 static void update_pcrs_for_enable(struct cpu_hw_events *cpuc) in update_pcrs_for_enable() argument
1006 if (cpuc->n_added) in update_pcrs_for_enable()
1007 read_in_all_counters(cpuc); in update_pcrs_for_enable()
1010 calculate_single_pcr(cpuc); in update_pcrs_for_enable()
1012 calculate_multiple_pcrs(cpuc); in update_pcrs_for_enable()
1018 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_enable() local
1021 if (cpuc->enabled) in sparc_pmu_enable()
1024 cpuc->enabled = 1; in sparc_pmu_enable()
1027 if (cpuc->n_events) in sparc_pmu_enable()
1028 update_pcrs_for_enable(cpuc); in sparc_pmu_enable()
1031 pcr_ops->write_pcr(i, cpuc->pcr[i]); in sparc_pmu_enable()
1036 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_disable() local
1039 if (!cpuc->enabled) in sparc_pmu_disable()
1042 cpuc->enabled = 0; in sparc_pmu_disable()
1043 cpuc->n_added = 0; in sparc_pmu_disable()
1046 u64 val = cpuc->pcr[i]; in sparc_pmu_disable()
1050 cpuc->pcr[i] = val; in sparc_pmu_disable()
1051 pcr_ops->write_pcr(i, cpuc->pcr[i]); in sparc_pmu_disable()
1055 static int active_event_index(struct cpu_hw_events *cpuc, in active_event_index() argument
1060 for (i = 0; i < cpuc->n_events; i++) { in active_event_index()
1061 if (cpuc->event[i] == event) in active_event_index()
1064 BUG_ON(i == cpuc->n_events); in active_event_index()
1065 return cpuc->current_idx[i]; in active_event_index()
1070 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_start() local
1071 int idx = active_event_index(cpuc, event); in sparc_pmu_start()
1080 sparc_pmu_enable_event(cpuc, &event->hw, idx); in sparc_pmu_start()
1085 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_stop() local
1086 int idx = active_event_index(cpuc, event); in sparc_pmu_stop()
1089 sparc_pmu_disable_event(cpuc, &event->hw, idx); in sparc_pmu_stop()
1101 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_del() local
1107 for (i = 0; i < cpuc->n_events; i++) { in sparc_pmu_del()
1108 if (event == cpuc->event[i]) { in sparc_pmu_del()
1117 while (++i < cpuc->n_events) { in sparc_pmu_del()
1118 cpuc->event[i - 1] = cpuc->event[i]; in sparc_pmu_del()
1119 cpuc->events[i - 1] = cpuc->events[i]; in sparc_pmu_del()
1120 cpuc->current_idx[i - 1] = in sparc_pmu_del()
1121 cpuc->current_idx[i]; in sparc_pmu_del()
1126 cpuc->n_events--; in sparc_pmu_del()
1136 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_read() local
1137 int idx = active_event_index(cpuc, event); in sparc_pmu_read()
1148 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in perf_stop_nmi_watchdog() local
1153 cpuc->pcr[i] = pcr_ops->read_pcr(i); in perf_stop_nmi_watchdog()
1359 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_add() local
1365 n0 = cpuc->n_events; in sparc_pmu_add()
1369 cpuc->event[n0] = event; in sparc_pmu_add()
1370 cpuc->events[n0] = event->hw.event_base; in sparc_pmu_add()
1371 cpuc->current_idx[n0] = PIC_NO_INDEX; in sparc_pmu_add()
1382 if (cpuc->txn_flags & PERF_PMU_TXN_ADD) in sparc_pmu_add()
1385 if (check_excludes(cpuc->event, n0, 1)) in sparc_pmu_add()
1387 if (sparc_check_constraints(cpuc->event, cpuc->events, n0 + 1)) in sparc_pmu_add()
1391 cpuc->n_events++; in sparc_pmu_add()
1392 cpuc->n_added++; in sparc_pmu_add()
1537 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); in sparc_pmu_commit_txn() local
1543 WARN_ON_ONCE(!cpuc->txn_flags); /* no txn in flight */ in sparc_pmu_commit_txn()
1545 if (cpuc->txn_flags & ~PERF_PMU_TXN_ADD) { in sparc_pmu_commit_txn()
1546 cpuc->txn_flags = 0; in sparc_pmu_commit_txn()
1550 n = cpuc->n_events; in sparc_pmu_commit_txn()
1551 if (check_excludes(cpuc->event, 0, n)) in sparc_pmu_commit_txn()
1553 if (sparc_check_constraints(cpuc->event, cpuc->events, n)) in sparc_pmu_commit_txn()
1556 cpuc->txn_flags = 0; in sparc_pmu_commit_txn()
1603 struct cpu_hw_events *cpuc; in perf_event_nmi_handler() local
1620 cpuc = this_cpu_ptr(&cpu_hw_events); in perf_event_nmi_handler()
1631 pcr_ops->write_pcr(0, cpuc->pcr[0]); in perf_event_nmi_handler()
1633 for (i = 0; i < cpuc->n_events; i++) { in perf_event_nmi_handler()
1634 struct perf_event *event = cpuc->event[i]; in perf_event_nmi_handler()
1635 int idx = cpuc->current_idx[i]; in perf_event_nmi_handler()
1641 pcr_ops->write_pcr(idx, cpuc->pcr[idx]); in perf_event_nmi_handler()