diff options
author | Maciej W. Rozycki <macro@linux-mips.org> | 2014-03-31 19:57:28 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-05-12 18:29:36 -0400 |
commit | 2db4bc3418c43f1e810b304c48f8ddff2535075b (patch) | |
tree | 70aecfaca9e45a7b2685ef3fb65f0cdf3f595e3a /arch/mips/lib/delay.c | |
parent | 824122a319d827d42aeb4646a3bf639937fdb2ce (diff) |
MIPS: __delay CPU_DADDI_WORKAROUNDS bug fix
With CPU_DADDI_WORKAROUNDS enabled __delay assembles with a macro in a
branch delay slot:
{standard input}: Assembler messages:
{standard input}:18: Warning: Macro instruction expanded into multiple
instructions in a branch delay slot
and broken code results:
0000000000000000 <__delay>:
0: 1480ffff bnez a0,0 <__delay>
4: 24010001 li at,1
8: 0081202f dsubu a0,a0,at
c: 03e00008 jr ra
10: 00000000 nop
14: 00000000 nop
Consequently the function loops indefinitely, showing up prominently as a
hang in the delay loop calibration at bootstrap.
This change corrects the problem by forcing the immediate 1 into a
register while keeping code produced identical where CPU_DADDI_WORKAROUNDS
is disabled.
Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/6669/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/lib/delay.c')
-rw-r--r-- | arch/mips/lib/delay.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/arch/mips/lib/delay.c b/arch/mips/lib/delay.c index 44713af15a62..705cfb7c1a74 100644 --- a/arch/mips/lib/delay.c +++ b/arch/mips/lib/delay.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Copyright (C) 1994 by Waldorf Electronics | 6 | * Copyright (C) 1994 by Waldorf Electronics |
7 | * Copyright (C) 1995 - 2000, 01, 03 by Ralf Baechle | 7 | * Copyright (C) 1995 - 2000, 01, 03 by Ralf Baechle |
8 | * Copyright (C) 1999, 2000 Silicon Graphics, Inc. | 8 | * Copyright (C) 1999, 2000 Silicon Graphics, Inc. |
9 | * Copyright (C) 2007 Maciej W. Rozycki | 9 | * Copyright (C) 2007, 2014 Maciej W. Rozycki |
10 | */ | 10 | */ |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/param.h> | 12 | #include <linux/param.h> |
@@ -15,6 +15,12 @@ | |||
15 | #include <asm/compiler.h> | 15 | #include <asm/compiler.h> |
16 | #include <asm/war.h> | 16 | #include <asm/war.h> |
17 | 17 | ||
18 | #ifndef CONFIG_CPU_DADDI_WORKAROUNDS | ||
19 | #define GCC_DADDI_IMM_ASM() "I" | ||
20 | #else | ||
21 | #define GCC_DADDI_IMM_ASM() "r" | ||
22 | #endif | ||
23 | |||
18 | void __delay(unsigned long loops) | 24 | void __delay(unsigned long loops) |
19 | { | 25 | { |
20 | __asm__ __volatile__ ( | 26 | __asm__ __volatile__ ( |
@@ -22,13 +28,13 @@ void __delay(unsigned long loops) | |||
22 | " .align 3 \n" | 28 | " .align 3 \n" |
23 | "1: bnez %0, 1b \n" | 29 | "1: bnez %0, 1b \n" |
24 | #if BITS_PER_LONG == 32 | 30 | #if BITS_PER_LONG == 32 |
25 | " subu %0, 1 \n" | 31 | " subu %0, %1 \n" |
26 | #else | 32 | #else |
27 | " dsubu %0, 1 \n" | 33 | " dsubu %0, %1 \n" |
28 | #endif | 34 | #endif |
29 | " .set reorder \n" | 35 | " .set reorder \n" |
30 | : "=r" (loops) | 36 | : "=r" (loops) |
31 | : "0" (loops)); | 37 | : GCC_DADDI_IMM_ASM() (1), "0" (loops)); |
32 | } | 38 | } |
33 | EXPORT_SYMBOL(__delay); | 39 | EXPORT_SYMBOL(__delay); |
34 | 40 | ||