Re: [PATCH v3 2/2] watchdog: w83627hf_wdt: Use WDOG_HW_RUNNING for running chip on boot

"Paul Louvel" <[email protected]>
Newsgroups org.kernel.vger.linux-watchdog,dev.linux.lists.sashiko-reviews
Message-ID <[email protected]>
On Mon Jul 6, 2026 at 12:40 PM CEST, sashiko-bot wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] Removing the manual hardware timeout refresh while still unconditionally switching the hardware timer base from minutes to seconds drastically truncates the remaining timeout if the BIOS originally configured it in minutes, risking unexpected system reboots.
> --
>
> commit 0014048ec369e2a09098aa033aeb725449e2fd67
> Author: Paul Louvel <[email protected]>
>
> watchdog: w83627hf_wdt: Use WDOG_HW_RUNNING for running chip on boot
>
> This patch updates the w83627hf watchdog driver to rely on the watchdog
> core's WDOG_HW_RUNNING flag to keep a running watchdog alive during boot.
> It replaces the previous behavior of manually issuing a single keepalive
> during initialization.
>
>> diff --git a/drivers/watchdog/w83627hf_wdt.c b/drivers/watchdog/w83627hf_wdt.c
>> --- a/drivers/watchdog/w83627hf_wdt.c
>> +++ b/drivers/watchdog/w83627hf_wdt.c
> [ ... ]
>> @@ -241,9 +241,8 @@ static int w83627hf_init(struct watchdog_device *wdog, enum chips chip)
>>  			pr_warn("Stopping previously enabled watchdog until userland kicks in\n");
>>  			superio_outb(cr_wdt_timeout, 0);
>>  		} else {
>> -			pr_info("Watchdog already running. Resetting timeout to %d sec\n",
>> -				wdog->timeout);
>> -			superio_outb(cr_wdt_timeout, wdog->timeout);
>> +			pr_info("Watchdog already running.\n");
>> +			set_bit(WDOG_HW_RUNNING, &wdog->status);
>>  		}
>>  	}
>>  
>
> [Severity: High]
> Does removing this explicit timeout reset create a risk of unexpected reboots?
>
> If the BIOS originally configured the watchdog with a timeout in minutes
> (for example, a timeout of 5 minutes), the hardware counter cr_wdt_timeout
> will hold the value 5.

First of all, the driver does not support minute mode for now.

>
> Because this patch removes the explicit write of wdog->timeout (which is
> typically 60) to cr_wdt_timeout, the counter retains the raw value 5.
> Just after this block in w83627hf_init(), the driver unconditionally
> switches the timebase to seconds:
>
> w83627hf_init() {
>     ...
>     /* set second mode & disable keyboard turning off watchdog */
>     t = superio_inb(cr_wdt_control) & ~0x0C;
>     superio_outb(cr_wdt_control, t);
>     ...
> }
>
> This immediately shrinks the remaining timeout from 5 minutes to 5 seconds.

True, but in those 5 seconds, the watchdog core will kick the watchdog
immediately. by calling start(), and thus refreshing the watchdog to 60 seconds.

>
> If the watchdog core's kworker is delayed, or if the system is configured
> not to ping the watchdog before user space takes over, could this unusually
> short timeout cause the system to reboot unexpectedly during early boot?

Yes, but expected. If WATCHDOG is enabled, then WATCHDOG_HANDLE_BOOT_ENABLED is
enabled by default unless explicitly disabled when configuring the kernel.




-- 
Paul Louvel, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.