watchdog: tegra: Stop watchdog first if restarting
Subsystems (2)
PATCH 1/1 watchdog: tegra: Stop watchdog first if restarting
If we need to restart the watchdog due to someone changing the timeout interval, stop the watchdog before restarting it. Otherwise, the new timeout doesn't seem to take.
--- drivers/watchdog/tegra_wdt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/watchdog/tegra_wdt.c +3 -1
@@ -140,8 +140,10 @@ static int tegra_wdt_set_timeout(struct watchdog_device *wdd, { wdd->timeout = timeout; -if (watchdog_active (wdd)) +if (watchdog_active (wdd)) { +tegra_wdt_stop (wdd);return tegra_wdt_start (wdd); + }return 0 ; }
Signature · 1 line
2.1.4
Quoted 5 lines · Andrew Chew
If we need to restart the watchdog due to someone changing the timeout interval, stop the watchdog before restarting it. Otherwise, the new timeout doesn't seem to take.
Signed-off-by Andrew Chew <[email protected]>
Some feedback from the maintainers would be helpful, though, especially if there is some other means to change the timeout without stopping the watchdog.
Guenter
Quoted 21 lines
--- drivers/watchdog/tegra_wdt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/watchdog/tegra_wdt.c +3
-1@@ -140,8 +140,10 @@ static int tegra_wdt_set_timeout(struct watchdog_device *wdd, { wdd->timeout = timeout; -if (watchdog_active (wdd)) +if (watchdog_active (wdd)) { +tegra_wdt_stop (wdd);return tegra_wdt_start (wdd); + }return 0 ; }
Thierry Reding
Reviewed-byQuoted 5 lines · Guenter Roeck
Quoted 4 lines · Andrew Chew
If we need to restart the watchdog due to someone changing the timeout interval, stop the watchdog before restarting it. Otherwise, the new timeout doesn't seem to take.
Quoted 7 lines
Quoted 1 line
Signed-off-by Andrew Chew <[email protected]>Reviewed-by Guenter Roeck <[email protected]>Some feedback from the maintainers would be helpful, though, especially if there is some other means to change the timeout without stopping the watchdog.
I don't think there is. The TIMER_WDT<w>_COMMAND_0 register has this description:
"The StartCounter bit enables watchdog counter operation, loads the watchdog counter, starts the watchdog timer to count down, resets the expiration count to 0, and clears all flags. Also used as restart.
..."
The way I read this is that the watchdog period (the field that the wdd->timeout value gets written to) is latched when the StartCounter bit transitions from 0 to 1. So this change looks correct to me:
Andrew, it might be worthwhile to file an internal bug report to see if we can get the TRM updated with a more explicit programming sequence or at least get confirmation from one of the hardware designers whether or not this is the correct sequence when changing the period.
Thierry