mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linu Cherian <lcherian@marvell.com>
To: <suzuki.poulose@arm.com>, <mike.leach@linaro.org>,
	<james.clark@arm.com>, <leo.yan@linaro.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<coresight@lists.linaro.org>, <linux-kernel@vger.kernel.org>,
	<robh+dt@kernel.org>, <krzysztof.kozlowski+dt@linaro.org>,
	<conor+dt@kernel.org>, <devicetree@vger.kernel.org>,
	<sgoutham@marvell.com>, <gcherian@marvell.com>,
	Linu Cherian <lcherian@marvell.com>
Subject: [RFC PATCH v3 7/7] coresight: etm4x: Configure ETM to trigger on panic
Date: Mon, 4 Sep 2023 10:35:47 +0530	[thread overview]
Message-ID: <20230904050548.28047-8-lcherian@marvell.com> (raw)
In-Reply-To: <20230904050548.28047-1-lcherian@marvell.com>

Configure ETM to generate a trigger on Ext out [0] on panic.
This is achieved by configuring a single address comparator
with the address of "panic" and by configuring Ext out [0] to
trigger on the comparator event.

This trigger can be used by the sinks to stop capture on panic.

Signed-off-by: Linu Cherian <lcherian@marvell.com>
---
 .../coresight/coresight-etm4x-core.c          | 17 +++++++++---
 drivers/hwtracing/coresight/coresight-etm4x.h | 26 +++++++++++++++++++
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
index 7c65d152aebb..423934efcd9d 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
@@ -62,6 +62,7 @@ static void etm4_set_default_config(struct etmv4_config *config);
 static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
 				  struct perf_event *event);
 static u64 etm4_get_access_type(struct etmv4_config *config);
+static u64 etm4_get_comparator_access_type(struct etmv4_config *config);
 
 static enum cpuhp_state hp_online;
 
@@ -1291,9 +1292,8 @@ static void etm4_set_victlr_access(struct etmv4_config *config)
 
 static void etm4_set_default_config(struct etmv4_config *config)
 {
-	/* disable all events tracing */
-	config->eventctrl0 = 0x0;
-	config->eventctrl1 = 0x0;
+	int rselector = 2; /* 0 and 1 are reserved */
+	int comp_idx = 0;
 
 	/* disable stalling */
 	config->stall_ctrl = 0x0;
@@ -1309,6 +1309,17 @@ static void etm4_set_default_config(struct etmv4_config *config)
 
 	/* TRCVICTLR::EXLEVEL_NS:EXLEVELS: Set kernel / user filtering */
 	etm4_set_victlr_access(config);
+
+	/* Configure the comparator with kernel panic address */
+	config->addr_val[comp_idx] = (u64)panic;
+	config->addr_acc[comp_idx] = etm4_get_comparator_access_type(config);
+	config->addr_type[comp_idx] = ETM_ADDR_TYPE_STOP;
+	config->res_ctrl[rselector] = ETM_RESGRP_SADDRCMP << 16 | BIT(comp_idx);
+
+	/* Connect external output [0] with comparator out */
+	config->eventctrl0 = 0x0 << 7 | rselector;
+
+	config->eventctrl1 = 0x0;
 }
 
 static u64 etm4_get_ns_access_type(struct etmv4_config *config)
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h
index 27c8a9901868..6ac5d5ee1877 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.h
+++ b/drivers/hwtracing/coresight/coresight-etm4x.h
@@ -612,6 +612,32 @@
 #define ETM_CNTR_MAX_VAL		0xFFFF
 #define ETM_TRACEID_MASK		0x3f
 
+/* ETM resource group encoding */
+#define ETM_RESGRP_EXTIN		0x0
+#define ETM_RESGRP_PECMP		0x1
+#define ETM_RESGRP_CNTRSEQ		0x2
+#define ETM_RESGRP_SSCMP		0x3
+#define ETM_RESGRP_SADDRCMP		0x4
+#define ETM_RESGRP_ADDRRANGECMP		0x5
+#define ETM_RESGRP_CIDCMP		0x6
+#define ETM_RESGRP_VCIDCMP		0x7
+
+#define ETM_EXTIN_0			0x0
+
+
+/* ETM resource group encoding */
+#define ETM_RESGRP_EXTIN		0x0
+#define ETM_RESGRP_PECMP		0x1
+#define ETM_RESGRP_CNTRSEQ		0x2
+#define ETM_RESGRP_SSCMP		0x3
+#define ETM_RESGRP_SADDRCMP		0x4
+#define ETM_RESGRP_ADDRRANGECMP		0x5
+#define ETM_RESGRP_CIDCMP		0x6
+#define ETM_RESGRP_VCIDCMP		0x7
+
+#define ETM_EXTIN_0			0x0
+
+
 /* ETMv4 programming modes */
 #define ETM_MODE_EXCLUDE		BIT(0)
 #define ETM_MODE_LOAD			BIT(1)
-- 
2.41.0


  parent reply	other threads:[~2023-09-04  5:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04  5:05 [RFC PATCH v3 0/8] Coresight for Kernel panic and watchdog reset Linu Cherian
2023-09-04  5:05 ` [RFC PATCH v3 1/7] dt-bindings: arm: coresight-tmc: Add "memory-region" property Linu Cherian
2023-09-04  6:23   ` Rob Herring
2023-09-09 14:12     ` [EXT] " Linu Cherian
2023-09-04  8:26   ` Suzuki K Poulose
2023-09-05 15:35     ` Rob Herring
2023-09-09 14:06     ` [EXT] " Linu Cherian
2023-09-04  5:05 ` [RFC PATCH v3 2/7] coresight: tmc-etr: Add support to use reserved trace memory Linu Cherian
2023-09-04  5:05 ` [RFC PATCH v3 3/7] coresight: core: Add provision for panic callbacks Linu Cherian
2023-09-04  5:05 ` [RFC PATCH v3 4/7] coresight: tmc: Enable panic sync handling Linu Cherian
2023-09-04  5:05 ` [RFC PATCH v3 5/7] coresight: tmc: Add support for reading tracedata from previous boot Linu Cherian
2023-09-04  5:05 ` [RFC PATCH v3 6/7] coresight: tmc: Stop trace capture on FlIn Linu Cherian
2023-09-04  5:05 ` Linu Cherian [this message]
2023-09-15 13:50 ` [RFC PATCH v3 0/8] Coresight for Kernel panic and watchdog reset James Clark
2023-09-19 11:39   ` [EXT] " Linu Cherian
2023-09-19 13:10     ` James Clark
2023-09-27  3:48       ` Linu Cherian

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=20230904050548.28047-8-lcherian@marvell.com \
    --to=lcherian@marvell.com \
    --cc=conor+dt@kernel.org \
    --cc=coresight@lists.linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gcherian@marvell.com \
    --cc=james.clark@arm.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.leach@linaro.org \
    --cc=robh+dt@kernel.org \
    --cc=sgoutham@marvell.com \
    --cc=suzuki.poulose@arm.com \
    /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

all inboxes | Powered by JetHome®