Skip to contentSkip to conversation

watchdog: tegra: Stop watchdog first if restarting

PATCH In review Andrew Chew 3 participants 3 messages Nov 10, 2015 – Nov 16, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 7f97cdd..9ec5760 100644
@@ -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
maintainer Reviewed-by on v1 1/1
#1 lore raw
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.

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
index 7f97cdd..9ec5760 100644
@@ -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;
  }
Reviewed-by
#2 lore raw
Quoted 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

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