[PATCH RFC 05/10] coresight: cpu-debug: Do not sample a core that is in reset

From: Igor Velkov via B4 Relay

Date: Fri Nov 27 2026 - 01:39:11 EST


From: Igor Velkov <iav@xxxxxx>

debug_access_permitted() lets the driver read the sampling registers
when EDPRSR shows the core powered and the OS Double Lock clear. A core
can be powered and held in reset: an idle Cortex-A72 on RK3399 reads
PU = 1, R = 1, and a read of its EDPCSR aborts.

Treat a core that EDPRSR reports in reset as not accessible, and print
the bit in the dump.

debug_read_regs() writes EDOSLAR before it reads EDPRSR, and on RK3399
that write already faults for such a core. The check covers the path
added later in this series, which reads EDPRSR first.

Signed-off-by: Igor Velkov <iav@xxxxxx>
---
Documentation/trace/coresight/coresight-cpu-debug.rst | 4 ++--
drivers/hwtracing/coresight/coresight-cpu-debug.c | 9 ++++++++-
2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/Documentation/trace/coresight/coresight-cpu-debug.rst b/Documentation/trace/coresight/coresight-cpu-debug.rst
index 32fbae244524..04bfd318cb2b 100644
--- a/Documentation/trace/coresight/coresight-cpu-debug.rst
+++ b/Documentation/trace/coresight/coresight-cpu-debug.rst
@@ -182,12 +182,12 @@ Here is an example of the debugging output format::

ARM external debug module:
coresight-cpu-debug 850000.debug: CPU[0]:
- coresight-cpu-debug 850000.debug: EDPRSR: 00000001 (Power:On DLK:Unlock)
+ coresight-cpu-debug 850000.debug: EDPRSR: 00000001 (Power:On Reset:No DLK:Unlock)
coresight-cpu-debug 850000.debug: EDPCSR: handle_IPI+0x174/0x1d8
coresight-cpu-debug 850000.debug: EDCIDSR: 00000000
coresight-cpu-debug 850000.debug: EDVIDSR: 90000000 (State:Non-secure Mode:EL1/0 Width:64bits VMID:0)
coresight-cpu-debug 852000.debug: CPU[1]:
- coresight-cpu-debug 852000.debug: EDPRSR: 00000001 (Power:On DLK:Unlock)
+ coresight-cpu-debug 852000.debug: EDPRSR: 00000001 (Power:On Reset:No DLK:Unlock)
coresight-cpu-debug 852000.debug: EDPCSR: debug_notifier_call+0x23c/0x358
coresight-cpu-debug 852000.debug: EDCIDSR: 00000000
coresight-cpu-debug 852000.debug: EDVIDSR: 90000000 (State:Non-secure Mode:EL1/0 Width:64bits VMID:0)
diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c
index 9a8ce85fc468..64b5abe33aa8 100644
--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c
+++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c
@@ -51,6 +51,7 @@

/* bits definition for EDPRSR */
#define EDPRSR_DLK BIT(6)
+#define EDPRSR_R BIT(2)
#define EDPRSR_PU BIT(0)

/* bits definition for EDVIDSR */
@@ -129,6 +130,7 @@ static void debug_os_unlock(struct debug_drvdata *drvdata)
* registers to avoid lockup issue:
*
* - CPU power domain is powered off;
+ * - The CPU is in reset;
* - The OS Double Lock is locked;
*
* By checking EDPRSR can get to know if meet these conditions.
@@ -139,6 +141,10 @@ static bool debug_access_permitted(struct debug_drvdata *drvdata)
if (!(drvdata->edprsr & EDPRSR_PU))
return false;

+ /* CPU is in reset */
+ if (drvdata->edprsr & EDPRSR_R)
+ return false;
+
/* The OS Double Lock is locked */
if (drvdata->edprsr & EDPRSR_DLK)
return false;
@@ -293,9 +299,10 @@ static void debug_dump_regs(struct debug_drvdata *drvdata)
struct device *dev = drvdata->dev;
unsigned long pc;

- dev_emerg(dev, " EDPRSR: %08x (Power:%s DLK:%s)\n",
+ dev_emerg(dev, " EDPRSR: %08x (Power:%s Reset:%s DLK:%s)\n",
drvdata->edprsr,
drvdata->edprsr & EDPRSR_PU ? "On" : "Off",
+ drvdata->edprsr & EDPRSR_R ? "Yes" : "No",
drvdata->edprsr & EDPRSR_DLK ? "Lock" : "Unlock");

if (!debug_access_permitted(drvdata)) {

--
2.43.0