Skip to contentSkip to conversation

watchdog:improve w83627hf_wdt to timeout in minutes

PATCH Superseded Tony Chung 3 participants 4 messages Mar 25, 2013 – Mar 29, 2013 1 message not in the archive Watchdog device drivers

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Tony Chung

author
#0 lore raw

PATCH 1/1 watchdog:improve w83627hf_wdt to timeout in minutes

The current maximum of 255 seconds is insufficient. For example, crash dump could take 5+ minutes.

---
 drivers/watchdog/w83627hf_wdt.c |   73 ++++++++++++++++++++++++++++++--------
 1 files changed, 57 insertions(+), 16 deletions(-)
drivers/watchdog/w83627hf_wdt.c +57 -16
index 92f1326..d26adfb 100644
@@ -58,7 +58,7 @@ MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port (default 0x2E)");
 static int timeout = WATCHDOG_TIMEOUT;	/* in seconds */
 module_param(timeout, int, 0);
 MODULE_PARM_DESC(timeout,
-		"Watchdog timeout in seconds. 1 <= timeout <= 255, default="
+		"Watchdog timeout in seconds. 1 <= timeout <= 15300, default="
 				__MODULE_STRING(WATCHDOG_TIMEOUT) ".");
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
@@ -67,6 +67,29 @@ MODULE_PARM_DESC(nowayout,
 		"Watchdog cannot be stopped once started (default="
 				__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
+/* timeout unit in minute */
+static bool use_minute;
+static char *unit;
+static int max_timeout = 15300; /* 255*60 seconds */
+
+static inline int wdt_round_secs_to_minute(int t)
+{
+	return (t + 59) / 60;
+}
+
+static inline int wdt_use_minute(int t)
+{
+	if (t > 255) {
+		t = wdt_round_secs_to_minute(t);
+		use_minute = 1;
+		unit = "minutes";
+	} else {
+		use_minute = 0;
+		unit = "secs";
+	}
+	return t;
+}
+
 /*
  *	Kernel methods.
  */
@@ -107,6 +130,23 @@ static void w83627hf_unselect_wd_register(void)
 	outb_p(0xAA, WDT_EFER); /* Leave extended function mode */
 }
 
+/* set CRF5 register */
+static void w83627hf_set_crf5(void)
+{
+	unsigned char t;
+
+	outb_p(0xF5, WDT_EFER); /* Select CRF5 */
+	t = inb_p(WDT_EFDR);      /* read CRF5 */
+	t &= ~0x0C;               /* set second mode & disable keyboard
+				    turning off watchdog */
+	t |= 0x02;		  /* enable the WDTO# output low pulse
+				    to the KBRST# pin (PIN60) */
+	if (use_minute)
+		t |= 0x80;        /* set timeout in minute */
+
+	outb_p(t, WDT_EFDR);    /* Write back to CRF5 */
+}
+
 /* tyan motherboards seem to set F5 to 0x4C ?
  * So explicitly init to appropriate value. */
 
@@ -116,21 +156,16 @@ static void w83627hf_init(void)
 
 	w83627hf_select_wd_register();
 
+	w83627hf_set_crf5();
+
 	outb_p(0xF6, WDT_EFER); /* Select CRF6 */
 	t = inb_p(WDT_EFDR);      /* read CRF6 */
 	if (t != 0) {
-		pr_info("Watchdog already running. Resetting timeout to %d sec\n",
-			timeout);
+		pr_info("Watchdog already running.  Reset timeout to %d %s\n",
+			timeout, unit);
 		outb_p(timeout, WDT_EFDR);    /* Write back to CRF6 */
 	}
 
-	outb_p(0xF5, WDT_EFER); /* Select CRF5 */
-	t = inb_p(WDT_EFDR);      /* read CRF5 */
-	t &= ~0x0C;               /* set second mode & disable keyboard
-				    turning off watchdog */
-	t |= 0x02;		  /* enable the WDTO# output low pulse
-				    to the KBRST# pin (PIN60) */
-	outb_p(t, WDT_EFDR);    /* Write back to CRF5 */
 
 	outb_p(0xF7, WDT_EFER); /* Select CRF7 */
 	t = inb_p(WDT_EFDR);      /* read CRF7 */
@@ -147,6 +182,9 @@ static void wdt_set_time(int timeout)
 
 	w83627hf_select_wd_register();
 
+	if (use_minute)
+		w83627hf_set_crf5();
+
 	outb_p(0xF6, WDT_EFER);    /* Select CRF6 */
 	outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF6 */
 
@@ -169,9 +207,9 @@ static int wdt_disable(void)
 
 static int wdt_set_heartbeat(int t)
 {
-	if (t < 1 || t > 255)
+	if (t < 1 || t > max_timeout)
 		return -EINVAL;
-	timeout = t;
+	timeout = wdt_use_minute(t);
 	return 0;
 }
 
@@ -262,9 +300,11 @@ static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		wdt_ping();
 		/* Fall */
 	case WDIOC_GETTIMEOUT:
-		return put_user(timeout, p);
+		timeval = (use_minute) ? timeout * 60 : timeout;
+		return put_user(timeval, p);
 	case WDIOC_GETTIMELEFT:
 		timeval = wdt_get_time();
+		timeval = (use_minute) ? timeval * 60 : timeval;
 		return put_user(timeval, p);
 	default:
 		return -ENOTTY;
@@ -346,7 +386,8 @@ static int __init wdt_init(void)
 
 	if (wdt_set_heartbeat(timeout)) {
 		wdt_set_heartbeat(WATCHDOG_TIMEOUT);
-		pr_info("timeout value must be 1 <= timeout <= 255, using %d\n",
+		pr_info("timeout value must be 1 <= timeout <= %d, using %d\n",
+			max_timeout,
 			WATCHDOG_TIMEOUT);
 	}
 
@@ -371,8 +412,8 @@ static int __init wdt_init(void)
 		goto unreg_reboot;
 	}
 
-	pr_info("initialized. timeout=%d sec (nowayout=%d)\n",
-		timeout, nowayout);
+	pr_info("initialized. timeout=%d %s (nowayout=%d)\n",
+		timeout, unit, nowayout);
 
 out:
 	return ret;
Signature · 1 line
1.7.0.4
maintainer
#1 lore raw
Quoted 4 lines · Tony Chung

The current maximum of 255 seconds is insufficient. For example, crash dump could take 5+ minutes.

I would suggest to use the port to the watchdog infrastructure for any changes on this driver.

Quoted 20 lines
---
 drivers/watchdog/w83627hf_wdt.c |   73 ++++++++++++++++++++++++++++++--------
 1 files changed, 57 insertions(+), 16 deletions(-)
drivers/watchdog/w83627hf_wdt.c +1 -1
index 92f1326..d26adfb 100644
@@ -58,7 +58,7 @@ MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port (default 0x2E)");
 static int timeout = WATCHDOG_TIMEOUT;	/* in seconds */
 module_param(timeout, int, 0);
 MODULE_PARM_DESC(timeout,
-		"Watchdog timeout in seconds. 1 <= timeout <= 255, default="
+		"Watchdog timeout in seconds. 1 <= timeout <= 15300, default="
 				__MODULE_STRING(WATCHDOG_TIMEOUT) ".");
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
@@ -67,6 +67,29 @@ MODULE_PARM_DESC(nowayout,
 		"Watchdog cannot be stopped once started (default="
 				__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");

drivers/watchdog/w83627hf_wdt.c MODULE_PARM_DESC(nowayout, · line 78

Quoted 10 lines
drivers/watchdog/w83627hf_wdt.c +9 -0
 
+/* timeout unit in minute */
+static bool use_minute;
+static char *unit;
+static int max_timeout = 15300; /* 255*60 seconds */
+
+static inline int wdt_round_secs_to_minute(int t)
+{
+	return (t + 59) / 60;
+}

Use DIV_ROUND_UP().

drivers/watchdog/w83627hf_wdt.c MODULE_PARM_DESC(nowayout, · line 84

Quoted 6 lines
drivers/watchdog/w83627hf_wdt.c +6 -0
+
+static inline int wdt_use_minute(int t)
+{
+	if (t > 255) {
+		t = wdt_round_secs_to_minute(t);
+		use_minute = 1;

bool has true / false.

Quoted 62 lines
drivers/watchdog/w83627hf_wdt.c +29 -9
+		unit = "minutes";
+	} else {
+		use_minute = 0;
+		unit = "secs";
+	}
+	return t;
+}
+
 /*
  *	Kernel methods.
  */
@@ -107,6 +130,23 @@ static void w83627hf_unselect_wd_register(void)
 	outb_p(0xAA, WDT_EFER); /* Leave extended function mode */
 }
 
+/* set CRF5 register */
+static void w83627hf_set_crf5(void)
+{
+	unsigned char t;
+
+	outb_p(0xF5, WDT_EFER); /* Select CRF5 */
+	t = inb_p(WDT_EFDR);      /* read CRF5 */
+	t &= ~0x0C;               /* set second mode & disable keyboard
+				    turning off watchdog */
+	t |= 0x02;		  /* enable the WDTO# output low pulse
+				    to the KBRST# pin (PIN60) */
+	if (use_minute)
+		t |= 0x80;        /* set timeout in minute */
+
+	outb_p(t, WDT_EFDR);    /* Write back to CRF5 */
+}
+
 /* tyan motherboards seem to set F5 to 0x4C ?
  * So explicitly init to appropriate value. */
 
@@ -116,21 +156,16 @@ static void w83627hf_init(void)
 
 	w83627hf_select_wd_register();
 
+	w83627hf_set_crf5();
+
 	outb_p(0xF6, WDT_EFER); /* Select CRF6 */
 	t = inb_p(WDT_EFDR);      /* read CRF6 */
 	if (t != 0) {
-		pr_info("Watchdog already running. Resetting timeout to %d sec\n",
-			timeout);
+		pr_info("Watchdog already running.  Reset timeout to %d %s\n",
+			timeout, unit);
 		outb_p(timeout, WDT_EFDR);    /* Write back to CRF6 */
 	}
 
-	outb_p(0xF5, WDT_EFER); /* Select CRF5 */
-	t = inb_p(WDT_EFDR);      /* read CRF5 */
-	t &= ~0x0C;               /* set second mode & disable keyboard
-				    turning off watchdog */
-	t |= 0x02;		  /* enable the WDTO# output low pulse
-				    to the KBRST# pin (PIN60) */
-	outb_p(t, WDT_EFDR);    /* Write back to CRF5 */
 
 	outb_p(0xF7, WDT_EFER); /* Select CRF7 */
 	t = inb_p(WDT_EFDR);      /* read CRF7 */

drivers/watchdog/w83627hf_wdt.c static void wdt_set_time(int timeout) · line 186

Quoted 5 lines
drivers/watchdog/w83627hf_wdt.c +2 -0
@@ -147,6 +182,9 @@ static void wdt_set_time(int timeout)
 
 	w83627hf_select_wd_register();
 
+	if (use_minute)
+		w83627hf_set_crf5();

What if the new timeout is less than 256 seconds ?

drivers/watchdog/w83627hf_wdt.c static int wdt_disable(void) · line 212

Quoted 13 lines
drivers/watchdog/w83627hf_wdt.c +3 -2
+
 	outb_p(0xF6, WDT_EFER);    /* Select CRF6 */
 	outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF6 */
 
@@ -169,9 +207,9 @@ static int wdt_disable(void)
 
 static int wdt_set_heartbeat(int t)
 {
-	if (t < 1 || t > 255)
+	if (t < 1 || t > max_timeout)
 		return -EINVAL;
-	timeout = t;
+	timeout = wdt_use_minute(t);

This should probably also update the watchdog timer register.

drivers/watchdog/w83627hf_wdt.c static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 303

Quoted 9 lines
drivers/watchdog/w83627hf_wdt.c +1 -1
 	return 0;
 }
 
@@ -262,9 +300,11 @@ static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		wdt_ping();
 		/* Fall */
 	case WDIOC_GETTIMEOUT:
-		return put_user(timeout, p);
+		timeval = (use_minute) ? timeout * 60 : timeout;

Isn't timeout always in seconds ?

Quoted 8 lines
drivers/watchdog/w83627hf_wdt.c +2 -0
+		return put_user(timeval, p);
 	case WDIOC_GETTIMELEFT:
 		timeval = wdt_get_time();
+		timeval = (use_minute) ? timeval * 60 : timeval;
 		return put_user(timeval, p);
 	default:
 		return -ENOTTY;

drivers/watchdog/w83627hf_wdt.c static int __init wdt_init(void) · line 390

Quoted 6 lines
drivers/watchdog/w83627hf_wdt.c +2 -1
@@ -346,7 +386,8 @@ static int __init wdt_init(void)
 
 	if (wdt_set_heartbeat(timeout)) {
 		wdt_set_heartbeat(WATCHDOG_TIMEOUT);
-		pr_info("timeout value must be 1 <= timeout <= 255, using %d\n",
+		pr_info("timeout value must be 1 <= timeout <= %d, using %d\n",
+			max_timeout,

That is still a constant, isn't it ? Why use a variable ?

Quoted 22 lines
drivers/watchdog/w83627hf_wdt.c +2 -2
 			WATCHDOG_TIMEOUT);
 	}
 
@@ -371,8 +412,8 @@ static int __init wdt_init(void)
 		goto unreg_reboot;
 	}
 
-	pr_info("initialized. timeout=%d sec (nowayout=%d)\n",
-		timeout, nowayout);
+	pr_info("initialized. timeout=%d %s (nowayout=%d)\n",
+		timeout, unit, nowayout);
 
 out:
 	return ret;
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAHyaeP0aTBcqpb0uUcwKCfzi-gJfrEoX6vQK08kN5Vh7sOqVBg@mail.gmail.com

maintainer
#3 lore raw
Quoted 5 lines · Tony Chung

Thanks Guenter.

So will the new watchdog infrastructure for this driver back-ported to older LTS releases?

I don't think so.

Guenter

Quoted 207 lines · Guenter Roeck
Quoted 201 lines · Tony Chung
Quoted 4 lines

The current maximum of 255 seconds is insufficient. For example, crash dump could take 5+ minutes.

I would suggest to use the port to the watchdog infrastructure for any changes on this driver.

Quoted 2 lines
---
 drivers/watchdog/w83627hf_wdt.c |   73

++++++++++++++++++++++++++++++--------

Review

Quoted 3 lines
 1 files changed, 57 insertions(+), 16 deletions(-)
(quoted diff) +0 -0

b/drivers/watchdog/w83627hf_wdt.c

drivers/watchdog/w83627hf_wdt.c MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port

Quoted 4 lines

index 92f1326..d26adfb 100644

drivers/watchdog/w83627hf_wdt.c +0 -0
@@ -58,7 +58,7 @@ MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port

(default 0x2E)");

drivers/watchdog/w83627hf_wdt.c MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port (default 0x2E)");

Quoted 4 lines
drivers/watchdog/w83627hf_wdt.c +0 -1
 static int timeout = WATCHDOG_TIMEOUT;       /* in seconds */
 module_param(timeout, int, 0);
 MODULE_PARM_DESC(timeout,
-             "Watchdog timeout in seconds. 1 <= timeout <= 255,

default="

drivers/watchdog/w83627hf_wdt.c MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port · line 61

Quoted 1 line
drivers/watchdog/w83627hf_wdt.c +1 -0
+             "Watchdog timeout in seconds. 1 <= timeout <= 15300,

default="

Quoted 6 lines
drivers/watchdog/w83627hf_wdt.c +0 -0
                              __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
@@ -67,6 +67,29 @@ MODULE_PARM_DESC(nowayout,
              "Watchdog cannot be stopped once started (default="
                              __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");

drivers/watchdog/w83627hf_wdt.c MODULE_PARM_DESC(nowayout, · line 78

Quoted 10 lines
drivers/watchdog/w83627hf_wdt.c +9 -0
 
+/* timeout unit in minute */
+static bool use_minute;
+static char *unit;
+static int max_timeout = 15300; /* 255*60 seconds */
+
+static inline int wdt_round_secs_to_minute(int t)
+{
+     return (t + 59) / 60;
+}

Use DIV_ROUND_UP().

drivers/watchdog/w83627hf_wdt.c MODULE_PARM_DESC(nowayout, · line 84

Quoted 6 lines
drivers/watchdog/w83627hf_wdt.c +6 -0
+
+static inline int wdt_use_minute(int t)
+{
+     if (t > 255) {
+             t = wdt_round_secs_to_minute(t);
+             use_minute = 1;

bool has true / false.

Quoted 36 lines
drivers/watchdog/w83627hf_wdt.c +25 -0
+             unit = "minutes";
+     } else {
+             use_minute = 0;
+             unit = "secs";
+     }
+     return t;
+}
+
 /*
  *   Kernel methods.
  */
@@ -107,6 +130,23 @@ static void w83627hf_unselect_wd_register(void)
      outb_p(0xAA, WDT_EFER); /* Leave extended function mode */
 }
 
+/* set CRF5 register */
+static void w83627hf_set_crf5(void)
+{
+     unsigned char t;
+
+     outb_p(0xF5, WDT_EFER); /* Select CRF5 */
+     t = inb_p(WDT_EFDR);      /* read CRF5 */
+     t &= ~0x0C;               /* set second mode & disable keyboard
+                                 turning off watchdog */
+     t |= 0x02;                /* enable the WDTO# output low pulse
+                                 to the KBRST# pin (PIN60) */
+     if (use_minute)
+             t |= 0x80;        /* set timeout in minute */
+
+     outb_p(t, WDT_EFDR);    /* Write back to CRF5 */
+}
+
 /* tyan motherboards seem to set F5 to 0x4C ?
  * So explicitly init to appropriate value. */
 

drivers/watchdog/w83627hf_wdt.c static void w83627hf_init(void) · line 122

Quoted 9 lines
drivers/watchdog/w83627hf_wdt.c +2 -1
@@ -116,21 +156,16 @@ static void w83627hf_init(void)
 
      w83627hf_select_wd_register();
 
+     w83627hf_set_crf5();
+
      outb_p(0xF6, WDT_EFER); /* Select CRF6 */
      t = inb_p(WDT_EFDR);      /* read CRF6 */
      if (t != 0) {
-             pr_info("Watchdog already running. Resetting timeout to %d

sec\n",

drivers/watchdog/w83627hf_wdt.c static void w83627hf_init(void) · line 164

Quoted 2 lines
drivers/watchdog/w83627hf_wdt.c +1 -1
-                     timeout);
+             pr_info("Watchdog already running.  Reset timeout to %d

%s\n",

Quoted 15 lines
drivers/watchdog/w83627hf_wdt.c +1 -7
+                     timeout, unit);
              outb_p(timeout, WDT_EFDR);    /* Write back to CRF6 */
      }
 
-     outb_p(0xF5, WDT_EFER); /* Select CRF5 */
-     t = inb_p(WDT_EFDR);      /* read CRF5 */
-     t &= ~0x0C;               /* set second mode & disable keyboard
-                                 turning off watchdog */
-     t |= 0x02;                /* enable the WDTO# output low pulse
-                                 to the KBRST# pin (PIN60) */
-     outb_p(t, WDT_EFDR);    /* Write back to CRF5 */
 
      outb_p(0xF7, WDT_EFER); /* Select CRF7 */
      t = inb_p(WDT_EFDR);      /* read CRF7 */

drivers/watchdog/w83627hf_wdt.c static void wdt_set_time(int timeout) · line 186

Quoted 5 lines
drivers/watchdog/w83627hf_wdt.c +2 -0
@@ -147,6 +182,9 @@ static void wdt_set_time(int timeout)
 
      w83627hf_select_wd_register();
 
+     if (use_minute)
+             w83627hf_set_crf5();

What if the new timeout is less than 256 seconds ?

drivers/watchdog/w83627hf_wdt.c static int wdt_disable(void) · line 212

Quoted 13 lines
drivers/watchdog/w83627hf_wdt.c +3 -2
+
      outb_p(0xF6, WDT_EFER);    /* Select CRF6 */
      outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF6 */
 
@@ -169,9 +207,9 @@ static int wdt_disable(void)
 
 static int wdt_set_heartbeat(int t)
 {
-     if (t < 1 || t > 255)
+     if (t < 1 || t > max_timeout)
              return -EINVAL;
-     timeout = t;
+     timeout = wdt_use_minute(t);

This should probably also update the watchdog timer register.

drivers/watchdog/w83627hf_wdt.c static long wdt_ioctl(struct file *file, unsigned

Quoted 4 lines
drivers/watchdog/w83627hf_wdt.c +0 -0
      return 0;
 }
 
@@ -262,9 +300,11 @@ static long wdt_ioctl(struct file *file, unsigned

int cmd, unsigned long arg)

drivers/watchdog/w83627hf_wdt.c static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 303

Quoted 5 lines
drivers/watchdog/w83627hf_wdt.c +1 -1
              wdt_ping();
              /* Fall */
      case WDIOC_GETTIMEOUT:
-             return put_user(timeout, p);
+             timeval = (use_minute) ? timeout * 60 : timeout;

Isn't timeout always in seconds ?

drivers/watchdog/w83627hf_wdt.c static int __init wdt_init(void) · line 349

Quoted 12 lines
drivers/watchdog/w83627hf_wdt.c +2 -1
+             return put_user(timeval, p);
      case WDIOC_GETTIMELEFT:
              timeval = wdt_get_time();
+             timeval = (use_minute) ? timeval * 60 : timeval;
              return put_user(timeval, p);
      default:
              return -ENOTTY;
@@ -346,7 +386,8 @@ static int __init wdt_init(void)
 
      if (wdt_set_heartbeat(timeout)) {
              wdt_set_heartbeat(WATCHDOG_TIMEOUT);
-             pr_info("timeout value must be 1 <= timeout <= 255, using

%d\n",

drivers/watchdog/w83627hf_wdt.c static int __init wdt_init(void) · line 389

Quoted 1 line
drivers/watchdog/w83627hf_wdt.c +1 -0
+             pr_info("timeout value must be 1 <= timeout <= %d, using

%d\n",

drivers/watchdog/w83627hf_wdt.c static int __init wdt_init(void) · line 390

Quoted 1 line
drivers/watchdog/w83627hf_wdt.c +1 -0
+                     max_timeout,

That is still a constant, isn't it ? Why use a variable ?

Quoted 17 lines
drivers/watchdog/w83627hf_wdt.c +2 -3
                      WATCHDOG_TIMEOUT);
      }
 
@@ -371,8 +412,8 @@ static int __init wdt_init(void)
              goto unreg_reboot;
      }
 
-     pr_info("initialized. timeout=%d sec (nowayout=%d)\n",
-             timeout, nowayout);
+     pr_info("initialized. timeout=%d %s (nowayout=%d)\n",
+             timeout, unit, nowayout);
 
 out:
      return ret;
--

1.7.0.4

Quoted 2 lines

--
To unsubscribe from this list: send the line "unsubscribe

linux-watchdog" in

Quoted 3 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
- Tony Chung
#4 lore raw
In reply to Tony Chung
Quoted 78 lines · Tony Chung

The current maximum of 255 seconds is insufficient. For example, crash dump could take 5+ minutes.

---
 drivers/watchdog/w83627hf_wdt.c |   73 ++++++++++++++++++++++++++++++--------
 1 files changed, 57 insertions(+), 16 deletions(-)
drivers/watchdog/w83627hf_wdt.c +41 -1
index 92f1326..d26adfb 100644
@@ -58,7 +58,7 @@ MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port (default 0x2E)");
 static int timeout = WATCHDOG_TIMEOUT;	/* in seconds */
 module_param(timeout, int, 0);
 MODULE_PARM_DESC(timeout,
-		"Watchdog timeout in seconds. 1 <= timeout <= 255, default="
+		"Watchdog timeout in seconds. 1 <= timeout <= 15300, default="
 				__MODULE_STRING(WATCHDOG_TIMEOUT) ".");
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
@@ -67,6 +67,29 @@ MODULE_PARM_DESC(nowayout,
 		"Watchdog cannot be stopped once started (default="
 				__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
+/* timeout unit in minute */
+static bool use_minute;
+static char *unit;
+static int max_timeout = 15300; /* 255*60 seconds */
+
+static inline int wdt_round_secs_to_minute(int t)
+{
+	return (t + 59) / 60;
+}
+
+static inline int wdt_use_minute(int t)
+{
+	if (t > 255) {
+		t = wdt_round_secs_to_minute(t);
+		use_minute = 1;
+		unit = "minutes";
+	} else {
+		use_minute = 0;
+		unit = "secs";
+	}
+	return t;
+}
+
 /*
  *	Kernel methods.
  */
@@ -107,6 +130,23 @@ static void w83627hf_unselect_wd_register(void)
 	outb_p(0xAA, WDT_EFER); /* Leave extended function mode */
 }
 
+/* set CRF5 register */
+static void w83627hf_set_crf5(void)
+{
+	unsigned char t;
+
+	outb_p(0xF5, WDT_EFER); /* Select CRF5 */
+	t = inb_p(WDT_EFDR);      /* read CRF5 */
+	t &= ~0x0C;               /* set second mode & disable keyboard
+				    turning off watchdog */
+	t |= 0x02;		  /* enable the WDTO# output low pulse
+				    to the KBRST# pin (PIN60) */
+	if (use_minute)
+		t |= 0x80;        /* set timeout in minute */
+
+	outb_p(t, WDT_EFDR);    /* Write back to CRF5 */
+}
+
 /* tyan motherboards seem to set F5 to 0x4C ?
  * So explicitly init to appropriate value. */
 
@@ -116,21 +156,16 @@ static void w83627hf_init(void)
 
 	w83627hf_select_wd_register();

drivers/watchdog/w83627hf_wdt.c static void w83627hf_init(void) · line 165

Quoted 10 lines
drivers/watchdog/w83627hf_wdt.c +4 -2
 
+	w83627hf_set_crf5();
+
 	outb_p(0xF6, WDT_EFER); /* Select CRF6 */
 	t = inb_p(WDT_EFDR);      /* read CRF6 */
 	if (t != 0) {
-		pr_info("Watchdog already running. Resetting timeout to %d sec\n",
-			timeout);
+		pr_info("Watchdog already running.  Reset timeout to %d %s\n",
+			timeout, unit);

"Resetting" is better as otherwise it might read as an instruction to the user. Alternatively you could have: "Timeout was reset to ..."

Quoted 14 lines
drivers/watchdog/w83627hf_wdt.c +0 -7
 		outb_p(timeout, WDT_EFDR);    /* Write back to CRF6 */
 	}
 
-	outb_p(0xF5, WDT_EFER); /* Select CRF5 */
-	t = inb_p(WDT_EFDR);      /* read CRF5 */
-	t &= ~0x0C;               /* set second mode & disable keyboard
-				    turning off watchdog */
-	t |= 0x02;		  /* enable the WDTO# output low pulse
-				    to the KBRST# pin (PIN60) */
-	outb_p(t, WDT_EFDR);    /* Write back to CRF5 */
 
 	outb_p(0xF7, WDT_EFER); /* Select CRF7 */
 	t = inb_p(WDT_EFDR);      /* read CRF7 */

drivers/watchdog/w83627hf_wdt.c static void wdt_set_time(int timeout) · line 186

Quoted 5 lines
drivers/watchdog/w83627hf_wdt.c +2 -0
@@ -147,6 +182,9 @@ static void wdt_set_time(int timeout)
 
 	w83627hf_select_wd_register();
 
+	if (use_minute)
+		w83627hf_set_crf5();

Why is this bit needed in set_time()?

On a general note, one has to be careful when changing between second and minute modes, if the watchdog is already running (from the BIOS for example).

thanks,
Pádraig.
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html