From: Alexander Sverdlin Date: Tue, 26 Nov 2024 07:36:43 +0000 (+0100) Subject: watchdog: rti: Fix off-by-one in heartbeat recovery X-Git-Tag: v6.14-rc1~88^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6a569e299f2be13e5e0f487930455b55a9cb4874;p=thirdparty%2Fkernel%2Flinux.git watchdog: rti: Fix off-by-one in heartbeat recovery 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 Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20241126073646.126752-1-alexander.sverdlin@siemens.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c index 58c9445c0f885..e01dd1c13e2c4 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);