From patchwork Fri Nov 16 18:42:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 151370 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp772283ljp; Fri, 16 Nov 2018 10:42:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/U2KwvwyVtUWjNA9KYqaSRDx1LHMOOonDNelTq0TR05ZdJDWD0meZ7eUJ1n9EpdS6INbVgC X-Received: by 2002:a17:902:6e16:: with SMTP id u22mr2444057plk.175.1542393760098; Fri, 16 Nov 2018 10:42:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542393760; cv=none; d=google.com; s=arc-20160816; b=WqvGWruv+R5J6JVPiMWsNxlIALGaXWV41ckOtU19qDMWZgAEuquXXcfMHm/pIGJhUC ze7znHfwGfgPmToUVo3UwJMoAkyRpJXanv322lFVMhq88oIgJDAY8+bhv8+WBvyFxVqo oMAA6CK/BpQjhGDMjzEp7GE7vet3xIKebxNzbv7Sq1QYLJ4zQjknmta+YyzdBGT4FWSO /jsoR6SkbDISYL0n1smT5D6wBPons14cFRBgOPs+ar11cmAo+egv/G49JKRpoR3WnjRc tQnJOBPke2P0HV4e7aifbEtOoJyrlNmdfnAt0MGaiTVuCNBhhOJdl5tGmwTG3qQpz7UY oJVw== 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=n6NuaXTvDWIetVmFktrRRwuNkHydvvOOmRq+K+4VF1M=; b=WQrcxumBsngeTvfF5abBE/xLBQmJM1/iF99S1a+iIu0dJfzfApEtfXmT0cSDsPzA7E ELKnLvB2ZOyc/Xwp1gFrmh0dk1IbeyKG1vOgz3pUnKD0z61ENn/2ozSzSUckU7eAahyI 8G7pf4Wsx3ZwCXSDYnayp0dU2VfPGbWOMwqFEImHatqb9tAoOuYLZkud0JDiMlVGWy9f BRAu+N91BkO/lxnhkQYRcwzsfS5YtiiAAcFcdPAp5xG1CJfA9FgDgPQ/OHWahvPAjriY E+i18/jMSEX4D7y8jf1WK4jT5Dryft9rpXtApuOBXrvr5ZY5fCFC4AJbS7lPd+XsA1Sd kgqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R1ccPhLH; 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 u9-v6si36287442plm.284.2018.11.16.10.42.39; Fri, 16 Nov 2018 10:42:40 -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=R1ccPhLH; 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 S2390375AbeKQE4J (ORCPT + 32 others); Fri, 16 Nov 2018 23:56:09 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36752 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729431AbeKQE4I (ORCPT ); Fri, 16 Nov 2018 23:56:08 -0500 Received: by mail-pl1-f195.google.com with SMTP id y6-v6so3977479plt.3 for ; Fri, 16 Nov 2018 10:42:36 -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=n6NuaXTvDWIetVmFktrRRwuNkHydvvOOmRq+K+4VF1M=; b=R1ccPhLHj0TC4DGM3KblDF7t12Rt2BugVfVHwvbJTHUx098oJNllJlLu4TV51/SVPN XLA2zI3pxrHS0DuQZu+TyZHIl9meV6Q4TyjC3ib1J4Qv22ifYEA/FyJNii0escXENlCe CwEVmBBXEPG8EQJKe59jjjtLkufkCxO08O1L4= 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=n6NuaXTvDWIetVmFktrRRwuNkHydvvOOmRq+K+4VF1M=; b=lIWRErowW2MlxgW61BTEbSVswZZKe04Qk3ZmGs7fWOJ4wFuN4066r1G7Oi9ziqM6+x Bcgo58kFMvFdVXmobvAafNgFOOfS3LESNJE0khy4YwxsKk33GOz51O1RiYZ7RgbyloYU dmxoqv135EdOw2PXuGcX/RRkUIe0M9YRzsobURKIa6IseL+jJiljOsjC5mnLJis67T7P CkoypdKRTq8HyenFHlnWxP2xjnKZ8p4lKvX/M3cw35b/DPAGgxAjW9MC1B+OEnFFuov+ Te1wqvswcNTHdEqlnZp6vFTxFPLaK0Wmor2Qc/Fnf5jsXUFUTVJ/1X6LzNTG1h6F1+Bp eBDA== X-Gm-Message-State: AGRZ1gKwxdcxsfijRqIPzupmdMIa362qWE1PCl2X0g309kV3TJ5xYRm9 WzXKaozoBeQv4kmMCJb4bEbx7g== X-Received: by 2002:a17:902:6b01:: with SMTP id o1-v6mr12164938plk.333.1542393756105; Fri, 16 Nov 2018 10:42:36 -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.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Nov 2018 10:42:35 -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 1/3] perf tools: Add configuration for ETMv3 trace protocol Date: Fri, 16 Nov 2018 11:42:30 -0700 Message-Id: <1542393752-10196-2-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 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 --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 8 ++++ tools/perf/util/cs-etm.c | 54 ++++++++++++++++++------- 2 files changed, 48 insertions(+), 14 deletions(-) -- 2.7.4 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 612b5755f742..c0c67c919093 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -43,6 +43,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; @@ -55,6 +62,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 73430b73570d..830e9136ad7c 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -122,15 +122,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 */ @@ -360,15 +373,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 */ From patchwork Fri Nov 16 18:42:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 151371 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp772305ljp; Fri, 16 Nov 2018 10:42:41 -0800 (PST) X-Google-Smtp-Source: AJdET5eojX/0Ti4XQnRYhJXrJ6SJQY49GLLdN8vECsKnwx3xc1ysDrZoZPV1PrcS80mbbVkWunVx X-Received: by 2002:a17:902:a516:: with SMTP id s22-v6mr11958118plq.255.1542393761472; Fri, 16 Nov 2018 10:42:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542393761; cv=none; d=google.com; s=arc-20160816; b=uuXfnJuhV6npBc16FC+cH/3PTUY2/lZlm4BSnzgsowi7n0SoG8GKNRecL0LUkVw32f K9aDpnD9zIC0Men42x5pFvmqhjSUSC8RfenUWSqxJ7/GOOw5q6q3RN2Af0f3W2N3zhly 3rk2WgjN6916863YQ6DG+GBHeZS+0EcfoMWagdbg3Y6K1dqMDcnt2lHBnw/NmnHq7zpx MFkfwQHg+Ut9bCCMayemZsgpsfdi9vEbRmyKjZe/XInZwIuTNMFL2eXZw5xyGiSYs8DN fTUw/goCpEIYXHtF2lBCpcr4fLb0GxLFYjK92gamkERMfkSVklyQLaQU9QBvWYvZjoaV eFNQ== 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=7uXAOOMCbxu3NrD8kWXeIGqCAjNGZU3sGkuc69CifPM=; b=E6TuTJZwlI93SZmRpH5eH4R3sOzMGYh92gy/F58CaYmSmNxMPi+dD9VuDsivNdxDKN stVthRK0caBIloblQOfEsHOrkdp4l1xYkiP6eo4s2JGFnEqGzLW/y0wlI4qPo+RUjLcO WIfBlEXE713GygWUyTnTyvkxZbVYY5+Q5JjJaCA+1/jYnpN9WxVy5VSzUCxKZoSWzmTf BBBkdt/zvQjH3xVCd02vNaCniJF/XBgnSUUwgHOyQSCyWkvtDYkiojIRPhFFaswRmJ3i +VUeZklhKA9TLHJATfh0RyizLJHuRfdSShXXmFJVilUepVPzD765TPaitHcdpSsyoN6C 2WtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YgLk3yUg; 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.41; Fri, 16 Nov 2018 10:42:41 -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=YgLk3yUg; 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 S2390396AbeKQE4K (ORCPT + 32 others); Fri, 16 Nov 2018 23:56:10 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46904 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390356AbeKQE4J (ORCPT ); Fri, 16 Nov 2018 23:56:09 -0500 Received: by mail-pl1-f196.google.com with SMTP id t13so8576071ply.13 for ; Fri, 16 Nov 2018 10:42:38 -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=7uXAOOMCbxu3NrD8kWXeIGqCAjNGZU3sGkuc69CifPM=; b=YgLk3yUgQapgyUBaJn6OXlkCfuSls4akSxz02J4HU6Hgb7CKcIouaowVcWNJyKPgZk HGtLGVHkEGO2wp2OA3hG3K8qJSKavM2vgmItJQB8xfHYWbkKaCVE0h28mmIOXgDOYWMY AeARp0N0KuQvWwNJTsPTjzHPHUMiN6ElBlEpo= 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=7uXAOOMCbxu3NrD8kWXeIGqCAjNGZU3sGkuc69CifPM=; b=CUnV5Qiq0dOD5xCkWHEpkDzsxcpjg0oP2b6S+KKUG7uxFRCz9LkCzMEKuO+73JPSx/ 499jS8H2/wPvPiqPisGxq/p4O52vMkrZCwb3sYneHTCMEx4zg6fkoxzMc2QSezZVKpBB m/yeoy7xy2nxa2RcZY1aNP1zdrEq5vabJvhBJ5xilbyhgYOedClQiPNqCbNOizYsYsTQ K6sU3QapQT6BDjGdchjD/h7KhAMX2ZxKpXF2yBFIuYrl34ymeWgF/k3RhvG+VGTAdI9x EtyycVQvoCTmOqv9+XIK3Rkok9KbiBc7JGs5BRmAVr00Cis5bJ20ElHvVzb79w70jsJ8 hIcw== X-Gm-Message-State: AGRZ1gIPmfUpwqlbuoyeD5azi/sKhxDIxthL1ulNZJwpLvuM+raNwJEg UAlwCcoiHQdeXhbEgMB+1DUXeg== X-Received: by 2002:a17:902:14e:: with SMTP id 72-v6mr11612297plb.299.1542393757593; Fri, 16 Nov 2018 10:42:37 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Nov 2018 10:42:36 -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 2/3] perf tools: Add support for ETMv3 trace decoding Date: Fri, 16 Nov 2018 11:42:31 -0700 Message-Id: <1542393752-10196-3-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 Add support for the creation of packet printer and decoder for the ETMv3 trace architecture. That way traces generated by tracers adhering to that trace protocol can be handled properly by the perf infrastructure. Signed-off-by: Mathieu Poirier --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) -- 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 938def6d0bb9..84a86d2f25c9 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -116,6 +116,19 @@ int cs_etm_decoder__get_packet(struct cs_etm_decoder *decoder, return 1; } +static int cs_etm_decoder__gen_etmv3_config(struct cs_etm_trace_params *params, + ocsd_etmv3_cfg *config) +{ + config->reg_idr = params->etmv3.reg_idr; + config->reg_ctrl = params->etmv3.reg_ctrl; + config->reg_ccer = params->etmv3.reg_ccer; + config->reg_trc_id = params->etmv3.reg_trc_id; + config->arch_ver = ARCH_V7; + config->core_prof = profile_CortexA; + + return 0; +} + static void cs_etm_decoder__gen_etmv4_config(struct cs_etm_trace_params *params, ocsd_etmv4_cfg *config) { @@ -237,10 +250,16 @@ cs_etm_decoder__create_etm_packet_printer(struct cs_etm_trace_params *t_params, struct cs_etm_decoder *decoder) { const char *decoder_name; + ocsd_etmv3_cfg config_etmv3; ocsd_etmv4_cfg trace_config_etmv4; void *trace_config; switch (t_params->protocol) { + case CS_ETM_PROTO_ETMV3: + cs_etm_decoder__gen_etmv3_config(t_params, &config_etmv3); + decoder_name = OCSD_BUILTIN_DCD_ETMV3; + trace_config = &config_etmv3; + break; case CS_ETM_PROTO_ETMV4i: cs_etm_decoder__gen_etmv4_config(t_params, &trace_config_etmv4); decoder_name = OCSD_BUILTIN_DCD_ETMV4I; @@ -398,11 +417,17 @@ static int cs_etm_decoder__create_etm_packet_decoder( struct cs_etm_decoder *decoder) { const char *decoder_name; + ocsd_etmv3_cfg config_etmv3; ocsd_etmv4_cfg trace_config_etmv4; void *trace_config; u8 csid; switch (t_params->protocol) { + case CS_ETM_PROTO_ETMV3: + cs_etm_decoder__gen_etmv3_config(t_params, &config_etmv3); + decoder_name = OCSD_BUILTIN_DCD_ETMV3; + trace_config = &config_etmv3; + break; case CS_ETM_PROTO_ETMV4i: cs_etm_decoder__gen_etmv4_config(t_params, &trace_config_etmv4); decoder_name = OCSD_BUILTIN_DCD_ETMV4I; 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 =