Lines Matching refs:pmu
105 struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu) in uncore_pmu_to_box() argument
113 return dieid < uncore_max_dies() ? pmu->boxes[dieid] : NULL; in uncore_pmu_to_box()
354 return &box->pmu->pmu == event->pmu; in is_box_event()
364 max_count = box->pmu->type->num_counters; in uncore_collect_events()
365 if (box->pmu->type->fixed_ctl) in uncore_collect_events()
398 struct intel_uncore_type *type = box->pmu->type; in uncore_get_event_constraint()
423 if (box->pmu->type->ops->put_constraint) in uncore_put_event_constraint()
424 box->pmu->type->ops->put_constraint(box, event); in uncore_put_event_constraint()
662 static int uncore_validate_group(struct intel_uncore_pmu *pmu, in uncore_validate_group() argument
673 fake_box = uncore_alloc_box(pmu->type, NUMA_NO_NODE); in uncore_validate_group()
677 fake_box->pmu = pmu; in uncore_validate_group()
703 struct intel_uncore_pmu *pmu; in uncore_pmu_event_init() local
708 if (event->attr.type != event->pmu->type) in uncore_pmu_event_init()
711 pmu = uncore_event_to_pmu(event); in uncore_pmu_event_init()
713 if (pmu->func_id < 0) in uncore_pmu_event_init()
726 box = uncore_pmu_to_box(pmu, event->cpu); in uncore_pmu_event_init()
741 if (!pmu->type->fixed_ctl) in uncore_pmu_event_init()
747 if (pmu->type->single_fixed && pmu->pmu_idx > 0) in uncore_pmu_event_init()
766 (pmu->type->event_mask | ((u64)pmu->type->event_mask_ext << 32)); in uncore_pmu_event_init()
767 if (pmu->type->ops->hw_config) { in uncore_pmu_event_init()
768 ret = pmu->type->ops->hw_config(box, event); in uncore_pmu_event_init()
775 ret = uncore_validate_group(pmu, event); in uncore_pmu_event_init()
782 static void uncore_pmu_enable(struct pmu *pmu) in uncore_pmu_enable() argument
787 uncore_pmu = container_of(pmu, struct intel_uncore_pmu, pmu); in uncore_pmu_enable()
799 static void uncore_pmu_disable(struct pmu *pmu) in uncore_pmu_disable() argument
804 uncore_pmu = container_of(pmu, struct intel_uncore_pmu, pmu); in uncore_pmu_disable()
833 static int uncore_pmu_register(struct intel_uncore_pmu *pmu) in uncore_pmu_register() argument
837 if (!pmu->type->pmu) { in uncore_pmu_register()
838 pmu->pmu = (struct pmu) { in uncore_pmu_register()
839 .attr_groups = pmu->type->attr_groups, in uncore_pmu_register()
851 .attr_update = pmu->type->attr_update, in uncore_pmu_register()
854 pmu->pmu = *pmu->type->pmu; in uncore_pmu_register()
855 pmu->pmu.attr_groups = pmu->type->attr_groups; in uncore_pmu_register()
856 pmu->pmu.attr_update = pmu->type->attr_update; in uncore_pmu_register()
859 if (pmu->type->num_boxes == 1) { in uncore_pmu_register()
860 if (strlen(pmu->type->name) > 0) in uncore_pmu_register()
861 sprintf(pmu->name, "uncore_%s", pmu->type->name); in uncore_pmu_register()
863 sprintf(pmu->name, "uncore"); in uncore_pmu_register()
865 sprintf(pmu->name, "uncore_%s_%d", pmu->type->name, in uncore_pmu_register()
866 pmu->pmu_idx); in uncore_pmu_register()
869 ret = perf_pmu_register(&pmu->pmu, pmu->name, -1); in uncore_pmu_register()
871 pmu->registered = true; in uncore_pmu_register()
875 static void uncore_pmu_unregister(struct intel_uncore_pmu *pmu) in uncore_pmu_unregister() argument
877 if (!pmu->registered) in uncore_pmu_unregister()
879 perf_pmu_unregister(&pmu->pmu); in uncore_pmu_unregister()
880 pmu->registered = false; in uncore_pmu_unregister()
883 static void uncore_free_boxes(struct intel_uncore_pmu *pmu) in uncore_free_boxes() argument
888 kfree(pmu->boxes[die]); in uncore_free_boxes()
889 kfree(pmu->boxes); in uncore_free_boxes()
894 struct intel_uncore_pmu *pmu = type->pmus; in uncore_type_exit() local
900 if (pmu) { in uncore_type_exit()
901 for (i = 0; i < type->num_boxes; i++, pmu++) { in uncore_type_exit()
902 uncore_pmu_unregister(pmu); in uncore_type_exit()
903 uncore_free_boxes(pmu); in uncore_type_exit()
1022 struct intel_uncore_pmu *pmu = NULL; in uncore_pci_find_dev_pmu() local
1035 pmu = &type->pmus[UNCORE_PCI_DEV_IDX(data)]; in uncore_pci_find_dev_pmu()
1041 return pmu; in uncore_pci_find_dev_pmu()
1054 struct intel_uncore_pmu *pmu, in uncore_pci_pmu_register() argument
1060 if (WARN_ON_ONCE(pmu->boxes[die] != NULL)) in uncore_pci_pmu_register()
1067 if (pmu->func_id < 0) in uncore_pci_pmu_register()
1068 pmu->func_id = pdev->devfn; in uncore_pci_pmu_register()
1070 WARN_ON_ONCE(pmu->func_id != pdev->devfn); in uncore_pci_pmu_register()
1076 box->pmu = pmu; in uncore_pci_pmu_register()
1079 pmu->boxes[die] = box; in uncore_pci_pmu_register()
1080 if (atomic_inc_return(&pmu->activeboxes) > 1) in uncore_pci_pmu_register()
1084 ret = uncore_pmu_register(pmu); in uncore_pci_pmu_register()
1086 pmu->boxes[die] = NULL; in uncore_pci_pmu_register()
1099 struct intel_uncore_pmu *pmu = NULL; in uncore_pci_probe() local
1124 pmu = uncore_pci_find_dev_pmu(pdev, pci_drv->id_table); in uncore_pci_probe()
1125 if (pmu == NULL) in uncore_pci_probe()
1132 pmu = &type->pmus[UNCORE_PCI_DEV_IDX(id->driver_data)]; in uncore_pci_probe()
1135 ret = uncore_pci_pmu_register(pdev, type, pmu, phys_id, die); in uncore_pci_probe()
1137 pci_set_drvdata(pdev, pmu->boxes[die]); in uncore_pci_probe()
1148 static void uncore_pci_pmu_unregister(struct intel_uncore_pmu *pmu, in uncore_pci_pmu_unregister() argument
1151 struct intel_uncore_box *box = pmu->boxes[die]; in uncore_pci_pmu_unregister()
1156 pmu->boxes[die] = NULL; in uncore_pci_pmu_unregister()
1157 if (atomic_dec_return(&pmu->activeboxes) == 0) in uncore_pci_pmu_unregister()
1158 uncore_pmu_unregister(pmu); in uncore_pci_pmu_unregister()
1166 struct intel_uncore_pmu *pmu; in uncore_pci_remove() local
1184 pmu = box->pmu; in uncore_pci_remove()
1188 uncore_pci_pmu_unregister(pmu, phys_id, die); in uncore_pci_remove()
1196 struct intel_uncore_pmu *pmu; in uncore_bus_notify() local
1203 pmu = uncore_pci_find_dev_pmu(pdev, uncore_pci_sub_driver->id_table); in uncore_bus_notify()
1204 if (!pmu) in uncore_bus_notify()
1210 uncore_pci_pmu_unregister(pmu, phys_id, die); in uncore_bus_notify()
1223 struct intel_uncore_pmu *pmu; in uncore_pci_sub_driver_init() local
1243 pmu = &type->pmus[UNCORE_PCI_DEV_IDX(ids->driver_data)]; in uncore_pci_sub_driver_init()
1244 if (!pmu) in uncore_pci_sub_driver_init()
1251 if (!uncore_pci_pmu_register(pci_sub_dev, type, pmu, in uncore_pci_sub_driver_init()
1320 struct intel_uncore_pmu *pmu = type->pmus; in uncore_change_type_ctx() local
1325 for (i = 0; i < type->num_boxes; i++, pmu++) { in uncore_change_type_ctx()
1326 box = pmu->boxes[die]; in uncore_change_type_ctx()
1342 perf_pmu_migrate_context(&pmu->pmu, old_cpu, new_cpu); in uncore_change_type_ctx()
1357 struct intel_uncore_pmu *pmu; in uncore_box_unref() local
1363 pmu = type->pmus; in uncore_box_unref()
1364 for (i = 0; i < type->num_boxes; i++, pmu++) { in uncore_box_unref()
1365 box = pmu->boxes[id]; in uncore_box_unref()
1405 struct intel_uncore_pmu *pmu; in allocate_boxes() local
1412 pmu = type->pmus; in allocate_boxes()
1413 for (i = 0; i < type->num_boxes; i++, pmu++) { in allocate_boxes()
1414 if (pmu->boxes[die]) in allocate_boxes()
1419 box->pmu = pmu; in allocate_boxes()
1427 box->pmu->boxes[die] = box; in allocate_boxes()
1443 struct intel_uncore_pmu *pmu; in uncore_box_ref() local
1453 pmu = type->pmus; in uncore_box_ref()
1454 for (i = 0; i < type->num_boxes; i++, pmu++) { in uncore_box_ref()
1455 box = pmu->boxes[id]; in uncore_box_ref()