Lines Matching refs:tx2_pmu

112 			struct tx2_uncore_pmu *tx2_pmu);
254 struct tx2_uncore_pmu *tx2_pmu; in cpumask_show() local
256 tx2_pmu = pmu_to_tx2_pmu(dev_get_drvdata(dev)); in cpumask_show()
257 return cpumap_print_to_pagebuf(true, buf, cpumask_of(tx2_pmu->cpu)); in cpumask_show()
304 static int alloc_counter(struct tx2_uncore_pmu *tx2_pmu) in alloc_counter() argument
308 counter = find_first_zero_bit(tx2_pmu->active_counters, in alloc_counter()
309 tx2_pmu->max_counters); in alloc_counter()
310 if (counter == tx2_pmu->max_counters) in alloc_counter()
313 set_bit(counter, tx2_pmu->active_counters); in alloc_counter()
317 static inline void free_counter(struct tx2_uncore_pmu *tx2_pmu, int counter) in free_counter() argument
319 clear_bit(counter, tx2_pmu->active_counters); in free_counter()
323 struct tx2_uncore_pmu *tx2_pmu) in init_cntr_base_l3c() argument
328 tx2_pmu = pmu_to_tx2_pmu(event->pmu); in init_cntr_base_l3c()
329 cmask = tx2_pmu->counters_mask; in init_cntr_base_l3c()
332 hwc->config_base = (unsigned long)tx2_pmu->base in init_cntr_base_l3c()
334 hwc->event_base = (unsigned long)tx2_pmu->base in init_cntr_base_l3c()
339 struct tx2_uncore_pmu *tx2_pmu) in init_cntr_base_dmc() argument
344 tx2_pmu = pmu_to_tx2_pmu(event->pmu); in init_cntr_base_dmc()
345 cmask = tx2_pmu->counters_mask; in init_cntr_base_dmc()
347 hwc->config_base = (unsigned long)tx2_pmu->base in init_cntr_base_dmc()
350 hwc->event_base = (unsigned long)tx2_pmu->base in init_cntr_base_dmc()
355 struct tx2_uncore_pmu *tx2_pmu) in init_cntr_base_ccpi2() argument
360 cmask = tx2_pmu->counters_mask; in init_cntr_base_ccpi2()
362 hwc->config_base = (unsigned long)tx2_pmu->base in init_cntr_base_ccpi2()
364 hwc->event_base = (unsigned long)tx2_pmu->base; in init_cntr_base_ccpi2()
371 struct tx2_uncore_pmu *tx2_pmu; in uncore_start_event_l3c() local
373 tx2_pmu = pmu_to_tx2_pmu(event->pmu); in uncore_start_event_l3c()
374 emask = tx2_pmu->events_mask; in uncore_start_event_l3c()
392 struct tx2_uncore_pmu *tx2_pmu; in uncore_start_event_dmc() local
395 tx2_pmu = pmu_to_tx2_pmu(event->pmu); in uncore_start_event_dmc()
396 cmask = tx2_pmu->counters_mask; in uncore_start_event_dmc()
397 emask = tx2_pmu->events_mask; in uncore_start_event_dmc()
417 struct tx2_uncore_pmu *tx2_pmu; in uncore_stop_event_dmc() local
420 tx2_pmu = pmu_to_tx2_pmu(event->pmu); in uncore_stop_event_dmc()
421 cmask = tx2_pmu->counters_mask; in uncore_stop_event_dmc()
434 struct tx2_uncore_pmu *tx2_pmu; in uncore_start_event_ccpi2() local
436 tx2_pmu = pmu_to_tx2_pmu(event->pmu); in uncore_start_event_ccpi2()
437 emask = tx2_pmu->events_mask; in uncore_start_event_ccpi2()
467 struct tx2_uncore_pmu *tx2_pmu; in tx2_uncore_event_update() local
472 tx2_pmu = pmu_to_tx2_pmu(event->pmu); in tx2_uncore_event_update()
473 type = tx2_pmu->type; in tx2_uncore_event_update()
474 cmask = tx2_pmu->counters_mask; in tx2_uncore_event_update()
475 emask = tx2_pmu->events_mask; in tx2_uncore_event_update()
476 prorate_factor = tx2_pmu->prorate_factor; in tx2_uncore_event_update()
575 struct tx2_uncore_pmu *tx2_pmu; in tx2_uncore_event_init() local
592 tx2_pmu = pmu_to_tx2_pmu(event->pmu); in tx2_uncore_event_init()
593 if (tx2_pmu->cpu >= nr_cpu_ids) in tx2_uncore_event_init()
595 event->cpu = tx2_pmu->cpu; in tx2_uncore_event_init()
597 if (event->attr.config >= tx2_pmu->max_events) in tx2_uncore_event_init()
604 if (!tx2_uncore_validate_event_group(event, tx2_pmu->max_counters)) in tx2_uncore_event_init()
613 struct tx2_uncore_pmu *tx2_pmu; in tx2_uncore_event_start() local
616 tx2_pmu = pmu_to_tx2_pmu(event->pmu); in tx2_uncore_event_start()
618 tx2_pmu->start_event(event, flags); in tx2_uncore_event_start()
622 if (!tx2_pmu->hrtimer_callback) in tx2_uncore_event_start()
626 if (bitmap_weight(tx2_pmu->active_counters, in tx2_uncore_event_start()
627 tx2_pmu->max_counters) == 1) { in tx2_uncore_event_start()
628 hrtimer_start(&tx2_pmu->hrtimer, in tx2_uncore_event_start()
629 ns_to_ktime(tx2_pmu->hrtimer_interval), in tx2_uncore_event_start()
637 struct tx2_uncore_pmu *tx2_pmu; in tx2_uncore_event_stop() local
642 tx2_pmu = pmu_to_tx2_pmu(event->pmu); in tx2_uncore_event_stop()
643 tx2_pmu->stop_event(event); in tx2_uncore_event_stop()
655 struct tx2_uncore_pmu *tx2_pmu; in tx2_uncore_event_add() local
657 tx2_pmu = pmu_to_tx2_pmu(event->pmu); in tx2_uncore_event_add()
660 hwc->idx = alloc_counter(tx2_pmu); in tx2_uncore_event_add()
664 tx2_pmu->events[hwc->idx] = event; in tx2_uncore_event_add()
666 tx2_pmu->init_cntr_base(event, tx2_pmu); in tx2_uncore_event_add()
677 struct tx2_uncore_pmu *tx2_pmu = pmu_to_tx2_pmu(event->pmu); in tx2_uncore_event_del() local
681 cmask = tx2_pmu->counters_mask; in tx2_uncore_event_del()
685 free_counter(tx2_pmu, GET_COUNTERID(event, cmask)); in tx2_uncore_event_del()
688 tx2_pmu->events[hwc->idx] = NULL; in tx2_uncore_event_del()
691 if (!tx2_pmu->hrtimer_callback) in tx2_uncore_event_del()
694 if (bitmap_empty(tx2_pmu->active_counters, tx2_pmu->max_counters)) in tx2_uncore_event_del()
695 hrtimer_cancel(&tx2_pmu->hrtimer); in tx2_uncore_event_del()
705 struct tx2_uncore_pmu *tx2_pmu; in tx2_hrtimer_callback() local
708 tx2_pmu = container_of(timer, struct tx2_uncore_pmu, hrtimer); in tx2_hrtimer_callback()
709 max_counters = tx2_pmu->max_counters; in tx2_hrtimer_callback()
711 if (bitmap_empty(tx2_pmu->active_counters, max_counters)) in tx2_hrtimer_callback()
714 for_each_set_bit(idx, tx2_pmu->active_counters, max_counters) { in tx2_hrtimer_callback()
715 struct perf_event *event = tx2_pmu->events[idx]; in tx2_hrtimer_callback()
719 hrtimer_forward_now(timer, ns_to_ktime(tx2_pmu->hrtimer_interval)); in tx2_hrtimer_callback()
724 struct tx2_uncore_pmu *tx2_pmu) in tx2_uncore_pmu_register() argument
726 struct device *dev = tx2_pmu->dev; in tx2_uncore_pmu_register()
727 char *name = tx2_pmu->name; in tx2_uncore_pmu_register()
730 tx2_pmu->pmu = (struct pmu) { in tx2_uncore_pmu_register()
732 .attr_groups = tx2_pmu->attr_groups, in tx2_uncore_pmu_register()
743 tx2_pmu->pmu.name = devm_kasprintf(dev, GFP_KERNEL, in tx2_uncore_pmu_register()
746 return perf_pmu_register(&tx2_pmu->pmu, tx2_pmu->pmu.name, -1); in tx2_uncore_pmu_register()
749 static int tx2_uncore_pmu_add_dev(struct tx2_uncore_pmu *tx2_pmu) in tx2_uncore_pmu_add_dev() argument
753 cpu = cpumask_any_and(cpumask_of_node(tx2_pmu->node), in tx2_uncore_pmu_add_dev()
756 tx2_pmu->cpu = cpu; in tx2_uncore_pmu_add_dev()
758 if (tx2_pmu->hrtimer_callback) { in tx2_uncore_pmu_add_dev()
759 hrtimer_init(&tx2_pmu->hrtimer, in tx2_uncore_pmu_add_dev()
761 tx2_pmu->hrtimer.function = tx2_pmu->hrtimer_callback; in tx2_uncore_pmu_add_dev()
764 ret = tx2_uncore_pmu_register(tx2_pmu); in tx2_uncore_pmu_add_dev()
766 dev_err(tx2_pmu->dev, "%s PMU: Failed to init driver\n", in tx2_uncore_pmu_add_dev()
767 tx2_pmu->name); in tx2_uncore_pmu_add_dev()
774 &tx2_pmu->hpnode); in tx2_uncore_pmu_add_dev()
776 dev_err(tx2_pmu->dev, "Error %d registering hotplug", ret); in tx2_uncore_pmu_add_dev()
781 list_add(&tx2_pmu->entry, &tx2_pmus); in tx2_uncore_pmu_add_dev()
783 dev_dbg(tx2_pmu->dev, "%s PMU UNCORE registered\n", in tx2_uncore_pmu_add_dev()
784 tx2_pmu->pmu.name); in tx2_uncore_pmu_add_dev()
791 struct tx2_uncore_pmu *tx2_pmu; in tx2_uncore_pmu_init_dev() local
825 tx2_pmu = devm_kzalloc(dev, sizeof(*tx2_pmu), GFP_KERNEL); in tx2_uncore_pmu_init_dev()
826 if (!tx2_pmu) in tx2_uncore_pmu_init_dev()
829 tx2_pmu->dev = dev; in tx2_uncore_pmu_init_dev()
830 tx2_pmu->type = type; in tx2_uncore_pmu_init_dev()
831 tx2_pmu->base = base; in tx2_uncore_pmu_init_dev()
832 tx2_pmu->node = dev_to_node(dev); in tx2_uncore_pmu_init_dev()
833 INIT_LIST_HEAD(&tx2_pmu->entry); in tx2_uncore_pmu_init_dev()
835 switch (tx2_pmu->type) { in tx2_uncore_pmu_init_dev()
837 tx2_pmu->max_counters = TX2_PMU_DMC_L3C_MAX_COUNTERS; in tx2_uncore_pmu_init_dev()
838 tx2_pmu->counters_mask = 0x3; in tx2_uncore_pmu_init_dev()
839 tx2_pmu->prorate_factor = TX2_PMU_L3_TILES; in tx2_uncore_pmu_init_dev()
840 tx2_pmu->max_events = L3_EVENT_MAX; in tx2_uncore_pmu_init_dev()
841 tx2_pmu->events_mask = 0x1f; in tx2_uncore_pmu_init_dev()
842 tx2_pmu->hrtimer_interval = TX2_PMU_HRTIMER_INTERVAL; in tx2_uncore_pmu_init_dev()
843 tx2_pmu->hrtimer_callback = tx2_hrtimer_callback; in tx2_uncore_pmu_init_dev()
844 tx2_pmu->attr_groups = l3c_pmu_attr_groups; in tx2_uncore_pmu_init_dev()
845 tx2_pmu->name = devm_kasprintf(dev, GFP_KERNEL, in tx2_uncore_pmu_init_dev()
846 "uncore_l3c_%d", tx2_pmu->node); in tx2_uncore_pmu_init_dev()
847 tx2_pmu->init_cntr_base = init_cntr_base_l3c; in tx2_uncore_pmu_init_dev()
848 tx2_pmu->start_event = uncore_start_event_l3c; in tx2_uncore_pmu_init_dev()
849 tx2_pmu->stop_event = uncore_stop_event_l3c; in tx2_uncore_pmu_init_dev()
852 tx2_pmu->max_counters = TX2_PMU_DMC_L3C_MAX_COUNTERS; in tx2_uncore_pmu_init_dev()
853 tx2_pmu->counters_mask = 0x3; in tx2_uncore_pmu_init_dev()
854 tx2_pmu->prorate_factor = TX2_PMU_DMC_CHANNELS; in tx2_uncore_pmu_init_dev()
855 tx2_pmu->max_events = DMC_EVENT_MAX; in tx2_uncore_pmu_init_dev()
856 tx2_pmu->events_mask = 0x1f; in tx2_uncore_pmu_init_dev()
857 tx2_pmu->hrtimer_interval = TX2_PMU_HRTIMER_INTERVAL; in tx2_uncore_pmu_init_dev()
858 tx2_pmu->hrtimer_callback = tx2_hrtimer_callback; in tx2_uncore_pmu_init_dev()
859 tx2_pmu->attr_groups = dmc_pmu_attr_groups; in tx2_uncore_pmu_init_dev()
860 tx2_pmu->name = devm_kasprintf(dev, GFP_KERNEL, in tx2_uncore_pmu_init_dev()
861 "uncore_dmc_%d", tx2_pmu->node); in tx2_uncore_pmu_init_dev()
862 tx2_pmu->init_cntr_base = init_cntr_base_dmc; in tx2_uncore_pmu_init_dev()
863 tx2_pmu->start_event = uncore_start_event_dmc; in tx2_uncore_pmu_init_dev()
864 tx2_pmu->stop_event = uncore_stop_event_dmc; in tx2_uncore_pmu_init_dev()
868 tx2_pmu->max_counters = TX2_PMU_CCPI2_MAX_COUNTERS; in tx2_uncore_pmu_init_dev()
869 tx2_pmu->counters_mask = 0x7; in tx2_uncore_pmu_init_dev()
870 tx2_pmu->prorate_factor = 1; in tx2_uncore_pmu_init_dev()
871 tx2_pmu->max_events = CCPI2_EVENT_MAX; in tx2_uncore_pmu_init_dev()
872 tx2_pmu->events_mask = 0x1ff; in tx2_uncore_pmu_init_dev()
873 tx2_pmu->attr_groups = ccpi2_pmu_attr_groups; in tx2_uncore_pmu_init_dev()
874 tx2_pmu->name = devm_kasprintf(dev, GFP_KERNEL, in tx2_uncore_pmu_init_dev()
875 "uncore_ccpi2_%d", tx2_pmu->node); in tx2_uncore_pmu_init_dev()
876 tx2_pmu->init_cntr_base = init_cntr_base_ccpi2; in tx2_uncore_pmu_init_dev()
877 tx2_pmu->start_event = uncore_start_event_ccpi2; in tx2_uncore_pmu_init_dev()
878 tx2_pmu->stop_event = uncore_stop_event_ccpi2; in tx2_uncore_pmu_init_dev()
879 tx2_pmu->hrtimer_callback = NULL; in tx2_uncore_pmu_init_dev()
882 devm_kfree(dev, tx2_pmu); in tx2_uncore_pmu_init_dev()
886 return tx2_pmu; in tx2_uncore_pmu_init_dev()
892 struct tx2_uncore_pmu *tx2_pmu; in tx2_uncore_pmu_add() local
905 tx2_pmu = tx2_uncore_pmu_init_dev((struct device *)data, in tx2_uncore_pmu_add()
908 if (!tx2_pmu) in tx2_uncore_pmu_add()
911 if (tx2_uncore_pmu_add_dev(tx2_pmu)) { in tx2_uncore_pmu_add()
921 struct tx2_uncore_pmu *tx2_pmu; in tx2_uncore_pmu_online_cpu() local
923 tx2_pmu = hlist_entry_safe(hpnode, in tx2_uncore_pmu_online_cpu()
929 if ((tx2_pmu->cpu >= nr_cpu_ids) && in tx2_uncore_pmu_online_cpu()
930 (tx2_pmu->node == cpu_to_node(cpu))) in tx2_uncore_pmu_online_cpu()
931 tx2_pmu->cpu = cpu; in tx2_uncore_pmu_online_cpu()
940 struct tx2_uncore_pmu *tx2_pmu; in tx2_uncore_pmu_offline_cpu() local
943 tx2_pmu = hlist_entry_safe(hpnode, in tx2_uncore_pmu_offline_cpu()
946 if (cpu != tx2_pmu->cpu) in tx2_uncore_pmu_offline_cpu()
949 if (tx2_pmu->hrtimer_callback) in tx2_uncore_pmu_offline_cpu()
950 hrtimer_cancel(&tx2_pmu->hrtimer); in tx2_uncore_pmu_offline_cpu()
955 cpumask_of_node(tx2_pmu->node), in tx2_uncore_pmu_offline_cpu()
958 tx2_pmu->cpu = new_cpu; in tx2_uncore_pmu_offline_cpu()
961 perf_pmu_migrate_context(&tx2_pmu->pmu, cpu, new_cpu); in tx2_uncore_pmu_offline_cpu()
1002 struct tx2_uncore_pmu *tx2_pmu, *temp; in tx2_uncore_remove() local
1006 list_for_each_entry_safe(tx2_pmu, temp, &tx2_pmus, entry) { in tx2_uncore_remove()
1007 if (tx2_pmu->node == dev_to_node(dev)) { in tx2_uncore_remove()
1010 &tx2_pmu->hpnode); in tx2_uncore_remove()
1011 perf_pmu_unregister(&tx2_pmu->pmu); in tx2_uncore_remove()
1012 list_del(&tx2_pmu->entry); in tx2_uncore_remove()