diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2015-06-25 04:16:57 -0400 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2015-07-09 08:06:33 -0400 |
commit | 9138d4138d8e1f0acf734d2fb3455108bf43380f (patch) | |
tree | 4e2b8f33d65fe05d21cca03d465530f88b8f3fc5 /arch/arc | |
parent | 70d93d89416562c32adc9444a15677bdf25a72ab (diff) |
ARC: Add llock/scond to futex backend
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'arch/arc')
-rw-r--r-- | arch/arc/include/asm/futex.h | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/arch/arc/include/asm/futex.h b/arch/arc/include/asm/futex.h index 05b5aaf5b0f9..70cfe16b742d 100644 --- a/arch/arc/include/asm/futex.h +++ b/arch/arc/include/asm/futex.h | |||
@@ -16,12 +16,40 @@ | |||
16 | #include <linux/uaccess.h> | 16 | #include <linux/uaccess.h> |
17 | #include <asm/errno.h> | 17 | #include <asm/errno.h> |
18 | 18 | ||
19 | #ifdef CONFIG_ARC_HAS_LLSC | ||
20 | |||
21 | #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg)\ | ||
22 | \ | ||
23 | __asm__ __volatile__( \ | ||
24 | "1: llock %1, [%2] \n" \ | ||
25 | insn "\n" \ | ||
26 | "2: scond %0, [%2] \n" \ | ||
27 | " bnz 1b \n" \ | ||
28 | " mov %0, 0 \n" \ | ||
29 | "3: \n" \ | ||
30 | " .section .fixup,\"ax\" \n" \ | ||
31 | " .align 4 \n" \ | ||
32 | "4: mov %0, %4 \n" \ | ||
33 | " b 3b \n" \ | ||
34 | " .previous \n" \ | ||
35 | " .section __ex_table,\"a\" \n" \ | ||
36 | " .align 4 \n" \ | ||
37 | " .word 1b, 4b \n" \ | ||
38 | " .word 2b, 4b \n" \ | ||
39 | " .previous \n" \ | ||
40 | \ | ||
41 | : "=&r" (ret), "=&r" (oldval) \ | ||
42 | : "r" (uaddr), "r" (oparg), "ir" (-EFAULT) \ | ||
43 | : "cc", "memory") | ||
44 | |||
45 | #else /* !CONFIG_ARC_HAS_LLSC */ | ||
46 | |||
19 | #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg)\ | 47 | #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg)\ |
20 | \ | 48 | \ |
21 | __asm__ __volatile__( \ | 49 | __asm__ __volatile__( \ |
22 | "1: ld %1, [%2] \n" \ | 50 | "1: ld %1, [%2] \n" \ |
23 | insn "\n" \ | 51 | insn "\n" \ |
24 | "2: st %0, [%2] \n" \ | 52 | "2: st %0, [%2] \n" \ |
25 | " mov %0, 0 \n" \ | 53 | " mov %0, 0 \n" \ |
26 | "3: \n" \ | 54 | "3: \n" \ |
27 | " .section .fixup,\"ax\" \n" \ | 55 | " .section .fixup,\"ax\" \n" \ |
@@ -39,6 +67,8 @@ | |||
39 | : "r" (uaddr), "r" (oparg), "ir" (-EFAULT) \ | 67 | : "r" (uaddr), "r" (oparg), "ir" (-EFAULT) \ |
40 | : "cc", "memory") | 68 | : "cc", "memory") |
41 | 69 | ||
70 | #endif | ||
71 | |||
42 | static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) | 72 | static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) |
43 | { | 73 | { |
44 | int op = (encoded_op >> 28) & 7; | 74 | int op = (encoded_op >> 28) & 7; |
@@ -123,11 +153,17 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, u32 oldval, | |||
123 | 153 | ||
124 | pagefault_disable(); | 154 | pagefault_disable(); |
125 | 155 | ||
126 | /* TBD : can use llock/scond */ | ||
127 | __asm__ __volatile__( | 156 | __asm__ __volatile__( |
128 | "1: ld %0, [%3] \n" | 157 | #ifdef CONFIG_ARC_HAS_LLSC |
129 | " brne %0, %1, 3f \n" | 158 | "1: llock %0, [%3] \n" |
130 | "2: st %2, [%3] \n" | 159 | " brne %0, %1, 3f \n" |
160 | "2: scond %2, [%3] \n" | ||
161 | " bnz 1b \n" | ||
162 | #else | ||
163 | "1: ld %0, [%3] \n" | ||
164 | " brne %0, %1, 3f \n" | ||
165 | "2: st %2, [%3] \n" | ||
166 | #endif | ||
131 | "3: \n" | 167 | "3: \n" |
132 | " .section .fixup,\"ax\" \n" | 168 | " .section .fixup,\"ax\" \n" |
133 | "4: mov %0, %4 \n" | 169 | "4: mov %0, %4 \n" |