Skip to content

Commit 980bcd3

Browse files
committed
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
2 parents 114143a + e799bef commit 980bcd3

File tree

6 files changed

+12
-2
lines changed

6 files changed

+12
-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
*/ \

arch/sh/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ config SUPERH
1414
select ARCH_HIBERNATION_POSSIBLE if MMU
1515
select ARCH_MIGHT_HAVE_PC_PARPORT
1616
select ARCH_WANT_IPC_PARSE_VERSION
17+
select ARCH_NEED_CMPXCHG_1_EMU
1718
select CPU_NO_EFFICIENT_FFS
1819
select DMA_DECLARE_COHERENT
1920
select GENERIC_ATOMIC64

arch/sh/include/asm/cmpxchg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <linux/compiler.h>
1111
#include <linux/types.h>
12+
#include <linux/cmpxchg-emu.h>
1213

1314
#if defined(CONFIG_GUSA_RB)
1415
#include <asm/cmpxchg-grb.h>
@@ -56,6 +57,8 @@ static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old,
5657
unsigned long new, int size)
5758
{
5859
switch (size) {
60+
case 1:
61+
return cmpxchg_emu_u8(ptr, old, new);
5962
case 4:
6063
return __cmpxchg_u32(ptr, old, new);
6164
}

arch/xtensa/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ config XTENSA
1414
select ARCH_HAS_DMA_SET_UNCACHED if MMU
1515
select ARCH_HAS_STRNCPY_FROM_USER if !KASAN
1616
select ARCH_HAS_STRNLEN_USER
17+
select ARCH_NEED_CMPXCHG_1_EMU
1718
select ARCH_USE_MEMTEST
1819
select ARCH_USE_QUEUED_RWLOCKS
1920
select ARCH_USE_QUEUED_SPINLOCKS

arch/xtensa/include/asm/cmpxchg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <linux/bits.h>
1717
#include <linux/stringify.h>
18+
#include <linux/cmpxchg-emu.h>
1819

1920
/*
2021
* cmpxchg
@@ -74,6 +75,7 @@ static __inline__ unsigned long
7475
__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
7576
{
7677
switch (size) {
78+
case 1: return cmpxchg_emu_u8(ptr, old, new);
7779
case 4: return __cmpxchg_u32(ptr, old, new);
7880
default: __cmpxchg_called_with_bad_pointer();
7981
return old;

0 commit comments

Comments
 (0)