Commit 4c2efb23 authored by James Clark's avatar James Clark Committed by Arnaldo Carvalho de Melo
Browse files

perf cs-etm: Make a helper to find the Coresight evsel



This pattern occurs a few times and we'll add another one later, so add
a helper function for it.

Reviewed-by: default avatarIan Rogers <irogers@google.com>
Reviewed-by: default avatarLeo Yan <leo.yan@arm.com>
Signed-off-by: default avatarJames Clark <james.clark@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 8e2ef85c
Loading
Loading
Loading
Loading
+27 −23
Original line number Diff line number Diff line
@@ -302,6 +302,19 @@ static int cs_etm_set_sink_attr(struct perf_pmu *pmu,
	return 0;
}

static struct evsel *cs_etm_get_evsel(struct evlist *evlist,
				      struct perf_pmu *cs_etm_pmu)
{
	struct evsel *evsel;

	evlist__for_each_entry(evlist, evsel) {
		if (evsel->core.attr.type == cs_etm_pmu->type)
			return evsel;
	}

	return NULL;
}

static int cs_etm_recording_options(struct auxtrace_record *itr,
				    struct evlist *evlist,
				    struct record_opts *opts)
@@ -473,15 +486,12 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,

static u64 cs_etm_get_config(struct auxtrace_record *itr)
{
	u64 config = 0;
	struct cs_etm_recording *ptr =
			container_of(itr, struct cs_etm_recording, itr);
	struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu;
	struct evlist *evlist = ptr->evlist;
	struct evsel *evsel;
	struct evsel *evsel = cs_etm_get_evsel(evlist, cs_etm_pmu);

	evlist__for_each_entry(evlist, evsel) {
		if (evsel->core.attr.type == cs_etm_pmu->type) {
	/*
	 * Variable perf_event_attr::config is assigned to
	 * ETMv3/PTM.  The bit fields have been made to match
@@ -490,12 +500,7 @@ static u64 cs_etm_get_config(struct auxtrace_record *itr)
	 * drivers/hwtracing/coresight/coresight-perf.c for
	 * details.
	 */
			config = evsel->core.attr.config;
			break;
		}
	}

	return config;
	return evsel ? evsel->core.attr.config : 0;
}

#ifndef BIT
@@ -829,12 +834,11 @@ static int cs_etm_snapshot_start(struct auxtrace_record *itr)
{
	struct cs_etm_recording *ptr =
			container_of(itr, struct cs_etm_recording, itr);
	struct evsel *evsel;
	struct evsel *evsel = cs_etm_get_evsel(ptr->evlist, ptr->cs_etm_pmu);

	evlist__for_each_entry(ptr->evlist, evsel) {
		if (evsel->core.attr.type == ptr->cs_etm_pmu->type)
	if (evsel)
		return evsel__disable(evsel);
	}

	return -EINVAL;
}