Skip to content

Commit 15a5cd1

Browse files
mathieupoirieracmel
authored andcommitted
perf cs-etm: Add support for PTMv1.1 decoding
This patch is re-using the mechanic set forth by ETMv3 to add support for PTM decoding. Configuration for both encoding protocol is similar but the generated stream itself is very different, hence requiring special handling. 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-4-git-send-email-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 7d0f4fe commit 15a5cd1

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

‎tools/perf/util/cs-etm-decoder/cs-etm-decoder.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,11 @@ cs_etm_decoder__create_etm_packet_printer(struct cs_etm_trace_params *t_params,
256256

257257
switch (t_params->protocol) {
258258
case CS_ETM_PROTO_ETMV3:
259+
case CS_ETM_PROTO_PTM:
259260
cs_etm_decoder__gen_etmv3_config(t_params, &config_etmv3);
260-
decoder_name = OCSD_BUILTIN_DCD_ETMV3;
261+
decoder_name = (t_params->protocol == CS_ETM_PROTO_ETMV3) ?
262+
OCSD_BUILTIN_DCD_ETMV3 :
263+
OCSD_BUILTIN_DCD_PTM;
261264
trace_config = &config_etmv3;
262265
break;
263266
case CS_ETM_PROTO_ETMV4i:
@@ -453,8 +456,11 @@ static int cs_etm_decoder__create_etm_packet_decoder(
453456

454457
switch (t_params->protocol) {
455458
case CS_ETM_PROTO_ETMV3:
459+
case CS_ETM_PROTO_PTM:
456460
cs_etm_decoder__gen_etmv3_config(t_params, &config_etmv3);
457-
decoder_name = OCSD_BUILTIN_DCD_ETMV3;
461+
decoder_name = (t_params->protocol == CS_ETM_PROTO_ETMV3) ?
462+
OCSD_BUILTIN_DCD_ETMV3 :
463+
OCSD_BUILTIN_DCD_PTM;
458464
trace_config = &config_etmv3;
459465
break;
460466
case CS_ETM_PROTO_ETMV4i:

‎tools/perf/util/cs-etm-decoder/cs-etm-decoder.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ enum {
9696
CS_ETM_PROTO_ETMV3 = 1,
9797
CS_ETM_PROTO_ETMV4i,
9898
CS_ETM_PROTO_ETMV4d,
99+
CS_ETM_PROTO_PTM,
99100
};
100101

101102
enum {

‎tools/perf/util/cs-etm.c‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@ static int cs_etm__update_queues(struct cs_etm_auxtrace *etm);
8383
static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm,
8484
pid_t tid, u64 time_);
8585

86+
/* PTMs ETMIDR [11:8] set to b0011 */
87+
#define ETMIDR_PTM_VERSION 0x00000300
88+
89+
static u32 cs_etm__get_v7_protocol_version(u32 etmidr)
90+
{
91+
etmidr &= ETMIDR_PTM_VERSION;
92+
93+
if (etmidr == ETMIDR_PTM_VERSION)
94+
return CS_ETM_PROTO_PTM;
95+
96+
return CS_ETM_PROTO_ETMV3;
97+
}
98+
8699
static void cs_etm__packet_dump(const char *pkt_string)
87100
{
88101
const char *color = PERF_COLOR_BLUE;
@@ -115,7 +128,10 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm,
115128
t_params = zalloc(sizeof(*t_params) * etm->num_cpu);
116129
for (i = 0; i < etm->num_cpu; i++) {
117130
if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) {
118-
t_params[i].protocol = CS_ETM_PROTO_ETMV3;
131+
u32 etmidr = etm->metadata[i][CS_ETM_ETMIDR];
132+
133+
t_params[i].protocol =
134+
cs_etm__get_v7_protocol_version(etmidr);
119135
t_params[i].etmv3.reg_ctrl =
120136
etm->metadata[i][CS_ETM_ETMCR];
121137
t_params[i].etmv3.reg_trc_id =
@@ -366,7 +382,10 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm,
366382

367383
for (i = 0; i < etm->num_cpu; i++) {
368384
if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) {
369-
t_params[i].protocol = CS_ETM_PROTO_ETMV3;
385+
u32 etmidr = etm->metadata[i][CS_ETM_ETMIDR];
386+
387+
t_params[i].protocol =
388+
cs_etm__get_v7_protocol_version(etmidr);
370389
t_params[i].etmv3.reg_ctrl =
371390
etm->metadata[i][CS_ETM_ETMCR];
372391
t_params[i].etmv3.reg_trc_id =

0 commit comments

Comments
 (0)