]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
watchdog: apple: set max_hw_heartbeat_ms instead of max_timeout
authorFlorian Klink <flokli@flokli.de>
Tue, 6 May 2025 14:26:22 +0000 (17:26 +0300)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sun, 1 Jun 2025 11:16:20 +0000 (13:16 +0200)
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>
drivers/watchdog/apple_wdt.c

index 95d9e37df41cd371a45b1390646cadc55fade72c..66a158f67a712bbed394d660071e02140e66c2e5 100644 (file)
@@ -95,9 +95,12 @@ static int apple_wdt_ping(struct watchdog_device *wdd)
 static int apple_wdt_set_timeout(struct watchdog_device *wdd, unsigned int s)
 {
        struct apple_wdt *wdt = to_apple_wdt(wdd);
+       u32 actual;
 
        writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_CUR_TIME);
-       writel_relaxed(wdt->clk_rate * s, wdt->regs + APPLE_WDT_WD1_BITE_TIME);
+
+       actual = min(s, wdd->max_hw_heartbeat_ms / 1000);
+       writel_relaxed(wdt->clk_rate * actual, wdt->regs + APPLE_WDT_WD1_BITE_TIME);
 
        wdd->timeout = s;
 
@@ -177,7 +180,7 @@ static int apple_wdt_probe(struct platform_device *pdev)
 
        wdt->wdd.ops = &apple_wdt_ops;
        wdt->wdd.info = &apple_wdt_info;
-       wdt->wdd.max_timeout = U32_MAX / wdt->clk_rate;
+       wdt->wdd.max_hw_heartbeat_ms = U32_MAX / wdt->clk_rate * 1000;
        wdt->wdd.timeout = APPLE_WDT_TIMEOUT_DEFAULT;
 
        wdt_ctrl = readl_relaxed(wdt->regs + APPLE_WDT_WD1_CTRL);