riscv: hibernation: Remove duplicate call of suspend_restore_csrs

Message ID 20230519102908.253458-1-suagrfillet@gmail.com
State New
Headers
Series riscv: hibernation: Remove duplicate call of suspend_restore_csrs |

Commit Message

Song Shuai May 19, 2023, 10:29 a.m. UTC
  The suspend_restore_csrs is called in both __hibernate_cpu_resume
and the `else` of subsequent swsusp_arch_suspend.

Removing the first call makes both suspend_{save,restore}_csrs
left in swsusp_arch_suspend for clean code.

Signed-off-by: Song Shuai <suagrfillet@gmail.com>
Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
---
 arch/riscv/kernel/hibernate-asm.S | 1 -
 1 file changed, 1 deletion(-)
  

Comments

JeeHeng Sia May 19, 2023, 11:14 a.m. UTC | #1
looks good to me.

Thanks
Regards
Jee Heng

> -----Original Message-----
> From: Song Shuai <suagrfillet@gmail.com>
> Sent: Friday, May 19, 2023 6:29 PM
> To: paul.walmsley@sifive.com; palmer@dabbelt.com; aou@eecs.berkeley.edu; suagrfillet@gmail.com; Mason Huo
> <mason.huo@starfivetech.com>; Leyfoon Tan <leyfoon.tan@starfivetech.com>; ajones@ventanamicro.com; JeeHeng Sia
> <jeeheng.sia@starfivetech.com>
> Cc: linux-riscv@lists.infradead.org; linux-kernel@vger.kernel.org; Song Shuai <songshuaishuai@tinylab.org>
> Subject: [PATCH] riscv: hibernation: Remove duplicate call of suspend_restore_csrs
> 
> The suspend_restore_csrs is called in both __hibernate_cpu_resume
> and the `else` of subsequent swsusp_arch_suspend.
> 
> Removing the first call makes both suspend_{save,restore}_csrs
> left in swsusp_arch_suspend for clean code.
> 
> Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
> ---
>  arch/riscv/kernel/hibernate-asm.S | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/arch/riscv/kernel/hibernate-asm.S b/arch/riscv/kernel/hibernate-asm.S
> index 5c76671c7e15..d698dd7df637 100644
> --- a/arch/riscv/kernel/hibernate-asm.S
> +++ b/arch/riscv/kernel/hibernate-asm.S
> @@ -28,7 +28,6 @@ ENTRY(__hibernate_cpu_resume)
> 
>  	REG_L	a0, hibernate_cpu_context
> 
> -	suspend_restore_csrs
>  	suspend_restore_regs
Good catch. This function is invoked twice to restore the CSRs. I am good with removing this function from here.
> 
>  	/* Return zero value. */
> --
> 2.20.1
  
Conor Dooley May 19, 2023, 11:28 a.m. UTC | #2
Hey,

On Fri, May 19, 2023 at 11:14:27AM +0000, JeeHeng Sia wrote:

> > The suspend_restore_csrs is called in both __hibernate_cpu_resume
> > and the `else` of subsequent swsusp_arch_suspend.
> > 
> > Removing the first call makes both suspend_{save,restore}_csrs
> > left in swsusp_arch_suspend for clean code.
> > 
> > Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> > Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>

BTW, why the two email addresses? The tinylab one here seems entirely
redundant - unless it is your employer, in which case should it be the
only SoB address & also in the author field?

Also, Fixes tag?

> > ---
> >  arch/riscv/kernel/hibernate-asm.S | 1 -
> >  1 file changed, 1 deletion(-)
> > 
> > diff --git a/arch/riscv/kernel/hibernate-asm.S b/arch/riscv/kernel/hibernate-asm.S
> > index 5c76671c7e15..d698dd7df637 100644
> > --- a/arch/riscv/kernel/hibernate-asm.S
> > +++ b/arch/riscv/kernel/hibernate-asm.S
> > @@ -28,7 +28,6 @@ ENTRY(__hibernate_cpu_resume)
> > 
> >  	REG_L	a0, hibernate_cpu_context
> > 
> > -	suspend_restore_csrs
> >  	suspend_restore_regs

> Good catch. This function is invoked twice to restore the CSRs.
> I am good with removing this function from here.

If that's a review, then please either give an R-b or A-b tag :)

Thanks,
Conor.
  
Conor Dooley May 19, 2023, 8:07 p.m. UTC | #3
On Fri, May 19, 2023 at 12:28:07PM +0100, Conor Dooley wrote:
> Hey,
> 
> On Fri, May 19, 2023 at 11:14:27AM +0000, JeeHeng Sia wrote:
> 
> > > The suspend_restore_csrs is called in both __hibernate_cpu_resume
> > > and the `else` of subsequent swsusp_arch_suspend.
> > > 
> > > Removing the first call makes both suspend_{save,restore}_csrs
> > > left in swsusp_arch_suspend for clean code.

It took me embarrassingly long to wrap my head around the control flow
here again. I'm not sure that I agree with you that splitting the calls
between asm & c is cleaner, but whatever:
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>

> > > 
> > > Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> > > Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
> 
> BTW, why the two email addresses? The tinylab one here seems entirely
> redundant - unless it is your employer, in which case should it be the
> only SoB address & also in the author field?

Deja vu with my questioning your email address, but does your
tinylab address actually repeat "shuai"?

> Also, Fixes tag?
> 
> > > ---
> > >  arch/riscv/kernel/hibernate-asm.S | 1 -
> > >  1 file changed, 1 deletion(-)
> > > 
> > > diff --git a/arch/riscv/kernel/hibernate-asm.S b/arch/riscv/kernel/hibernate-asm.S
> > > index 5c76671c7e15..d698dd7df637 100644
> > > --- a/arch/riscv/kernel/hibernate-asm.S
> > > +++ b/arch/riscv/kernel/hibernate-asm.S
> > > @@ -28,7 +28,6 @@ ENTRY(__hibernate_cpu_resume)
> > > 
> > >  	REG_L	a0, hibernate_cpu_context
> > > 
> > > -	suspend_restore_csrs
> > >  	suspend_restore_regs
> 
> > Good catch. This function is invoked twice to restore the CSRs.
> > I am good with removing this function from here.
> 
> If that's a review, then please either give an R-b or A-b tag :)
> 
> Thanks,
> Conor.
  
JeeHeng Sia May 22, 2023, 1:11 a.m. UTC | #4
> -----Original Message-----
> From: Conor Dooley <conor@kernel.org>
> Sent: Saturday, May 20, 2023 4:07 AM
> To: Conor Dooley <conor.dooley@microchip.com>
> Cc: JeeHeng Sia <jeeheng.sia@starfivetech.com>; Song Shuai <suagrfillet@gmail.com>; paul.walmsley@sifive.com;
> palmer@dabbelt.com; aou@eecs.berkeley.edu; Mason Huo <mason.huo@starfivetech.com>; Leyfoon Tan
> <leyfoon.tan@starfivetech.com>; ajones@ventanamicro.com; linux-riscv@lists.infradead.org; linux-kernel@vger.kernel.org; Song
> Shuai <songshuaishuai@tinylab.org>
> Subject: Re: [PATCH] riscv: hibernation: Remove duplicate call of suspend_restore_csrs
> 
> On Fri, May 19, 2023 at 12:28:07PM +0100, Conor Dooley wrote:
> > Hey,
> >
> > On Fri, May 19, 2023 at 11:14:27AM +0000, JeeHeng Sia wrote:
> >
> > > > The suspend_restore_csrs is called in both __hibernate_cpu_resume
> > > > and the `else` of subsequent swsusp_arch_suspend.
> > > >
> > > > Removing the first call makes both suspend_{save,restore}_csrs
> > > > left in swsusp_arch_suspend for clean code.
> 
> It took me embarrassingly long to wrap my head around the control flow
> here again. I'm not sure that I agree with you that splitting the calls
> between asm & c is cleaner, but whatever:
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> 
> > > >
> > > > Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> > > > Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
> >
> > BTW, why the two email addresses? The tinylab one here seems entirely
> > redundant - unless it is your employer, in which case should it be the
> > only SoB address & also in the author field?
> 
> Deja vu with my questioning your email address, but does your
> tinylab address actually repeat "shuai"?
> 
> > Also, Fixes tag?
> >
> > > > ---
> > > >  arch/riscv/kernel/hibernate-asm.S | 1 -
> > > >  1 file changed, 1 deletion(-)
> > > >
> > > > diff --git a/arch/riscv/kernel/hibernate-asm.S b/arch/riscv/kernel/hibernate-asm.S
> > > > index 5c76671c7e15..d698dd7df637 100644
> > > > --- a/arch/riscv/kernel/hibernate-asm.S
> > > > +++ b/arch/riscv/kernel/hibernate-asm.S
> > > > @@ -28,7 +28,6 @@ ENTRY(__hibernate_cpu_resume)
> > > >
> > > >  	REG_L	a0, hibernate_cpu_context
> > > >
> > > > -	suspend_restore_csrs
> > > >  	suspend_restore_regs
> >
> > > Good catch. This function is invoked twice to restore the CSRs.
> > > I am good with removing this function from here.
> >
> > If that's a review, then please either give an R-b or A-b tag :)
Reviewed-by: JeeHeng Sia <jeeheng.sia@starfivetech.com >
> >
> > Thanks,
> > Conor.
>
  
Song Shuai May 22, 2023, 2:44 a.m. UTC | #5
Conor Dooley <conor@kernel.org> 于2023年5月19日周五 20:07写道:
>
> On Fri, May 19, 2023 at 12:28:07PM +0100, Conor Dooley wrote:
> > Hey,
> >
> > On Fri, May 19, 2023 at 11:14:27AM +0000, JeeHeng Sia wrote:
> >
> > > > The suspend_restore_csrs is called in both __hibernate_cpu_resume
> > > > and the `else` of subsequent swsusp_arch_suspend.
> > > >
> > > > Removing the first call makes both suspend_{save,restore}_csrs
> > > > left in swsusp_arch_suspend for clean code.
>
> It took me embarrassingly long to wrap my head around the control flow
> here again. I'm not sure that I agree with you that splitting the calls
> between asm & c is cleaner, but whatever:
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
>
> > > >
> > > > Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> > > > Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
> >
> > BTW, why the two email addresses? The tinylab one here seems entirely
> > redundant - unless it is your employer, in which case should it be the
> > only SoB address & also in the author field?
>
> Deja vu with my questioning your email address, but does your
> tinylab address actually repeat "shuai"?
>
Yes, that's my full name.
As you noticed, I'm switching my email from Gmail to Tinylab but did
something wrong.
Thanks for your correction, I'll re-send this patch with your
suggestions applied.

> > Also, Fixes tag?
> >
> > > > ---
> > > >  arch/riscv/kernel/hibernate-asm.S | 1 -
> > > >  1 file changed, 1 deletion(-)
> > > >
> > > > diff --git a/arch/riscv/kernel/hibernate-asm.S b/arch/riscv/kernel/hibernate-asm.S
> > > > index 5c76671c7e15..d698dd7df637 100644
> > > > --- a/arch/riscv/kernel/hibernate-asm.S
> > > > +++ b/arch/riscv/kernel/hibernate-asm.S
> > > > @@ -28,7 +28,6 @@ ENTRY(__hibernate_cpu_resume)
> > > >
> > > >   REG_L   a0, hibernate_cpu_context
> > > >
> > > > - suspend_restore_csrs
> > > >   suspend_restore_regs
> >
> > > Good catch. This function is invoked twice to restore the CSRs.
> > > I am good with removing this function from here.
> >
> > If that's a review, then please either give an R-b or A-b tag :)
> >
> > Thanks,
> > Conor.
>
>
  
patchwork-bot+linux-riscv@kernel.org June 20, 2023, 1 a.m. UTC | #6
Hello:

This patch was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Fri, 19 May 2023 18:29:08 +0800 you wrote:
> The suspend_restore_csrs is called in both __hibernate_cpu_resume
> and the `else` of subsequent swsusp_arch_suspend.
> 
> Removing the first call makes both suspend_{save,restore}_csrs
> left in swsusp_arch_suspend for clean code.
> 
> Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
> 
> [...]

Here is the summary with links:
  - riscv: hibernation: Remove duplicate call of suspend_restore_csrs
    https://git.kernel.org/riscv/c/c6399b893043

You are awesome, thank you!
  

Patch

diff --git a/arch/riscv/kernel/hibernate-asm.S b/arch/riscv/kernel/hibernate-asm.S
index 5c76671c7e15..d698dd7df637 100644
--- a/arch/riscv/kernel/hibernate-asm.S
+++ b/arch/riscv/kernel/hibernate-asm.S
@@ -28,7 +28,6 @@  ENTRY(__hibernate_cpu_resume)
 
 	REG_L	a0, hibernate_cpu_context
 
-	suspend_restore_csrs
 	suspend_restore_regs
 
 	/* Return zero value. */