Lines Matching refs:hisi_ptt
27 static bool hisi_ptt_wait_tuning_finish(struct hisi_ptt *hisi_ptt) in hisi_ptt_wait_tuning_finish() argument
31 return !readl_poll_timeout(hisi_ptt->iobase + HISI_PTT_TUNING_INT_STAT, in hisi_ptt_wait_tuning_finish()
41 struct hisi_ptt *hisi_ptt = to_hisi_ptt(dev_get_drvdata(dev)); in hisi_ptt_tune_attr_show() local
50 mutex_lock(&hisi_ptt->tune_lock); in hisi_ptt_tune_attr_show()
52 reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); in hisi_ptt_tune_attr_show()
56 writel(reg, hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); in hisi_ptt_tune_attr_show()
59 writel(~0U, hisi_ptt->iobase + HISI_PTT_TUNING_DATA); in hisi_ptt_tune_attr_show()
61 if (!hisi_ptt_wait_tuning_finish(hisi_ptt)) { in hisi_ptt_tune_attr_show()
62 mutex_unlock(&hisi_ptt->tune_lock); in hisi_ptt_tune_attr_show()
66 reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_DATA); in hisi_ptt_tune_attr_show()
70 mutex_unlock(&hisi_ptt->tune_lock); in hisi_ptt_tune_attr_show()
78 struct hisi_ptt *hisi_ptt = to_hisi_ptt(dev_get_drvdata(dev)); in hisi_ptt_tune_attr_store() local
90 mutex_lock(&hisi_ptt->tune_lock); in hisi_ptt_tune_attr_store()
92 reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); in hisi_ptt_tune_attr_store()
96 writel(reg, hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); in hisi_ptt_tune_attr_store()
98 hisi_ptt->iobase + HISI_PTT_TUNING_DATA); in hisi_ptt_tune_attr_store()
100 if (!hisi_ptt_wait_tuning_finish(hisi_ptt)) { in hisi_ptt_tune_attr_store()
101 mutex_unlock(&hisi_ptt->tune_lock); in hisi_ptt_tune_attr_store()
105 mutex_unlock(&hisi_ptt->tune_lock); in hisi_ptt_tune_attr_store()
164 static bool hisi_ptt_wait_trace_hw_idle(struct hisi_ptt *hisi_ptt) in hisi_ptt_wait_trace_hw_idle() argument
168 return !readl_poll_timeout_atomic(hisi_ptt->iobase + HISI_PTT_TRACE_STS, in hisi_ptt_wait_trace_hw_idle()
174 static void hisi_ptt_wait_dma_reset_done(struct hisi_ptt *hisi_ptt) in hisi_ptt_wait_dma_reset_done() argument
178 readl_poll_timeout_atomic(hisi_ptt->iobase + HISI_PTT_TRACE_WR_STS, in hisi_ptt_wait_dma_reset_done()
183 static void hisi_ptt_trace_end(struct hisi_ptt *hisi_ptt) in hisi_ptt_trace_end() argument
185 writel(0, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL); in hisi_ptt_trace_end()
188 writel(HISI_PTT_TRACE_INT_MASK_ALL, hisi_ptt->iobase + HISI_PTT_TRACE_INT_MASK); in hisi_ptt_trace_end()
190 hisi_ptt->trace_ctrl.started = false; in hisi_ptt_trace_end()
193 static int hisi_ptt_trace_start(struct hisi_ptt *hisi_ptt) in hisi_ptt_trace_start() argument
195 struct hisi_ptt_trace_ctrl *ctrl = &hisi_ptt->trace_ctrl; in hisi_ptt_trace_start()
200 if (!hisi_ptt_wait_trace_hw_idle(hisi_ptt)) { in hisi_ptt_trace_start()
201 pci_err(hisi_ptt->pdev, "Failed to start trace, the device is still busy\n"); in hisi_ptt_trace_start()
208 val = readl(hisi_ptt->iobase + HISI_PTT_TRACE_CTRL); in hisi_ptt_trace_start()
210 writel(val, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL); in hisi_ptt_trace_start()
212 hisi_ptt_wait_dma_reset_done(hisi_ptt); in hisi_ptt_trace_start()
214 val = readl(hisi_ptt->iobase + HISI_PTT_TRACE_CTRL); in hisi_ptt_trace_start()
216 writel(val, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL); in hisi_ptt_trace_start()
219 hisi_ptt->trace_ctrl.buf_index = 0; in hisi_ptt_trace_start()
226 writel(HISI_PTT_TRACE_INT_STAT_MASK, hisi_ptt->iobase + HISI_PTT_TRACE_INT_STAT); in hisi_ptt_trace_start()
227 writel(0, hisi_ptt->iobase + HISI_PTT_TRACE_INT_MASK); in hisi_ptt_trace_start()
233 val |= FIELD_PREP(HISI_PTT_TRACE_CTRL_TARGET_SEL, hisi_ptt->trace_ctrl.filter); in hisi_ptt_trace_start()
234 if (!hisi_ptt->trace_ctrl.is_port) in hisi_ptt_trace_start()
239 writel(val, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL); in hisi_ptt_trace_start()
244 static int hisi_ptt_update_aux(struct hisi_ptt *hisi_ptt, int index, bool stop) in hisi_ptt_update_aux() argument
246 struct hisi_ptt_trace_ctrl *ctrl = &hisi_ptt->trace_ctrl; in hisi_ptt_update_aux()
267 reg = readl(hisi_ptt->iobase + HISI_PTT_TRACE_WR_STS); in hisi_ptt_update_aux()
301 struct hisi_ptt *hisi_ptt = context; in hisi_ptt_isr() local
304 status = readl(hisi_ptt->iobase + HISI_PTT_TRACE_INT_STAT); in hisi_ptt_isr()
311 writel(status, hisi_ptt->iobase + HISI_PTT_TRACE_INT_STAT); in hisi_ptt_isr()
319 if (hisi_ptt_update_aux(hisi_ptt, buf_idx, false)) in hisi_ptt_isr()
320 hisi_ptt_trace_end(hisi_ptt); in hisi_ptt_isr()
322 hisi_ptt->trace_ctrl.buf_index = (buf_idx + 1) % HISI_PTT_TRACE_BUF_CNT; in hisi_ptt_isr()
332 static int hisi_ptt_register_irq(struct hisi_ptt *hisi_ptt) in hisi_ptt_register_irq() argument
334 struct pci_dev *pdev = hisi_ptt->pdev; in hisi_ptt_register_irq()
347 hisi_ptt->trace_irq = pci_irq_vector(pdev, HISI_PTT_TRACE_DMA_IRQ); in hisi_ptt_register_irq()
348 ret = devm_request_irq(&pdev->dev, hisi_ptt->trace_irq, hisi_ptt_isr, in hisi_ptt_register_irq()
350 hisi_ptt); in hisi_ptt_register_irq()
353 hisi_ptt->trace_irq, ret); in hisi_ptt_register_irq()
360 static void hisi_ptt_del_free_filter(struct hisi_ptt *hisi_ptt, in hisi_ptt_del_free_filter() argument
364 hisi_ptt->port_mask &= ~hisi_ptt_get_filter_val(filter->devid, true); in hisi_ptt_del_free_filter()
372 hisi_ptt_alloc_add_filter(struct hisi_ptt *hisi_ptt, u16 devid, bool is_port) in hisi_ptt_alloc_add_filter() argument
378 filter_name = kasprintf(GFP_KERNEL, "%04x:%02x:%02x.%d", pci_domain_nr(hisi_ptt->pdev->bus), in hisi_ptt_alloc_add_filter()
381 pci_err(hisi_ptt->pdev, "failed to allocate name for filter %04x:%02x:%02x.%d\n", in hisi_ptt_alloc_add_filter()
382 pci_domain_nr(hisi_ptt->pdev->bus), PCI_BUS_NUM(devid), in hisi_ptt_alloc_add_filter()
389 pci_err(hisi_ptt->pdev, "failed to add filter for %s\n", in hisi_ptt_alloc_add_filter()
400 list_add_tail(&filter->list, &hisi_ptt->port_filters); in hisi_ptt_alloc_add_filter()
403 hisi_ptt->port_mask |= hisi_ptt_get_filter_val(filter->devid, true); in hisi_ptt_alloc_add_filter()
405 list_add_tail(&filter->list, &hisi_ptt->req_filters); in hisi_ptt_alloc_add_filter()
424 static int hisi_ptt_create_rp_filter_attr(struct hisi_ptt *hisi_ptt, in hisi_ptt_create_rp_filter_attr() argument
427 struct kobject *kobj = &hisi_ptt->hisi_ptt_pmu.dev->kobj; in hisi_ptt_create_rp_filter_attr()
438 static void hisi_ptt_remove_rp_filter_attr(struct hisi_ptt *hisi_ptt, in hisi_ptt_remove_rp_filter_attr() argument
441 struct kobject *kobj = &hisi_ptt->hisi_ptt_pmu.dev->kobj; in hisi_ptt_remove_rp_filter_attr()
447 static int hisi_ptt_create_req_filter_attr(struct hisi_ptt *hisi_ptt, in hisi_ptt_create_req_filter_attr() argument
450 struct kobject *kobj = &hisi_ptt->hisi_ptt_pmu.dev->kobj; in hisi_ptt_create_req_filter_attr()
461 static void hisi_ptt_remove_req_filter_attr(struct hisi_ptt *hisi_ptt, in hisi_ptt_remove_req_filter_attr() argument
464 struct kobject *kobj = &hisi_ptt->hisi_ptt_pmu.dev->kobj; in hisi_ptt_remove_req_filter_attr()
470 static int hisi_ptt_create_filter_attr(struct hisi_ptt *hisi_ptt, in hisi_ptt_create_filter_attr() argument
476 ret = hisi_ptt_create_rp_filter_attr(hisi_ptt, filter); in hisi_ptt_create_filter_attr()
478 ret = hisi_ptt_create_req_filter_attr(hisi_ptt, filter); in hisi_ptt_create_filter_attr()
481 pci_err(hisi_ptt->pdev, "failed to create sysfs attribute for filter %s\n", in hisi_ptt_create_filter_attr()
487 static void hisi_ptt_remove_filter_attr(struct hisi_ptt *hisi_ptt, in hisi_ptt_remove_filter_attr() argument
491 hisi_ptt_remove_rp_filter_attr(hisi_ptt, filter); in hisi_ptt_remove_filter_attr()
493 hisi_ptt_remove_req_filter_attr(hisi_ptt, filter); in hisi_ptt_remove_filter_attr()
499 struct hisi_ptt *hisi_ptt = data; in hisi_ptt_remove_all_filter_attributes() local
501 mutex_lock(&hisi_ptt->filter_lock); in hisi_ptt_remove_all_filter_attributes()
503 list_for_each_entry(filter, &hisi_ptt->req_filters, list) in hisi_ptt_remove_all_filter_attributes()
504 hisi_ptt_remove_filter_attr(hisi_ptt, filter); in hisi_ptt_remove_all_filter_attributes()
506 list_for_each_entry(filter, &hisi_ptt->port_filters, list) in hisi_ptt_remove_all_filter_attributes()
507 hisi_ptt_remove_filter_attr(hisi_ptt, filter); in hisi_ptt_remove_all_filter_attributes()
509 hisi_ptt->sysfs_inited = false; in hisi_ptt_remove_all_filter_attributes()
510 mutex_unlock(&hisi_ptt->filter_lock); in hisi_ptt_remove_all_filter_attributes()
513 static int hisi_ptt_init_filter_attributes(struct hisi_ptt *hisi_ptt) in hisi_ptt_init_filter_attributes() argument
518 mutex_lock(&hisi_ptt->filter_lock); in hisi_ptt_init_filter_attributes()
525 ret = devm_add_action(&hisi_ptt->pdev->dev, in hisi_ptt_init_filter_attributes()
527 hisi_ptt); in hisi_ptt_init_filter_attributes()
531 list_for_each_entry(filter, &hisi_ptt->port_filters, list) { in hisi_ptt_init_filter_attributes()
532 ret = hisi_ptt_create_filter_attr(hisi_ptt, filter); in hisi_ptt_init_filter_attributes()
537 list_for_each_entry(filter, &hisi_ptt->req_filters, list) { in hisi_ptt_init_filter_attributes()
538 ret = hisi_ptt_create_filter_attr(hisi_ptt, filter); in hisi_ptt_init_filter_attributes()
543 hisi_ptt->sysfs_inited = true; in hisi_ptt_init_filter_attributes()
545 mutex_unlock(&hisi_ptt->filter_lock); in hisi_ptt_init_filter_attributes()
554 struct hisi_ptt *hisi_ptt; in hisi_ptt_update_filters() local
556 hisi_ptt = container_of(delayed_work, struct hisi_ptt, work); in hisi_ptt_update_filters()
558 if (!mutex_trylock(&hisi_ptt->filter_lock)) { in hisi_ptt_update_filters()
559 schedule_delayed_work(&hisi_ptt->work, HISI_PTT_WORK_DELAY_MS); in hisi_ptt_update_filters()
563 while (kfifo_get(&hisi_ptt->filter_update_kfifo, &info)) { in hisi_ptt_update_filters()
570 filter = hisi_ptt_alloc_add_filter(hisi_ptt, info.devid, info.is_port); in hisi_ptt_update_filters()
580 if (hisi_ptt->sysfs_inited && in hisi_ptt_update_filters()
581 hisi_ptt_create_filter_attr(hisi_ptt, filter)) { in hisi_ptt_update_filters()
582 hisi_ptt_del_free_filter(hisi_ptt, filter); in hisi_ptt_update_filters()
589 target_list = info.is_port ? &hisi_ptt->port_filters : in hisi_ptt_update_filters()
590 &hisi_ptt->req_filters; in hisi_ptt_update_filters()
594 if (hisi_ptt->sysfs_inited) in hisi_ptt_update_filters()
595 hisi_ptt_remove_filter_attr(hisi_ptt, filter); in hisi_ptt_update_filters()
597 hisi_ptt_del_free_filter(hisi_ptt, filter); in hisi_ptt_update_filters()
603 mutex_unlock(&hisi_ptt->filter_lock); in hisi_ptt_update_filters()
613 struct hisi_ptt *hisi_ptt = container_of(nb, struct hisi_ptt, hisi_ptt_nb); in hisi_ptt_notifier_call() local
625 if (port_devid < hisi_ptt->lower_bdf || in hisi_ptt_notifier_call()
626 port_devid > hisi_ptt->upper_bdf) in hisi_ptt_notifier_call()
649 if (kfifo_in_spinlocked(&hisi_ptt->filter_update_kfifo, &info, 1, in hisi_ptt_notifier_call()
650 &hisi_ptt->filter_update_lock)) in hisi_ptt_notifier_call()
651 schedule_delayed_work(&hisi_ptt->work, 0); in hisi_ptt_notifier_call()
653 pci_warn(hisi_ptt->pdev, in hisi_ptt_notifier_call()
664 struct hisi_ptt *hisi_ptt = data; in hisi_ptt_init_filters() local
671 if (port_devid < hisi_ptt->lower_bdf || in hisi_ptt_init_filters()
672 port_devid > hisi_ptt->upper_bdf) in hisi_ptt_init_filters()
680 filter = hisi_ptt_alloc_add_filter(hisi_ptt, pci_dev_id(pdev), in hisi_ptt_init_filters()
691 struct hisi_ptt *hisi_ptt = data; in hisi_ptt_release_filters() local
693 list_for_each_entry_safe(filter, tmp, &hisi_ptt->req_filters, list) in hisi_ptt_release_filters()
694 hisi_ptt_del_free_filter(hisi_ptt, filter); in hisi_ptt_release_filters()
696 list_for_each_entry_safe(filter, tmp, &hisi_ptt->port_filters, list) in hisi_ptt_release_filters()
697 hisi_ptt_del_free_filter(hisi_ptt, filter); in hisi_ptt_release_filters()
700 static int hisi_ptt_config_trace_buf(struct hisi_ptt *hisi_ptt) in hisi_ptt_config_trace_buf() argument
702 struct hisi_ptt_trace_ctrl *ctrl = &hisi_ptt->trace_ctrl; in hisi_ptt_config_trace_buf()
703 struct device *dev = &hisi_ptt->pdev->dev; in hisi_ptt_config_trace_buf()
722 hisi_ptt->iobase + HISI_PTT_TRACE_ADDR_BASE_LO_0 + in hisi_ptt_config_trace_buf()
725 hisi_ptt->iobase + HISI_PTT_TRACE_ADDR_BASE_HI_0 + in hisi_ptt_config_trace_buf()
728 writel(HISI_PTT_TRACE_BUF_SIZE, hisi_ptt->iobase + HISI_PTT_TRACE_ADDR_SIZE); in hisi_ptt_config_trace_buf()
733 static int hisi_ptt_init_ctrls(struct hisi_ptt *hisi_ptt) in hisi_ptt_init_ctrls() argument
735 struct pci_dev *pdev = hisi_ptt->pdev; in hisi_ptt_init_ctrls()
740 INIT_DELAYED_WORK(&hisi_ptt->work, hisi_ptt_update_filters); in hisi_ptt_init_ctrls()
741 INIT_KFIFO(hisi_ptt->filter_update_kfifo); in hisi_ptt_init_ctrls()
742 spin_lock_init(&hisi_ptt->filter_update_lock); in hisi_ptt_init_ctrls()
744 INIT_LIST_HEAD(&hisi_ptt->port_filters); in hisi_ptt_init_ctrls()
745 INIT_LIST_HEAD(&hisi_ptt->req_filters); in hisi_ptt_init_ctrls()
746 mutex_init(&hisi_ptt->filter_lock); in hisi_ptt_init_ctrls()
748 ret = hisi_ptt_config_trace_buf(hisi_ptt); in hisi_ptt_init_ctrls()
761 reg = readl(hisi_ptt->iobase + HISI_PTT_DEVICE_RANGE); in hisi_ptt_init_ctrls()
762 hisi_ptt->upper_bdf = FIELD_GET(HISI_PTT_DEVICE_RANGE_UPPER, reg); in hisi_ptt_init_ctrls()
763 hisi_ptt->lower_bdf = FIELD_GET(HISI_PTT_DEVICE_RANGE_LOWER, reg); in hisi_ptt_init_ctrls()
765 bus = pci_find_bus(pci_domain_nr(pdev->bus), PCI_BUS_NUM(hisi_ptt->upper_bdf)); in hisi_ptt_init_ctrls()
767 pci_walk_bus(bus, hisi_ptt_init_filters, hisi_ptt); in hisi_ptt_init_ctrls()
769 ret = devm_add_action_or_reset(&pdev->dev, hisi_ptt_release_filters, hisi_ptt); in hisi_ptt_init_ctrls()
773 hisi_ptt->trace_ctrl.on_cpu = -1; in hisi_ptt_init_ctrls()
780 struct hisi_ptt *hisi_ptt = to_hisi_ptt(dev_get_drvdata(dev)); in cpumask_show() local
781 const cpumask_t *cpumask = cpumask_of_node(dev_to_node(&hisi_ptt->pdev->dev)); in cpumask_show()
943 static int hisi_ptt_trace_valid_filter(struct hisi_ptt *hisi_ptt, u64 config) in hisi_ptt_trace_valid_filter() argument
945 unsigned long val, port_mask = hisi_ptt->port_mask; in hisi_ptt_trace_valid_filter()
949 hisi_ptt->trace_ctrl.is_port = FIELD_GET(HISI_PTT_PMU_FILTER_IS_PORT, config); in hisi_ptt_trace_valid_filter()
961 mutex_lock(&hisi_ptt->filter_lock); in hisi_ptt_trace_valid_filter()
962 if (!hisi_ptt->trace_ctrl.is_port) { in hisi_ptt_trace_valid_filter()
963 list_for_each_entry(filter, &hisi_ptt->req_filters, list) { in hisi_ptt_trace_valid_filter()
973 mutex_unlock(&hisi_ptt->filter_lock); in hisi_ptt_trace_valid_filter()
977 static void hisi_ptt_pmu_init_configs(struct hisi_ptt *hisi_ptt, struct perf_event *event) in hisi_ptt_pmu_init_configs() argument
979 struct hisi_ptt_trace_ctrl *ctrl = &hisi_ptt->trace_ctrl; in hisi_ptt_pmu_init_configs()
983 hisi_ptt->trace_ctrl.filter = val; in hisi_ptt_pmu_init_configs()
997 struct hisi_ptt *hisi_ptt = to_hisi_ptt(event->pmu); in hisi_ptt_pmu_event_init() local
1001 if (event->attr.type != hisi_ptt->hisi_ptt_pmu.type) in hisi_ptt_pmu_event_init()
1012 ret = hisi_ptt_trace_valid_filter(hisi_ptt, event->attr.config); in hisi_ptt_pmu_event_init()
1084 struct hisi_ptt *hisi_ptt = to_hisi_ptt(event->pmu); in hisi_ptt_pmu_start() local
1085 struct perf_output_handle *handle = &hisi_ptt->trace_ctrl.handle; in hisi_ptt_pmu_start()
1095 spin_lock(&hisi_ptt->pmu_lock); in hisi_ptt_pmu_start()
1096 if (hisi_ptt->trace_ctrl.started) { in hisi_ptt_pmu_start()
1107 ret = irq_set_affinity(hisi_ptt->trace_irq, cpumask_of(cpu)); in hisi_ptt_pmu_start()
1111 hisi_ptt->trace_ctrl.on_cpu = cpu; in hisi_ptt_pmu_start()
1121 hisi_ptt_pmu_init_configs(hisi_ptt, event); in hisi_ptt_pmu_start()
1123 ret = hisi_ptt_trace_start(hisi_ptt); in hisi_ptt_pmu_start()
1130 spin_unlock(&hisi_ptt->pmu_lock); in hisi_ptt_pmu_start()
1134 spin_unlock(&hisi_ptt->pmu_lock); in hisi_ptt_pmu_start()
1139 struct hisi_ptt *hisi_ptt = to_hisi_ptt(event->pmu); in hisi_ptt_pmu_stop() local
1145 spin_lock(&hisi_ptt->pmu_lock); in hisi_ptt_pmu_stop()
1146 if (hisi_ptt->trace_ctrl.started) { in hisi_ptt_pmu_stop()
1147 hisi_ptt_trace_end(hisi_ptt); in hisi_ptt_pmu_stop()
1149 if (!hisi_ptt_wait_trace_hw_idle(hisi_ptt)) in hisi_ptt_pmu_stop()
1152 hisi_ptt_update_aux(hisi_ptt, hisi_ptt->trace_ctrl.buf_index, true); in hisi_ptt_pmu_stop()
1154 spin_unlock(&hisi_ptt->pmu_lock); in hisi_ptt_pmu_stop()
1163 struct hisi_ptt *hisi_ptt = to_hisi_ptt(event->pmu); in hisi_ptt_pmu_add() local
1168 if (!cpumask_test_cpu(cpu, cpumask_of_node(dev_to_node(&hisi_ptt->pdev->dev)))) in hisi_ptt_pmu_add()
1201 static int hisi_ptt_register_pmu(struct hisi_ptt *hisi_ptt) in hisi_ptt_register_pmu() argument
1209 &hisi_ptt->hotplug_node); in hisi_ptt_register_pmu()
1213 ret = devm_add_action_or_reset(&hisi_ptt->pdev->dev, in hisi_ptt_register_pmu()
1215 &hisi_ptt->hotplug_node); in hisi_ptt_register_pmu()
1219 mutex_init(&hisi_ptt->tune_lock); in hisi_ptt_register_pmu()
1220 spin_lock_init(&hisi_ptt->pmu_lock); in hisi_ptt_register_pmu()
1222 hisi_ptt->hisi_ptt_pmu = (struct pmu) { in hisi_ptt_register_pmu()
1224 .parent = &hisi_ptt->pdev->dev, in hisi_ptt_register_pmu()
1238 reg = readl(hisi_ptt->iobase + HISI_PTT_LOCATION); in hisi_ptt_register_pmu()
1242 pmu_name = devm_kasprintf(&hisi_ptt->pdev->dev, GFP_KERNEL, "hisi_ptt%u_%u", in hisi_ptt_register_pmu()
1247 ret = perf_pmu_register(&hisi_ptt->hisi_ptt_pmu, pmu_name, -1); in hisi_ptt_register_pmu()
1251 return devm_add_action_or_reset(&hisi_ptt->pdev->dev, in hisi_ptt_register_pmu()
1253 &hisi_ptt->hisi_ptt_pmu); in hisi_ptt_register_pmu()
1258 struct hisi_ptt *hisi_ptt = data; in hisi_ptt_unregister_filter_update_notifier() local
1260 bus_unregister_notifier(&pci_bus_type, &hisi_ptt->hisi_ptt_nb); in hisi_ptt_unregister_filter_update_notifier()
1263 cancel_delayed_work_sync(&hisi_ptt->work); in hisi_ptt_unregister_filter_update_notifier()
1267 static int hisi_ptt_register_filter_update_notifier(struct hisi_ptt *hisi_ptt) in hisi_ptt_register_filter_update_notifier() argument
1271 hisi_ptt->hisi_ptt_nb.notifier_call = hisi_ptt_notifier_call; in hisi_ptt_register_filter_update_notifier()
1272 ret = bus_register_notifier(&pci_bus_type, &hisi_ptt->hisi_ptt_nb); in hisi_ptt_register_filter_update_notifier()
1276 return devm_add_action_or_reset(&hisi_ptt->pdev->dev, in hisi_ptt_register_filter_update_notifier()
1278 hisi_ptt); in hisi_ptt_register_filter_update_notifier()
1304 struct hisi_ptt *hisi_ptt; in hisi_ptt_probe() local
1313 hisi_ptt = devm_kzalloc(&pdev->dev, sizeof(*hisi_ptt), GFP_KERNEL); in hisi_ptt_probe()
1314 if (!hisi_ptt) in hisi_ptt_probe()
1317 hisi_ptt->pdev = pdev; in hisi_ptt_probe()
1318 pci_set_drvdata(pdev, hisi_ptt); in hisi_ptt_probe()
1332 hisi_ptt->iobase = pcim_iomap_table(pdev)[2]; in hisi_ptt_probe()
1342 ret = hisi_ptt_register_irq(hisi_ptt); in hisi_ptt_probe()
1346 ret = hisi_ptt_init_ctrls(hisi_ptt); in hisi_ptt_probe()
1352 ret = hisi_ptt_register_filter_update_notifier(hisi_ptt); in hisi_ptt_probe()
1356 ret = hisi_ptt_register_pmu(hisi_ptt); in hisi_ptt_probe()
1362 ret = hisi_ptt_init_filter_attributes(hisi_ptt); in hisi_ptt_probe()
1385 struct hisi_ptt *hisi_ptt; in hisi_ptt_cpu_teardown() local
1389 hisi_ptt = hlist_entry_safe(node, struct hisi_ptt, hotplug_node); in hisi_ptt_cpu_teardown()
1390 src = hisi_ptt->trace_ctrl.on_cpu; in hisi_ptt_cpu_teardown()
1391 dev = hisi_ptt->hisi_ptt_pmu.dev; in hisi_ptt_cpu_teardown()
1393 if (!hisi_ptt->trace_ctrl.started || src != cpu) in hisi_ptt_cpu_teardown()
1396 target = cpumask_any_but(cpumask_of_node(dev_to_node(&hisi_ptt->pdev->dev)), cpu); in hisi_ptt_cpu_teardown()
1402 perf_pmu_migrate_context(&hisi_ptt->hisi_ptt_pmu, src, target); in hisi_ptt_cpu_teardown()
1408 if (irq_set_affinity(hisi_ptt->trace_irq, cpumask_of(target))) in hisi_ptt_cpu_teardown()
1411 hisi_ptt->trace_ctrl.on_cpu = target; in hisi_ptt_cpu_teardown()