From patchwork Tue Dec 4 20:39:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 152863 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp8511700ljp; Tue, 4 Dec 2018 12:39:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/XOxdbcDR5QQzfRKZ07DwF9Mz82qjzt3lifA/MKvv5dwufOZyASo+m05oQUyAlMs0Jp36Sa X-Received: by 2002:a62:1c06:: with SMTP id c6mr21093660pfc.157.1543955953031; Tue, 04 Dec 2018 12:39:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543955953; cv=none; d=google.com; s=arc-20160816; b=rB35vUEiXvr8EpPohZMSA3mXf3ku5kPSFzvhLd7VT8VwoXC5U8jxHhsL+PdJWREFRr 4vTrOVjPZXxKrhkUEXaF0l690pcHV7OftUp9NDhjj8xmcZ3tMnwdrBl4FzpAoFfZVuVr vRQhS7GcDVyprdY3LACsnYDrmafKSPieZeKoUIIEkfPZax0ALmvlzV51z7zKAnx6bXZg DP5QELHCzdlpsAmwDNT/4jvY0c5pPPbDo5qjg7zrZ4WOKK95FgTrfU+l4nH/pKVMy6Gb vq4GKlTT+NQz53Y8CRl/LveIQ9EB2wSe7/Qnb66G/3EPR7xmvCKOKVUoBHq9eOij4YMd zm+Q== 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=u2gt8Wi/Pp2nbXPJoOjHcqKgK2Xr02Ac9i9XfdNYK1lGHoTI8YVAxCz6pj7YCpKFim 7WpXIFvXpy7LQnqumlyhSrmy62xbPE150QOnodYLWdTBUxof5xYIalXu+VR2M0ZpzFGp JnYP8W3Y6P2gZ/pgGh0g3vjAK4kgSRCbJHvsFDe0VKlETyEODVhTGIm16tay8Eyrt7kc WuEQOTpoYgH4NeWpNzoiViPwhTAo6WSceD+IYWKWHxbcG+ajWeZ6MCsurCfLLzTiL5+8 0fC5jBGi2blY2oaPg9oViKbRW+R216YgdGaSW0D7f34fcLwTL6/q1s75D9alu4omLhMH odMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WXuf8ZHg; 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 g184si18580061pfb.288.2018.12.04.12.39.12; Tue, 04 Dec 2018 12:39:13 -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=WXuf8ZHg; 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 S1726372AbeLDUjL (ORCPT + 31 others); Tue, 4 Dec 2018 15:39:11 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45301 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbeLDUjI (ORCPT ); Tue, 4 Dec 2018 15:39:08 -0500 Received: by mail-pg1-f195.google.com with SMTP id y4so7880773pgc.12 for ; Tue, 04 Dec 2018 12:39:08 -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=WXuf8ZHgfXM8hFipNJqrnlBcTvAYQRbWJD2GjJ5MIM7fMqDI0QYHkKoH+/DcNC709E vhp/zGQPEQ3P1t9f/7s1dShvlZRqVS3pjoRceA3RG1w3NzympRlAmlFXd9MNmOnvnWwY yIAPJVMeSwKwxkv+GxVs22kvCaTfnuZ4kGtZk= 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=KWDeaHGMU6WenhP0TbdFbLN6C/SyMSIaVOeCfoJzevx4sEFq4379wgqUNSiFI5Ca8L HwqUGoVpfhhwSMhjgSh1pyUG4Tld4zvP95REsHIY6edw1p86Pn9DGdlioSg0hsXu0SQ2 UFdyTTb6TMe1A1JnSF47ulQStjKgBQjwqmoc4A04WEcxIeq5QLVQcIfgV7gtALSC9hdQ pbk7jElA1xZPZgcxg34p8rk5iSi71WhHxhVq70M8IDVtksNfUaz1laiHVQqKIdwe9mz8 aL/r2PcbCv7hJ3vSi0bxM0nR5O5tpowM+NqEqAc/cvuR2qOiTfVBQsI6bQ6O37ClespG MreQ== X-Gm-Message-State: AA+aEWZC9Goq9AFlnHuhMszZ0wp/uMQAyX3JbR+b5CFBHVLEqKMsnl0R UciklBONGOlgyrrS8YOoMD/zFg== X-Received: by 2002:a62:8949:: with SMTP id v70mr20951469pfd.85.1543955947701; Tue, 04 Dec 2018 12:39:07 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id r76sm29783274pfb.69.2018.12.04.12.39.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Dec 2018 12:39:07 -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 RESEND 1/3] perf tools: Add configuration for ETMv3 trace protocol Date: Tue, 4 Dec 2018 13:39:02 -0700 Message-Id: <1543955944-10042-2-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543955944-10042-1-git-send-email-mathieu.poirier@linaro.org> References: <1543955944-10042-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 Tue Dec 4 20:39:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 152865 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp8511830ljp; Tue, 4 Dec 2018 12:39:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/WNmJfzIrpjqW4C/qpuqQ+FjDvU2dH11sIlRuVy+HJ73s9eie4WMhm3qoG2XyJS3t1cqRdK X-Received: by 2002:a62:2606:: with SMTP id m6mr20992864pfm.133.1543955961959; Tue, 04 Dec 2018 12:39:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543955961; cv=none; d=google.com; s=arc-20160816; b=sYNZrRFgu4Dwqw5PSYldS/weReFHdOs/tKbWDXk9mKMOL4JP7QgPPF8mOd8jzE6+Qf YJQdye6yBxrYdZdM77FrkKr6rRPGTrVnBGPvBBcmMxTZTHBVQCcZPcF5QAXcv/MH1vJz RVhayDYBHqf1uWchZQmS31l31cCUW5myjQJcN9m3tRgdxvNAAB6KmWxVdYF+sbrM0CiQ JQScPd6uQjMyC018+m/ea3sB/3tzwkfb9hMafGoT5SKiq/yGHtM33ma6N8+QY10DtpH/ 2c1xuK15y8a8oNClNWrzXehGnZcrSbThG12uJdbdtpJmy2HHWeZIBhmvABtroyv2mHWj x0dQ== 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=VqBc9Gq3LytAyrW6i6tZvFTE9zrKBHeOcOUbC3Kc/Ze0zh2e+t9jMWMolgNHk+99hH e57e+nXat1Q8kyR5vS66pcvj00j+yx9u4AOM7dmEswZBA2EbcHiT6rgP+2dQnmvX1oH9 tRG8D4VWYQHZwuByh422yeDydlo1uxeKUXXSH8t+fQiDtHtEJ4qcDB9suSBmOdqbQrVW +910fu9rwVgzpK1mpn8IlWOVZ8SyqN+xSiVcDUuvNdFsJb7Inx/qze80uK9eoxZMCxNz r1qY6u8DJjw4xXcXwRAq7IPup41ZImvL+3pOy/Rzyk0XZJwxgvQ6gWsnajIZqP14vagO 0xUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iecUL2z1; 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 59si19859058ple.291.2018.12.04.12.39.21; Tue, 04 Dec 2018 12:39:21 -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=iecUL2z1; 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 S1726475AbeLDUjU (ORCPT + 31 others); Tue, 4 Dec 2018 15:39:20 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:41304 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbeLDUjJ (ORCPT ); Tue, 4 Dec 2018 15:39:09 -0500 Received: by mail-pf1-f193.google.com with SMTP id b7so8794102pfi.8 for ; Tue, 04 Dec 2018 12:39:09 -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=iecUL2z1/4wS3WhGPKUzl4IQnx1Ey/RZTh0iOlII1lWJjwffvCYN17q47rRfM4lh78 k+d0YcBAYjjPqzYzpSVzj2Wm1VNazAuT4OBU9KN8HAdBn/GgM1vLjSkT8qXZGAUtb6s4 jATqDhJlqMq0vNWEglGTG/DQc7I6+o7Q5piGE= 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=cjaRd7WreXbLyWZ7DZmZMMiBsE0r4OlmOTDhHlCaTYI6sMCBhFm5qEA4LtSTxTlz9T Wp8qq6wRywGL3OIR8L/U3AJJmrqAv4CHkVwIa03qlUN8l9sgppKAEF/jZRemZ3zVVMay XpUEWP//GuiJ7sTpWj5nNNZhgHDujCAiaUEVOL1P5hTBP9H2uKOnL4hS2pO2+3Hdy72R bBG4kwOZkRgRtgle5PphBzRpdYf7NgABuXZIFPMnPjsZWCJm0t+RvCoehAKvIo3OzdOx Fuv5MMnGNrJDrAhbwLA+zgTI/5loLQD/MG+wPrTyHgNoxcHbXWq21J8A2AlU6WDsyI2q oVSA== X-Gm-Message-State: AA+aEWZdAHAiESQ2NhVMjwUr9D9fseF7fWiUmSu6xLb0ybN0jFfjMk/l Lgpeuz2HIiiue+PrBeeZIG65IA== X-Received: by 2002:a63:e302:: with SMTP id f2mr18305424pgh.320.1543955948796; Tue, 04 Dec 2018 12:39:08 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id r76sm29783274pfb.69.2018.12.04.12.39.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Dec 2018 12:39:08 -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 RESEND 2/3] perf tools: Add support for ETMv3 trace decoding Date: Tue, 4 Dec 2018 13:39:03 -0700 Message-Id: <1543955944-10042-3-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543955944-10042-1-git-send-email-mathieu.poirier@linaro.org> References: <1543955944-10042-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 Tue Dec 4 20:39:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 152864 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp8511739ljp; Tue, 4 Dec 2018 12:39:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/XVfReM7qe9J5UiihQIOYhkPPwYzhfjBD+NPkYTDi1H8jREMBkRMijZBkHyJ8oyD//e2MCZ X-Received: by 2002:a17:902:d806:: with SMTP id a6mr20580988plz.172.1543955956080; Tue, 04 Dec 2018 12:39:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543955956; cv=none; d=google.com; s=arc-20160816; b=ii+9Z0Z5wrw3hDgbwfpfZJ85fxMw7rQTFE6OUWz9XlEJOj73QDZGUe3cRtMyvXpxTq LOPa8mFVgM+H9obSEQ1A5zppKQ/sEkbqEjx1x+EqtGMAn4YHUsleLu5tk85Ix2wLU62i XXR8HVDSnb6/GhzWcMpnTF0ByjXC9D9RhNY1vyv18hNJ0QLVrxyBVL75IwPj0pwVEGAp IkcSR2gq+46oR9hnfDtFlXhDyE0G5viSvzCRWGXHgJxn4688mwWdCWq0ivTFqOLBfVki pxVD/8kN8gE5PdEZmIIAwkrJ8dAQu2ffkrD9ozuu6YVrByXQFf/b+6kKArhNz8C9xaUr 9Chg== 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=zoi/IhxvrF6Xh1NUJSlO47my/9EXMQ9kl5IMzwIFSqnSji9b6MJeA0jjgreX2KWPI+ f/W7u6tGE2kzbbG2KDp2NxuUMYoaSUYSo0FGX6aRstigaIjUe846rOU1gsqMoKzXYgzh EPG3XtFlOeukMnksYKWfsASc4mR0kjGD+TgSQO4xOQ8/o+aEAzxHbWITebLD7/Ix0SfT uHloTs1VFGOiVfGG5RoH/YyZQnjxTZQjqYm+zpCrZxCyI6AAENGwA2TUImywsEhoDLD4 9jUtWOIy+CH8kA3dREPfeLP0+4J46azsHaFQ34Ja59beLFZClVPSUP/f52Iryz2pPsH/ nDOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AK+x+9jT; 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 g184si18580061pfb.288.2018.12.04.12.39.15; Tue, 04 Dec 2018 12:39:16 -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=AK+x+9jT; 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 S1726452AbeLDUjP (ORCPT + 31 others); Tue, 4 Dec 2018 15:39:15 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35338 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726349AbeLDUjK (ORCPT ); Tue, 4 Dec 2018 15:39:10 -0500 Received: by mail-pg1-f194.google.com with SMTP id s198so7916046pgs.2 for ; Tue, 04 Dec 2018 12:39:10 -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=AK+x+9jTmPsXIh/RC5ghWxEZ2gyXXIfS05G+mFTDE4HejXnVWqehGX7uAgby+zfFpH ++mRLrYlRQTVvBWHTU+Wea4EjZ49z4uSRGrIgh03l/SctmubCoxIrWjdcrNe+67ltU8v KV8ZcWBAxLjobbEQXkaddg3J8wbDuQU5iEnrY= 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=B87H2RIvAt9hj0Eoa9Qd9KQ0bGFHYfmPUaZyCaexC5Rih6J1xahWpqyJDXhnF0Bfe6 1HapRzvXM7zl9KOPNmndDfAUuNkO2xD1+wjWnylBa77PQVmE1oBsaV+HGwZren/BKPh6 wGY/HBxNSbFL8mWr9Az6CbNDJb2XjfgQh+W025hrRgsAA76pkoBlg4021hjnyZiCTmZG Z8ERt/g06Rke4BIRI1ptzibqepCflEMqPugEReHl4OsG/8DoczlCFb0qCLuf9ASVnsIB NLgFV2uZrW0oDAMni3XH3qMBmJvyYAJOJDQQw3tmaOvW8IbA91H9XPZiuj2b7Pl0BLYw jMFQ== X-Gm-Message-State: AA+aEWbki4zIWmeSrUxCAa2JrTH4h5rf4xhv14msZhtRzMh34agUlcGb sG93rrvb01pEPPuQdPzrIay88Q== X-Received: by 2002:a63:4187:: with SMTP id o129mr16639663pga.370.1543955949940; Tue, 04 Dec 2018 12:39:09 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id r76sm29783274pfb.69.2018.12.04.12.39.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Dec 2018 12:39:09 -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 RESEND 3/3] perf tools: Add support for PTMv1.1 decoding Date: Tue, 4 Dec 2018 13:39:04 -0700 Message-Id: <1543955944-10042-4-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543955944-10042-1-git-send-email-mathieu.poirier@linaro.org> References: <1543955944-10042-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 =