linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: pm8941-pwrkey - respect reboot_mode for warm reset
@ 2021-06-29  3:05 Shawn Guo
  2021-07-11  9:57 ` Luca Weiss
  0 siblings, 1 reply; 4+ messages in thread
From: Shawn Guo @ 2021-06-29  3:05 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Bjorn Andersson, linux-arm-msm, linux-input, Shawn Guo

On some devices, e.g. Sony Xperia M4 Aqua, warm reset is used to reboot
device into bootloader and recovery mode.  Instead of always doing hard
reset, add a check on reboot_mode for possible warm reset.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/input/misc/pm8941-pwrkey.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c
index cf8104454e74..9b14d6eb1918 100644
--- a/drivers/input/misc/pm8941-pwrkey.c
+++ b/drivers/input/misc/pm8941-pwrkey.c
@@ -27,6 +27,7 @@
 #define PON_PS_HOLD_RST_CTL2		0x5b
 #define  PON_PS_HOLD_ENABLE		BIT(7)
 #define  PON_PS_HOLD_TYPE_MASK		0x0f
+#define  PON_PS_HOLD_TYPE_WARM_RESET	1
 #define  PON_PS_HOLD_TYPE_SHUTDOWN	4
 #define  PON_PS_HOLD_TYPE_HARD_RESET	7
 
@@ -93,7 +94,10 @@ static int pm8941_reboot_notify(struct notifier_block *nb,
 		break;
 	case SYS_RESTART:
 	default:
-		reset_type = PON_PS_HOLD_TYPE_HARD_RESET;
+		if (reboot_mode == REBOOT_WARM)
+			reset_type = PON_PS_HOLD_TYPE_WARM_RESET;
+		else
+			reset_type = PON_PS_HOLD_TYPE_HARD_RESET;
 		break;
 	}
 
-- 
2.17.1


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

* Re: [PATCH] Input: pm8941-pwrkey - respect reboot_mode for warm reset
  2021-06-29  3:05 [PATCH] Input: pm8941-pwrkey - respect reboot_mode for warm reset Shawn Guo
@ 2021-07-11  9:57 ` Luca Weiss
  2021-07-14  9:40   ` Shawn Guo
  0 siblings, 1 reply; 4+ messages in thread
From: Luca Weiss @ 2021-07-11  9:57 UTC (permalink / raw)
  To: Dmitry Torokhov, Shawn Guo
  Cc: Bjorn Andersson, linux-arm-msm, linux-input, Shawn Guo

Hi Shawn,

On Dienstag, 29. Juni 2021 05:05:09 CEST Shawn Guo wrote:
> On some devices, e.g. Sony Xperia M4 Aqua, warm reset is used to reboot
> device into bootloader and recovery mode.  Instead of always doing hard
> reset, add a check on reboot_mode for possible warm reset.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/input/misc/pm8941-pwrkey.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/misc/pm8941-pwrkey.c
> b/drivers/input/misc/pm8941-pwrkey.c index cf8104454e74..9b14d6eb1918
> 100644
> --- a/drivers/input/misc/pm8941-pwrkey.c
> +++ b/drivers/input/misc/pm8941-pwrkey.c
> @@ -27,6 +27,7 @@
>  #define PON_PS_HOLD_RST_CTL2		0x5b
>  #define  PON_PS_HOLD_ENABLE		BIT(7)
>  #define  PON_PS_HOLD_TYPE_MASK		0x0f
> +#define  PON_PS_HOLD_TYPE_WARM_RESET	1
>  #define  PON_PS_HOLD_TYPE_SHUTDOWN	4
>  #define  PON_PS_HOLD_TYPE_HARD_RESET	7
> 
> @@ -93,7 +94,10 @@ static int pm8941_reboot_notify(struct notifier_block
> *nb, break;
>  	case SYS_RESTART:
>  	default:
> -		reset_type = PON_PS_HOLD_TYPE_HARD_RESET;
> +		if (reboot_mode == REBOOT_WARM)

This doesn't compile with CONFIG_INPUT_PM8941_PWRKEY=m

 ERROR: modpost: "reboot_mode" [drivers/input/misc/pm8941-pwrkey.ko] undefined!

Also just to clarify, this is supposed to trigger when rebooting with 
LINUX_REBOOT_CMD_RESTART2 and adding an argument that way, right?

Regards
Luca

> +			reset_type = PON_PS_HOLD_TYPE_WARM_RESET;
> +		else
> +			reset_type = PON_PS_HOLD_TYPE_HARD_RESET;
>  		break;
>  	}





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

* Re: [PATCH] Input: pm8941-pwrkey - respect reboot_mode for warm reset
  2021-07-11  9:57 ` Luca Weiss
@ 2021-07-14  9:40   ` Shawn Guo
  2022-02-26 10:04     ` Luca Weiss
  0 siblings, 1 reply; 4+ messages in thread
From: Shawn Guo @ 2021-07-14  9:40 UTC (permalink / raw)
  To: Luca Weiss; +Cc: Dmitry Torokhov, Bjorn Andersson, linux-arm-msm, linux-input

Hi Luca,

On Sun, Jul 11, 2021 at 11:57:25AM +0200, Luca Weiss wrote:
> Hi Shawn,
> 
> On Dienstag, 29. Juni 2021 05:05:09 CEST Shawn Guo wrote:
> > On some devices, e.g. Sony Xperia M4 Aqua, warm reset is used to reboot
> > device into bootloader and recovery mode.  Instead of always doing hard
> > reset, add a check on reboot_mode for possible warm reset.
> > 
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > ---
> >  drivers/input/misc/pm8941-pwrkey.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/input/misc/pm8941-pwrkey.c
> > b/drivers/input/misc/pm8941-pwrkey.c index cf8104454e74..9b14d6eb1918
> > 100644
> > --- a/drivers/input/misc/pm8941-pwrkey.c
> > +++ b/drivers/input/misc/pm8941-pwrkey.c
> > @@ -27,6 +27,7 @@
> >  #define PON_PS_HOLD_RST_CTL2		0x5b
> >  #define  PON_PS_HOLD_ENABLE		BIT(7)
> >  #define  PON_PS_HOLD_TYPE_MASK		0x0f
> > +#define  PON_PS_HOLD_TYPE_WARM_RESET	1
> >  #define  PON_PS_HOLD_TYPE_SHUTDOWN	4
> >  #define  PON_PS_HOLD_TYPE_HARD_RESET	7
> > 
> > @@ -93,7 +94,10 @@ static int pm8941_reboot_notify(struct notifier_block
> > *nb, break;
> >  	case SYS_RESTART:
> >  	default:
> > -		reset_type = PON_PS_HOLD_TYPE_HARD_RESET;
> > +		if (reboot_mode == REBOOT_WARM)
> 
> This doesn't compile with CONFIG_INPUT_PM8941_PWRKEY=m
> 
>  ERROR: modpost: "reboot_mode" [drivers/input/misc/pm8941-pwrkey.ko] undefined!

Thanks for the report!  I will add a patch to export the symbol.

> 
> Also just to clarify, this is supposed to trigger when rebooting with 
> LINUX_REBOOT_CMD_RESTART2 and adding an argument that way, right?

With either of the following two methods, 'reboot_mode' will be turned
into REBOOT_WARM.

- Boot kernel with 'reboot=warm' on cmdline

- Set warm mode via sysfs entry
  $ echo warm > /sys/kernel/reboot/mode

Shawn

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

* Re: [PATCH] Input: pm8941-pwrkey - respect reboot_mode for warm reset
  2021-07-14  9:40   ` Shawn Guo
@ 2022-02-26 10:04     ` Luca Weiss
  0 siblings, 0 replies; 4+ messages in thread
From: Luca Weiss @ 2022-02-26 10:04 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Dmitry Torokhov, Bjorn Andersson, linux-arm-msm, linux-input,
	Sebastian Reichel

Hi Shawn,

On Mittwoch, 14. Juli 2021 11:40:46 CET Shawn Guo wrote:
> Hi Luca,
> 
> On Sun, Jul 11, 2021 at 11:57:25AM +0200, Luca Weiss wrote:
> > Hi Shawn,
> > 
> > On Dienstag, 29. Juni 2021 05:05:09 CEST Shawn Guo wrote:
> > > On some devices, e.g. Sony Xperia M4 Aqua, warm reset is used to reboot
> > > device into bootloader and recovery mode.  Instead of always doing hard
> > > reset, add a check on reboot_mode for possible warm reset.
> > > 
> > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > > ---
> > > 
> > >  drivers/input/misc/pm8941-pwrkey.c | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/input/misc/pm8941-pwrkey.c
> > > b/drivers/input/misc/pm8941-pwrkey.c index cf8104454e74..9b14d6eb1918
> > > 100644
> > > --- a/drivers/input/misc/pm8941-pwrkey.c
> > > +++ b/drivers/input/misc/pm8941-pwrkey.c
> > > @@ -27,6 +27,7 @@
> > > 
> > >  #define PON_PS_HOLD_RST_CTL2		0x5b
> > >  #define  PON_PS_HOLD_ENABLE		BIT(7)
> > >  #define  PON_PS_HOLD_TYPE_MASK		0x0f
> > > 
> > > +#define  PON_PS_HOLD_TYPE_WARM_RESET	1
> > > 
> > >  #define  PON_PS_HOLD_TYPE_SHUTDOWN	4
> > >  #define  PON_PS_HOLD_TYPE_HARD_RESET	7
> > > 
> > > @@ -93,7 +94,10 @@ static int pm8941_reboot_notify(struct notifier_block
> > > *nb, break;
> > > 
> > >  	case SYS_RESTART:
> > > 
> > >  	default:
> > > -		reset_type = PON_PS_HOLD_TYPE_HARD_RESET;
> > > +		if (reboot_mode == REBOOT_WARM)
> > 
> > This doesn't compile with CONFIG_INPUT_PM8941_PWRKEY=m
> > 
> >  ERROR: modpost: "reboot_mode" [drivers/input/misc/pm8941-pwrkey.ko]
> >  undefined!
> Thanks for the report!  I will add a patch to export the symbol.
> 
> > Also just to clarify, this is supposed to trigger when rebooting with
> > LINUX_REBOOT_CMD_RESTART2 and adding an argument that way, right?
> 
> With either of the following two methods, 'reboot_mode' will be turned
> into REBOOT_WARM.
> 
> - Boot kernel with 'reboot=warm' on cmdline
> 
> - Set warm mode via sysfs entry
>   $ echo warm > /sys/kernel/reboot/mode

+CC Sebastian Reichel

Do you have an idea how this situation should look from user space? Just using 
LINUX_REBOOT_CMD_RESTART2 with the param won't work if the reboot mode also 
has to be set to work - but that's also not the case on all boards.

Just LINUX_REBOOT_CMD_RESTART2 works fine on newer qcom SoCs that iirc store it 
in a pmic register that seems to survive a hard reboot.

Would it be a good idea to introduce a new dt property for e.g.
syscon-reboot-mode that makes it switch to warm reboot mode when a reboot mode 
is passed to the kernel? That way user space wouldn't need to care whether a 
particular board needs warm reboot or can just use the default hard reboot.

Regards
Luca

> Shawn





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

end of thread, other threads:[~2022-02-26 10:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29  3:05 [PATCH] Input: pm8941-pwrkey - respect reboot_mode for warm reset Shawn Guo
2021-07-11  9:57 ` Luca Weiss
2021-07-14  9:40   ` Shawn Guo
2022-02-26 10:04     ` Luca Weiss

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).