From: Heyi Guo <guoheyi@linux.alibaba.com>
To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org,
linux-watchdog@vger.kernel.org
Cc: Heyi Guo <guoheyi@linux.alibaba.com>,
Wim Van Sebroeck <wim@linux-watchdog.org>,
Guenter Roeck <linux@roeck-us.net>, Joel Stanley <joel@jms.id.au>,
Andrew Jeffery <andrew@codeconstruct.com.au>,
Eddie James <eajames@linux.ibm.com>
Subject: [PATCH 1/2] driver/aspeed-wdt: fix pretimeout for counting down logic
Date: Tue, 18 Feb 2025 11:16:58 +0800 [thread overview]
Message-ID: <20250218031709.103823-1-guoheyi@linux.alibaba.com> (raw)
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
next reply other threads:[~2025-02-18 3:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-18 3:16 Heyi Guo [this message]
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)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250218031709.103823-1-guoheyi@linux.alibaba.com \
--to=guoheyi@linux.alibaba.com \
--cc=andrew@codeconstruct.com.au \
--cc=devicetree@vger.kernel.org \
--cc=eajames@linux.ibm.com \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=wim@linux-watchdog.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.