Skip to content

Commit f1b5644

Browse files
committed
ARM: Emulate one-byte cmpxchg
Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on ARM systems with ARCH == ARMv6K. [ paulmck: Apply Arnd Bergmann and Nathan Chancellor feedback. ] [ paulmck: Apply Linus Walleij feedback. ] Reported-by: Mark Brown <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Reported-by: Naresh Kamboju <[email protected]> Closes: https://lore.kernel.org/all/CA+G9fYuZ+pf6p8AXMZWtdFtX-gbG8HMaBKp=XbxcdzA_QeLkxQ@mail.gmail.com/ Signed-off-by: Paul E. McKenney <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Cc: "Russell King (Oracle)" <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Andrew Davis <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Eric DeVolder <[email protected]> Cc: Rob Herring <[email protected]> Cc: <[email protected]>
1 parent 1613e60 commit f1b5644

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

arch/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ config ARM
3434
select ARCH_MIGHT_HAVE_PC_PARPORT
3535
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
3636
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7
37+
select ARCH_NEED_CMPXCHG_1_EMU if CPU_V6
3738
select ARCH_SUPPORTS_ATOMIC_RMW
3839
select ARCH_SUPPORTS_CFI_CLANG
3940
select ARCH_SUPPORTS_HUGETLBFS if ARM_LPAE

arch/arm/include/asm/cmpxchg.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/irqflags.h>
66
#include <linux/prefetch.h>
77
#include <asm/barrier.h>
8+
#include <linux/cmpxchg-emu.h>
89

910
#if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110)
1011
/*
@@ -162,7 +163,11 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
162163
prefetchw((const void *)ptr);
163164

164165
switch (size) {
165-
#ifndef CONFIG_CPU_V6 /* min ARCH >= ARMv6K */
166+
#ifdef CONFIG_CPU_V6 /* ARCH == ARMv6 */
167+
case 1:
168+
oldval = cmpxchg_emu_u8((volatile u8 *)ptr, old, new);
169+
break;
170+
#else /* min ARCH > ARMv6 */
166171
case 1:
167172
do {
168173
asm volatile("@ __cmpxchg1\n"

0 commit comments

Comments
 (0)