Lines Matching +full:low +full:- +full:vt

1 // SPDX-License-Identifier: GPL-2.0
21 #include "dfl-fme.h"
88 * Performance Counter Registers for IOMMU / VT-D.
90 * VT-D Events are listed below as VTD_EVNT_* and VTD_SIP_EVNT_*
134 * struct fme_perf_priv - priv data structure for fme perf driver
163 * struct fme_perf_event_ops - callbacks for fme perf events
186 return cpumap_print_to_pagebuf(true, buf, cpumask_of(priv->cpu)); in cpumask_show()
217 PMU_FORMAT_ATTR(event, "config:0-11");
218 PMU_FORMAT_ATTR(evtype, "config:12-15");
219 PMU_FORMAT_ATTR(portid, "config:16-23");
236 * it with detected events (using pmu->attr_update).
271 u32 low; in fme_read_perf_cntr_reg() local
278 * support 64bit read - readq is split into 2 readl. in fme_read_perf_cntr_reg()
282 low = readl(addr); in fme_read_perf_cntr_reg()
283 } while (((u32)v) > low); in fme_read_perf_cntr_reg()
293 return -EINVAL; in basic_event_init()
299 void __iomem *base = priv->ioaddr; in basic_read_event_counter()
306 if (priv->id == FME_FEATURE_ID_GLOBAL_IPERF && in cache_event_init()
310 return -EINVAL; in cache_event_init()
316 void __iomem *base = priv->ioaddr; in cache_read_event_counter()
337 dev_err(priv->dev, "timeout, unmatched cache event code in counter register.\n"); in cache_read_event_counter()
355 if (priv->id == FME_FEATURE_ID_GLOBAL_DPERF && in is_fabric_event_supported()
365 void __iomem *base = priv->ioaddr; in fabric_event_init()
370 return -EINVAL; in fabric_event_init()
380 spin_lock(&priv->fab_lock); in fabric_event_init()
381 if (priv->fab_users && priv->fab_port_id != portid) { in fabric_event_init()
382 dev_dbg(priv->dev, "conflict fabric event monitoring mode.\n"); in fabric_event_init()
383 ret = -EOPNOTSUPP; in fabric_event_init()
387 priv->fab_users++; in fabric_event_init()
393 if (priv->fab_port_id == portid) in fabric_event_init()
396 priv->fab_port_id = portid; in fabric_event_init()
410 spin_unlock(&priv->fab_lock); in fabric_event_init()
417 spin_lock(&priv->fab_lock); in fabric_event_destroy()
418 priv->fab_users--; in fabric_event_destroy()
419 spin_unlock(&priv->fab_lock); in fabric_event_destroy()
425 void __iomem *base = priv->ioaddr; in fabric_read_event_counter()
436 dev_err(priv->dev, "timeout, unmatched fab event code in counter register.\n"); in fabric_read_event_counter()
446 if (priv->id == FME_FEATURE_ID_GLOBAL_IPERF && in vtd_event_init()
450 return -EINVAL; in vtd_event_init()
456 void __iomem *base = priv->ioaddr; in vtd_read_event_counter()
469 dev_err(priv->dev, "timeout, unmatched vtd event code in counter register.\n"); in vtd_read_event_counter()
479 if (priv->id == FME_FEATURE_ID_GLOBAL_IPERF && in vtd_sip_event_init()
483 return -EINVAL; in vtd_sip_event_init()
489 void __iomem *base = priv->ioaddr; in vtd_sip_read_event_counter()
500 dev_err(priv->dev, "timeout, unmatched vtd sip event code in counter register\n"); in vtd_sip_read_event_counter()
530 config = (unsigned long)eattr->var; in fme_perf_event_show()
540 return (ssize_t)(ptr - buf); in fme_perf_event_show()
612 return (priv->id == FME_FEATURE_ID_GLOBAL_IPERF) ? attr->mode : 0; in fme_perf_events_visible()
681 var = (unsigned long)eattr->var; in fme_perf_fabric_events_visible()
684 return attr->mode; in fme_perf_fabric_events_visible()
788 struct fme_perf_event_ops *ops = get_event_ops(event->hw.event_base); in fme_perf_event_destroy()
789 struct fme_perf_priv *priv = to_fme_perf_priv(event->pmu); in fme_perf_event_destroy()
791 if (ops->event_destroy) in fme_perf_event_destroy()
792 ops->event_destroy(priv, event->hw.idx, event->hw.config_base); in fme_perf_event_destroy()
797 struct fme_perf_priv *priv = to_fme_perf_priv(event->pmu); in fme_perf_event_init()
798 struct hw_perf_event *hwc = &event->hw; in fme_perf_event_init()
803 if (event->attr.type != event->pmu->type) in fme_perf_event_init()
804 return -ENOENT; in fme_perf_event_init()
808 * Therefore, it does not support per-process mode. in fme_perf_event_init()
811 if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) in fme_perf_event_init()
812 return -EINVAL; in fme_perf_event_init()
814 if (event->cpu < 0) in fme_perf_event_init()
815 return -EINVAL; in fme_perf_event_init()
817 if (event->cpu != priv->cpu) in fme_perf_event_init()
818 return -EINVAL; in fme_perf_event_init()
820 eventid = get_event(event->attr.config); in fme_perf_event_init()
821 portid = get_portid(event->attr.config); in fme_perf_event_init()
822 evtype = get_evtype(event->attr.config); in fme_perf_event_init()
824 return -EINVAL; in fme_perf_event_init()
826 hwc->event_base = evtype; in fme_perf_event_init()
827 hwc->idx = (int)eventid; in fme_perf_event_init()
828 hwc->config_base = portid; in fme_perf_event_init()
830 event->destroy = fme_perf_event_destroy; in fme_perf_event_init()
832 dev_dbg(priv->dev, "%s event=0x%x, evtype=0x%x, portid=0x%x,\n", in fme_perf_event_init()
836 if (ops->event_init) in fme_perf_event_init()
837 return ops->event_init(priv, eventid, portid); in fme_perf_event_init()
844 struct fme_perf_event_ops *ops = get_event_ops(event->hw.event_base); in fme_perf_event_update()
845 struct fme_perf_priv *priv = to_fme_perf_priv(event->pmu); in fme_perf_event_update()
846 struct hw_perf_event *hwc = &event->hw; in fme_perf_event_update()
849 now = ops->read_counter(priv, (u32)hwc->idx, hwc->config_base); in fme_perf_event_update()
850 prev = local64_read(&hwc->prev_count); in fme_perf_event_update()
851 delta = now - prev; in fme_perf_event_update()
853 local64_add(delta, &event->count); in fme_perf_event_update()
858 struct fme_perf_event_ops *ops = get_event_ops(event->hw.event_base); in fme_perf_event_start()
859 struct fme_perf_priv *priv = to_fme_perf_priv(event->pmu); in fme_perf_event_start()
860 struct hw_perf_event *hwc = &event->hw; in fme_perf_event_start()
863 count = ops->read_counter(priv, (u32)hwc->idx, hwc->config_base); in fme_perf_event_start()
864 local64_set(&hwc->prev_count, count); in fme_perf_event_start()
892 void __iomem *base = priv->ioaddr; in fme_perf_setup_hardware()
899 priv->fab_port_id = FME_PORTID_ROOT; in fme_perf_setup_hardware()
901 priv->fab_port_id = FIELD_GET(FAB_PORT_ID, v); in fme_perf_setup_hardware()
907 struct pmu *pmu = &priv->pmu; in fme_perf_pmu_register()
911 spin_lock_init(&priv->fab_lock); in fme_perf_pmu_register()
915 pmu->task_ctx_nr = perf_invalid_context; in fme_perf_pmu_register()
916 pmu->attr_groups = fme_perf_groups; in fme_perf_pmu_register()
917 pmu->attr_update = fme_perf_events_groups; in fme_perf_pmu_register()
918 pmu->event_init = fme_perf_event_init; in fme_perf_pmu_register()
919 pmu->add = fme_perf_event_add; in fme_perf_pmu_register()
920 pmu->del = fme_perf_event_del; in fme_perf_pmu_register()
921 pmu->start = fme_perf_event_start; in fme_perf_pmu_register()
922 pmu->stop = fme_perf_event_stop; in fme_perf_pmu_register()
923 pmu->read = fme_perf_event_read; in fme_perf_pmu_register()
924 pmu->capabilities = PERF_PMU_CAP_NO_INTERRUPT | in fme_perf_pmu_register()
927 name = devm_kasprintf(priv->dev, GFP_KERNEL, "dfl_fme%d", pdev->id); in fme_perf_pmu_register()
929 ret = perf_pmu_register(pmu, name, -1); in fme_perf_pmu_register()
938 perf_pmu_unregister(&priv->pmu); in fme_perf_pmu_unregister()
948 if (cpu != priv->cpu) in fme_perf_offline_cpu()
955 priv->cpu = target; in fme_perf_offline_cpu()
956 perf_pmu_migrate_context(&priv->pmu, cpu, target); in fme_perf_offline_cpu()
967 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in fme_perf_init()
969 return -ENOMEM; in fme_perf_init()
971 priv->dev = &pdev->dev; in fme_perf_init()
972 priv->ioaddr = feature->ioaddr; in fme_perf_init()
973 priv->id = feature->id; in fme_perf_init()
974 priv->cpu = raw_smp_processor_id(); in fme_perf_init()
982 priv->cpuhp_state = ret; in fme_perf_init()
985 ret = cpuhp_state_add_instance_nocalls(priv->cpuhp_state, &priv->node); in fme_perf_init()
993 feature->priv = priv; in fme_perf_init()
997 cpuhp_state_remove_instance_nocalls(priv->cpuhp_state, &priv->node); in fme_perf_init()
999 cpuhp_remove_multi_state(priv->cpuhp_state); in fme_perf_init()
1006 struct fme_perf_priv *priv = feature->priv; in fme_perf_uinit()
1009 cpuhp_state_remove_instance_nocalls(priv->cpuhp_state, &priv->node); in fme_perf_uinit()
1010 cpuhp_remove_multi_state(priv->cpuhp_state); in fme_perf_uinit()