Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <yujie.liu@intel.com>
Signed-off-by: Yujie Liu <yujie.liu@intel.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Tested-by: Yujie Liu <yujie.liu@intel.com>
Reviewed-by: Guo Ren <guoren@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: <linux-csky@vger.kernel.org>

+11
+1
arch/csky/Kconfig
··· 37 37 select ARCH_INLINE_SPIN_UNLOCK_BH if !PREEMPTION 38 38 select ARCH_INLINE_SPIN_UNLOCK_IRQ if !PREEMPTION 39 39 select ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE if !PREEMPTION 40 + select ARCH_NEED_CMPXCHG_1_EMU 40 41 select ARCH_WANT_FRAME_POINTERS if !CPU_CK610 && $(cc-option,-mbacktrace) 41 42 select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT 42 43 select COMMON_CLK
+10
arch/csky/include/asm/cmpxchg.h
··· 6 6 #ifdef CONFIG_SMP 7 7 #include <linux/bug.h> 8 8 #include <asm/barrier.h> 9 + #include <linux/cmpxchg-emu.h> 9 10 10 11 #define __xchg_relaxed(new, ptr, size) \ 11 12 ({ \ ··· 62 61 __typeof__(old) __old = (old); \ 63 62 __typeof__(*(ptr)) __ret; \ 64 63 switch (size) { \ 64 + case 1: \ 65 + __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ 66 + break; \ 65 67 case 4: \ 66 68 asm volatile ( \ 67 69 "1: ldex.w %0, (%3) \n" \ ··· 95 91 __typeof__(old) __old = (old); \ 96 92 __typeof__(*(ptr)) __ret; \ 97 93 switch (size) { \ 94 + case 1: \ 95 + __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ 96 + break; \ 98 97 case 4: \ 99 98 asm volatile ( \ 100 99 "1: ldex.w %0, (%3) \n" \ ··· 129 122 __typeof__(old) __old = (old); \ 130 123 __typeof__(*(ptr)) __ret; \ 131 124 switch (size) { \ 125 + case 1: \ 126 + __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ 127 + break; \ 132 128 case 4: \ 133 129 asm volatile ( \ 134 130 RELEASE_FENCE \