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.
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCgAxFiEEbK7UrM+RBIrCoViJnr8S83LZ+4wFAmbkTmETHHBhdWxtY2tA
 a2VybmVsLm9yZwAKCRCevxLzctn7jK0iD/9fdgX46HZhR2iGH6kHeBR5teXpvLQw
 2SR/e1WyqhuyhqDHknskMMqVg2uCpIw6qihp1pm+4ZmEsR+jwkA10fc4wnYI7cdf
 Zce/crItXAum4V79ykUO2gKlpuyGJXelrnSuZjPJAa9VXSDSZ/nhibSNFWCaGVrU
 29Qy/BBC/I4tlHuV7SSJKfnYv8GnpGPAuFDQd5Hxj8eWUtu+RAfzt9grBkCoSWWY
 5zSmPZEvbjVtpkPJcNf03OlU6s028p3PY2TW623plbRo998r07NzkoO96Ml1HlCv
 6TMLUptaImyqEr2bLGJ/YB1B8A+Hbmd9xgsWF3EwGgaS8F+2tuvKd4trcOrZ5NKn
 6xMAqUC58BnW7HOPaNqwP3agExVvfFq+ZBZQj/S4feWL4TrT8JfgmVvtkzUGO5DD
 TJOgcsjbcAt39Qli3ckfaZ8AVk9ZjHvGK0M7wcSqsPvhM355VCyyw2Ea/x9/cjn5
 D6BjMnZzbEuDx6u+/mCOuUYvokus+leMhaxnmWnc66Yf60kQUsNKJzoCaeaFzhKv
 h5B5J1jiwsyIFE9+TcQ5YBQCuAsqthKzROUP+WiNV1b59qHGJugasju2ufiodTzc
 TkCWSVrKtwEwldPjyIKXXoOMMKe1XkYPYbRyXjyTs/PiaByKM9nVbKnJqu26XlTm
 JF8N4+nNQvT2Sw==
 =FObp
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2024-09-16 07:34:24 +02:00
commit 980bcd35ae
6 changed files with 12 additions and 2 deletions

View 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

View 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 \
*/ \

View File

@ -14,6 +14,7 @@ config SUPERH
select ARCH_HIBERNATION_POSSIBLE if MMU
select ARCH_MIGHT_HAVE_PC_PARPORT
select ARCH_WANT_IPC_PARSE_VERSION
select ARCH_NEED_CMPXCHG_1_EMU
select CPU_NO_EFFICIENT_FFS
select DMA_DECLARE_COHERENT
select GENERIC_ATOMIC64

View File

@ -9,6 +9,7 @@
#include <linux/compiler.h>
#include <linux/types.h>
#include <linux/cmpxchg-emu.h>
#if defined(CONFIG_GUSA_RB)
#include <asm/cmpxchg-grb.h>
@ -56,6 +57,8 @@ static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old,
unsigned long new, int size)
{
switch (size) {
case 1:
return cmpxchg_emu_u8(ptr, old, new);
case 4:
return __cmpxchg_u32(ptr, old, new);
}

View File

@ -14,6 +14,7 @@ config XTENSA
select ARCH_HAS_DMA_SET_UNCACHED if MMU
select ARCH_HAS_STRNCPY_FROM_USER if !KASAN
select ARCH_HAS_STRNLEN_USER
select ARCH_NEED_CMPXCHG_1_EMU
select ARCH_USE_MEMTEST
select ARCH_USE_QUEUED_RWLOCKS
select ARCH_USE_QUEUED_SPINLOCKS

View File

@ -15,6 +15,7 @@
#include <linux/bits.h>
#include <linux/stringify.h>
#include <linux/cmpxchg-emu.h>
/*
* cmpxchg
@ -74,6 +75,7 @@ static __inline__ unsigned long
__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
{
switch (size) {
case 1: return cmpxchg_emu_u8(ptr, old, new);
case 4: return __cmpxchg_u32(ptr, old, new);
default: __cmpxchg_called_with_bad_pointer();
return old;