@@ -50,16 +50,32 @@ static struct perf_pmu **find_all_arm_spe_pmus(int *nr_spes, int *err)
5050 return arm_spe_pmus ;
5151}
5252
53+ static struct perf_pmu * find_pmu_for_event (struct perf_pmu * * pmus ,
54+ int pmu_nr , struct evsel * evsel )
55+ {
56+ int i ;
57+
58+ if (!pmus )
59+ return NULL ;
60+
61+ for (i = 0 ; i < pmu_nr ; i ++ ) {
62+ if (evsel -> core .attr .type == pmus [i ]-> type )
63+ return pmus [i ];
64+ }
65+
66+ return NULL ;
67+ }
68+
5369struct auxtrace_record
5470* auxtrace_record__init (struct evlist * evlist , int * err )
5571{
56- struct perf_pmu * cs_etm_pmu ;
72+ struct perf_pmu * cs_etm_pmu = NULL ;
73+ struct perf_pmu * * arm_spe_pmus = NULL ;
5774 struct evsel * evsel ;
58- bool found_etm = false ;
75+ struct perf_pmu * found_etm = NULL ;
5976 struct perf_pmu * found_spe = NULL ;
60- struct perf_pmu * * arm_spe_pmus = NULL ;
77+ int auxtrace_event_cnt = 0 ;
6178 int nr_spes = 0 ;
62- int i = 0 ;
6379
6480 if (!evlist )
6581 return NULL ;
@@ -68,24 +84,23 @@ struct auxtrace_record
6884 arm_spe_pmus = find_all_arm_spe_pmus (& nr_spes , err );
6985
7086 evlist__for_each_entry (evlist , evsel ) {
71- if (cs_etm_pmu &&
72- evsel -> core .attr .type == cs_etm_pmu -> type )
73- found_etm = true;
74-
75- if (!nr_spes || found_spe )
76- continue ;
77-
78- for (i = 0 ; i < nr_spes ; i ++ ) {
79- if (evsel -> core .attr .type == arm_spe_pmus [i ]-> type ) {
80- found_spe = arm_spe_pmus [i ];
81- break ;
82- }
83- }
87+ if (cs_etm_pmu && !found_etm )
88+ found_etm = find_pmu_for_event (& cs_etm_pmu , 1 , evsel );
89+
90+ if (arm_spe_pmus && !found_spe )
91+ found_spe = find_pmu_for_event (arm_spe_pmus , nr_spes , evsel );
8492 }
93+
8594 free (arm_spe_pmus );
8695
87- if (found_etm && found_spe ) {
88- pr_err ("Concurrent ARM Coresight ETM and SPE operation not currently supported\n" );
96+ if (found_etm )
97+ auxtrace_event_cnt ++ ;
98+
99+ if (found_spe )
100+ auxtrace_event_cnt ++ ;
101+
102+ if (auxtrace_event_cnt > 1 ) {
103+ pr_err ("Concurrent AUX trace operation not currently supported\n" );
89104 * err = - EOPNOTSUPP ;
90105 return NULL ;
91106 }
0 commit comments