Linux Watchdog driver development
 help / color / mirror / Atom feed
* [PATCH] watchdog: rti: Fix off-by-one in heartbeat recovery
@ 2024-11-26  7:36 A. Sverdlin
  2024-11-26 15:32 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: A. Sverdlin @ 2024-11-26  7:36 UTC (permalink / raw)
  To: linux-watchdog
  Cc: Alexander Sverdlin, Wim Van Sebroeck, Guenter Roeck,
	Judith Mendez, Vignesh Raghavendra, Tero Kristo

From: Alexander Sverdlin <alexander.sverdlin@siemens.com>

According to AM62x TRM WDT period is (RTIDWDPRLD + 1) * (2^13) / RTICLK1,
Fix the heartbeat recovery. In practice this doesn't affect rounded
heatbeat in seconds, but it does correct 4% of error in milliseconds,
for, say, default 60s heartbeat. This affects last_ping calculation.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
---
 drivers/watchdog/rti_wdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
index 563d842014dfb..0416e54b17edb 100644
--- a/drivers/watchdog/rti_wdt.c
+++ b/drivers/watchdog/rti_wdt.c
@@ -273,7 +273,8 @@ static int rti_wdt_probe(struct platform_device *pdev)
 
 		set_bit(WDOG_HW_RUNNING, &wdd->status);
 		time_left_ms = rti_wdt_get_timeleft_ms(wdd);
-		heartbeat_ms = readl(wdt->base + RTIDWDPRLD);
+		/* AM62x TRM: texp = (RTIDWDPRLD + 1) * (2^13) / RTICLK1 */
+		heartbeat_ms = readl(wdt->base + RTIDWDPRLD) + 1;
 		heartbeat_ms <<= WDT_PRELOAD_SHIFT;
 		heartbeat_ms *= 1000;
 		do_div(heartbeat_ms, wdt->freq);
-- 
2.47.0


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

* Re: [PATCH] watchdog: rti: Fix off-by-one in heartbeat recovery
  2024-11-26  7:36 [PATCH] watchdog: rti: Fix off-by-one in heartbeat recovery A. Sverdlin
@ 2024-11-26 15:32 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2024-11-26 15:32 UTC (permalink / raw)
  To: A. Sverdlin, linux-watchdog
  Cc: Wim Van Sebroeck, Judith Mendez, Vignesh Raghavendra, Tero Kristo

On 11/25/24 23:36, A. Sverdlin wrote:
> From: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> 
> According to AM62x TRM WDT period is (RTIDWDPRLD + 1) * (2^13) / RTICLK1,
> Fix the heartbeat recovery. In practice this doesn't affect rounded
> heatbeat in seconds, but it does correct 4% of error in milliseconds,
> for, say, default 60s heartbeat. This affects last_ping calculation.
> 
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/watchdog/rti_wdt.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
> index 563d842014dfb..0416e54b17edb 100644
> --- a/drivers/watchdog/rti_wdt.c
> +++ b/drivers/watchdog/rti_wdt.c
> @@ -273,7 +273,8 @@ static int rti_wdt_probe(struct platform_device *pdev)
>   
>   		set_bit(WDOG_HW_RUNNING, &wdd->status);
>   		time_left_ms = rti_wdt_get_timeleft_ms(wdd);
> -		heartbeat_ms = readl(wdt->base + RTIDWDPRLD);
> +		/* AM62x TRM: texp = (RTIDWDPRLD + 1) * (2^13) / RTICLK1 */
> +		heartbeat_ms = readl(wdt->base + RTIDWDPRLD) + 1;
>   		heartbeat_ms <<= WDT_PRELOAD_SHIFT;
>   		heartbeat_ms *= 1000;
>   		do_div(heartbeat_ms, wdt->freq);


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

end of thread, other threads:[~2024-11-26 15:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-26  7:36 [PATCH] watchdog: rti: Fix off-by-one in heartbeat recovery A. Sverdlin
2024-11-26 15:32 ` Guenter Roeck

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