SUPERH platform development
 help / color / mirror / Atom feed
* [PATCH cmpxchg 12/14] sh: Emulate one-byte cmpxchg
       [not found] <7b3646e0-667c-48e2-8f09-e493c43c30cb@paulmck-laptop>
@ 2024-04-08 17:49 ` Paul E. McKenney
  2024-04-18  8:04   ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Paul E. McKenney @ 2024-04-08 17:49 UTC (permalink / raw)
  To: linux-arch, linux-kernel
  Cc: elver, akpm, tglx, peterz, dianders, pmladek, torvalds,
	Arnd Bergmann, Paul E. McKenney, Andi Shyti, Palmer Dabbelt,
	Masami Hiramatsu, linux-sh

Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on sh.

[ paulmck: Drop two-byte support per Arnd Bergmann 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 | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 2ad3e29f0ebec..f47e9ccf4efd2 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -16,6 +16,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..27a9040983cfe 100644
--- a/arch/sh/include/asm/cmpxchg.h
+++ b/arch/sh/include/asm/cmpxchg.h
@@ -56,6 +56,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((volatile u8 *)ptr, old, new);
 	case 4:
 		return __cmpxchg_u32(ptr, old, new);
 	}
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH cmpxchg 12/14] sh: Emulate one-byte cmpxchg
  2024-04-08 17:49 ` [PATCH cmpxchg 12/14] sh: Emulate one-byte cmpxchg Paul E. McKenney
@ 2024-04-18  8:04   ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2024-04-18  8:04 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: linux-arch, linux-kernel, elver, akpm, tglx, peterz, dianders,
	pmladek, torvalds, Arnd Bergmann, Andi Shyti, Palmer Dabbelt,
	Masami Hiramatsu, linux-sh

Hi Paul,

On Mon, Apr 8, 2024 at 7:50 PM Paul E. McKenney <paulmck@kernel.org> wrote:
> Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on sh.
>
> [ paulmck: Drop two-byte support per Arnd Bergmann feedback. ]
>
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

Thanks for your patch!

> --- a/arch/sh/include/asm/cmpxchg.h
> +++ b/arch/sh/include/asm/cmpxchg.h
> @@ -56,6 +56,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((volatile u8 *)ptr, old, new);

The cast is not needed.

>         case 4:
>                 return __cmpxchg_u32(ptr, old, new);
>         }

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-18  8:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <7b3646e0-667c-48e2-8f09-e493c43c30cb@paulmck-laptop>
2024-04-08 17:49 ` [PATCH cmpxchg 12/14] sh: Emulate one-byte cmpxchg Paul E. McKenney
2024-04-18  8:04   ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox