Skip to contentSkip to conversation

watchdog: sbsa_gwdt: add shutdown hook to driver

PATCH In review Qiang Zhao 2 participants 4 messages Aug 24, 2020 – Aug 27, 2020 Watchdog device drivers

lore
Share & tools
lore

Qiang Zhao

author
#0 lore raw

PATCH 1/1 watchdog: sbsa_gwdt: add shutdown hook to driver

From: Zhao Qiang <[email protected]>

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.

---
 drivers/watchdog/sbsa_gwdt.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/watchdog/sbsa_gwdt.c +9 -0
index f0f1e3b..bbcd04d 100644
@@ -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,
 };
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 7 lines · Qiang Zhao

From: Zhao Qiang <[email protected]>

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

Quoted 33 lines
---
 drivers/watchdog/sbsa_gwdt.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/watchdog/sbsa_gwdt.c +9 -0
index f0f1e3b..bbcd04d 100644
@@ -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,
 };
author
#2 lore raw
Quoted 10 lines · Guenter Roeck

-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: 2020年8月24日 21:29
To: Qiang Zhao <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] watchdog: sbsa_gwdt: add shutdown hook to driver

Quoted 2 lines · Qiang Zhao

From: Zhao Qiang <[email protected]>

Quoted 8 lines
Quoted 5 lines

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

maintainer
#3 lore raw
Quoted 18 lines · Qiang Zhao
Quoted 16 lines · Guenter Roeck

-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: 2020年8月24日 21:29
To: Qiang Zhao <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] watchdog: sbsa_gwdt: add shutdown hook to driver

Quoted 7 lines · Qiang Zhao

From: Zhao Qiang <[email protected]>

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.

Quoted 8 lines
Quoted 2 lines

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