Skip to content

Commit f2519d4

Browse files
committed
ARC: Emulate one-byte cmpxchg
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 <[email protected]> Cc: Andi Shyti <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: <[email protected]> Acked-by: Vineet Gupta <[email protected]>
1 parent 8400291 commit f2519d4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

arch/arc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ config ARC
1313
select ARCH_HAS_SETUP_DMA_OPS
1414
select ARCH_HAS_SYNC_DMA_FOR_CPU
1515
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
16+
select ARCH_NEED_CMPXCHG_1_EMU
1617
select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC
1718
select ARCH_32BIT_OFF_T
1819
select BUILDTIME_TABLE_SORT

arch/arc/include/asm/cmpxchg.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/build_bug.h>
1010
#include <linux/types.h>
11+
#include <linux/cmpxchg-emu.h>
1112

1213
#include <asm/barrier.h>
1314
#include <asm/smp.h>
@@ -46,6 +47,9 @@
4647
__typeof__(*(ptr)) _prev_; \
4748
\
4849
switch(sizeof((_p_))) { \
50+
case 1: \
51+
_prev_ = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)_p_, (uintptr_t)_o_, (uintptr_t)_n_); \
52+
break; \
4953
case 4: \
5054
_prev_ = __cmpxchg(_p_, _o_, _n_); \
5155
break; \
@@ -65,8 +69,6 @@
6569
__typeof__(*(ptr)) _prev_; \
6670
unsigned long __flags; \
6771
\
68-
BUILD_BUG_ON(sizeof(_p_) != 4); \
69-
\
7072
/* \
7173
* spin lock/unlock provide the needed smp_mb() before/after \
7274
*/ \

0 commit comments

Comments
 (0)