linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: sbsa_gwdt: add shutdown hook to driver
@ 2020-08-24  8:18 Qiang Zhao
  2020-08-24 13:28 ` Guenter Roeck
  0 siblings, 1 reply; 4+ messages in thread
From: Qiang Zhao @ 2020-08-24  8:18 UTC (permalink / raw)
  To: wim, linux; +Cc: linux-watchdog, linux-kernel, Zhao Qiang

From: Zhao Qiang <qiang.zhao@nxp.com>

Kexec maybe need more time than timeout of wdt(sbsa)
which will reset the system.
So it is necessary to add shutdown hook to disable the
wdt when run kexec.

Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
---
 drivers/watchdog/sbsa_gwdt.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c
index f0f1e3b..bbcd04d 100644
--- a/drivers/watchdog/sbsa_gwdt.c
+++ b/drivers/watchdog/sbsa_gwdt.c
@@ -313,6 +313,14 @@ static int sbsa_gwdt_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static void sbsa_gwdt_shutdown(struct platform_device *pdev)
+{
+	struct sbsa_gwdt *gwdt;
+
+	gwdt = platform_get_drvdata(pdev);
+	sbsa_gwdt_stop(&gwdt->wdd);
+}
+
 /* Disable watchdog if it is active during suspend */
 static int __maybe_unused sbsa_gwdt_suspend(struct device *dev)
 {
@@ -357,6 +365,7 @@ static struct platform_driver sbsa_gwdt_driver = {
 		.pm = &sbsa_gwdt_pm_ops,
 		.of_match_table = sbsa_gwdt_of_match,
 	},
+	.shutdown = sbsa_gwdt_shutdown,
 	.probe = sbsa_gwdt_probe,
 	.id_table = sbsa_gwdt_pdev_match,
 };
-- 
2.7.4


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

* Re: [PATCH] watchdog: sbsa_gwdt: add shutdown hook to driver
  2020-08-24  8:18 [PATCH] watchdog: sbsa_gwdt: add shutdown hook to driver Qiang Zhao
@ 2020-08-24 13:28 ` Guenter Roeck
  2020-08-27  7:55   ` Qiang Zhao
  0 siblings, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2020-08-24 13:28 UTC (permalink / raw)
  To: Qiang Zhao, wim; +Cc: linux-watchdog, linux-kernel

On 8/24/20 1:18 AM, Qiang Zhao wrote:
> From: Zhao Qiang <qiang.zhao@nxp.com>
> 
> Kexec maybe need more time than timeout of wdt(sbsa)
> which will reset the system.
> So it is necessary to add shutdown hook to disable the
> wdt when run kexec.
> 

Please explain why watchdog_stop_on_reboot() does not work.

Thanks,
Guenter

> Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
> ---
>  drivers/watchdog/sbsa_gwdt.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c
> index f0f1e3b..bbcd04d 100644
> --- a/drivers/watchdog/sbsa_gwdt.c
> +++ b/drivers/watchdog/sbsa_gwdt.c
> @@ -313,6 +313,14 @@ static int sbsa_gwdt_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static void sbsa_gwdt_shutdown(struct platform_device *pdev)
> +{
> +	struct sbsa_gwdt *gwdt;
> +
> +	gwdt = platform_get_drvdata(pdev);
> +	sbsa_gwdt_stop(&gwdt->wdd);
> +}
> +
>  /* Disable watchdog if it is active during suspend */
>  static int __maybe_unused sbsa_gwdt_suspend(struct device *dev)
>  {
> @@ -357,6 +365,7 @@ static struct platform_driver sbsa_gwdt_driver = {
>  		.pm = &sbsa_gwdt_pm_ops,
>  		.of_match_table = sbsa_gwdt_of_match,
>  	},
> +	.shutdown = sbsa_gwdt_shutdown,
>  	.probe = sbsa_gwdt_probe,
>  	.id_table = sbsa_gwdt_pdev_match,
>  };
> 


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

* RE: [PATCH] watchdog: sbsa_gwdt: add shutdown hook to driver
  2020-08-24 13:28 ` Guenter Roeck
@ 2020-08-27  7:55   ` Qiang Zhao
  2020-08-27 16:52     ` Guenter Roeck
  0 siblings, 1 reply; 4+ messages in thread
From: Qiang Zhao @ 2020-08-27  7:55 UTC (permalink / raw)
  To: Guenter Roeck, wim; +Cc: linux-watchdog, linux-kernel

On 8/24/20 21:29 AM, Guenter Roeck <linux@roeck-us.net> wrote:

> -----Original Message-----
> From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter Roeck
> Sent: 2020年8月24日 21:29
> To: Qiang Zhao <qiang.zhao@nxp.com>; wim@linux-watchdog.org
> Cc: linux-watchdog@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] watchdog: sbsa_gwdt: add shutdown hook to driver
> 
> On 8/24/20 1:18 AM, Qiang Zhao wrote:
> > From: Zhao Qiang <qiang.zhao@nxp.com>
> >
> > Kexec maybe need more time than timeout of wdt(sbsa) which will reset
> > the system.
> > So it is necessary to add shutdown hook to disable the wdt when run
> > kexec.
> >
> 
> Please explain why watchdog_stop_on_reboot() does not work.
> 

Thank you for your comments, it is helpful.
I investigate this issue again, found that this watchdog are enabled by uboot,
Meanwhile in kernel, it is not the default watchdog, in another words, it is not active in kernel.
So watchdog_stop_on_reboot() does not work.
This patch is not the right solution for the situation, I will abandon it. 

Best Regards
Qiang Zhao

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

* Re: [PATCH] watchdog: sbsa_gwdt: add shutdown hook to driver
  2020-08-27  7:55   ` Qiang Zhao
@ 2020-08-27 16:52     ` Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2020-08-27 16:52 UTC (permalink / raw)
  To: Qiang Zhao; +Cc: wim, linux-watchdog, linux-kernel

On Thu, Aug 27, 2020 at 07:55:31AM +0000, Qiang Zhao wrote:
> On 8/24/20 21:29 AM, Guenter Roeck <linux@roeck-us.net> wrote:
> 
> > -----Original Message-----
> > From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter Roeck
> > Sent: 2020年8月24日 21:29
> > To: Qiang Zhao <qiang.zhao@nxp.com>; wim@linux-watchdog.org
> > Cc: linux-watchdog@vger.kernel.org; linux-kernel@vger.kernel.org
> > Subject: Re: [PATCH] watchdog: sbsa_gwdt: add shutdown hook to driver
> > 
> > On 8/24/20 1:18 AM, Qiang Zhao wrote:
> > > From: Zhao Qiang <qiang.zhao@nxp.com>
> > >
> > > Kexec maybe need more time than timeout of wdt(sbsa) which will reset
> > > the system.
> > > So it is necessary to add shutdown hook to disable the wdt when run
> > > kexec.
> > >
> > 
> > Please explain why watchdog_stop_on_reboot() does not work.
> > 
> 
> Thank you for your comments, it is helpful.
> I investigate this issue again, found that this watchdog are enabled by uboot,
> Meanwhile in kernel, it is not the default watchdog, in another words, it is not active in kernel.
> So watchdog_stop_on_reboot() does not work.
> This patch is not the right solution for the situation, I will abandon it. 

Yes, it is the wrong solution. watchdog_reboot_notifier() needs to be
fixed instead: It needs to check check if the hardware watchdog is running
(not if it is active). Also, the reboot notifier should only be registered
if the stop callback exists (and otherwise bail out with an error).

Thanks,
Guenter

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

end of thread, other threads:[~2020-08-27 16:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-24  8:18 [PATCH] watchdog: sbsa_gwdt: add shutdown hook to driver Qiang Zhao
2020-08-24 13:28 ` Guenter Roeck
2020-08-27  7:55   ` Qiang Zhao
2020-08-27 16:52     ` Guenter Roeck

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