]> www.infradead.org Git - linux.git/commitdiff
ARC: Emulate one-byte cmpxchg
authorPaul E. McKenney <paulmck@kernel.org>
Mon, 18 Mar 2024 08:27:35 +0000 (01:27 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Fri, 13 Sep 2024 14:10:37 +0000 (07:10 -0700)
Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on arc.

[ paulmck: Drop two-byte support per Arnd Bergmann feedback. ]
[ paulmck: Apply feedback from Naresh Kamboju. ]
[ paulmck: Apply kernel test robot feedback. ]
[ paulmck: Apply feedback from Vineet Gupta. ]

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Andi Shyti <andi.shyti@linux.intel.com>
Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Palmer Dabbelt <palmer@rivosinc.com>
Cc: <linux-snps-arc@lists.infradead.org>
Acked-by: Vineet Gupta <vgupta@kernel.org>
arch/arc/Kconfig
arch/arc/include/asm/cmpxchg.h

index fd0b0a0d4686ac2e110bf57538c6759fb2a41b65..163608fd49d189fa35e48fc2a03ac61714cb66de 100644 (file)
@@ -13,6 +13,7 @@ config ARC
        select ARCH_HAS_SETUP_DMA_OPS
        select ARCH_HAS_SYNC_DMA_FOR_CPU
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE
+       select ARCH_NEED_CMPXCHG_1_EMU
        select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC
        select ARCH_32BIT_OFF_T
        select BUILDTIME_TABLE_SORT
index e138fde067dea53d6c17d0520521f0a88a4c0dd2..58045c898340458da6e8e02f653ace55a05253c9 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/build_bug.h>
 #include <linux/types.h>
+#include <linux/cmpxchg-emu.h>
 
 #include <asm/barrier.h>
 #include <asm/smp.h>
@@ -46,6 +47,9 @@
        __typeof__(*(ptr)) _prev_;                                      \
                                                                        \
        switch(sizeof((_p_))) {                                         \
+       case 1:                                                         \
+               _prev_ = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)_p_, (uintptr_t)_o_, (uintptr_t)_n_);        \
+               break;                                                  \
        case 4:                                                         \
                _prev_ = __cmpxchg(_p_, _o_, _n_);                      \
                break;                                                  \
@@ -65,8 +69,6 @@
        __typeof__(*(ptr)) _prev_;                                      \
        unsigned long __flags;                                          \
                                                                        \
-       BUILD_BUG_ON(sizeof(_p_) != 4);                                 \
-                                                                       \
        /*                                                              \
         * spin lock/unlock provide the needed smp_mb() before/after    \
         */                                                             \