Commit 980bcd35 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'cmpxchg.2024.09.15a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu

Pull byte cmpxchg updates from Paul McKenney:
 "ARC/sh/xtensa: Provide one-byte cmpxchg emulation

  This series provides emulated one-byte cmpxchg() support for ARM, sh,
  and xtensa using the cmpxchg_emu_u8() function that uses a four-byte
  cmpxchg() to emulate the one-byte variant.

  This covers all architectures"

* tag 'cmpxchg.2024.09.15a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu:
  xtensa: Emulate one-byte cmpxchg
  sh: Emulate one-byte cmpxchg
  ARC: Emulate one-byte cmpxchg
parents 114143a5 e799bef0
...@@ -13,6 +13,7 @@ config ARC ...@@ -13,6 +13,7 @@ config ARC
select ARCH_HAS_SETUP_DMA_OPS select ARCH_HAS_SETUP_DMA_OPS
select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYNC_DMA_FOR_DEVICE select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select ARCH_NEED_CMPXCHG_1_EMU
select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC
select ARCH_32BIT_OFF_T select ARCH_32BIT_OFF_T
select BUILDTIME_TABLE_SORT select BUILDTIME_TABLE_SORT
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/build_bug.h> #include <linux/build_bug.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/cmpxchg-emu.h>
#include <asm/barrier.h> #include <asm/barrier.h>
#include <asm/smp.h> #include <asm/smp.h>
...@@ -46,6 +47,9 @@ ...@@ -46,6 +47,9 @@
__typeof__(*(ptr)) _prev_; \ __typeof__(*(ptr)) _prev_; \
\ \
switch(sizeof((_p_))) { \ switch(sizeof((_p_))) { \
case 1: \
_prev_ = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)_p_, (uintptr_t)_o_, (uintptr_t)_n_); \
break; \
case 4: \ case 4: \
_prev_ = __cmpxchg(_p_, _o_, _n_); \ _prev_ = __cmpxchg(_p_, _o_, _n_); \
break; \ break; \
...@@ -65,8 +69,6 @@ ...@@ -65,8 +69,6 @@
__typeof__(*(ptr)) _prev_; \ __typeof__(*(ptr)) _prev_; \
unsigned long __flags; \ unsigned long __flags; \
\ \
BUILD_BUG_ON(sizeof(_p_) != 4); \
\
/* \ /* \
* spin lock/unlock provide the needed smp_mb() before/after \ * spin lock/unlock provide the needed smp_mb() before/after \
*/ \ */ \
......
...@@ -14,6 +14,7 @@ config SUPERH ...@@ -14,6 +14,7 @@ config SUPERH
select ARCH_HIBERNATION_POSSIBLE if MMU select ARCH_HIBERNATION_POSSIBLE if MMU
select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_PARPORT
select ARCH_WANT_IPC_PARSE_VERSION select ARCH_WANT_IPC_PARSE_VERSION
select ARCH_NEED_CMPXCHG_1_EMU
select CPU_NO_EFFICIENT_FFS select CPU_NO_EFFICIENT_FFS
select DMA_DECLARE_COHERENT select DMA_DECLARE_COHERENT
select GENERIC_ATOMIC64 select GENERIC_ATOMIC64
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/cmpxchg-emu.h>
#if defined(CONFIG_GUSA_RB) #if defined(CONFIG_GUSA_RB)
#include <asm/cmpxchg-grb.h> #include <asm/cmpxchg-grb.h>
...@@ -56,6 +57,8 @@ static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old, ...@@ -56,6 +57,8 @@ static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old,
unsigned long new, int size) unsigned long new, int size)
{ {
switch (size) { switch (size) {
case 1:
return cmpxchg_emu_u8(ptr, old, new);
case 4: case 4:
return __cmpxchg_u32(ptr, old, new); return __cmpxchg_u32(ptr, old, new);
} }
......
...@@ -14,6 +14,7 @@ config XTENSA ...@@ -14,6 +14,7 @@ config XTENSA
select ARCH_HAS_DMA_SET_UNCACHED if MMU select ARCH_HAS_DMA_SET_UNCACHED if MMU
select ARCH_HAS_STRNCPY_FROM_USER if !KASAN select ARCH_HAS_STRNCPY_FROM_USER if !KASAN
select ARCH_HAS_STRNLEN_USER select ARCH_HAS_STRNLEN_USER
select ARCH_NEED_CMPXCHG_1_EMU
select ARCH_USE_MEMTEST select ARCH_USE_MEMTEST
select ARCH_USE_QUEUED_RWLOCKS select ARCH_USE_QUEUED_RWLOCKS
select ARCH_USE_QUEUED_SPINLOCKS select ARCH_USE_QUEUED_SPINLOCKS
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/bits.h> #include <linux/bits.h>
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/cmpxchg-emu.h>
/* /*
* cmpxchg * cmpxchg
...@@ -74,6 +75,7 @@ static __inline__ unsigned long ...@@ -74,6 +75,7 @@ static __inline__ unsigned long
__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
{ {
switch (size) { switch (size) {
case 1: return cmpxchg_emu_u8(ptr, old, new);
case 4: return __cmpxchg_u32(ptr, old, new); case 4: return __cmpxchg_u32(ptr, old, new);
default: __cmpxchg_called_with_bad_pointer(); default: __cmpxchg_called_with_bad_pointer();
return old; return old;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment