Linux Watchdog driver development
 help / color / mirror / Atom feed
From: "Paul Louvel" <paul.louvel@bootlin.com>
To: <sashiko-reviews@lists.linux.dev>,
	"Paul Louvel" <paul.louvel@bootlin.com>
Cc: <linux-watchdog@vger.kernel.org>
Subject: Re: [PATCH v4 6/6] watchdog: w83627hf_wdt: Add minute mode counting
Date: Tue, 13 Oct 2026 16:22:59 +0200	[thread overview]
Message-ID: <DM3S0X9T1346.1A2X1MLPGV9O6@bootlin.com> (raw)
In-Reply-To: <sashiko-outbox-169886@kernel.org>

On Tue Oct 13, 2026 at 4:08 PM CEST, sashiko-bot wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] watchdog: spurious hardware reboot during timeout mode transition
> --
>
> commit e9913194bed75434ff662763db21c93683fc01dc
> Author: Paul Louvel <paul.louvel@bootlin.com>
>
> watchdog: w83627hf_wdt: Add minute mode counting
>
> All of the chips supported by the driver can be set to minute mode,
> allowing timeout value up to 255 minutes. Add it to the driver.
>
>> diff --git a/drivers/watchdog/w83627hf_wdt.c b/drivers/watchdog/w83627hf_wdt.c
>> index 0b9195e7e95ef..8f78fe64acde9 100644
>> --- a/drivers/watchdog/w83627hf_wdt.c
>> +++ b/drivers/watchdog/w83627hf_wdt.c
>
> [ ... ]
>
>> @@ -290,6 +284,7 @@ static int w83627hf_init(struct watchdog_device *wdog, enum chips chip)
>>  static int wdt_set_time(struct watchdog_device *wdog, unsigned int timeout)
>>  {
>>  	struct w83627hf_data *data = watchdog_get_drvdata(wdog);
>> +	unsigned char ctrl;
>>  	int ret;
>>  
>>  	ret = superio_enter(data->sio->addr, data->sio->cfg_enter);
>> @@ -297,6 +292,15 @@ static int wdt_set_time(struct watchdog_device *wdog, unsigned int timeout)
>>  		return ret;
>>  
>>  	superio_select(data->sio->addr, W83627HF_LD_WDT);
>> +
>> +	ctrl = superio_inb(data->sio->addr, data->reg->control);
>> +
>> +	if (data->minute_mode)
>> +		ctrl |= WDT_CTRL_MINUTE_MODE;
>> +	else
>> +		ctrl &= ~WDT_CTRL_MINUTE_MODE;
>> +
>> +	superio_outb(data->sio->addr, data->reg->control, ctrl);
>>  	superio_outb(data->sio->addr, data->reg->timeout, timeout);
>
> [Severity: High]
> Can this sequence trigger a spurious hardware reboot during a timeout mode
> transition?
>
> In wdt_set_time(), the hardware control register is updated first to change
> between minute and second modes, immediately followed by the timeout register:
>
> 	superio_outb(data->sio->addr, data->reg->control, ctrl);
> 	superio_outb(data->sio->addr, data->reg->timeout, timeout);
>
> When transitioning from minute mode to second mode (for example, from 1 minute
> to 10 seconds), the hardware control register is updated first. The hardware
> timer momentarily retains its old value (1) but interprets it under the new
> unit (seconds), meaning it evaluates that only 1 second is left.
>
> If the thread is preempted (e.g., by an SMI or a hypervisor) between these two
> superio_outb() calls for longer than this intermediate duration, will the
> hardware watchdog fire and spuriously reboot the system?

Yes it could happen if the hardware does not take measures to avoid this. Also,
one second is a long time between those two writes, I doubt this ever happens in
practice.

>
> Would it be safer to temporarily disable the watchdog (by writing 0 to the
> timeout register) before modifying the control register's mode bit?
>

Yes.

>>  	superio_exit(data->sio->addr, data->sio->cfg_leave);
>>

-- 
Paul Louvel, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


      reply	other threads:[~2026-10-13 14:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 13:58 [PATCH v4 0/6] watchdog: w83627hf_wdt: Convert driver to the driver model and add minute support Paul Louvel
2026-10-13 13:58 ` [PATCH v4 1/6] watchdog: w83627hf_wdt: Fix watchdog identity truncation Paul Louvel
2026-10-13 13:58 ` [PATCH v4 2/6] watchdog: w83627hf_wdt: Replace magic numbers with descriptive macros Paul Louvel
2026-10-13 13:58 ` [PATCH v4 3/6] watchdog: w83627hf_wdt: Convert to platform driver model Paul Louvel
2026-10-13 13:58 ` [PATCH v4 4/6] watchdog: w83627hf_wdt: Move register offsets into driver data Paul Louvel
2026-10-13 13:58 ` [PATCH v4 5/6] watchdog: w83627hf_wdt: Store Super I/O configurations in platform data Paul Louvel
2026-10-13 13:58 ` [PATCH v4 6/6] watchdog: w83627hf_wdt: Add minute mode counting Paul Louvel
2026-10-13 14:08   ` sashiko-bot
2026-10-13 14:22     ` Paul Louvel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM3S0X9T1346.1A2X1MLPGV9O6@bootlin.com \
    --to=paul.louvel@bootlin.com \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox