Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: apple: set max_hw_heartbeat_ms instead of max_timeout

The hardware only supports timeouts slightly below 3mins, but by using
max_hw_heartbeat_ms we can let the kernel take care of supporting larger
timeouts than that requested from userspace.

Switching to max_hw_heartbeat_ms also means our set_timeout function now
needs to configure the hardware to the minimum of either the requested
timeout (in seconds) or the maximum supported by the user (in seconds).

Signed-off-by: Florian Klink <flokli@flokli.de>
Reviewed-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Link: https://lore.kernel.org/r/20250506142621.11428-2-flokli@flokli.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Florian Klink and committed by
Wim Van Sebroeck
45f1884d 1aea3e1e

+5 -2
+5 -2
drivers/watchdog/apple_wdt.c
··· 95 95 static int apple_wdt_set_timeout(struct watchdog_device *wdd, unsigned int s) 96 96 { 97 97 struct apple_wdt *wdt = to_apple_wdt(wdd); 98 + u32 actual; 98 99 99 100 writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_CUR_TIME); 100 - writel_relaxed(wdt->clk_rate * s, wdt->regs + APPLE_WDT_WD1_BITE_TIME); 101 + 102 + actual = min(s, wdd->max_hw_heartbeat_ms / 1000); 103 + writel_relaxed(wdt->clk_rate * actual, wdt->regs + APPLE_WDT_WD1_BITE_TIME); 101 104 102 105 wdd->timeout = s; 103 106 ··· 180 177 181 178 wdt->wdd.ops = &apple_wdt_ops; 182 179 wdt->wdd.info = &apple_wdt_info; 183 - wdt->wdd.max_timeout = U32_MAX / wdt->clk_rate; 180 + wdt->wdd.max_hw_heartbeat_ms = U32_MAX / wdt->clk_rate * 1000; 184 181 wdt->wdd.timeout = APPLE_WDT_TIMEOUT_DEFAULT; 185 182 186 183 wdt_ctrl = readl_relaxed(wdt->regs + APPLE_WDT_WD1_CTRL);