[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6fda7aa7-244a-4650-b120-acd66ca0d1c9@roeck-us.net>
Date: Wed, 17 Dec 2025 20:53:33 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Zhu Ling <1536943441@...com>, linux-watchdog@...r.kernel.org
Cc: wim@...ux-watchdog.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] watchdog: sbsa-gwdt: clamp timeout before updating
wdd->timeout
On 12/17/25 18:31, Zhu Ling wrote:
> sbsa_gwdt_set_timeout() updates wdd->timeout before clamping the user
> requested value to the hardware-supported range. As a result,
> WDIOC_GETTIMEOUT and sysfs may report a timeout larger than what is
> actually programmed into the hardware.
>
> Clamp the timeout first and then update wdd->timeout so that
> userspace-visible values always reflect the effective hardware
> timeout.
>
> Signed-off-by: Zhu Ling <1536943441@...com>
> ---
> drivers/watchdog/sbsa_gwdt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c
> index 6ce1bfb39..826469645 100644
> --- a/drivers/watchdog/sbsa_gwdt.c
> +++ b/drivers/watchdog/sbsa_gwdt.c
> @@ -155,8 +155,8 @@ static int sbsa_gwdt_set_timeout(struct watchdog_device *wdd,
> {
> struct sbsa_gwdt *gwdt = watchdog_get_drvdata(wdd);
>
> - wdd->timeout = timeout;
> timeout = clamp_t(unsigned int, timeout, 1, wdd->max_hw_heartbeat_ms / 1000);
> + wdd->timeout = timeout;
>
> if (action)
> sbsa_gwdt_reg_write((u64)gwdt->clk * timeout, gwdt);
This is wrong. With max_hw_heartbeat_ms set, the timeout value is not limited to
the hardware timeout and becomes a virtual timeout. If it is larger than the
maximum hardware timeout, the watchdog core will issue any necessary heartbeats.
The current code is perfectly correct.
NACK.
Guenter
Powered by blists - more mailing lists