diff mbox series

[v3,cmpxchg,2/4] sh: Emulate one-byte cmpxchg

Message ID 20240604170437.2362545-2-paulmck@kernel.org (mailing list archive)
State New
Headers show
Series None | expand

Commit Message

Paul E. McKenney June 4, 2024, 5:04 p.m. UTC
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(+)

Comments

John Paul Adrian Glaubitz June 4, 2024, 5:09 p.m. UTC | #1
Hello,

On Tue, 2024-06-04 at 10:04 -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 5e6a3ead51fb1..f723e2256c9c1 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..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);
>  	}

Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>

I can pick this up through my SH tree unless someone insists this to
go through some other tree.

Adrian

PS: I'm a bit stumped that I'm not CC'ed as the SH maintainer.
Paul E. McKenney June 4, 2024, 5:50 p.m. UTC | #2
On Tue, Jun 04, 2024 at 07:09:11PM +0200, John Paul Adrian Glaubitz wrote:
> Hello,
> 
> On Tue, 2024-06-04 at 10:04 -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 5e6a3ead51fb1..f723e2256c9c1 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..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);
> >  	}
> 
> Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> 
> I can pick this up through my SH tree unless someone insists this to
> go through some other tree.

Please do take it, and thank you!  When I see it in -next, I will drop
it from my tree.

> Adrian
> 
> PS: I'm a bit stumped that I'm not CC'ed as the SH maintainer.

Me too, now that you mention it.  I did generate the list some time
back, but "git blame" shows you being maintainer for more than a year.
Yet I do have the linux-sh email list, so it is unlikely that I pasted
the get_maintainer.pl output from the wrong commit.

I am forced to hypothesize that I fat-fingered the output of
get_maintainer.pl when adding the Cc lines to that commit.

Please accept my apologies for having left you out!

							Thanx, Paul
John Paul Adrian Glaubitz June 4, 2024, 5:56 p.m. UTC | #3
Hello,

On Tue, 2024-06-04 at 10:50 -0700, Paul E. McKenney wrote:
> > Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> > 
> > I can pick this up through my SH tree unless someone insists this to
> > go through some other tree.
> 
> Please do take it, and thank you!  When I see it in -next, I will drop
> it from my tree.

I'll pick it up over the weekend for which I have planned my usual kernel
review and merge session.

> > Adrian
> > 
> > PS: I'm a bit stumped that I'm not CC'ed as the SH maintainer.
> 
> Me too, now that you mention it.  I did generate the list some time
> back, but "git blame" shows you being maintainer for more than a year.
> Yet I do have the linux-sh email list, so it is unlikely that I pasted
> the get_maintainer.pl output from the wrong commit.
> 
> I am forced to hypothesize that I fat-fingered the output of
> get_maintainer.pl when adding the Cc lines to that commit.
> 
> Please accept my apologies for having left you out!

No worries. I was just surprised as I assume get_maintainer.pl should have
done the right thing and spit out the names of the responsible maintainers.

Thanks,
Adrian
Paul E. McKenney June 4, 2024, 9:14 p.m. UTC | #4
On Tue, Jun 04, 2024 at 07:56:49PM +0200, John Paul Adrian Glaubitz wrote:
> Hello,
> 
> On Tue, 2024-06-04 at 10:50 -0700, Paul E. McKenney wrote:
> > > Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> > > 
> > > I can pick this up through my SH tree unless someone insists this to
> > > go through some other tree.
> > 
> > Please do take it, and thank you!  When I see it in -next, I will drop
> > it from my tree.
> 
> I'll pick it up over the weekend for which I have planned my usual kernel
> review and merge session.

Very good, and again, thank you!

> > > Adrian
> > > 
> > > PS: I'm a bit stumped that I'm not CC'ed as the SH maintainer.
> > 
> > Me too, now that you mention it.  I did generate the list some time
> > back, but "git blame" shows you being maintainer for more than a year.
> > Yet I do have the linux-sh email list, so it is unlikely that I pasted
> > the get_maintainer.pl output from the wrong commit.
> > 
> > I am forced to hypothesize that I fat-fingered the output of
> > get_maintainer.pl when adding the Cc lines to that commit.
> > 
> > Please accept my apologies for having left you out!
> 
> No worries. I was just surprised as I assume get_maintainer.pl should have
> done the right thing and spit out the names of the responsible maintainers.

I will look more carefully next time.

							Thanx, Paul
Paul E. McKenney June 17, 2024, 4:50 p.m. UTC | #5
On Tue, Jun 04, 2024 at 02:14:54PM -0700, Paul E. McKenney wrote:
> On Tue, Jun 04, 2024 at 07:56:49PM +0200, John Paul Adrian Glaubitz wrote:
> > Hello,
> > 
> > On Tue, 2024-06-04 at 10:50 -0700, Paul E. McKenney wrote:
> > > > Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> > > > 
> > > > I can pick this up through my SH tree unless someone insists this to
> > > > go through some other tree.
> > > 
> > > Please do take it, and thank you!  When I see it in -next, I will drop
> > > it from my tree.
> > 
> > I'll pick it up over the weekend for which I have planned my usual kernel
> > review and merge session.
> 
> Very good, and again, thank you!

Just following up...  I don't yet see this from you in -next.  When your
version does show up in -next, I will drop my copy from -rcu.

							Thanx, Paul
John Paul Adrian Glaubitz June 17, 2024, 8:30 p.m. UTC | #6
Hi Paul,

On Mon, 2024-06-17 at 09:50 -0700, Paul E. McKenney wrote:
> On Tue, Jun 04, 2024 at 02:14:54PM -0700, Paul E. McKenney wrote:
> > On Tue, Jun 04, 2024 at 07:56:49PM +0200, John Paul Adrian Glaubitz wrote:
> > > Hello,
> > > 
> > > On Tue, 2024-06-04 at 10:50 -0700, Paul E. McKenney wrote:
> > > > > Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> > > > > 
> > > > > I can pick this up through my SH tree unless someone insists this to
> > > > > go through some other tree.
> > > > 
> > > > Please do take it, and thank you!  When I see it in -next, I will drop
> > > > it from my tree.
> > > 
> > > I'll pick it up over the weekend for which I have planned my usual kernel
> > > review and merge session.
> > 
> > Very good, and again, thank you!
> 
> Just following up...  I don't yet see this from you in -next.  When your
> version does show up in -next, I will drop my copy from -rcu.

Sorry, I was very busy last week and didn't get around to do any kernel stuff.

I will take care of it this week, I have not forgotten about it and I never let
patches unanswered, and unmerged once I have reviewed them.

Adrian
Paul E. McKenney June 17, 2024, 9:59 p.m. UTC | #7
On Mon, Jun 17, 2024 at 10:30:40PM +0200, John Paul Adrian Glaubitz wrote:
> Hi Paul,
> 
> On Mon, 2024-06-17 at 09:50 -0700, Paul E. McKenney wrote:
> > On Tue, Jun 04, 2024 at 02:14:54PM -0700, Paul E. McKenney wrote:
> > > On Tue, Jun 04, 2024 at 07:56:49PM +0200, John Paul Adrian Glaubitz wrote:
> > > > Hello,
> > > > 
> > > > On Tue, 2024-06-04 at 10:50 -0700, Paul E. McKenney wrote:
> > > > > > Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> > > > > > 
> > > > > > I can pick this up through my SH tree unless someone insists this to
> > > > > > go through some other tree.
> > > > > 
> > > > > Please do take it, and thank you!  When I see it in -next, I will drop
> > > > > it from my tree.
> > > > 
> > > > I'll pick it up over the weekend for which I have planned my usual kernel
> > > > review and merge session.
> > > 
> > > Very good, and again, thank you!
> > 
> > Just following up...  I don't yet see this from you in -next.  When your
> > version does show up in -next, I will drop my copy from -rcu.
> 
> Sorry, I was very busy last week and didn't get around to do any kernel stuff.
> 
> I will take care of it this week, I have not forgotten about it and I never let
> patches unanswered, and unmerged once I have reviewed them.

Very good, thank you, and apologies for the noise.

							Thanx, Paul
diff mbox series

Patch

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 5e6a3ead51fb1..f723e2256c9c1 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..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);
 	}