Lines Matching full:pmu
122 struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu) in uncore_pmu_to_box() argument
130 return dieid < uncore_max_dies() ? pmu->boxes[dieid] : NULL; in uncore_pmu_to_box()
363 * Using uncore_pmu_event_init pmu event_init callback
370 return &box->pmu->pmu == event->pmu; in is_box_event()
380 max_count = box->pmu->type->num_counters; in uncore_collect_events()
381 if (box->pmu->type->fixed_ctl) in uncore_collect_events()
414 struct intel_uncore_type *type = box->pmu->type; in uncore_get_event_constraint()
439 if (box->pmu->type->ops->put_constraint) in uncore_put_event_constraint()
440 box->pmu->type->ops->put_constraint(box, event); in uncore_put_event_constraint()
676 * PMU if it was the only group available.
678 static int uncore_validate_group(struct intel_uncore_pmu *pmu, in uncore_validate_group() argument
689 fake_box = uncore_alloc_box(pmu->type, NUMA_NO_NODE); in uncore_validate_group()
693 fake_box->pmu = pmu; in uncore_validate_group()
719 struct intel_uncore_pmu *pmu; in uncore_pmu_event_init() local
724 if (event->attr.type != event->pmu->type) in uncore_pmu_event_init()
727 pmu = uncore_event_to_pmu(event); in uncore_pmu_event_init()
728 /* no device found for this pmu */ in uncore_pmu_event_init()
729 if (pmu->func_id < 0) in uncore_pmu_event_init()
742 box = uncore_pmu_to_box(pmu, event->cpu); in uncore_pmu_event_init()
757 if (!pmu->type->fixed_ctl) in uncore_pmu_event_init()
760 * if there is only one fixed counter, only the first pmu in uncore_pmu_event_init()
763 if (pmu->type->single_fixed && pmu->pmu_idx > 0) in uncore_pmu_event_init()
782 (pmu->type->event_mask | ((u64)pmu->type->event_mask_ext << 32)); in uncore_pmu_event_init()
783 if (pmu->type->ops->hw_config) { in uncore_pmu_event_init()
784 ret = pmu->type->ops->hw_config(box, event); in uncore_pmu_event_init()
791 ret = uncore_validate_group(pmu, event); in uncore_pmu_event_init()
798 static void uncore_pmu_enable(struct pmu *pmu) in uncore_pmu_enable() argument
803 uncore_pmu = container_of(pmu, struct intel_uncore_pmu, pmu); in uncore_pmu_enable()
813 static void uncore_pmu_disable(struct pmu *pmu) in uncore_pmu_disable() argument
818 uncore_pmu = container_of(pmu, struct intel_uncore_pmu, pmu); in uncore_pmu_disable()
845 void uncore_get_alias_name(char *pmu_name, struct intel_uncore_pmu *pmu) in uncore_get_alias_name() argument
847 struct intel_uncore_type *type = pmu->type; in uncore_get_alias_name()
853 type->type_id, type->box_ids[pmu->pmu_idx]); in uncore_get_alias_name()
857 static void uncore_get_pmu_name(struct intel_uncore_pmu *pmu) in uncore_get_pmu_name() argument
859 struct intel_uncore_type *type = pmu->type; in uncore_get_pmu_name()
866 uncore_get_alias_name(pmu->name, pmu); in uncore_get_pmu_name()
872 sprintf(pmu->name, "uncore_%s", type->name); in uncore_get_pmu_name()
874 sprintf(pmu->name, "uncore"); in uncore_get_pmu_name()
879 sprintf(pmu->name, "uncore_%s_%d", type->name, in uncore_get_pmu_name()
880 type->box_ids ? type->box_ids[pmu->pmu_idx] : pmu->pmu_idx); in uncore_get_pmu_name()
884 static int uncore_pmu_register(struct intel_uncore_pmu *pmu) in uncore_pmu_register() argument
888 if (!pmu->type->pmu) { in uncore_pmu_register()
889 pmu->pmu = (struct pmu) { in uncore_pmu_register()
890 .attr_groups = pmu->type->attr_groups, in uncore_pmu_register()
902 .attr_update = pmu->type->attr_update, in uncore_pmu_register()
905 pmu->pmu = *pmu->type->pmu; in uncore_pmu_register()
906 pmu->pmu.attr_groups = pmu->type->attr_groups; in uncore_pmu_register()
907 pmu->pmu.attr_update = pmu->type->attr_update; in uncore_pmu_register()
910 uncore_get_pmu_name(pmu); in uncore_pmu_register()
912 ret = perf_pmu_register(&pmu->pmu, pmu->name, -1); in uncore_pmu_register()
914 pmu->registered = true; in uncore_pmu_register()
918 static void uncore_pmu_unregister(struct intel_uncore_pmu *pmu) in uncore_pmu_unregister() argument
920 if (!pmu->registered) in uncore_pmu_unregister()
922 perf_pmu_unregister(&pmu->pmu); in uncore_pmu_unregister()
923 pmu->registered = false; in uncore_pmu_unregister()
926 static void uncore_free_boxes(struct intel_uncore_pmu *pmu) in uncore_free_boxes() argument
931 kfree(pmu->boxes[die]); in uncore_free_boxes()
932 kfree(pmu->boxes); in uncore_free_boxes()
937 struct intel_uncore_pmu *pmu = type->pmus; in uncore_type_exit() local
943 if (pmu) { in uncore_type_exit()
944 for (i = 0; i < type->num_boxes; i++, pmu++) { in uncore_type_exit()
945 uncore_pmu_unregister(pmu); in uncore_type_exit()
946 uncore_free_boxes(pmu); in uncore_type_exit()
1081 * Find the PMU of a PCI device.
1083 * @ids: The ID table of the available PCI devices with a PMU.
1089 struct intel_uncore_pmu *pmu = NULL; in uncore_pci_find_dev_pmu() local
1105 pmu = &type->pmus[UNCORE_PCI_DEV_IDX(data)]; in uncore_pci_find_dev_pmu()
1111 return pmu; in uncore_pci_find_dev_pmu()
1115 * Register the PMU for a PCI device
1117 * @type: The corresponding PMU type of the device.
1118 * @pmu: The corresponding PMU of the device.
1123 struct intel_uncore_pmu *pmu, in uncore_pci_pmu_register() argument
1129 if (WARN_ON_ONCE(pmu->boxes[die] != NULL)) in uncore_pci_pmu_register()
1136 if (pmu->func_id < 0) in uncore_pci_pmu_register()
1137 pmu->func_id = pdev->devfn; in uncore_pci_pmu_register()
1139 WARN_ON_ONCE(pmu->func_id != pdev->devfn); in uncore_pci_pmu_register()
1144 box->pmu = pmu; in uncore_pci_pmu_register()
1147 pmu->boxes[die] = box; in uncore_pci_pmu_register()
1148 if (atomic_inc_return(&pmu->activeboxes) > 1) in uncore_pci_pmu_register()
1151 /* First active box registers the pmu */ in uncore_pci_pmu_register()
1152 ret = uncore_pmu_register(pmu); in uncore_pci_pmu_register()
1154 pmu->boxes[die] = NULL; in uncore_pci_pmu_register()
1167 struct intel_uncore_pmu *pmu = NULL; in uncore_pci_probe() local
1186 * for multiple instances of an uncore PMU device type. We should check in uncore_pci_probe()
1192 pmu = uncore_pci_find_dev_pmu(pdev, pci_drv->id_table); in uncore_pci_probe()
1193 if (pmu == NULL) in uncore_pci_probe()
1200 pmu = &type->pmus[UNCORE_PCI_DEV_IDX(id->driver_data)]; in uncore_pci_probe()
1203 ret = uncore_pci_pmu_register(pdev, type, pmu, die); in uncore_pci_probe()
1205 pci_set_drvdata(pdev, pmu->boxes[die]); in uncore_pci_probe()
1211 * Unregister the PMU of a PCI device
1212 * @pmu: The corresponding PMU is unregistered.
1215 static void uncore_pci_pmu_unregister(struct intel_uncore_pmu *pmu, int die) in uncore_pci_pmu_unregister() argument
1217 struct intel_uncore_box *box = pmu->boxes[die]; in uncore_pci_pmu_unregister()
1219 pmu->boxes[die] = NULL; in uncore_pci_pmu_unregister()
1220 if (atomic_dec_return(&pmu->activeboxes) == 0) in uncore_pci_pmu_unregister()
1221 uncore_pmu_unregister(pmu); in uncore_pci_pmu_unregister()
1229 struct intel_uncore_pmu *pmu; in uncore_pci_remove() local
1247 pmu = box->pmu; in uncore_pci_remove()
1251 uncore_pci_pmu_unregister(pmu, die); in uncore_pci_remove()
1260 struct intel_uncore_pmu *pmu; in uncore_bus_notify() local
1263 /* Unregister the PMU when the device is going to be deleted. */ in uncore_bus_notify()
1267 pmu = uncore_pci_find_dev_pmu(pdev, ids); in uncore_bus_notify()
1268 if (!pmu) in uncore_bus_notify()
1274 uncore_pci_pmu_unregister(pmu, die); in uncore_bus_notify()
1294 struct intel_uncore_pmu *pmu; in uncore_pci_sub_driver_init() local
1305 * corresponding PMU. in uncore_pci_sub_driver_init()
1314 pmu = &type->pmus[UNCORE_PCI_DEV_IDX(ids->driver_data)]; in uncore_pci_sub_driver_init()
1315 if (!pmu) in uncore_pci_sub_driver_init()
1321 if (!uncore_pci_pmu_register(pci_sub_dev, type, pmu, in uncore_pci_sub_driver_init()
1350 struct intel_uncore_pmu *pmu; in uncore_pci_pmus_register() local
1367 pmu = &type->pmus[i]; in uncore_pci_pmus_register()
1369 uncore_pci_pmu_register(pdev, type, pmu, die); in uncore_pci_pmus_register()
1438 struct intel_uncore_pmu *pmu = type->pmus; in uncore_change_type_ctx() local
1443 for (i = 0; i < type->num_boxes; i++, pmu++) { in uncore_change_type_ctx()
1444 box = pmu->boxes[die]; in uncore_change_type_ctx()
1460 perf_pmu_migrate_context(&pmu->pmu, old_cpu, new_cpu); in uncore_change_type_ctx()
1475 struct intel_uncore_pmu *pmu; in uncore_box_unref() local
1481 pmu = type->pmus; in uncore_box_unref()
1482 for (i = 0; i < type->num_boxes; i++, pmu++) { in uncore_box_unref()
1483 box = pmu->boxes[id]; in uncore_box_unref()
1523 struct intel_uncore_pmu *pmu; in allocate_boxes() local
1530 pmu = type->pmus; in allocate_boxes()
1531 for (i = 0; i < type->num_boxes; i++, pmu++) { in allocate_boxes()
1532 if (pmu->boxes[die]) in allocate_boxes()
1537 box->pmu = pmu; in allocate_boxes()
1545 box->pmu->boxes[die] = box; in allocate_boxes()
1561 struct intel_uncore_pmu *pmu; in uncore_box_ref() local
1571 pmu = type->pmus; in uncore_box_ref()
1572 for (i = 0; i < type->num_boxes; i++, pmu++) { in uncore_box_ref()
1573 box = pmu->boxes[id]; in uncore_box_ref()