aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDietmar Eggemann <dietmar.eggemann@arm.com>2012-09-26 12:28:47 -0400
committerWill Deacon <will.deacon@arm.com>2012-11-09 06:47:06 -0500
commit9e962f76602dbd293a57030f4ce5a4b57853e2ea (patch)
tree1aeb4316196f247d27ab0e7db933285fad1d12bc /arch
parent0daa034e696ac601061cbf60fda41ad39678ae14 (diff)
ARM: hw_breakpoint: use CRn as argument for debug reg accessor macros
The coprocessor register CRn for accesses to the debug register can be a different one than C0. Take this into account for the ARM_DBG_READ and the ARM_DBG_WRITE macro. The inline assembler calls which used a coprocessor register CRn other than C0 are replaced by the ARM_DBG_READ or ARM_DBG_WRITE macro. Tested-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/include/asm/hw_breakpoint.h8
-rw-r--r--arch/arm/kernel/hw_breakpoint.c40
2 files changed, 24 insertions, 24 deletions
diff --git a/arch/arm/include/asm/hw_breakpoint.h b/arch/arm/include/asm/hw_breakpoint.h
index c190bc992f0e..01169dd723f1 100644
--- a/arch/arm/include/asm/hw_breakpoint.h
+++ b/arch/arm/include/asm/hw_breakpoint.h
@@ -98,12 +98,12 @@ static inline void decode_ctrl_reg(u32 reg,
98#define ARM_BASE_WCR 112 98#define ARM_BASE_WCR 112
99 99
100/* Accessor macros for the debug registers. */ 100/* Accessor macros for the debug registers. */
101#define ARM_DBG_READ(M, OP2, VAL) do {\ 101#define ARM_DBG_READ(N, M, OP2, VAL) do {\
102 asm volatile("mrc p14, 0, %0, c0," #M ", " #OP2 : "=r" (VAL));\ 102 asm volatile("mrc p14, 0, %0, " #N "," #M ", " #OP2 : "=r" (VAL));\
103} while (0) 103} while (0)
104 104
105#define ARM_DBG_WRITE(M, OP2, VAL) do {\ 105#define ARM_DBG_WRITE(N, M, OP2, VAL) do {\
106 asm volatile("mcr p14, 0, %0, c0," #M ", " #OP2 : : "r" (VAL));\ 106 asm volatile("mcr p14, 0, %0, " #N "," #M ", " #OP2 : : "r" (VAL));\
107} while (0) 107} while (0)
108 108
109struct notifier_block; 109struct notifier_block;
diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
index 8e9532152bd9..05febbaecb44 100644
--- a/arch/arm/kernel/hw_breakpoint.c
+++ b/arch/arm/kernel/hw_breakpoint.c
@@ -52,14 +52,14 @@ static u8 debug_arch;
52/* Maximum supported watchpoint length. */ 52/* Maximum supported watchpoint length. */
53static u8 max_watchpoint_len; 53static u8 max_watchpoint_len;
54 54
55#define READ_WB_REG_CASE(OP2, M, VAL) \ 55#define READ_WB_REG_CASE(OP2, M, VAL) \
56 case ((OP2 << 4) + M): \ 56 case ((OP2 << 4) + M): \
57 ARM_DBG_READ(c ## M, OP2, VAL); \ 57 ARM_DBG_READ(c0, c ## M, OP2, VAL); \
58 break 58 break
59 59
60#define WRITE_WB_REG_CASE(OP2, M, VAL) \ 60#define WRITE_WB_REG_CASE(OP2, M, VAL) \
61 case ((OP2 << 4) + M): \ 61 case ((OP2 << 4) + M): \
62 ARM_DBG_WRITE(c ## M, OP2, VAL);\ 62 ARM_DBG_WRITE(c0, c ## M, OP2, VAL); \
63 break 63 break
64 64
65#define GEN_READ_WB_REG_CASES(OP2, VAL) \ 65#define GEN_READ_WB_REG_CASES(OP2, VAL) \
@@ -141,7 +141,7 @@ static u8 get_debug_arch(void)
141 return ARM_DEBUG_ARCH_V6; 141 return ARM_DEBUG_ARCH_V6;
142 } 142 }
143 143
144 ARM_DBG_READ(c0, 0, didr); 144 ARM_DBG_READ(c0, c0, 0, didr);
145 return (didr >> 16) & 0xf; 145 return (didr >> 16) & 0xf;
146} 146}
147 147
@@ -169,7 +169,7 @@ static int debug_exception_updates_fsr(void)
169static int get_num_wrp_resources(void) 169static int get_num_wrp_resources(void)
170{ 170{
171 u32 didr; 171 u32 didr;
172 ARM_DBG_READ(c0, 0, didr); 172 ARM_DBG_READ(c0, c0, 0, didr);
173 return ((didr >> 28) & 0xf) + 1; 173 return ((didr >> 28) & 0xf) + 1;
174} 174}
175 175
@@ -177,7 +177,7 @@ static int get_num_wrp_resources(void)
177static int get_num_brp_resources(void) 177static int get_num_brp_resources(void)
178{ 178{
179 u32 didr; 179 u32 didr;
180 ARM_DBG_READ(c0, 0, didr); 180 ARM_DBG_READ(c0, c0, 0, didr);
181 return ((didr >> 24) & 0xf) + 1; 181 return ((didr >> 24) & 0xf) + 1;
182} 182}
183 183
@@ -231,14 +231,14 @@ static int get_num_brps(void)
231static int monitor_mode_enabled(void) 231static int monitor_mode_enabled(void)
232{ 232{
233 u32 dscr; 233 u32 dscr;
234 ARM_DBG_READ(c1, 0, dscr); 234 ARM_DBG_READ(c0, c1, 0, dscr);
235 return !!(dscr & ARM_DSCR_MDBGEN); 235 return !!(dscr & ARM_DSCR_MDBGEN);
236} 236}
237 237
238static int enable_monitor_mode(void) 238static int enable_monitor_mode(void)
239{ 239{
240 u32 dscr; 240 u32 dscr;
241 ARM_DBG_READ(c1, 0, dscr); 241 ARM_DBG_READ(c0, c1, 0, dscr);
242 242
243 /* If monitor mode is already enabled, just return. */ 243 /* If monitor mode is already enabled, just return. */
244 if (dscr & ARM_DSCR_MDBGEN) 244 if (dscr & ARM_DSCR_MDBGEN)
@@ -248,11 +248,11 @@ static int enable_monitor_mode(void)
248 switch (get_debug_arch()) { 248 switch (get_debug_arch()) {
249 case ARM_DEBUG_ARCH_V6: 249 case ARM_DEBUG_ARCH_V6:
250 case ARM_DEBUG_ARCH_V6_1: 250 case ARM_DEBUG_ARCH_V6_1:
251 ARM_DBG_WRITE(c1, 0, (dscr | ARM_DSCR_MDBGEN)); 251 ARM_DBG_WRITE(c0, c1, 0, (dscr | ARM_DSCR_MDBGEN));
252 break; 252 break;
253 case ARM_DEBUG_ARCH_V7_ECP14: 253 case ARM_DEBUG_ARCH_V7_ECP14:
254 case ARM_DEBUG_ARCH_V7_1: 254 case ARM_DEBUG_ARCH_V7_1:
255 ARM_DBG_WRITE(c2, 2, (dscr | ARM_DSCR_MDBGEN)); 255 ARM_DBG_WRITE(c0, c2, 2, (dscr | ARM_DSCR_MDBGEN));
256 isb(); 256 isb();
257 break; 257 break;
258 default: 258 default:
@@ -260,7 +260,7 @@ static int enable_monitor_mode(void)
260 } 260 }
261 261
262 /* Check that the write made it through. */ 262 /* Check that the write made it through. */
263 ARM_DBG_READ(c1, 0, dscr); 263 ARM_DBG_READ(c0, c1, 0, dscr);
264 if (WARN_ONCE(!(dscr & ARM_DSCR_MDBGEN), 264 if (WARN_ONCE(!(dscr & ARM_DSCR_MDBGEN),
265 "Failed to enable monitor mode on CPU %d.\n", 265 "Failed to enable monitor mode on CPU %d.\n",
266 smp_processor_id())) 266 smp_processor_id()))
@@ -853,7 +853,7 @@ static int hw_breakpoint_pending(unsigned long addr, unsigned int fsr,
853 local_irq_enable(); 853 local_irq_enable();
854 854
855 /* We only handle watchpoints and hardware breakpoints. */ 855 /* We only handle watchpoints and hardware breakpoints. */
856 ARM_DBG_READ(c1, 0, dscr); 856 ARM_DBG_READ(c0, c1, 0, dscr);
857 857
858 /* Perform perf callbacks. */ 858 /* Perform perf callbacks. */
859 switch (ARM_DSCR_MOE(dscr)) { 859 switch (ARM_DSCR_MOE(dscr)) {
@@ -921,14 +921,14 @@ static void reset_ctrl_regs(void *unused)
921 * Ensure sticky power-down is clear (i.e. debug logic is 921 * Ensure sticky power-down is clear (i.e. debug logic is
922 * powered up). 922 * powered up).
923 */ 923 */
924 asm volatile("mrc p14, 0, %0, c1, c5, 4" : "=r" (val)); 924 ARM_DBG_READ(c1, c5, 4, val);
925 if ((val & 0x1) == 0) 925 if ((val & 0x1) == 0)
926 err = -EPERM; 926 err = -EPERM;
927 927
928 /* 928 /*
929 * Check whether we implement OS save and restore. 929 * Check whether we implement OS save and restore.
930 */ 930 */
931 asm volatile("mrc p14, 0, %0, c1, c1, 4" : "=r" (val)); 931 ARM_DBG_READ(c1, c1, 4, val);
932 if ((val & 0x9) == 0) 932 if ((val & 0x9) == 0)
933 goto clear_vcr; 933 goto clear_vcr;
934 break; 934 break;
@@ -936,7 +936,7 @@ static void reset_ctrl_regs(void *unused)
936 /* 936 /*
937 * Ensure the OS double lock is clear. 937 * Ensure the OS double lock is clear.
938 */ 938 */
939 asm volatile("mrc p14, 0, %0, c1, c3, 4" : "=r" (val)); 939 ARM_DBG_READ(c1, c3, 4, val);
940 if ((val & 0x1) == 1) 940 if ((val & 0x1) == 1)
941 err = -EPERM; 941 err = -EPERM;
942 break; 942 break;
@@ -952,7 +952,7 @@ static void reset_ctrl_regs(void *unused)
952 * Unconditionally clear the OS lock by writing a value 952 * Unconditionally clear the OS lock by writing a value
953 * other than 0xC5ACCE55 to the access register. 953 * other than 0xC5ACCE55 to the access register.
954 */ 954 */
955 asm volatile("mcr p14, 0, %0, c1, c0, 4" : : "r" (0)); 955 ARM_DBG_WRITE(c1, c0, 4, 0);
956 isb(); 956 isb();
957 957
958 /* 958 /*
@@ -960,7 +960,7 @@ static void reset_ctrl_regs(void *unused)
960 * enabling monitor mode. 960 * enabling monitor mode.
961 */ 961 */
962clear_vcr: 962clear_vcr:
963 asm volatile("mcr p14, 0, %0, c0, c7, 0" : : "r" (0)); 963 ARM_DBG_WRITE(c0, c7, 0, 0);
964 isb(); 964 isb();
965 965
966 if (cpumask_intersects(&debug_err_mask, cpumask_of(cpu))) { 966 if (cpumask_intersects(&debug_err_mask, cpumask_of(cpu))) {