.. | .. |
---|
6 | 6 | |
---|
7 | 7 | #include <stdbool.h> |
---|
8 | 8 | #include <linux/coresight-pmu.h> |
---|
| 9 | +#include <linux/zalloc.h> |
---|
9 | 10 | |
---|
10 | 11 | #include "../../util/auxtrace.h" |
---|
| 12 | +#include "../../util/debug.h" |
---|
11 | 13 | #include "../../util/evlist.h" |
---|
12 | 14 | #include "../../util/pmu.h" |
---|
13 | 15 | #include "cs-etm.h" |
---|
.. | .. |
---|
49 | 51 | } |
---|
50 | 52 | |
---|
51 | 53 | struct auxtrace_record |
---|
52 | | -*auxtrace_record__init(struct perf_evlist *evlist, int *err) |
---|
| 54 | +*auxtrace_record__init(struct evlist *evlist, int *err) |
---|
53 | 55 | { |
---|
54 | 56 | struct perf_pmu *cs_etm_pmu; |
---|
55 | | - struct perf_evsel *evsel; |
---|
| 57 | + struct evsel *evsel; |
---|
56 | 58 | bool found_etm = false; |
---|
57 | | - bool found_spe = false; |
---|
58 | | - static struct perf_pmu **arm_spe_pmus = NULL; |
---|
59 | | - static int nr_spes = 0; |
---|
| 59 | + struct perf_pmu *found_spe = NULL; |
---|
| 60 | + struct perf_pmu **arm_spe_pmus = NULL; |
---|
| 61 | + int nr_spes = 0; |
---|
60 | 62 | int i = 0; |
---|
61 | 63 | |
---|
62 | 64 | if (!evlist) |
---|
63 | 65 | return NULL; |
---|
64 | 66 | |
---|
65 | 67 | cs_etm_pmu = perf_pmu__find(CORESIGHT_ETM_PMU_NAME); |
---|
66 | | - |
---|
67 | | - if (!arm_spe_pmus) |
---|
68 | | - arm_spe_pmus = find_all_arm_spe_pmus(&nr_spes, err); |
---|
| 68 | + arm_spe_pmus = find_all_arm_spe_pmus(&nr_spes, err); |
---|
69 | 69 | |
---|
70 | 70 | evlist__for_each_entry(evlist, evsel) { |
---|
71 | 71 | if (cs_etm_pmu && |
---|
72 | | - evsel->attr.type == cs_etm_pmu->type) |
---|
| 72 | + evsel->core.attr.type == cs_etm_pmu->type) |
---|
73 | 73 | found_etm = true; |
---|
74 | 74 | |
---|
75 | | - if (!nr_spes) |
---|
| 75 | + if (!nr_spes || found_spe) |
---|
76 | 76 | continue; |
---|
77 | 77 | |
---|
78 | 78 | for (i = 0; i < nr_spes; i++) { |
---|
79 | | - if (evsel->attr.type == arm_spe_pmus[i]->type) { |
---|
80 | | - found_spe = true; |
---|
| 79 | + if (evsel->core.attr.type == arm_spe_pmus[i]->type) { |
---|
| 80 | + found_spe = arm_spe_pmus[i]; |
---|
81 | 81 | break; |
---|
82 | 82 | } |
---|
83 | 83 | } |
---|
84 | 84 | } |
---|
| 85 | + free(arm_spe_pmus); |
---|
85 | 86 | |
---|
86 | 87 | if (found_etm && found_spe) { |
---|
87 | 88 | pr_err("Concurrent ARM Coresight ETM and SPE operation not currently supported\n"); |
---|
.. | .. |
---|
94 | 95 | |
---|
95 | 96 | #if defined(__aarch64__) |
---|
96 | 97 | if (found_spe) |
---|
97 | | - return arm_spe_recording_init(err, arm_spe_pmus[i]); |
---|
| 98 | + return arm_spe_recording_init(err, found_spe); |
---|
98 | 99 | #endif |
---|
99 | 100 | |
---|
100 | 101 | /* |
---|