aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorBoris BREZILLON <b.brezillon@overkiz.com>2013-11-03 12:52:43 -0500
committerWim Van Sebroeck <wim@iguana.be>2014-01-28 15:34:38 -0500
commita04c3f01d33f4661424deeff67913699a0910c53 (patch)
tree0632c5a099c300fe0414244cebe8dce8ce051334 /drivers/watchdog
parent1444797fc178b58e91cf29a438efd05dd890d43a (diff)
watchdog: at91sam9_wdt: avoid spurious watchdog reset during init
Use the min_heartbeat value instead of the calculated heartbeat value for the first watchdog reset to avoid spurious watchdog reset. Resetting the watchdog counter during init might lead to a watchdog fault reset because the watchdog counter has to be running for at least min_heartbeat. Resetting the watchdog counter after heartbeat might lead to a watchdog timeout reset because the watchdog counter is running for more than max_heartbeat time. Using min_heartbeat instead of heartbeat does not guarantee that the watchdog won't trigger a reset, but at least it reduces the chances to be in such a case. Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/at91sam9_wdt.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index 65f469145950..ab0c4e0165d1 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -213,7 +213,15 @@ static int at91_wdt_init(struct platform_device *pdev, struct at91wdt *wdt)
213 tmp & wdt->mr_mask, wdt->mr & wdt->mr_mask); 213 tmp & wdt->mr_mask, wdt->mr & wdt->mr_mask);
214 214
215 setup_timer(&wdt->timer, at91_ping, (unsigned long)wdt); 215 setup_timer(&wdt->timer, at91_ping, (unsigned long)wdt);
216 mod_timer(&wdt->timer, jiffies + wdt->heartbeat); 216
217 /*
218 * Use min_heartbeat the first time to avoid spurious watchdog reset:
219 * we don't know for how long the watchdog counter is running, and
220 * - resetting it right now might trigger a watchdog fault reset
221 * - waiting for heartbeat time might lead to a watchdog timeout
222 * reset
223 */
224 mod_timer(&wdt->timer, jiffies + min_heartbeat);
217 225
218 /* Try to set timeout from device tree first */ 226 /* Try to set timeout from device tree first */
219 if (watchdog_init_timeout(&wdt->wdd, 0, dev)) 227 if (watchdog_init_timeout(&wdt->wdd, 0, dev))