[PATCH RFC 06/10] coresight: cpu-debug: Factor out debug_read_pcsr()
From: Igor Velkov via B4 Relay
Date: Fri Nov 27 2026 - 01:39:16 EST
From: Igor Velkov <iav@xxxxxx>
Move the reads of EDPCSR and of the registers it latches out of
debug_read_regs(), so that they can be reused without the EDPRCR power
request.
No functional change.
Signed-off-by: Igor Velkov <iav@xxxxxx>
---
drivers/hwtracing/coresight/coresight-cpu-debug.c | 46 ++++++++++++-----------
1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c
index 64b5abe33aa8..63bc4cb8df52 100644
--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c
+++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c
@@ -199,27 +199,8 @@ static void debug_force_cpu_powered_up(struct debug_drvdata *drvdata)
goto try_again;
}
-static void debug_read_regs(struct debug_drvdata *drvdata)
+static void debug_read_pcsr(struct debug_drvdata *drvdata)
{
- u32 save_edprcr;
-
- CS_UNLOCK(drvdata->base);
-
- /* Unlock os lock */
- debug_os_unlock(drvdata);
-
- /* Save EDPRCR register */
- save_edprcr = readl_relaxed(drvdata->base + EDPRCR);
-
- /*
- * Ensure CPU power domain is enabled to let registers
- * are accessiable.
- */
- debug_force_cpu_powered_up(drvdata);
-
- if (!debug_access_permitted(drvdata))
- goto out;
-
drvdata->edpcsr = readl_relaxed(drvdata->base + EDPCSR);
/*
@@ -230,7 +211,7 @@ static void debug_read_regs(struct debug_drvdata *drvdata)
* UNKNOWN state. So directly bail out for this case.
*/
if (drvdata->edpcsr == EDPCSR_PROHIBITED)
- goto out;
+ return;
/*
* A read of the EDPCSR normally has the side-effect of
@@ -245,8 +226,29 @@ static void debug_read_regs(struct debug_drvdata *drvdata)
if (drvdata->edvidsr_present)
drvdata->edvidsr = readl_relaxed(drvdata->base + EDVIDSR);
+}
+
+static void debug_read_regs(struct debug_drvdata *drvdata)
+{
+ u32 save_edprcr;
+
+ CS_UNLOCK(drvdata->base);
+
+ /* Unlock os lock */
+ debug_os_unlock(drvdata);
+
+ /* Save EDPRCR register */
+ save_edprcr = readl_relaxed(drvdata->base + EDPRCR);
+
+ /*
+ * Ensure CPU power domain is enabled to let registers
+ * are accessiable.
+ */
+ debug_force_cpu_powered_up(drvdata);
+
+ if (debug_access_permitted(drvdata))
+ debug_read_pcsr(drvdata);
-out:
/* Restore EDPRCR register */
writel_relaxed(save_edprcr, drvdata->base + EDPRCR);
--
2.43.0