[PATCH] ARM: hw_breakpoints: Check for CPU debug availability beforeenabling it

From: Santosh Shilimkar
Date: Mon Mar 18 2013 - 02:29:04 EST


CPU debug features like hardware break, watchpoints can be used only when
the debug mode is enabled and available for non-secure mode.

Hence check 'DBGAUTHSTATUS.DBGEN' before proceeding to enable the
features.

Thanks to Will for pointers and Lokesh for the analysis of the issue on
OMAP4 where after a CPU power cycle, debug mode gets disabled.

Cc: Will Deacon <Will.Deacon@xxxxxxx>

Tested-by: Lokesh Vutla <lokeshvutla@xxxxxx>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@xxxxxx>
---
arch/arm/kernel/hw_breakpoint.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
index 96093b7..683a7cf 100644
--- a/arch/arm/kernel/hw_breakpoint.c
+++ b/arch/arm/kernel/hw_breakpoint.c
@@ -930,6 +930,14 @@ static void reset_ctrl_regs(void *unused)
int i, raw_num_brps, err = 0, cpu = smp_processor_id();
u32 val;

+ /* Check if we have access to CPU debug features */
+ ARM_DBG_READ(c7, c14, 6, val);
+ if ((val & 0x1) == 0) {
+ pr_warn_once("CPU %d debug is unavailable\n", cpu);
+ cpumask_or(&debug_err_mask, &debug_err_mask, cpumask_of(cpu));
+ return;
+ }
+
/*
* v7 debug contains save and restore registers so that debug state
* can be maintained across low-power modes without leaving the debug
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/