Skip to contentSkip to conversation

watchdog: armada_37xx_wdt: Fix .set_timeout callback

PATCH In review Pali Rohár 3 participants 4 messages Jul 26, 2022 – Sep 24, 2022

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

PATCH 1/1 watchdog: armada_37xx_wdt: Fix .set_timeout callback

ioctl(WDIOC_SETTIMEOUT) calls .set_timeout and .ping callbacks and it is expected that it changes current watchdog timeout.

armada_37xx_wdt's .ping callback just reping counter 0 and does not touch counter 1 used for timeout. So it is needed to set counter 1 to the new value in .set_timeout callback to ensure ioctl(WDIOC_SETTIMEOUT) functionality. Fix it.

Fixes 54e3d9b518c8 ("watchdog: Add support for Armada 37xx CPU watchdog")
---
 drivers/watchdog/armada_37xx_wdt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/watchdog/armada_37xx_wdt.c +2 -0
index 1635f421ef2c..b84cba94b135 100644
@@ -179,6 +179,8 @@ static int armada_37xx_wdt_set_timeout(struct watchdog_device *wdt,
 	dev->timeout = (u64)dev->clk_rate * timeout;
 	do_div(dev->timeout, CNTR_CTRL_PRESCALE_MIN);
 
+	set_counter_value(dev, CNTR_ID_WDOG, dev->timeout);
+
 	return 0;
 }
 
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Pali Rohár

ioctl(WDIOC_SETTIMEOUT) calls .set_timeout and .ping callbacks and it is expected that it changes current watchdog timeout.

armada_37xx_wdt's .ping callback just reping counter 0 and does not touch counter 1 used for timeout. So it is needed to set counter 1 to the new value in .set_timeout callback to ensure ioctl(WDIOC_SETTIMEOUT) functionality. Fix it.

Fixes 54e3d9b518c8 ("watchdog: Add support for Armada 37xx CPU watchdog")
Quoted 17 lines
---
  drivers/watchdog/armada_37xx_wdt.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/watchdog/armada_37xx_wdt.c +2 -0
index 1635f421ef2c..b84cba94b135 100644
@@ -179,6 +179,8 @@ static int armada_37xx_wdt_set_timeout(struct watchdog_device *wdt,
  	dev->timeout = (u64)dev->clk_rate * timeout;
  	do_div(dev->timeout, CNTR_CTRL_PRESCALE_MIN);
 
+	set_counter_value(dev, CNTR_ID_WDOG, dev->timeout);
+
  	return 0;
  }
 
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Pali Rohár
Quoted 10 lines · On Tue, 26 Jul 2022 10:56:12 +0200 Pali Rohár <[email protected]> wrote:

ioctl(WDIOC_SETTIMEOUT) calls .set_timeout and .ping callbacks and it is expected that it changes current watchdog timeout.

armada_37xx_wdt's .ping callback just reping counter 0 and does not touch counter 1 used for timeout. So it is needed to set counter 1 to the new value in .set_timeout callback to ensure ioctl(WDIOC_SETTIMEOUT) functionality. Fix it.

Fixes 54e3d9b518c8 ("watchdog: Add support for Armada 37xx CPU watchdog")
#3 lore raw
In reply to Pali Rohár

PING?

Quoted 30 lines · On Tuesday 26 July 2022 10:56:12 Pali Rohár wrote:

ioctl(WDIOC_SETTIMEOUT) calls .set_timeout and .ping callbacks and it is expected that it changes current watchdog timeout.

armada_37xx_wdt's .ping callback just reping counter 0 and does not touch counter 1 used for timeout. So it is needed to set counter 1 to the new value in .set_timeout callback to ensure ioctl(WDIOC_SETTIMEOUT) functionality. Fix it.

Fixes 54e3d9b518c8 ("watchdog: Add support for Armada 37xx CPU watchdog")
---
 drivers/watchdog/armada_37xx_wdt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/watchdog/armada_37xx_wdt.c +2 -0
index 1635f421ef2c..b84cba94b135 100644
@@ -179,6 +179,8 @@ static int armada_37xx_wdt_set_timeout(struct watchdog_device *wdt,
 	dev->timeout = (u64)dev->clk_rate * timeout;
 	do_div(dev->timeout, CNTR_CTRL_PRESCALE_MIN);
 
+	set_counter_value(dev, CNTR_ID_WDOG, dev->timeout);
+
 	return 0;
 }
 
Signature · 1 line
2.20.1