Skip to contentSkip to conversation

Retu watchdog clean-up and fix to make it behave

PATCH In review Tony Lindgren 2 participants 7 messages May 13, 2008 – May 15, 2008 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): retu-2008-05-12-173514

#1 lore raw

cover Retu watchdog clean-up and fix to make it behave

Hi all,

These patches clean retu watchdog code a bit, and make it behave like a standard Linux watchdog device. The cost is about 250 bytes larger kernel.

I'm also planning to remove the non-standard watchdog behaviour unless somebody has good arguments why we should keep it.

Regards,

Tony

#2 lore raw

PATCH 1/3 CBUS: Fix retu mutex handling

Fix retu mutex handling. Also use mutex_lock instead of unhandled mutex_lock_interruptible.

---
 drivers/cbus/retu-wdt.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/cbus/retu-wdt.c +3 -3
index 63194d8..85202ef 100644
@@ -40,7 +40,7 @@
 #define RETU_WDT_MAX_TIMER 63
 
 static struct completion retu_wdt_completion;
-static DECLARE_MUTEX(retu_wdt_mutex);	/* Avoid simultaneous writes to watchdog register */
+static DEFINE_MUTEX(retu_wdt_mutex);
 
 static unsigned int period_val = RETU_WDT_DEFAULT_TIMER;	/* Current period of watchdog */
 static int counter_param = RETU_WDT_MAX_TIMER;
@@ -52,12 +52,12 @@ static int retu_modify_counter(unsigned int new)
 	if (new < RETU_WDT_MIN_TIMER || new > RETU_WDT_MAX_TIMER)
 		return -EINVAL;
 
-	down_interruptible(&retu_wdt_mutex);
+	mutex_lock(&retu_wdt_mutex);
 
 	period_val = new;
 	retu_write_reg(RETU_REG_WATCHDOG, (u16)period_val);
 
-	up(&retu_wdt_mutex);
+	mutex_unlock(&retu_wdt_mutex);
 	return ret;
 }
 
Signature · 1 line
1.5.3.6
#3 lore raw

PATCH 2/3 CBUS: Checkpatch.pl fixes for retu-wdt.c

Checkpatch.pl fixes for retu-wdt.c

---
 drivers/cbus/retu-wdt.c |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
drivers/cbus/retu-wdt.c +14 -10
index 85202ef..b7b20b7 100644
@@ -42,7 +42,8 @@
 static struct completion retu_wdt_completion;
 static DEFINE_MUTEX(retu_wdt_mutex);
 
-static unsigned int period_val = RETU_WDT_DEFAULT_TIMER;	/* Current period of watchdog */
+/* Current period of watchdog */
+static unsigned int period_val = RETU_WDT_DEFAULT_TIMER;
 static int counter_param = RETU_WDT_MAX_TIMER;
 
 static int retu_modify_counter(unsigned int new)
@@ -61,15 +62,16 @@ static int retu_modify_counter(unsigned int new)
 	return ret;
 }
 
-static ssize_t retu_wdt_period_show(struct device *dev, struct device_attribute *attr,
-				    char *buf)
+static ssize_t retu_wdt_period_show(struct device *dev,
+				struct device_attribute *attr, char *buf)
 {
 	/* Show current max counter */
 	return sprintf(buf, "%u\n", (u16)period_val);
 }
 
-static ssize_t retu_wdt_period_store(struct device *dev, struct device_attribute *attr,
-				     const char *buf, size_t count)
+static ssize_t retu_wdt_period_store(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t count)
 {
 	unsigned int new_period;
 	int ret;
@@ -86,8 +88,8 @@ static ssize_t retu_wdt_period_store(struct device *dev, struct device_attribute
 	return strnlen(buf, count);
 }
 
-static ssize_t retu_wdt_counter_show(struct device *dev, struct device_attribute *attr,
-				     char *buf)
+static ssize_t retu_wdt_counter_show(struct device *dev,
+				struct device_attribute *attr, char *buf)
 {
 	u16 counter;
 
@@ -99,7 +101,7 @@ static ssize_t retu_wdt_counter_show(struct device *dev, struct device_attribute
 }
 
 static DEVICE_ATTR(period, S_IRUGO | S_IWUSR, retu_wdt_period_show, \
-                   retu_wdt_period_store);
+			retu_wdt_period_store);
 static DEVICE_ATTR(counter, S_IRUGO, retu_wdt_counter_show, NULL);
 
 static int __devinit retu_wdt_probe(struct device *dev)
@@ -108,14 +110,16 @@ static int __devinit retu_wdt_probe(struct device *dev)
 
 	ret = device_create_file(dev, &dev_attr_period);
 	if (ret) {
-		printk(KERN_ERR "retu_wdt_probe: Error creating sys device file: period\n");
+		printk(KERN_ERR "retu_wdt_probe: Error creating "
+					"sys device file: period\n");
 		return ret;
 	}
 
 	ret = device_create_file(dev, &dev_attr_counter);
 	if (ret) {
 		device_remove_file(dev, &dev_attr_period);
-		printk(KERN_ERR "retu_wdt_probe: Error creating sys device file: counter\n");
+		printk(KERN_ERR "retu_wdt_probe: Error creating "
+					"sys device file: counter\n");
 	}
 
 	return ret;
Signature · 1 line
1.5.3.6
#4 lore raw

PATCH 3/3 CBUS: Make retu watchdog behave like a standard Linux watchdog

Make retu watchdog behave like a standard Linux watchdog.

Let the kernel do the kicking until the watchdog device is opened.

Note: We should remove the old non-standard interface, please change to use standard /dev/watchdog instead.

---
 drivers/cbus/Kconfig    |    2 +-
 drivers/cbus/retu-wdt.c |  184 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 183 insertions(+), 3 deletions(-)
drivers/cbus/Kconfig +1 -1
index 25f8039..c344a99 100644
@@ -72,7 +72,7 @@ config CBUS_RETU_RTC
 	  RTC in Retu. This will expose a sysfs interface for it.
 
 config CBUS_RETU_WDT
-	depends on CBUS_RETU && SYSFS
+	depends on CBUS_RETU && SYSFS && WATCHDOG
 	tristate "Support for Retu watchdog timer"
 	---help---
 	  Say Y here if you want support for the watchdog in Retu. This will
drivers/cbus/retu-wdt.c +182 -2

242 lines not on this page · raw message

Signature · 1 line
1.5.3.6
#5 lore raw

Re: [PATCH 3/3] CBUS: Make retu watchdog behave like a standard Linux watchdog

Hi Tony,

Quoted 3 lines · ext Tony Lindgren

Make retu watchdog behave like a standard Linux watchdog.

Let the kernel do the kicking until the watchdog device is opened.

This is not always the desidered behavior: the powerdown wd is used to ensure that the whole sw stack is healty: doing the kicking in kernelspace for free introduces the case where userspace can get stuck and the device does not powerdown.

Also the unconditional loading of the maximum value during probe is not aligned with the original reset logic, which was to have the powerdown wd to allow for 2 boot attempts:

-cold boot -> load max value in retu wd (63s)

           -> load 30s in omap wd

-try to kick both wds

if fail, then omap reboots, but retu keeps counting down

-warm boot -> let the retu wd untouched

           -> load 30s in omap wd

-try to kick both wds

if fail, retu powers down

That was the original idea in 770 times and i still like it.

To conclude, i'd see inkernel kicking more as a debugging feature while one is hacking at the kernel than a desirable quality of a stable kernel.

Signature · 10 lines
Cheers, Igor

---

Igor Stoppa
Nokia Devices R&D - Helsinki
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

Re: [PATCH 3/3] CBUS: Make retu watchdog behave like a standard Linux watchdog

Quoted 10 lines · Igor Stoppa

Hi Tony,

Quoted 3 lines · ext Tony Lindgren

Make retu watchdog behave like a standard Linux watchdog.

Let the kernel do the kicking until the watchdog device is opened.

This is not always the desidered behavior: the powerdown wd is used to ensure that the whole sw stack is healty: doing the kicking in kernelspace for free introduces the case where userspace can get stuck and the device does not powerdown.

That's why there's CONFIG_WATCHDOG_NOWAYOUT where the ping timer is not enabled at all, and the watchdog is just set to max until userspace watchdog software kicking starts.

Review

Quoted 7 lines

Also the unconditional loading of the maximum value during probe is not aligned with the original reset logic, which was to have the powerdown wd to allow for 2 boot attempts:

(quoted diff) +0 -2
-cold boot -> load max value in retu wd (63s)
           -> load 30s in omap wd
-try to kick both wds

Well you can set those values via /dev/watchdog too, right? And then use CONFIG_WATCHDOG_NOWAYOUT.

And ff CONFIG_WATCHDOG_NOWAYOUT is not set, the kernel ping timer only happens when /dev/watchdog is not open.

Quoted 6 lines

if fail, then omap reboots, but retu keeps counting down

(quoted diff) +0 -2
-warm boot -> let the retu wd untouched
           -> load 30s in omap wd
-try to kick both wds
Quoted 7 lines

if fail, retu powers down

That was the original idea in 770 times and i still like it.

To conclude, i'd see inkernel kicking more as a debugging feature while one is hacking at the kernel than a desirable quality of a stable kernel.

Considering that the /dev/watchdog interface is the standard, I see this patch as the only way we can get this code ever merged upstream. And it's easy to patch back the non-standard if you want to.

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

#7 lore raw

Re: [PATCH 3/3] CBUS: Make retu watchdog behave like a standard Linux watchdog

Quoted 40 lines · Tony Lindgren
Quoted 10 lines · Igor Stoppa

Hi Tony,

Quoted 3 lines · ext Tony Lindgren

Make retu watchdog behave like a standard Linux watchdog.

Let the kernel do the kicking until the watchdog device is opened.

This is not always the desidered behavior: the powerdown wd is used to ensure that the whole sw stack is healty: doing the kicking in kernelspace for free introduces the case where userspace can get stuck and the device does not powerdown.

That's why there's CONFIG_WATCHDOG_NOWAYOUT where the ping timer is not enabled at all, and the watchdog is just set to max until userspace watchdog software kicking starts.

Review

Quoted 7 lines

Also the unconditional loading of the maximum value during probe is not aligned with the original reset logic, which was to have the powerdown wd to allow for 2 boot attempts:

(quoted diff) +0 -2
-cold boot -> load max value in retu wd (63s)
           -> load 30s in omap wd
-try to kick both wds

Well you can set those values via /dev/watchdog too, right? And then use CONFIG_WATCHDOG_NOWAYOUT.

And ff CONFIG_WATCHDOG_NOWAYOUT is not set, the kernel ping timer only happens when /dev/watchdog is not open.

Quoted 10 lines

if fail, then omap reboots, but retu keeps counting down

(quoted diff) +0 -2
-warm boot -> let the retu wd untouched
           -> load 30s in omap wd
-try to kick both wds

if fail, retu powers down

That was the original idea in 770 times and i still like it.

Quoted 7 lines
Quoted 3 lines

To conclude, i'd see inkernel kicking more as a debugging feature while one is hacking at the kernel than a desirable quality of a stable kernel.

Considering that the /dev/watchdog interface is the standard, I see this patch as the only way we can get this code ever merged upstream. And it's easy to patch back the non-standard if you want to.

I'll push the first two patches today, third one still needs to be checked.

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