Linux Watchdog driver development
 help / color / mirror / Atom feed
* [PATCH 1/2] driver/aspeed-wdt: fix pretimeout for counting down logic
@ 2025-02-18  3:16 Heyi Guo
  2025-02-18  3:16 ` [PATCH 2/2] ARM: dts: aspeed: aspeed-g6.dtsi: enable IRQ for watchdogs Heyi Guo
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Heyi Guo @ 2025-02-18  3:16 UTC (permalink / raw)
  To: devicetree, linux-arm-kernel, linux-aspeed, linux-kernel,
	linux-watchdog
  Cc: Heyi Guo, Wim Van Sebroeck, Guenter Roeck, Joel Stanley,
	Andrew Jeffery, Eddie James

Aspeed watchdog uses counting down logic, so the value set to register
should be the value of subtracting pretimeout from total timeout.

Fixes: 9ec0b7e06835 ("watchdog: aspeed: Enable pre-timeout interrupt")

Signed-off-by: Heyi Guo <guoheyi@linux.alibaba.com>

Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@codeconstruct.com.au>
Cc: Eddie James <eajames@linux.ibm.com>
---
 drivers/watchdog/aspeed_wdt.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c
index b4773a6aaf8c..520d8aba12a5 100644
--- a/drivers/watchdog/aspeed_wdt.c
+++ b/drivers/watchdog/aspeed_wdt.c
@@ -187,6 +187,13 @@ static int aspeed_wdt_set_pretimeout(struct watchdog_device *wdd,
 	u32 actual = pretimeout * WDT_RATE_1MHZ;
 	u32 s = wdt->cfg->irq_shift;
 	u32 m = wdt->cfg->irq_mask;
+	u32 reload = readl(wdt->base + WDT_RELOAD_VALUE);
+
+	if (actual >= reload)
+		return -EINVAL;
+
+	/* watchdog timer is counting down */
+	actual = reload - actual;
 
 	wdd->pretimeout = pretimeout;
 	wdt->ctrl &= ~m;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-02-19  6:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-18  3:16 [PATCH 1/2] driver/aspeed-wdt: fix pretimeout for counting down logic Heyi Guo
2025-02-18  3:16 ` [PATCH 2/2] ARM: dts: aspeed: aspeed-g6.dtsi: enable IRQ for watchdogs Heyi Guo
2025-02-18  7:53   ` Krzysztof Kozlowski
2025-02-19  1:12   ` Andrew Jeffery
2025-02-18  5:33 ` [PATCH 1/2] driver/aspeed-wdt: fix pretimeout for counting down logic Guenter Roeck
2025-02-19  1:25   ` Andrew Jeffery
2025-02-19  1:40     ` Guenter Roeck
2025-02-19  3:41   ` Heyi Guo
2025-02-19  6:07     ` Guenter Roeck
2025-02-19  6:48       ` Heyi Guo
     [not found]   ` <7e2c5f2c-d07a-472c-aae5-6b639a144d88@linux.alibaba.com>
2025-02-19  3:51     ` Heyi Guo
2025-02-19  0:42 ` Rob Herring (Arm)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox