Lines Matching refs:event

88 	static u64 hisi_pcie_get_##_name(struct perf_event *event)	  \
90 return FIELD_GET(GENMASK(_hi, _lo), event->attr._config); \
93 HISI_PCIE_PMU_FILTER_ATTR(event, config, 16, 0);
174 * be treated as an independent event(index = 0x0010), "RX memory write packets
176 * bits are "real" event index, which can be used to set HISI_PCIE_EVENT_CTRL.
180 static u32 hisi_pcie_get_real_event(struct perf_event *event)
182 return hisi_pcie_get_event(event) & GENMASK(15, 0);
219 static void hisi_pcie_pmu_config_filter(struct perf_event *event)
221 struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
222 struct hw_perf_event *hwc = &event->hw;
226 /* Config HISI_PCIE_EVENT_CTRL according to event. */
227 reg |= FIELD_PREP(HISI_PCIE_EVENT_M, hisi_pcie_get_real_event(event));
230 port = hisi_pcie_get_port(event);
235 FIELD_PREP(HISI_PCIE_TARGET_M, hisi_pcie_get_bdf(event));
238 trig_len = hisi_pcie_get_trig_len(event);
241 reg |= FIELD_PREP(HISI_PCIE_TRIG_MODE_M, hisi_pcie_get_trig_mode(event));
246 thr_len = hisi_pcie_get_thr_len(event);
249 reg |= FIELD_PREP(HISI_PCIE_THR_MODE_M, hisi_pcie_get_thr_mode(event));
253 len_mode = hisi_pcie_get_len_mode(event);
262 static void hisi_pcie_pmu_clear_filter(struct perf_event *event)
264 struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
265 struct hw_perf_event *hwc = &event->hw;
291 static bool hisi_pcie_pmu_valid_filter(struct perf_event *event,
294 u32 requester_id = hisi_pcie_get_bdf(event);
296 if (hisi_pcie_get_thr_len(event) > HISI_PCIE_THR_MAX_VAL)
299 if (hisi_pcie_get_trig_len(event) > HISI_PCIE_TRIG_MAX_VAL)
311 struct perf_event *event)
313 return hisi_pcie_get_real_event(target) == hisi_pcie_get_real_event(event);
316 static bool hisi_pcie_pmu_validate_event_group(struct perf_event *event)
318 struct perf_event *sibling, *leader = event->group_leader;
325 if (leader->pmu != event->pmu)
328 if (leader != event && !hisi_pcie_pmu_cmp_event(leader, event))
329 event_group[counters++] = event;
332 for_each_sibling_event(sibling, event->group_leader) {
336 if (sibling->pmu != event->pmu)
351 static int hisi_pcie_pmu_event_init(struct perf_event *event)
353 struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
354 struct hw_perf_event *hwc = &event->hw;
356 /* Check the type first before going on, otherwise it's not our event */
357 if (event->attr.type != event->pmu->type)
360 event->cpu = pcie_pmu->on_cpu;
362 if (EXT_COUNTER_IS_USED(hisi_pcie_get_event(event)))
368 if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK)
371 if (!hisi_pcie_pmu_valid_filter(event, pcie_pmu))
374 if (!hisi_pcie_pmu_validate_event_group(event))
380 static u64 hisi_pcie_pmu_read_counter(struct perf_event *event)
382 struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
383 u32 idx = event->hw.idx;
385 return hisi_pcie_pmu_readq(pcie_pmu, event->hw.event_base, idx);
389 struct perf_event *event)
399 if (!hisi_pcie_pmu_cmp_event(sibling, event))
403 if (sibling->group_leader == event->group_leader)
424 static void hisi_pcie_pmu_event_update(struct perf_event *event)
426 struct hw_perf_event *hwc = &event->hw;
431 new_cnt = hisi_pcie_pmu_read_counter(event);
436 local64_add(delta, &event->count);
439 static void hisi_pcie_pmu_read(struct perf_event *event)
441 hisi_pcie_pmu_event_update(event);
444 static void hisi_pcie_pmu_set_period(struct perf_event *event)
446 struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
447 struct hw_perf_event *hwc = &event->hw;
495 static void hisi_pcie_pmu_start(struct perf_event *event, int flags)
497 struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
498 struct hw_perf_event *hwc = &event->hw;
508 hisi_pcie_pmu_config_filter(event);
511 hisi_pcie_pmu_set_period(event);
518 perf_event_update_userpage(event);
521 static void hisi_pcie_pmu_stop(struct perf_event *event, int flags)
523 struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
524 struct hw_perf_event *hwc = &event->hw;
526 hisi_pcie_pmu_event_update(event);
529 hisi_pcie_pmu_clear_filter(event);
539 static int hisi_pcie_pmu_add(struct perf_event *event, int flags)
541 struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
542 struct hw_perf_event *hwc = &event->hw;
547 /* Check all working events to find a related event. */
548 idx = hisi_pcie_pmu_find_related_event(pcie_pmu, event);
552 /* Current event shares an enabled counter with the related event */
563 pcie_pmu->hw_events[idx] = event;
569 hisi_pcie_pmu_start(event, PERF_EF_RELOAD);
574 static void hisi_pcie_pmu_del(struct perf_event *event, int flags)
576 struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
577 struct hw_perf_event *hwc = &event->hw;
579 hisi_pcie_pmu_stop(event, PERF_EF_UPDATE);
581 perf_event_update_userpage(event);
611 struct perf_event *event;
622 event = pcie_pmu->hw_events[idx];
623 if (!event)
626 hisi_pcie_pmu_event_update(event);
627 hisi_pcie_pmu_set_period(event);
703 /* Use this CPU for event counting */
730 HISI_PCIE_PMU_FORMAT_ATTR(event, "config:0-16"),