Some impovements about watchdog
v3 cover Some impovements about watchdog
Changelog:v1->v2 Update the commit messagesv2->v3 - Add the context about why using watchdog_timeout_invalid.
- Using SET_NOIRQ_SYSTEM_SLEEP_PM_OPS reduces redundant code for iTCO watchdog.v3->v4 - For patch 1, update commit message, rename WDAT_TIMEOUT_MIN
to WDAT_MIN_TIMEOUT, keeps consistent with WDAT_DEFAULT_TIMEOUT.
- For patch 4, iTCO_wdt_suspend_noirq and iTCO_wdt_resume_noirq are possible unused, so keep "ifdef CONFIG_PM_SLEEP ... #endif".
Liu Xinpeng (4):
watchdog: wdat_wdg: Using the existed function to check parameter
timeout
watchdog: wdat_wdg: Stop watchdog when rebooting the system
watchdog: wdat_wdg: Stop watchdog when uninstalling module
watchdog: iTCO_wdg: Make code more clearly with macro definition
drivers/watchdog/iTCO_wdt.c | 12 +++--------- drivers/watchdog/wdat_wdt.c | 7 +++++-- 2 files changed, 8 insertions(+), 11 deletions(-)
Signature · 1 line
2.23.0
PATCH v4 1/4 watchdog: wdat_wdg: Using the existed function to check parameter timeout
Context: If max_hw_heartbeat_ms is provided, the configured maximum timeout is not limited by it. The limit check in this driver therefore doesn't make much sense. Similar, the watchdog core ensures that minimum timeout limits are met if min_hw_heartbeat_ms is set. Using watchdog_timeout_invalid() makes more sense because it takes this into account.
--- drivers/watchdog/wdat_wdt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/watchdog/wdat_wdt.c +3 -2
@@ -55,6 +55,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");#define WDAT_DEFAULT_TIMEOUT 30 +#define WDAT_MIN_TIMEOUT 1static int timeout =WDAT_DEFAULT_TIMEOUT ;module_param (timeout, int,0 );
@@ -344,6 +345,7 @@ static int wdat_wdt_probe(struct platform_device *pdev) wdat->period = tbl->timer_period; wdat->wdd.min_hw_heartbeat_ms = wdat->period * tbl->min_count; wdat->wdd.max_hw_heartbeat_ms = wdat->period * tbl->max_count; + wdat->wdd.min_timeout =WDAT_MIN_TIMEOUT ; wdat->stopped_in_sleep = tbl->flags &ACPI_WDAT_STOPPED ; wdat->wdd.info = &wdat_wdt_info; wdat->wdd.ops = &wdat_wdt_ops;
@@ -450,8 +452,7 @@ static int wdat_wdt_probe(struct platform_device *pdev)* watchdog properly after it has opened the device. In some cases * the BIOS default is too short and causes immediate reboot. */ -if (timeout *1000 < wdat->wdd.min_hw_heartbeat_ms || - timeout *1000 > wdat->wdd.max_hw_heartbeat_ms) { +if (watchdog_timeout_invalid (&wdat->wdd, timeout)) {dev_warn (dev,"Invalid timeout %d given, using %d\n" , timeout,WDAT_DEFAULT_TIMEOUT ); timeout =WDAT_DEFAULT_TIMEOUT ;
Signature · 1 line
2.23.0
PATCH v4 2/4 watchdog: wdat_wdg: Stop watchdog when rebooting the system
In reply to Liu XinpengExecuting reboot command several times on the machine "Dell PowerEdge R740", UEFI security detection stopped machine with the following prompt:
UEFI0082: The system was reset due to a timeout from the watchdog timer. Check the System Event Log (SEL) or crash dumps from Operating Sysstem to identify the source that triggered the watchdog timer reset. Update the firmware or driver for the identified device.
iDRAC has warning event: "The watchdog timer reset the system".
This patch fixes this issue by adding the reboot notifier.
--- drivers/watchdog/wdat_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/wdat_wdt.c +1 -0
@@ -463,6 +463,7 @@ static int wdat_wdt_probe(struct platform_device *pdev)return ret;watchdog_set_nowayout (&wdat->wdd, nowayout); +watchdog_stop_on_reboot (&wdat->wdd);return devm_watchdog_register_device (dev, &wdat->wdd); }
Signature · 1 line
2.23.0
PATCH v4 3/4 watchdog: wdat_wdg: Stop watchdog when uninstalling module
In reply to Liu XinpengTest shows that wachdog still reboots machine after the module is removed. Use watchdog_stop_on_unregister to stop the watchdog on removing.
--- drivers/watchdog/wdat_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/wdat_wdt.c +1 -0
@@ -464,6 +464,7 @@ static int wdat_wdt_probe(struct platform_device *pdev)watchdog_set_nowayout (&wdat->wdd, nowayout);watchdog_stop_on_reboot (&wdat->wdd); +watchdog_stop_on_unregister (&wdat->wdd);return devm_watchdog_register_device (dev, &wdat->wdd); }
Signature · 1 line
2.23.0
PATCH v4 4/4 watchdog: iTCO_wdg: Make code more clearly with macro definition
In reply to Liu XinpengUsing SET_NOIRQ_SYSTEM_SLEEP_PM_OPS reduces redundant code.
--- drivers/watchdog/iTCO_wdt.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/watchdog/iTCO_wdt.c +4 -8
@@ -635,22 +635,18 @@ static int iTCO_wdt_resume_noirq(struct device *dev) return 0; } +#endif /* CONFIG_PM_SLEEP */ static const struct dev_pm_ops iTCO_wdt_pm = { - .suspend_noirq = iTCO_wdt_suspend_noirq, - .resume_noirq = iTCO_wdt_resume_noirq, +SET_NOIRQ_SYSTEM_SLEEP_PM_OPS (iTCO_wdt_suspend_noirq, + iTCO_wdt_resume_noirq) }; -#define ITCO_WDT_PM_OPS (&iTCO_wdt_pm) -#else -#define ITCO_WDT_PM_OPS NULL -#endif /* CONFIG_PM_SLEEP */ -static struct platform_driver iTCO_wdt_driver = { .probe = iTCO_wdt_probe, .driver = { .name =DRV_NAME , - .pm =ITCO_WDT_PM_OPS , + .pm = &iTCO_wdt_pm, }, };
Signature · 1 line
2.23.0