]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
watchdog: rti: Fix off-by-one in heartbeat recovery
authorAlexander Sverdlin <alexander.sverdlin@siemens.com>
Tue, 26 Nov 2024 07:36:43 +0000 (08:36 +0100)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Mon, 6 Jan 2025 18:37:49 +0000 (19:37 +0100)
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>
Link: https://lore.kernel.org/r/20241126073646.126752-1-alexander.sverdlin@siemens.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/rti_wdt.c

index 58c9445c0f885ca44c221a2cc145fc7d56e55de1..e01dd1c13e2c4ef77bc768d4b92d59bc12187fca 100644 (file)
@@ -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);