Merge branch 'x86-apic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / tools / perf / arch / arm / util / auxtrace.c
1 /*
2  * Copyright(C) 2015 Linaro Limited. All rights reserved.
3  * Author: Mathieu Poirier <mathieu.poirier@linaro.org>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published by
7  * the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include <stdbool.h>
19 #include <linux/coresight-pmu.h>
20
21 #include "../../util/auxtrace.h"
22 #include "../../util/evlist.h"
23 #include "../../util/pmu.h"
24 #include "cs-etm.h"
25
26 struct auxtrace_record
27 *auxtrace_record__init(struct perf_evlist *evlist, int *err)
28 {
29         struct perf_pmu *cs_etm_pmu;
30         struct perf_evsel *evsel;
31         bool found_etm = false;
32
33         cs_etm_pmu = perf_pmu__find(CORESIGHT_ETM_PMU_NAME);
34
35         if (evlist) {
36                 evlist__for_each_entry(evlist, evsel) {
37                         if (cs_etm_pmu &&
38                             evsel->attr.type == cs_etm_pmu->type)
39                                 found_etm = true;
40                 }
41         }
42
43         if (found_etm)
44                 return cs_etm_record_init(err);
45
46         /*
47          * Clear 'err' even if we haven't found a cs_etm event - that way perf
48          * record can still be used even if tracers aren't present.  The NULL
49          * return value will take care of telling the infrastructure HW tracing
50          * isn't available.
51          */
52         *err = 0;
53         return NULL;
54 }