From patchwork Tue Jul 11 11:29:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 9834547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 68D0460363 for ; Tue, 11 Jul 2017 11:30:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5791128403 for ; Tue, 11 Jul 2017 11:30:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 483EE283FB; Tue, 11 Jul 2017 11:30:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BAEC2283FB for ; Tue, 11 Jul 2017 11:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=wqRxF2SbLsaISsFuPZJR96EVndN4K4S9RGDoc61wdfQ=; b=OOF QDOjtuRMapYN5IeB8XGz+gPcPViwGN8vCgljdiQGxJt3tXvHFMUuARQMOZnYZW0SfStU52PyWPl1f i4T+mQqVB0odVx2+vLiL1scqqrl5/s+fn+Lkf577aiK0afMNYVNEz6ZTypV8dZ5w8h9kCzpinVS92 aZckFaID1OgO3BnB6tR0nYmXYcD7YFhCg/DcQYeBXa871wA9FM3OewengY62tes8fAX4epuyfs72r FZzmbN1WWHwy9d0/drqrdXgz2UR/0qefYkULFU+JFy/vBJE/kwdLose4W9dMNhrmwD+S+OwKqXHtS +bI91CYcF6I5GlaexGPjE+qDCM8DT+Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dUtMn-0007S5-2Z; Tue, 11 Jul 2017 11:30:09 +0000 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dUtMe-0006D5-R3 for linux-arm-kernel@lists.infradead.org; Tue, 11 Jul 2017 11:30:06 +0000 Received: by mail-wr0-x233.google.com with SMTP id 77so179157007wrb.1 for ; Tue, 11 Jul 2017 04:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=paYrm2xmojK/VVCM0c+OfQ+T78d2pP1QhAQ9wHSSybQ=; b=g0y1blGR80JteyR9fg/ersi4VKoPEqDk3xov1z2rMAMF37Y0wtEsxExsPF6nd5lroY N+uubjD0FnnZpv9gMILyTijxvPwXXEMRGFvInH62BPIYhssUJiFoQvNvswgqbbJEFwhZ JX1YeL15dOfVbVV3rRbQLxUQsgKItHJJj4xCQ= 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; bh=paYrm2xmojK/VVCM0c+OfQ+T78d2pP1QhAQ9wHSSybQ=; b=UkImuoX5ldso992QsDo5ZXQ/9oOu5M1GbxZ+XuM2dCU8bUhVGiGDOiCQd8ZDINthgK iYgfGabrtr5mn5oTh50GN/ZEj0yOMN4bSwQU8Egv0choBXk/zuAT3HuNjwfGN4sK8hDr p4Jd1Fy98gBQwx6xPXMwdslDs3CT0FtFIRn3GRvpqNB23rUy46a5bgxaQgiqj8PoIvuH CiAKLtlI3WBFPAnDl3Dj0OS4/SFJEJV0W6CPBeyu+7wDuI3QAmQp3HTET0ziUnX09Svf R4mGOCkXIlKEfwVe+UlQUg5Kr7kW+/Q+e3MMco6aEOqV9/JYqFAapsG7sad+IKwEaQZA 2jkg== X-Gm-Message-State: AIVw1109QY3XeOo4ZFEgxBXrQHFmX61Af3GHslSIk/wlrtOmAs/j8yqu VPNsoNc7J1kx67Wg X-Received: by 10.28.148.67 with SMTP id w64mr11029559wmd.55.1499772578511; Tue, 11 Jul 2017 04:29:38 -0700 (PDT) Received: from linaro.org (cpc116592-blbn11-2-0-cust240.10-1.cable.virginm.net. [80.5.18.241]) by smtp.gmail.com with ESMTPSA id 46sm25095937wrz.8.2017.07.11.04.29.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Jul 2017 04:29:37 -0700 (PDT) From: Mike Leach To: mathieu.poirier@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] perf: cs-etm: Fix ETMv4 CONFIGR entry in perf.data file Date: Tue, 11 Jul 2017 12:29:34 +0100 Message-Id: <1499772574-2267-1-git-send-email-mike.leach@linaro.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170711_043001_067000_4E2C13C8 X-CRM114-Status: GOOD ( 15.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Leach MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The value passed into the perf.data file for the CONFIGR register in ETMv4 was incorrectly being set to the command line options/ETMv3 value. Adds bit definitions and function to remap this value to the correct ETMv4 CONFIGR bit values for all selected options. Signed-off-by: Mike Leach --- include/linux/coresight-pmu.h | 5 +++++ tools/include/linux/coresight-pmu.h | 5 +++++ tools/perf/arch/arm/util/cs-etm.c | 28 +++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h index 45852c2..edfeaba 100644 --- a/include/linux/coresight-pmu.h +++ b/include/linux/coresight-pmu.h @@ -26,6 +26,11 @@ #define ETM_OPT_TS 28 #define ETM_OPT_RETSTK 29 +/* ETMv4 CONFIGR programming bits for the ETM OPTs */ +#define ETM4_CFG_BIT_CYCACC 4 +#define ETM4_CFG_BIT_TS 11 +#define ETM4_CFG_BIT_RETSTK 12 + static inline int coresight_get_trace_id(int cpu) { /* diff --git a/tools/include/linux/coresight-pmu.h b/tools/include/linux/coresight-pmu.h index 45852c2..edfeaba 100644 --- a/tools/include/linux/coresight-pmu.h +++ b/tools/include/linux/coresight-pmu.h @@ -26,6 +26,11 @@ #define ETM_OPT_TS 28 #define ETM_OPT_RETSTK 29 +/* ETMv4 CONFIGR programming bits for the ETM OPTs */ +#define ETM4_CFG_BIT_CYCACC 4 +#define ETM4_CFG_BIT_TS 11 +#define ETM4_CFG_BIT_RETSTK 12 + static inline int coresight_get_trace_id(int cpu) { /* diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 29361d9..997734b 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -266,6 +266,32 @@ static u64 cs_etm_get_config(struct auxtrace_record *itr) return config; } +#ifndef BIT +#define BIT(N) (1UL << (N)) +#endif + +static u64 cs_etmv4_get_config(struct auxtrace_record *itr) +{ + u64 config = 0; + u64 config_opts = 0; + + /* + * The perf event variable config bits represent both + * the command line options and register programming + * bits in ETMv3/PTM. For ETMv4 we must remap options + * to real bits + */ + config_opts = cs_etm_get_config(itr); + if (config_opts & BIT(ETM_OPT_CYCACC)) + config |= BIT(ETM4_CFG_BIT_CYCACC); + if (config_opts & BIT(ETM_OPT_TS)) + config |= BIT(ETM4_CFG_BIT_TS); + if (config_opts & BIT(ETM_OPT_RETSTK)) + config |= BIT(ETM4_CFG_BIT_RETSTK); + + return config; +} + static size_t cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused, struct perf_evlist *evlist __maybe_unused) @@ -363,7 +389,7 @@ static void cs_etm_get_metadata(int cpu, u32 *offset, magic = __perf_cs_etmv4_magic; /* Get trace configuration register */ info->priv[*offset + CS_ETMV4_TRCCONFIGR] = - cs_etm_get_config(itr); + cs_etmv4_get_config(itr); /* Get traceID from the framework */ info->priv[*offset + CS_ETMV4_TRCTRACEIDR] = coresight_get_trace_id(cpu);