mips/atomic: Fix cmpxchg64 barriers
authorPeter Zijlstra <peterz@infradead.org>
Thu, 13 Jun 2019 13:43:18 +0000 (15:43 +0200)
committerPaul Burton <paul.burton@mips.com>
Sat, 31 Aug 2019 10:03:46 +0000 (11:03 +0100)
There were no memory barriers on the 32bit implementation of
cmpxchg64(). Fix this.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Paul Burton <paul.burton@mips.com>
arch/mips/include/asm/cmpxchg.h

index f345a87..59cf5cb 100644 (file)
@@ -290,10 +290,13 @@ static inline unsigned long __cmpxchg64(volatile void *ptr,
         * will cause a build error unless cpu_has_64bits is a          \
         * compile-time constant 1.                                     \
         */                                                             \
-       if (cpu_has_64bits && kernel_uses_llsc)                         \
+       if (cpu_has_64bits && kernel_uses_llsc) {                       \
+               smp_mb__before_llsc();                                  \
                __res = __cmpxchg64((ptr), __old, __new);               \
-       else                                                            \
+               smp_llsc_mb();                                          \
+       } else {                                                        \
                __res = __cmpxchg64_unsupported();                      \
+       }                                                               \
                                                                        \
        __res;                                                          \
 })