mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] watchdog: bd96801_wdt: Fix timeout for enabled WDG
@ 2026-07-31  9:36 Matti Vaittinen
  2026-07-31 14:19 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Matti Vaittinen @ 2026-07-31  9:36 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen, Matti Vaittinen
  Cc: Matti Vaittinen, Wim Van Sebroeck, Guenter Roeck, Lee Jones,
	linux-watchdog, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2392 bytes --]

From: Matti Vaittinen <mazziesaccount@gmail.com>

When watchdog is enabled at the probe time, the bd96801 driver retrieves
the timeout configuration from the registers to set-up the heart-beat
values.

As Sashiko pointed out at
https://lore.kernel.org/all/20260722085819.495211F000E9@smtp.kernel.org/
the timeout values are incorrectly computed in driver, resulting wrong
heartbeat. This leads to devere problems if watchdog was enabled at probe
time.

According to the data-sheet, the "too fast" ping limit is configured as
multiple of FASTNG_MIN. Furthermore, the "too slow" ping limit is
configured as multiples of "too fast" timeout. The FASTNG_MIN is set to
11, meaning 1.1 mS and "too fast" and "too slow" limits are computed from
this. Hence, converting the limits to mS should be done by dividing by 10,
not by dividing by USEC_PER_MSEC.

Fix this by dividing the timeout values with correct scaling factor.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Fixes: 09dad69757b6 ("watchdog: ROHM BD96801 PMIC WDG driver")
---

Also, drop an extra whitespace while editing the file - feeling like
that single whitespace fix doesn't warrant own patch. Just let me know if
I feel wrong ;)

 drivers/watchdog/bd96801_wdt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/bd96801_wdt.c b/drivers/watchdog/bd96801_wdt.c
index 12b74fd2bc05..a25b7cf1488b 100644
--- a/drivers/watchdog/bd96801_wdt.c
+++ b/drivers/watchdog/bd96801_wdt.c
@@ -169,7 +169,6 @@ static int bd96801_set_wdt_mode(struct wdtbd96801 *w, unsigned int hw_margin,
 	int fastng, slowng, type, ret, reg, mask;
 	struct device *dev = w->dev;
 
-
 	if (hw_margin_min * 1000 > FASTNG_MAX_US) {
 		dev_err(dev, "Unsupported fast timeout %u uS [max %u]\n",
 			hw_margin_min * 1000, FASTNG_MAX_US);
@@ -258,10 +257,10 @@ static int bd96801_set_heartbeat_from_hw(struct wdtbd96801 *w,
 	fast = FASTNG_MIN << sel;
 
 	sel = (val & BD96801_WD_RATIO_MASK) + 1;
-	w->wdt.max_hw_heartbeat_ms = (fast << sel) / USEC_PER_MSEC;
+	w->wdt.max_hw_heartbeat_ms = (fast << sel) / 10;
 
 	if ((conf_reg & BD96801_WD_TYPE_MASK) == BD96801_WD_TYPE_WIN)
-		w->wdt.min_hw_heartbeat_ms = fast / USEC_PER_MSEC;
+		w->wdt.min_hw_heartbeat_ms = fast / 10;
 
 	return 0;
 }

base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
-- 
2.55.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] watchdog: bd96801_wdt: Fix timeout for enabled WDG
  2026-07-31  9:36 [PATCH] watchdog: bd96801_wdt: Fix timeout for enabled WDG Matti Vaittinen
@ 2026-07-31 14:19 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2026-07-31 14:19 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Matti Vaittinen, Matti Vaittinen, Wim Van Sebroeck, Lee Jones,
	linux-watchdog, linux-kernel

On Fri, Jul 31, 2026 at 12:36:28PM +0300, Matti Vaittinen wrote:
> From: Matti Vaittinen <mazziesaccount@gmail.com>
> 
> When watchdog is enabled at the probe time, the bd96801 driver retrieves
> the timeout configuration from the registers to set-up the heart-beat
> values.
> 
> As Sashiko pointed out at
> https://lore.kernel.org/all/20260722085819.495211F000E9@smtp.kernel.org/
> the timeout values are incorrectly computed in driver, resulting wrong
> heartbeat. This leads to devere problems if watchdog was enabled at probe
> time.
> 
> According to the data-sheet, the "too fast" ping limit is configured as
> multiple of FASTNG_MIN. Furthermore, the "too slow" ping limit is
> configured as multiples of "too fast" timeout. The FASTNG_MIN is set to
> 11, meaning 1.1 mS and "too fast" and "too slow" limits are computed from
> this. Hence, converting the limits to mS should be done by dividing by 10,
> not by dividing by USEC_PER_MSEC.
> 
> Fix this by dividing the timeout values with correct scaling factor.
> 
> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
> Fixes: 09dad69757b6 ("watchdog: ROHM BD96801 PMIC WDG driver")
> ---
> 
> Also, drop an extra whitespace while editing the file - feeling like
> that single whitespace fix doesn't warrant own patch. Just let me know if
> I feel wrong ;)

No problem (since you let me know and didn't do it silently).

Applied.

Thanks,
Guenter

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

end of thread, other threads:[~2026-07-31 14:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-31  9:36 [PATCH] watchdog: bd96801_wdt: Fix timeout for enabled WDG Matti Vaittinen
2026-07-31 14:19 ` Guenter Roeck

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

all inboxes | Powered by JetHome®