Skip to content

Commit ea7caff

Browse files
jgunthorpevineetgarc
authored andcommitted
ARC: atomics: Implement arch_atomic64_cmpxchg using _relaxed
The core atomic code has a number of macros where it elaborates architecture primitives into more functions. ARC uses arch_atomic64_cmpxchg() as it's architecture primitive which disable alot of the additional functions. Instead provide arch_cmpxchg64_relaxed() as the primitive and rely on the core macros to create arch_cmpxchg64(). The macros will also provide other functions, for instance, try_cmpxchg64_release(), giving a more complete implementation. Suggested-by: Mark Rutland <[email protected]> Link: https://lore.kernel.org/r/Z0747n5bSep4_1VX@J2N7QTR9R3 Signed-off-by: Jason Gunthorpe <[email protected]> Signed-off-by: Vineet Gupta <[email protected]>
1 parent 19272b3 commit ea7caff

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

arch/arc/include/asm/atomic64-arcv2.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,9 @@ ATOMIC64_OPS(xor, xor, xor)
137137
#undef ATOMIC64_OP_RETURN
138138
#undef ATOMIC64_OP
139139

140-
static inline s64
141-
arch_atomic64_cmpxchg(atomic64_t *ptr, s64 expected, s64 new)
140+
static inline u64 __arch_cmpxchg64_relaxed(volatile void *ptr, u64 old, u64 new)
142141
{
143-
s64 prev;
144-
145-
smp_mb();
142+
u64 prev;
146143

147144
__asm__ __volatile__(
148145
"1: llockd %0, [%1] \n"
@@ -152,14 +149,12 @@ arch_atomic64_cmpxchg(atomic64_t *ptr, s64 expected, s64 new)
152149
" bnz 1b \n"
153150
"2: \n"
154151
: "=&r"(prev)
155-
: "r"(ptr), "ir"(expected), "r"(new)
156-
: "cc"); /* memory clobber comes from smp_mb() */
157-
158-
smp_mb();
152+
: "r"(ptr), "ir"(old), "r"(new)
153+
: "memory", "cc");
159154

160155
return prev;
161156
}
162-
#define arch_atomic64_cmpxchg arch_atomic64_cmpxchg
157+
#define arch_cmpxchg64_relaxed __arch_cmpxchg64_relaxed
163158

164159
static inline s64 arch_atomic64_xchg(atomic64_t *ptr, s64 new)
165160
{

0 commit comments

Comments
 (0)