Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Dec 2014 04:54:43 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r275660 - head/sys/arm/broadcom/bcm2835
Message-ID:  <201412100454.sBA4shNe030673@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Wed Dec 10 04:54:43 2014
New Revision: 275660
URL: https://svnweb.freebsd.org/changeset/base/275660

Log:
  Fix the watchdog timeout calculation to prevent wrap.  The RPi hardware
  can't do a timeout bigger than 15 seconds.  The code wasn't checking for
  this and because bitmasking was involved the requested timeout was
  basically adjusted modulo-16.  That led to things like a 128 second
  timeout actually being a 9 second timeout, which accidentally worked fine
  until watchdogd was changed to only pet the dog once every 10 seconds.

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c
==============================================================================
--- head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c	Wed Dec 10 03:12:22 2014	(r275659)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c	Wed Dec 10 04:54:43 2014	(r275660)
@@ -142,14 +142,13 @@ bcmwd_watchdog_fn(void *private, u_int c
 
 	if (cmd > 0) {
 		sec = ((uint64_t)1 << (cmd & WD_INTERVAL)) / 1000000000;
-		ticks = (sec << 16) & BCM2835_WDOG_TIME_MASK;
-		if (ticks == 0) {
+		if (sec == 0 || sec > 15) {
 			/* 
 			 * Can't arm
 			 * disable watchdog as watchdog(9) requires
 			 */
 			device_printf(sc->dev,
-			    "Can't arm, timeout is less than 1 second\n");
+			    "Can't arm, timeout must be between 1-15 seconds\n");
 			WRITE(sc, BCM2835_RSTC_REG, 
 			    (BCM2835_PASWORD << BCM2835_PASSWORD_SHIFT) |
 			    BCM2835_RSTC_RESET);
@@ -157,6 +156,7 @@ bcmwd_watchdog_fn(void *private, u_int c
 			return;
 		}
 
+		ticks = (sec << 16) & BCM2835_WDOG_TIME_MASK;
 		reg = (BCM2835_PASWORD << BCM2835_PASSWORD_SHIFT) | ticks;
 		WRITE(sc, BCM2835_WDOG_REG, reg);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412100454.sBA4shNe030673>