[PATCH RFC 04/10] coresight: cpu-debug: Bound the power up retries

From: Igor Velkov via B4 Relay

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


From: Igor Velkov <iav@xxxxxx>

debug_force_cpu_powered_up() starts over whenever the core is found
powered down again right after CORENPDRQ is set, with no limit. Where
the power controller does not hold the core up, the caller never
returns.

Give up after three tries. EDPRSR then shows the core powered down and
debug_access_permitted() keeps the caller away from its registers.

Fixes: 2227b7c74634 ("coresight: add support for CPU debug module")
Signed-off-by: Igor Velkov <iav@xxxxxx>
---
drivers/hwtracing/coresight/coresight-cpu-debug.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c
index c55de98100a3..9a8ce85fc468 100644
--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c
+++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c
@@ -84,6 +84,7 @@

#define DEBUG_WAIT_SLEEP 1000
#define DEBUG_WAIT_TIMEOUT 32000
+#define DEBUG_POWER_UP_TRIES 3

struct debug_drvdata {
struct clk *pclk;
@@ -147,6 +148,7 @@ static bool debug_access_permitted(struct debug_drvdata *drvdata)

static void debug_force_cpu_powered_up(struct debug_drvdata *drvdata)
{
+ int tries = DEBUG_POWER_UP_TRIES;
u32 edprcr;

try_again:
@@ -186,8 +188,8 @@ static void debug_force_cpu_powered_up(struct debug_drvdata *drvdata)

drvdata->edprsr = readl_relaxed(drvdata->base + EDPRSR);

- /* The core power domain got switched off on use, try again */
- if (unlikely(!(drvdata->edprsr & EDPRSR_PU)))
+ /* The core power domain got switched off on use, try again if allowed */
+ if (unlikely(!(drvdata->edprsr & EDPRSR_PU)) && --tries)
goto try_again;
}


--
2.43.0