From patchwork Fri Nov 16 18:42:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 151372 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp772334ljp; Fri, 16 Nov 2018 10:42:43 -0800 (PST) X-Google-Smtp-Source: AJdET5e2HVLPIXt0r2rYr5/TXpUz/r6X6vGAkHCgZI+Lmry5jLIWMsaImwqFQcEzusr/X1RSQ+z4 X-Received: by 2002:a62:6241:: with SMTP id w62-v6mr12211274pfb.69.1542393763423; Fri, 16 Nov 2018 10:42:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542393763; cv=none; d=google.com; s=arc-20160816; b=QDZNwl05AxsBa2a9gI55UPkfhuSM8B7Qc79JH2DJUhMcneEvpj6EhjL23o4wq0NtPN DUWbCB0g9RnstJyLUf9RcbzAjJYpTRr3yKqXjSS67WT1+qEzwWywT7ISnZ4o7TeQNo5j R10ud3MVMYuMKnZuFQs9ZR4jWhqiKk15dpOq9s+fEfIz1CoVElJNQHxlEm/FAgZdJ1dU 5rJ32oiqS47NM2hu4DEIyWleGzriAIe7RgWiPbZetNC7303Jcx6tlu/UIt36fDU3ZSj6 xh5V0g06RrmAFFQaO62wjP2ZfmMowBvagNAFUK+LTWCbBFnieIn0Rk67cohp/26bxGhx 5Wbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=UCYgcEEMVlbQk66yjR27lIkghRdtDEI1kbeQRCjG2MQ=; b=g4d999PxrQqTNanSlrsFZA/CcpksMoFHQUT5XKPDdb2Dp1pSU92ezjwsDfcs3r7rq8 DonrOcaET+yp+i0ecWlcT/q54V3A3fJYwOsdC0mBMagopRYJD7pJXa89wfzcHTDXHdun 9C/1yBYf+39+or/HQKzu4RhpxCoJ2psCGtpd7JsKNA21rlfaYLMkUdJZYXUWsTJsyK4B e94edNiEUftk7Crpjjr9stAwa/zeGCDzI7ysSJ7Rzq7Djoeq45RD8QNlaP5sCMCj4mB0 QnbixvZ1MjmPdnaXoHY+aHIXSp52J9z3LAjUnOqca+ptnLXp6W5ADQJbH099RfqymMZ5 IcPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DkdU97a/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u5si29432672pgi.146.2018.11.16.10.42.43; Fri, 16 Nov 2018 10:42:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DkdU97a/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390422AbeKQE4M (ORCPT + 32 others); Fri, 16 Nov 2018 23:56:12 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40104 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390356AbeKQE4L (ORCPT ); Fri, 16 Nov 2018 23:56:11 -0500 Received: by mail-pg1-f196.google.com with SMTP id z10so10966388pgp.7 for ; Fri, 16 Nov 2018 10:42:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UCYgcEEMVlbQk66yjR27lIkghRdtDEI1kbeQRCjG2MQ=; b=DkdU97a/0tHEivMIH0GKqkvTOvfZOLLNfsr0K6qEB4gDhMgzhEQjJt84Z7Bv3hSc1P 0Hzggkb/aM9XmMrGWnN4WRKlmMA8XbLiUBhJjam1n72Jbo2Fiohk3jt1QUYrMl2hT9xd 7BA+krc5uevtAKPj0AC0UGiUVWABl5aHaiQZ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UCYgcEEMVlbQk66yjR27lIkghRdtDEI1kbeQRCjG2MQ=; b=N41xlLVmYg8hM3JarnhKqNUG5iO7AKcErbYDK6ZGFvW1F+ho2lWLzmm7/Tm05fcng2 V95YTV++xWW88/tiKJ0arKBh5M9w18EuUWtjat0qdZthxhL15SYfs9+JRBZiFVh5ivpM fKJkzbjnlCmVarj8loe2lHyecTMkT24UQwUmT6kbTgeswvXhC+J68KvTR2dBsUK/VWI+ b//gGHT5kx6TNUFPmFDn8S7nbOn/Hl7a+0kANbFMdSfFNMedATq3XQbiR+3Fy8CiMA3g NO/RpzK9d2T1TvxizpXxN3odNGCwtbeSoL0oG4TUBqX63it7mSUW6WEDv8H1oiebv0N3 AkiQ== X-Gm-Message-State: AGRZ1gK0TqkznMZ9zE48KVV97XQ7xHxG25Umdbqu57gzjGxUNB307ovV QuyDSjSDHwAjScPX8vIzoUOVTA== X-Received: by 2002:a62:6241:: with SMTP id w62-v6mr12211065pfb.69.1542393758996; Fri, 16 Nov 2018 10:42:38 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id v20-v6sm33724598pfm.114.2018.11.16.10.42.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Nov 2018 10:42:38 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org Cc: peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] perf tools: Add support for PTMv1.1 decoding Date: Fri, 16 Nov 2018 11:42:32 -0700 Message-Id: <1542393752-10196-4-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542393752-10196-1-git-send-email-mathieu.poirier@linaro.org> References: <1542393752-10196-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 10 ++++++++-- tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 1 + tools/perf/util/cs-etm.c | 23 +++++++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index 84a86d2f25c9..de8d792bc49d 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -256,8 +256,11 @@ cs_etm_decoder__create_etm_packet_printer(struct cs_etm_trace_params *t_params, switch (t_params->protocol) { case CS_ETM_PROTO_ETMV3: + case CS_ETM_PROTO_PTM: cs_etm_decoder__gen_etmv3_config(t_params, &config_etmv3); - decoder_name = OCSD_BUILTIN_DCD_ETMV3; + decoder_name = (t_params->protocol == CS_ETM_PROTO_ETMV3) ? + OCSD_BUILTIN_DCD_ETMV3 : + OCSD_BUILTIN_DCD_PTM; trace_config = &config_etmv3; break; case CS_ETM_PROTO_ETMV4i: @@ -424,8 +427,11 @@ static int cs_etm_decoder__create_etm_packet_decoder( switch (t_params->protocol) { case CS_ETM_PROTO_ETMV3: + case CS_ETM_PROTO_PTM: cs_etm_decoder__gen_etmv3_config(t_params, &config_etmv3); - decoder_name = OCSD_BUILTIN_DCD_ETMV3; + decoder_name = (t_params->protocol == CS_ETM_PROTO_ETMV3) ? + OCSD_BUILTIN_DCD_ETMV3 : + OCSD_BUILTIN_DCD_PTM; trace_config = &config_etmv3; break; case CS_ETM_PROTO_ETMV4i: 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 c0c67c919093..029e66b968a6 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -86,6 +86,7 @@ enum { CS_ETM_PROTO_ETMV3 = 1, CS_ETM_PROTO_ETMV4i, CS_ETM_PROTO_ETMV4d, + CS_ETM_PROTO_PTM, }; enum { diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 830e9136ad7c..2f1a176d55e8 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -91,6 +91,19 @@ static int cs_etm__update_queues(struct cs_etm_auxtrace *etm); static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, pid_t tid, u64 time_); +/* PTMs ETMIDR [11:8] set to b0011 */ +#define ETMIDR_PTM_VERSION 0x00000300 + +static u32 cs_etm__get_v7_protocol_version(u32 etmidr) +{ + etmidr &= ETMIDR_PTM_VERSION; + + if (etmidr == ETMIDR_PTM_VERSION) + return CS_ETM_PROTO_PTM; + + return CS_ETM_PROTO_ETMV3; +} + static void cs_etm__packet_dump(const char *pkt_string) { const char *color = PERF_COLOR_BLUE; @@ -123,7 +136,10 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, t_params = zalloc(sizeof(*t_params) * etm->num_cpu); for (i = 0; i < etm->num_cpu; i++) { if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { - t_params[i].protocol = CS_ETM_PROTO_ETMV3; + u32 etmidr = etm->metadata[i][CS_ETM_ETMIDR]; + + t_params[i].protocol = + cs_etm__get_v7_protocol_version(etmidr); t_params[i].etmv3.reg_ctrl = etm->metadata[i][CS_ETM_ETMCR]; t_params[i].etmv3.reg_trc_id = @@ -374,7 +390,10 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, for (i = 0; i < etm->num_cpu; i++) { if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { - t_params[i].protocol = CS_ETM_PROTO_ETMV3; + u32 etmidr = etm->metadata[i][CS_ETM_ETMIDR]; + + t_params[i].protocol = + cs_etm__get_v7_protocol_version(etmidr); t_params[i].etmv3.reg_ctrl = etm->metadata[i][CS_ETM_ETMCR]; t_params[i].etmv3.reg_trc_id =