linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 57/75] perf cs-etm: Add configuration for ETMv3 trace protocol
Date: Thu,  6 Dec 2018 18:25:44 -0300	[thread overview]
Message-ID: <20181206212602.20474-58-acme@kernel.org> (raw)
In-Reply-To: <20181206212602.20474-1-acme@kernel.org>

From: Mathieu Poirier <mathieu.poirier@linaro.org>

This patch deals with the proper initialisation of configuration
parameters for the ETMv3 trace protocol in order to properly handle
packets generated by tracers following this specification.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/1543955944-10042-2-git-send-email-mathieu.poirier@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 .../perf/util/cs-etm-decoder/cs-etm-decoder.h |  8 +++
 tools/perf/util/cs-etm.c                      | 54 ++++++++++++++-----
 2 files changed, 48 insertions(+), 14 deletions(-)

diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h
index 9351bd10d864..6b5525410a43 100644
--- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h
+++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h
@@ -53,6 +53,13 @@ struct cs_etm_queue;
 typedef u32 (*cs_etm_mem_cb_type)(struct cs_etm_queue *, u64,
 				  size_t, u8 *);
 
+struct cs_etmv3_trace_params {
+	u32 reg_ctrl;
+	u32 reg_trc_id;
+	u32 reg_ccer;
+	u32 reg_idr;
+};
+
 struct cs_etmv4_trace_params {
 	u32 reg_idr0;
 	u32 reg_idr1;
@@ -65,6 +72,7 @@ struct cs_etmv4_trace_params {
 struct cs_etm_trace_params {
 	int protocol;
 	union {
+		struct cs_etmv3_trace_params etmv3;
 		struct cs_etmv4_trace_params etmv4;
 	};
 };
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 48ad217bf0df..76e509c32a28 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -114,15 +114,28 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm,
 	/* Use metadata to fill in trace parameters for trace decoder */
 	t_params = zalloc(sizeof(*t_params) * etm->num_cpu);
 	for (i = 0; i < etm->num_cpu; i++) {
-		t_params[i].protocol = CS_ETM_PROTO_ETMV4i;
-		t_params[i].etmv4.reg_idr0 = etm->metadata[i][CS_ETMV4_TRCIDR0];
-		t_params[i].etmv4.reg_idr1 = etm->metadata[i][CS_ETMV4_TRCIDR1];
-		t_params[i].etmv4.reg_idr2 = etm->metadata[i][CS_ETMV4_TRCIDR2];
-		t_params[i].etmv4.reg_idr8 = etm->metadata[i][CS_ETMV4_TRCIDR8];
-		t_params[i].etmv4.reg_configr =
+		if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) {
+			t_params[i].protocol = CS_ETM_PROTO_ETMV3;
+			t_params[i].etmv3.reg_ctrl =
+					etm->metadata[i][CS_ETM_ETMCR];
+			t_params[i].etmv3.reg_trc_id =
+					etm->metadata[i][CS_ETM_ETMTRACEIDR];
+		} else if (etm->metadata[i][CS_ETM_MAGIC] ==
+						      __perf_cs_etmv4_magic) {
+			t_params[i].protocol = CS_ETM_PROTO_ETMV4i;
+			t_params[i].etmv4.reg_idr0 =
+					etm->metadata[i][CS_ETMV4_TRCIDR0];
+			t_params[i].etmv4.reg_idr1 =
+					etm->metadata[i][CS_ETMV4_TRCIDR1];
+			t_params[i].etmv4.reg_idr2 =
+					etm->metadata[i][CS_ETMV4_TRCIDR2];
+			t_params[i].etmv4.reg_idr8 =
+					etm->metadata[i][CS_ETMV4_TRCIDR8];
+			t_params[i].etmv4.reg_configr =
 					etm->metadata[i][CS_ETMV4_TRCCONFIGR];
-		t_params[i].etmv4.reg_traceidr =
+			t_params[i].etmv4.reg_traceidr =
 					etm->metadata[i][CS_ETMV4_TRCTRACEIDR];
+		}
 	}
 
 	/* Set decoder parameters to simply print the trace packets */
@@ -352,15 +365,28 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm,
 		goto out_free;
 
 	for (i = 0; i < etm->num_cpu; i++) {
-		t_params[i].protocol = CS_ETM_PROTO_ETMV4i;
-		t_params[i].etmv4.reg_idr0 = etm->metadata[i][CS_ETMV4_TRCIDR0];
-		t_params[i].etmv4.reg_idr1 = etm->metadata[i][CS_ETMV4_TRCIDR1];
-		t_params[i].etmv4.reg_idr2 = etm->metadata[i][CS_ETMV4_TRCIDR2];
-		t_params[i].etmv4.reg_idr8 = etm->metadata[i][CS_ETMV4_TRCIDR8];
-		t_params[i].etmv4.reg_configr =
+		if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) {
+			t_params[i].protocol = CS_ETM_PROTO_ETMV3;
+			t_params[i].etmv3.reg_ctrl =
+					etm->metadata[i][CS_ETM_ETMCR];
+			t_params[i].etmv3.reg_trc_id =
+					etm->metadata[i][CS_ETM_ETMTRACEIDR];
+		} else if (etm->metadata[i][CS_ETM_MAGIC] ==
+							__perf_cs_etmv4_magic) {
+			t_params[i].protocol = CS_ETM_PROTO_ETMV4i;
+			t_params[i].etmv4.reg_idr0 =
+					etm->metadata[i][CS_ETMV4_TRCIDR0];
+			t_params[i].etmv4.reg_idr1 =
+					etm->metadata[i][CS_ETMV4_TRCIDR1];
+			t_params[i].etmv4.reg_idr2 =
+					etm->metadata[i][CS_ETMV4_TRCIDR2];
+			t_params[i].etmv4.reg_idr8 =
+					etm->metadata[i][CS_ETMV4_TRCIDR8];
+			t_params[i].etmv4.reg_configr =
 					etm->metadata[i][CS_ETMV4_TRCCONFIGR];
-		t_params[i].etmv4.reg_traceidr =
+			t_params[i].etmv4.reg_traceidr =
 					etm->metadata[i][CS_ETMV4_TRCTRACEIDR];
+		}
 	}
 
 	/* Set decoder parameters to simply print the trace packets */
-- 
2.19.2


  parent reply	other threads:[~2018-12-06 21:30 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20181206212602.20474-1-acme@kernel.org>
2018-12-06 21:24 ` [PATCH 01/75] perf build: Give better hint about devel package for libssl Arnaldo Carvalho de Melo
2018-12-06 21:24 ` [PATCH 02/75] perf stat: Fix shadow stats for clock events Arnaldo Carvalho de Melo
2018-12-06 21:24 ` [PATCH 03/75] perf stat: Fix CSV mode column output for non-cgroup events Arnaldo Carvalho de Melo
2018-12-06 21:24 ` [PATCH 04/75] perf map: Remove extra indirection from map__find() Arnaldo Carvalho de Melo
2018-12-06 21:24 ` [PATCH 05/75] perf env: Also consider env->arch == NULL as local operation Arnaldo Carvalho de Melo
2018-12-06 21:24 ` [PATCH 06/75] perf machine: Record if a arch has a single user/kernel address space Arnaldo Carvalho de Melo
2018-12-06 21:24 ` [PATCH 07/75] perf thread: Add fallback functions for cases where cpumode is insufficient Arnaldo Carvalho de Melo
2018-12-06 21:24 ` [PATCH 08/75] perf tools: Use fallback for sample_addr_correlates_sym() cases Arnaldo Carvalho de Melo
2018-12-06 21:24 ` [PATCH 09/75] perf script: Use fallbacks for branch stacks Arnaldo Carvalho de Melo
2018-12-06 21:24 ` [PATCH 10/75] tools lib traceevent: Fix compile warnings in tools/lib/traceevent/event-parse.c Arnaldo Carvalho de Melo
2018-12-06 21:24 ` [PATCH 11/75] perf tests record: Allow for 'sleep' being 'coreutils' Arnaldo Carvalho de Melo
2018-12-06 21:24 ` [PATCH 12/75] perf test: Fix perf_event_attr test failure Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 13/75] tools include: Adopt ERR_CAST() from the kernel err.h header Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 14/75] perf bpf: Use ERR_CAST instead of ERR_PTR(PTR_ERR()) Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 15/75] perf top: Allow passing a kallsyms file Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 16/75] perf intel-pt: Fix error with config term "pt=0" Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 17/75] tools build feature: Check if libaio is available Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 18/75] perf mmap: Map data buffer for preserving collected data Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 19/75] perf record: Enable asynchronous trace writing Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 20/75] perf record: Extend trace writing to multi AIO Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 21/75] perf beauty mmap_flags: Check if the arch has a mmap.h file Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 22/75] tools lib traceevent: Add sanity check to is_timestamp_in_us() Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 23/75] perf annotate: Compute average IPC and IPC coverage per symbol Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 24/75] perf annotate: Create a annotate2 flag in struct symbol Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 25/75] perf report: Display average IPC and IPC coverage per symbol Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 26/75] perf report: Documentation average IPC and IPC coverage Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 27/75] tools lib traceevent: Implement new API tep_get_ref() Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 28/75] tools lib traceevent: Added support for pkg-config Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 29/75] tools lib traceevent: Install trace-seq.h API header file Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 30/75] tools lib traceevent, perf tools: Rename 'struct tep_event_format' to 'struct tep_event' Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 31/75] tools lib traceevent: Rename tep_free_format() to tep_free_event() Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 32/75] perf tools: traceevent API cleanup, remove __tep_data2host*() Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 33/75] tools lib traceevent: traceevent API cleanup Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 34/75] perf beauty mmap_flags: Fixed syntax error Fixed missing ']' error Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 35/75] perf cs-etm: Support for ARM A32/T32 instruction sets in CoreSight trace Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 36/75] perf tests ARM: Disable breakpoint tests 32-bit Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 37/75] perf vendor events intel: Fix diverse typos Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 38/75] tools lib traceevent: Fix diverse typos in comments Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 39/75] perf tools Documentation: Fix diverse typos Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 40/75] perf bpf-loader: Fix debugging message typo Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 41/75] perf tools: Fix diverse comment typos Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 42/75] tools lib subcmd: Fix a few source code " Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 43/75] perf tools: Allow specifying proc-map-timeout in config file Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 44/75] perf trace: We need to consider "nr" if "__syscall_nr" is not there Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 45/75] perf tools: Support 'srccode' output Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 46/75] perf ordered_events: Rework show_progress for __ordered_events__flush Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 47/75] perf ordered_events: Add private data member Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 48/75] perf top: Save and display the lost count stats Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 49/75] perf top: Move lost events warning to helpline Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 50/75] perf top: Add processing thread Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 51/75] perf top: Use cond variable instead of a lock Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 52/75] perf top: Set the 'session_done' volatile variable when exiting Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 53/75] perf top: Drop samples which are behind the refresh rate Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 54/75] perf top: Save and display the drop count stats Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 55/75] perf top: Display slow reader warning when droping samples Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 56/75] perf top: Move perf_top__reset_sample_counters() to after counts display Arnaldo Carvalho de Melo
2018-12-06 21:25 ` Arnaldo Carvalho de Melo [this message]
2018-12-06 21:25 ` [PATCH 58/75] perf cs-etm: Add support for ETMv3 trace decoding Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 59/75] perf cs-etm: Add support for PTMv1.1 decoding Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 60/75] perf dso: Fix unchecked usage of strncpy() Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 61/75] perf header: " Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 62/75] " Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 63/75] perf help: Remove needless use " Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 64/75] perf svghelper: Fix unchecked usage " Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 65/75] perf ui helpline: Use strlcpy() as a shorter form of strncpy() + explicit set nul Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 66/75] perf probe: Fix unchecked usage of strncpy() Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 67/75] perf parse-events: " Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 68/75] perf vendor events intel: Fix Load_Miss_Real_Latency on SKL/SKX Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 69/75] perf record: Fix memory leak on AIO objects deallocation Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 70/75] perf config: Modify size factor of snprintf Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 71/75] perf annotate: Introduce basic support for ARC Arnaldo Carvalho de Melo
2018-12-06 21:25 ` [PATCH 72/75] perf ordered_events: Add ordered_events__flush_time interface Arnaldo Carvalho de Melo
2018-12-06 21:26 ` [PATCH 73/75] perf trace: Move event delivery to a new deliver_event() function Arnaldo Carvalho de Melo
2018-12-06 21:26 ` [PATCH 74/75] perf ordered_events: Add first_time() method Arnaldo Carvalho de Melo
2018-12-06 21:26 ` [PATCH 75/75] perf trace: Add ordered processing Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181206212602.20474-58-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=coresight@lists.linaro.org \
    --cc=jolsa@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).