Merge branch 'for-next/sve' into for-next/core
[linux-2.6-microblaze.git] / drivers / perf / arm_smmuv3_pmu.c
index ff6fab4..2263488 100644 (file)
@@ -277,7 +277,7 @@ static int smmu_pmu_apply_event_filter(struct smmu_pmu *smmu_pmu,
                                       struct perf_event *event, int idx)
 {
        u32 span, sid;
-       unsigned int num_ctrs = smmu_pmu->num_counters;
+       unsigned int cur_idx, num_ctrs = smmu_pmu->num_counters;
        bool filter_en = !!get_filter_enable(event);
 
        span = filter_en ? get_filter_span(event) :
@@ -285,17 +285,19 @@ static int smmu_pmu_apply_event_filter(struct smmu_pmu *smmu_pmu,
        sid = filter_en ? get_filter_stream_id(event) :
                           SMMU_PMCG_DEFAULT_FILTER_SID;
 
-       /* Support individual filter settings */
-       if (!smmu_pmu->global_filter) {
+       cur_idx = find_first_bit(smmu_pmu->used_counters, num_ctrs);
+       /*
+        * Per-counter filtering, or scheduling the first globally-filtered
+        * event into an empty PMU so idx == 0 and it works out equivalent.
+        */
+       if (!smmu_pmu->global_filter || cur_idx == num_ctrs) {
                smmu_pmu_set_event_filter(event, idx, span, sid);
                return 0;
        }
 
-       /* Requested settings same as current global settings*/
-       idx = find_first_bit(smmu_pmu->used_counters, num_ctrs);
-       if (idx == num_ctrs ||
-           smmu_pmu_check_global_filter(smmu_pmu->events[idx], event)) {
-               smmu_pmu_set_event_filter(event, 0, span, sid);
+       /* Otherwise, must match whatever's currently scheduled */
+       if (smmu_pmu_check_global_filter(smmu_pmu->events[cur_idx], event)) {
+               smmu_pmu_set_evtyper(smmu_pmu, idx, get_event(event));
                return 0;
        }
 
@@ -509,11 +511,8 @@ static ssize_t smmu_pmu_event_show(struct device *dev,
        return sysfs_emit(page, "event=0x%02llx\n", pmu_attr->id);
 }
 
-#define SMMU_EVENT_ATTR(name, config)                                  \
-       (&((struct perf_pmu_events_attr) {                              \
-               .attr = __ATTR(name, 0444, smmu_pmu_event_show, NULL),  \
-               .id = config,                                           \
-       }).attr.attr)
+#define SMMU_EVENT_ATTR(name, config)                  \
+       PMU_EVENT_ATTR_ID(name, smmu_pmu_event_show, config)
 
 static struct attribute *smmu_pmu_events[] = {
        SMMU_EVENT_ATTR(cycles, 0),
@@ -628,7 +627,7 @@ static int smmu_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
 
        perf_pmu_migrate_context(&smmu_pmu->pmu, cpu, target);
        smmu_pmu->on_cpu = target;
-       WARN_ON(irq_set_affinity_hint(smmu_pmu->irq, cpumask_of(target)));
+       WARN_ON(irq_set_affinity(smmu_pmu->irq, cpumask_of(target)));
 
        return 0;
 }
@@ -839,15 +838,14 @@ static int smmu_pmu_probe(struct platform_device *pdev)
 
        /* Pick one CPU to be the preferred one to use */
        smmu_pmu->on_cpu = raw_smp_processor_id();
-       WARN_ON(irq_set_affinity_hint(smmu_pmu->irq,
-                                     cpumask_of(smmu_pmu->on_cpu)));
+       WARN_ON(irq_set_affinity(smmu_pmu->irq, cpumask_of(smmu_pmu->on_cpu)));
 
        err = cpuhp_state_add_instance_nocalls(cpuhp_state_num,
                                               &smmu_pmu->node);
        if (err) {
                dev_err(dev, "Error %d registering hotplug, PMU @%pa\n",
                        err, &res_0->start);
-               goto out_clear_affinity;
+               return err;
        }
 
        err = perf_pmu_register(&smmu_pmu->pmu, name, -1);
@@ -866,8 +864,6 @@ static int smmu_pmu_probe(struct platform_device *pdev)
 
 out_unregister:
        cpuhp_state_remove_instance_nocalls(cpuhp_state_num, &smmu_pmu->node);
-out_clear_affinity:
-       irq_set_affinity_hint(smmu_pmu->irq, NULL);
        return err;
 }
 
@@ -877,7 +873,6 @@ static int smmu_pmu_remove(struct platform_device *pdev)
 
        perf_pmu_unregister(&smmu_pmu->pmu);
        cpuhp_state_remove_instance_nocalls(cpuhp_state_num, &smmu_pmu->node);
-       irq_set_affinity_hint(smmu_pmu->irq, NULL);
 
        return 0;
 }