Message ID | 20240805192119.56816-3-paulmck@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Provide emulation for one-byte cmpxchg() | expand |
On Mon, 2024-08-05 at 12:21 -0700, Paul E. McKenney wrote: > Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on sh. > > [ paulmck: Drop two-byte support per Arnd Bergmann feedback. ] > [ paulmck: Apply feedback from Naresh Kamboju. ] > [ Apply Geert Uytterhoeven feedback. ] > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: Andi Shyti <andi.shyti@linux.intel.com> > Cc: Palmer Dabbelt <palmer@rivosinc.com> > Cc: Masami Hiramatsu <mhiramat@kernel.org> > Cc: Arnd Bergmann <arnd@arndb.de> > Cc: <linux-sh@vger.kernel.org> > --- > arch/sh/Kconfig | 1 + > arch/sh/include/asm/cmpxchg.h | 3 +++ > 2 files changed, 4 insertions(+) > > diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig > index 1aa3c4a0c5b27..e9103998cca91 100644 > --- a/arch/sh/Kconfig > +++ b/arch/sh/Kconfig > @@ -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 > diff --git a/arch/sh/include/asm/cmpxchg.h b/arch/sh/include/asm/cmpxchg.h > index 5d617b3ef78f7..1e5dc5ccf7bf5 100644 > --- a/arch/sh/include/asm/cmpxchg.h > +++ b/arch/sh/include/asm/cmpxchg.h > @@ -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); > } Acked-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Adrian
On Mon, Aug 05, 2024 at 10:13:38PM +0200, John Paul Adrian Glaubitz wrote: > On Mon, 2024-08-05 at 12:21 -0700, Paul E. McKenney wrote: > > Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on sh. > > > > [ paulmck: Drop two-byte support per Arnd Bergmann feedback. ] > > [ paulmck: Apply feedback from Naresh Kamboju. ] > > [ Apply Geert Uytterhoeven feedback. ] > > > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > Cc: Andi Shyti <andi.shyti@linux.intel.com> > > Cc: Palmer Dabbelt <palmer@rivosinc.com> > > Cc: Masami Hiramatsu <mhiramat@kernel.org> > > Cc: Arnd Bergmann <arnd@arndb.de> > > Cc: <linux-sh@vger.kernel.org> > > --- > > arch/sh/Kconfig | 1 + > > arch/sh/include/asm/cmpxchg.h | 3 +++ > > 2 files changed, 4 insertions(+) > > > > diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig > > index 1aa3c4a0c5b27..e9103998cca91 100644 > > --- a/arch/sh/Kconfig > > +++ b/arch/sh/Kconfig > > @@ -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 > > diff --git a/arch/sh/include/asm/cmpxchg.h b/arch/sh/include/asm/cmpxchg.h > > index 5d617b3ef78f7..1e5dc5ccf7bf5 100644 > > --- a/arch/sh/include/asm/cmpxchg.h > > +++ b/arch/sh/include/asm/cmpxchg.h > > @@ -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); > > } > > Acked-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Thank you very much! I will apply this on my next rebase. Thanx, Paul
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 1aa3c4a0c5b27..e9103998cca91 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -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 diff --git a/arch/sh/include/asm/cmpxchg.h b/arch/sh/include/asm/cmpxchg.h index 5d617b3ef78f7..1e5dc5ccf7bf5 100644 --- a/arch/sh/include/asm/cmpxchg.h +++ b/arch/sh/include/asm/cmpxchg.h @@ -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); }
Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on sh. [ paulmck: Drop two-byte support per Arnd Bergmann feedback. ] [ paulmck: Apply feedback from Naresh Kamboju. ] [ Apply Geert Uytterhoeven feedback. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Andi Shyti <andi.shyti@linux.intel.com> Cc: Palmer Dabbelt <palmer@rivosinc.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: <linux-sh@vger.kernel.org> --- arch/sh/Kconfig | 1 + arch/sh/include/asm/cmpxchg.h | 3 +++ 2 files changed, 4 insertions(+)