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 <broonie@kernel.org> Closes: https://lore.kernel.org/all/54798f68-48f7-4c65-9cba-47c0bf175143@sirena.org.uk/ Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org> Closes: https://lore.kernel.org/all/CA+G9fYuZ+pf6p8AXMZWtdFtX-gbG8HMaBKp=XbxcdzA_QeLkxQ@mail.gmail.com/ Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Cc: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Andrew Davis <afd@ti.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Eric DeVolder <eric.devolder@oracle.com> Cc: Rob Herring <robh@kernel.org> Cc: <linux-arm-kernel@lists.infradead.org>
1 parent 1613e60 commit f1b5644

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

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)