Skip to content

Commit 5800e77

Browse files
committed
csky: Emulate one-byte cmpxchg
Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on csky. [ paulmck: Apply kernel test robot feedback. ] [ paulmck: Drop two-byte support per Arnd Bergmann feedback. ] Co-developed-by: Yujie Liu <[email protected]> Signed-off-by: Yujie Liu <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Tested-by: Yujie Liu <[email protected]> Reviewed-by: Guo Ren <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: <[email protected]>
1 parent a88d970 commit 5800e77

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

arch/csky/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ config CSKY
3737
select ARCH_INLINE_SPIN_UNLOCK_BH if !PREEMPTION
3838
select ARCH_INLINE_SPIN_UNLOCK_IRQ if !PREEMPTION
3939
select ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE if !PREEMPTION
40+
select ARCH_NEED_CMPXCHG_1_EMU
4041
select ARCH_WANT_FRAME_POINTERS if !CPU_CK610 && $(cc-option,-mbacktrace)
4142
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
4243
select COMMON_CLK

arch/csky/include/asm/cmpxchg.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifdef CONFIG_SMP
77
#include <linux/bug.h>
88
#include <asm/barrier.h>
9+
#include <linux/cmpxchg-emu.h>
910

1011
#define __xchg_relaxed(new, ptr, size) \
1112
({ \
@@ -61,6 +62,9 @@
6162
__typeof__(old) __old = (old); \
6263
__typeof__(*(ptr)) __ret; \
6364
switch (size) { \
65+
case 1: \
66+
__ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \
67+
break; \
6468
case 4: \
6569
asm volatile ( \
6670
"1: ldex.w %0, (%3) \n" \
@@ -91,6 +95,9 @@
9195
__typeof__(old) __old = (old); \
9296
__typeof__(*(ptr)) __ret; \
9397
switch (size) { \
98+
case 1: \
99+
__ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \
100+
break; \
94101
case 4: \
95102
asm volatile ( \
96103
"1: ldex.w %0, (%3) \n" \
@@ -122,6 +129,9 @@
122129
__typeof__(old) __old = (old); \
123130
__typeof__(*(ptr)) __ret; \
124131
switch (size) { \
132+
case 1: \
133+
__ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \
134+
break; \
125135
case 4: \
126136
asm volatile ( \
127137
RELEASE_FENCE \

0 commit comments

Comments
 (0)