linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: leo.yan@linaro.org (Leo Yan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 4/4] coresight: etm4x: Hook panic dump callback for etmv4
Date: Tue, 21 Nov 2017 11:08:44 +0800	[thread overview]
Message-ID: <1511233724-11867-5-git-send-email-leo.yan@linaro.org> (raw)
In-Reply-To: <1511233724-11867-1-git-send-email-leo.yan@linaro.org>

We need to dump etmv4 info as metadata, so the data can be used for
offline checking for configuration and generate 'perf' compatible
file.  This commit hooks etmv4 callback for panic dump.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etm4x.c | 22 ++++++++++++++++++++++
 drivers/hwtracing/coresight/coresight-etm4x.h | 15 +++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
index cf364a5..bf9608b 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x.c
@@ -418,11 +418,33 @@ static void etm4_disable(struct coresight_device *csdev,
 		local_set(&drvdata->mode, CS_MODE_DISABLED);
 }
 
+static void etm4_panic_cb(void *data)
+{
+	struct coresight_device *csdev = (struct coresight_device *)data;
+	int cpu = smp_processor_id();
+	struct etmv4_drvdata *drvdata = etmdrvdata[cpu];
+	struct etmv4_config *config = &drvdata->config;
+	struct etmv4_metadata *metadata = &drvdata->metadata;
+
+	metadata->magic = ETM4_METADATA_MAGIC;
+	metadata->cpu = cpu;
+	metadata->trcconfigr = config->cfg;
+	metadata->trctraceidr = drvdata->trcid;
+	metadata->trcidr0 = readl_relaxed(drvdata->base + TRCIDR0);
+	metadata->trcidr1 = readl_relaxed(drvdata->base + TRCIDR1);
+	metadata->trcidr2 = readl_relaxed(drvdata->base + TRCIDR2);
+	metadata->trcidr8 = readl_relaxed(drvdata->base + TRCIDR8);
+	metadata->trcauthstatus = readl_relaxed(drvdata->base + TRCAUTHSTATUS);
+
+	coresight_dump_update(csdev, (char *)metadata, sizeof(*metadata));
+}
+
 static const struct coresight_ops_source etm4_source_ops = {
 	.cpu_id		= etm4_cpu_id,
 	.trace_id	= etm4_trace_id,
 	.enable		= etm4_enable,
 	.disable	= etm4_disable,
+	.panic_cb	= etm4_panic_cb,
 };
 
 static const struct coresight_ops etm4_cs_ops = {
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h
index b3b5ea7..08dc8b7 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.h
+++ b/drivers/hwtracing/coresight/coresight-etm4x.h
@@ -198,6 +198,20 @@
 #define ETM_EXLEVEL_NS_HYP		BIT(14)
 #define ETM_EXLEVEL_NS_NA		BIT(15)
 
+#define ETM4_METADATA_MAGIC		0x4040404040404040ULL
+
+struct etmv4_metadata {
+	u64 magic;
+	u64 cpu;
+	u64 trcconfigr;
+	u64 trctraceidr;
+	u64 trcidr0;
+	u64 trcidr1;
+	u64 trcidr2;
+	u64 trcidr8;
+	u64 trcauthstatus;
+};
+
 /**
  * struct etmv4_config - configuration information related to an ETMv4
  * @mode:	Controls various modes supported by this ETM.
@@ -393,6 +407,7 @@ struct etmv4_drvdata {
 	bool				atbtrig;
 	bool				lpoverride;
 	struct etmv4_config		config;
+	struct etmv4_metadata		metadata;
 };
 
 /* Address comparator access types */
-- 
2.7.4

  parent reply	other threads:[~2017-11-21  3:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21  3:08 [PATCH v2 0/4] coresight: support panic dump functionality Leo Yan
2017-11-21  3:08 ` [PATCH v2 1/4] coresight: Support " Leo Yan
2017-11-22 18:58   ` Mathieu Poirier
2017-11-24  1:54     ` Leo Yan
2017-11-24 16:29       ` Mathieu Poirier
2017-11-27  1:57         ` Leo Yan
2017-11-28 17:13           ` Mathieu Poirier
2017-11-21  3:08 ` [PATCH v2 2/4] coresight: Add and delete dump node for registration/unregistration Leo Yan
2017-11-21  3:08 ` [PATCH v2 3/4] coresight: tmc: Hook panic dump callback for ETB/ETF Leo Yan
2017-11-21  3:08 ` Leo Yan [this message]
2017-11-22 19:09   ` [PATCH v2 4/4] coresight: etm4x: Hook panic dump callback for etmv4 Mathieu Poirier
2017-11-23 17:03     ` Mathieu Poirier
2017-11-24  4:06       ` Leo Yan
2017-11-24 16:46         ` Mathieu Poirier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1511233724-11867-5-git-send-email-leo.yan@linaro.org \
    --to=leo.yan@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).