* [PATCH v3 cmpxchg 4/4] ARM: Emulate one-byte cmpxchg [not found] <1dee481f-d584-41d6-a5f1-d84375be5fe8@paulmck-laptop> @ 2024-06-04 17:04 ` Paul E. McKenney 2024-06-04 20:52 ` Linus Walleij 0 siblings, 1 reply; 5+ messages in thread From: Paul E. McKenney @ 2024-06-04 17:04 UTC (permalink / raw) To: linux-arch Cc: linux-kernel, kernel-team, elver, akpm, tglx, peterz, dianders, pmladek, torvalds, arnd, Paul E. McKenney, Mark Brown, Naresh Kamboju, Nathan Chancellor, Russell King (Oracle), Andrew Davis, Linus Walleij, Eric DeVolder, Rob Herring, linux-arm-kernel 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. ] 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> 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: Linus Walleij <linus.walleij@linaro.org> Cc: Eric DeVolder <eric.devolder@oracle.com> Cc: Rob Herring <robh@kernel.org> Cc: <linux-arm-kernel@lists.infradead.org> --- arch/arm/Kconfig | 1 + arch/arm/include/asm/cmpxchg.h | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index ee5115252aac4..a867a7d967aa5 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -34,6 +34,7 @@ config ARM select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7 + select ARCH_NEED_CMPXCHG_1_EMU if CPU_V6 select ARCH_SUPPORTS_ATOMIC_RMW select ARCH_SUPPORTS_CFI_CLANG select ARCH_SUPPORTS_HUGETLBFS if ARM_LPAE diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h index 44667bdb4707a..a428e06fe94ee 100644 --- a/arch/arm/include/asm/cmpxchg.h +++ b/arch/arm/include/asm/cmpxchg.h @@ -5,6 +5,7 @@ #include <linux/irqflags.h> #include <linux/prefetch.h> #include <asm/barrier.h> +#include <linux/cmpxchg-emu.h> #if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110) /* @@ -162,7 +163,11 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, prefetchw((const void *)ptr); switch (size) { -#ifndef CONFIG_CPU_V6 /* min ARCH >= ARMv6K */ +#ifdef CONFIG_CPU_V6 /* min ARCH < ARMv6K */ + case 1: + oldval = cmpxchg_emu_u8((volatile u8 *)ptr, old, new); + break; +#else /* min ARCH >= ARMv6K */ case 1: do { asm volatile("@ __cmpxchg1\n" -- 2.40.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 cmpxchg 4/4] ARM: Emulate one-byte cmpxchg 2024-06-04 17:04 ` [PATCH v3 cmpxchg 4/4] ARM: Emulate one-byte cmpxchg Paul E. McKenney @ 2024-06-04 20:52 ` Linus Walleij 2024-06-04 21:14 ` Paul E. McKenney 0 siblings, 1 reply; 5+ messages in thread From: Linus Walleij @ 2024-06-04 20:52 UTC (permalink / raw) To: Paul E. McKenney Cc: linux-arch, linux-kernel, kernel-team, elver, akpm, tglx, peterz, dianders, pmladek, torvalds, arnd, Mark Brown, Naresh Kamboju, Nathan Chancellor, Russell King (Oracle), Andrew Davis, Eric DeVolder, Rob Herring, linux-arm-kernel Hi Paul, thanks for your patch! This caught my eye: On Tue, Jun 4, 2024 at 7:04 PM Paul E. McKenney <paulmck@kernel.org> wrote: > Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on ARM systems > with ARCH < ARMv6K. ARCH == ARMv6. This ARCH < ARMv6K comes from inversion of the the a bit terse comment for ifndef CONFIG_CPU_V6, which means "out of the post-v6 CPUs, the following applies to those > V6". The code in the patch, IIUC make use of cmpxchg_emu_u8() if and only if the CPU is V6. > -#ifndef CONFIG_CPU_V6 /* min ARCH >= ARMv6K */ > +#ifdef CONFIG_CPU_V6 /* min ARCH < ARMv6K */ This is now a set with one member so this comment should say: /* ARCH == ARMv6 */ After this change. Yours, Linus Walleij _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 cmpxchg 4/4] ARM: Emulate one-byte cmpxchg 2024-06-04 20:52 ` Linus Walleij @ 2024-06-04 21:14 ` Paul E. McKenney 2024-06-05 8:38 ` Linus Walleij 0 siblings, 1 reply; 5+ messages in thread From: Paul E. McKenney @ 2024-06-04 21:14 UTC (permalink / raw) To: Linus Walleij Cc: linux-arch, linux-kernel, kernel-team, elver, akpm, tglx, peterz, dianders, pmladek, torvalds, arnd, Mark Brown, Naresh Kamboju, Nathan Chancellor, Russell King (Oracle), Andrew Davis, Eric DeVolder, Rob Herring, linux-arm-kernel On Tue, Jun 04, 2024 at 10:52:23PM +0200, Linus Walleij wrote: > Hi Paul, > > thanks for your patch! This caught my eye: > > On Tue, Jun 4, 2024 at 7:04 PM Paul E. McKenney <paulmck@kernel.org> wrote: > > > Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on ARM systems > > with ARCH < ARMv6K. > > ARCH == ARMv6. > > This ARCH < ARMv6K comes from inversion of the the a bit terse > comment for ifndef CONFIG_CPU_V6, which means "out of the > post-v6 CPUs, the following applies to those > V6". > > The code in the patch, IIUC make use of cmpxchg_emu_u8() > if and only if the CPU is V6. > > > -#ifndef CONFIG_CPU_V6 /* min ARCH >= ARMv6K */ > > +#ifdef CONFIG_CPU_V6 /* min ARCH < ARMv6K */ > > This is now a set with one member so this comment should say: > > /* ARCH == ARMv6 */ > > After this change. Thank you for looking this over! Does the following patch (to be merged into the original) capture it properly? Thanx, Paul ------------------------------------------------------------------------ diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h index a428e06fe94ee..9beb64d305866 100644 --- a/arch/arm/include/asm/cmpxchg.h +++ b/arch/arm/include/asm/cmpxchg.h @@ -163,11 +163,11 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, prefetchw((const void *)ptr); switch (size) { -#ifdef CONFIG_CPU_V6 /* min ARCH < ARMv6K */ +#ifdef CONFIG_CPU_V6 /* ARCH == ARMv6 */ case 1: oldval = cmpxchg_emu_u8((volatile u8 *)ptr, old, new); break; -#else /* min ARCH >= ARMv6K */ +#else /* min ARCH > ARMv6 */ case 1: do { asm volatile("@ __cmpxchg1\n" _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 cmpxchg 4/4] ARM: Emulate one-byte cmpxchg 2024-06-04 21:14 ` Paul E. McKenney @ 2024-06-05 8:38 ` Linus Walleij 2024-06-05 18:05 ` Paul E. McKenney 0 siblings, 1 reply; 5+ messages in thread From: Linus Walleij @ 2024-06-05 8:38 UTC (permalink / raw) To: paulmck Cc: linux-arch, linux-kernel, kernel-team, elver, akpm, tglx, peterz, dianders, pmladek, torvalds, arnd, Mark Brown, Naresh Kamboju, Nathan Chancellor, Russell King (Oracle), Andrew Davis, Eric DeVolder, Rob Herring, linux-arm-kernel On Tue, Jun 4, 2024 at 11:14 PM Paul E. McKenney <paulmck@kernel.org> wrote: > Thank you for looking this over! Does the following patch (to be merged > into the original) capture it properly? Yup, also fix the commit message to be == CPU_V6, with that: Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 cmpxchg 4/4] ARM: Emulate one-byte cmpxchg 2024-06-05 8:38 ` Linus Walleij @ 2024-06-05 18:05 ` Paul E. McKenney 0 siblings, 0 replies; 5+ messages in thread From: Paul E. McKenney @ 2024-06-05 18:05 UTC (permalink / raw) To: Linus Walleij Cc: linux-arch, linux-kernel, kernel-team, elver, akpm, tglx, peterz, dianders, pmladek, torvalds, arnd, Mark Brown, Naresh Kamboju, Nathan Chancellor, Russell King (Oracle), Andrew Davis, Eric DeVolder, Rob Herring, linux-arm-kernel On Wed, Jun 05, 2024 at 10:38:07AM +0200, Linus Walleij wrote: > On Tue, Jun 4, 2024 at 11:14 PM Paul E. McKenney <paulmck@kernel.org> wrote: > > > Thank you for looking this over! Does the following patch (to be merged > > into the original) capture it properly? > > Yup, also fix the commit message to be == CPU_V6, > with that: Good catch, and will fix. > Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Thank you! I will apply these on my next rebase. Thanx, Paul _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-06-05 18:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1dee481f-d584-41d6-a5f1-d84375be5fe8@paulmck-laptop>
2024-06-04 17:04 ` [PATCH v3 cmpxchg 4/4] ARM: Emulate one-byte cmpxchg Paul E. McKenney
2024-06-04 20:52 ` Linus Walleij
2024-06-04 21:14 ` Paul E. McKenney
2024-06-05 8:38 ` Linus Walleij
2024-06-05 18:05 ` Paul E. McKenney
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).