Skip to content

Commit 6312e11

Browse files
committed
ARC: Add llock/scond to futex backend
Signed-off-by: Vineet Gupta <[email protected]>
1 parent c9de296 commit 6312e11

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

arch/arc/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ if ISA_ARCOMPACT
119119

120120
config ARC_CPU_750D
121121
bool "ARC750D"
122+
select ARC_CANT_LLSC
122123
help
123124
Support for ARC750 core
124125

@@ -355,7 +356,7 @@ config ARC_CANT_LLSC
355356
config ARC_HAS_LLSC
356357
bool "Insn: LLOCK/SCOND (efficient atomic ops)"
357358
default y
358-
depends on !ARC_CPU_750D && !ARC_CANT_LLSC
359+
depends on !ARC_CANT_LLSC
359360

360361
config ARC_HAS_SWAPE
361362
bool "Insn: SWAPE (endian-swap)"

arch/arc/include/asm/futex.h

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,40 @@
1616
#include <linux/uaccess.h>
1717
#include <asm/errno.h>
1818

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+
1947
#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg)\
2048
\
2149
__asm__ __volatile__( \
22-
"1: ld %1, [%2] \n" \
50+
"1: ld %1, [%2] \n" \
2351
insn "\n" \
24-
"2: st %0, [%2] \n" \
52+
"2: st %0, [%2] \n" \
2553
" mov %0, 0 \n" \
2654
"3: \n" \
2755
" .section .fixup,\"ax\" \n" \
@@ -39,6 +67,8 @@
3967
: "r" (uaddr), "r" (oparg), "ir" (-EFAULT) \
4068
: "cc", "memory")
4169

70+
#endif
71+
4272
static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
4373
{
4474
int op = (encoded_op >> 28) & 7;
@@ -123,11 +153,17 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, u32 oldval,
123153

124154
pagefault_disable(); /* implies preempt_disable() */
125155

126-
/* TBD : can use llock/scond */
127156
__asm__ __volatile__(
128-
"1: ld %0, [%3] \n"
129-
" brne %0, %1, 3f \n"
130-
"2: st %2, [%3] \n"
157+
#ifdef CONFIG_ARC_HAS_LLSC
158+
"1: llock %0, [%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
131167
"3: \n"
132168
" .section .fixup,\"ax\" \n"
133169
"4: mov %0, %4 \n"

0 commit comments

Comments
 (0)