Linux Watchdog driver development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rustam Adilov" <adilov@disroot.org>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v2 1/1] watchdog: realtek-otto: Change to use regmap API
Date: Tue, 19 May 2026 18:56:34 +0000	[thread overview]
Message-ID: <20260519185634.A77AD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260519182329.24472-2-adilov@disroot.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Calling `disable_irq()` in the watchdog restart handler can cause a system deadlock and sleeps in an atomic context during reboot.
--

commit 31e0a644ed16d3bca39871dd569420fedb50663e
Author: Rustam Adilov <adilov@disroot.org>

watchdog: realtek-otto: Change to use regmap API

This commit converts the Realtek Otto watchdog driver to use the regmap API
for register access instead of direct MMIO. It simplifies the code by
replacing read/modify/write sequences with regmap-specific functions like
regmap_update_bits.

> diff --git a/drivers/watchdog/realtek_otto_wdt.c b/drivers/watchdog/realtek_otto_wdt.c
> index 01b3ef89bacfc..504a7d379f4ae 100644
> --- a/drivers/watchdog/realtek_otto_wdt.c
> +++ b/drivers/watchdog/realtek_otto_wdt.c

[ ... ]

> @@ -193,7 +183,7 @@ static int otto_wdt_restart(struct watchdog_device *wdev, unsigned long reboot_m
>  
>  	/* Configure for shortest timeout and wait for reset to occur */
>  	v = FIELD_PREP(OTTO_WDT_CTRL_RST_MODE, reset_mode) | OTTO_WDT_CTRL_ENABLE;
> -	iowrite32(v, ctrl->base + OTTO_WDT_REG_CTRL);
> +	regmap_write(ctrl->regmap, OTTO_WDT_REG_CTRL, v);
>  
>  	mdelay(3 * otto_wdt_tick_ms(ctrl, 0));
>  

[Severity: High]
This isn't a bug introduced by this patch, but since you are modifying this
function, could the disable_irq() call earlier in otto_wdt_restart() cause a
deadlock during reboot?

Looking at the full otto_wdt_restart() function, it disables the interrupt
before triggering the hardware reset:

static int otto_wdt_restart(...)
{
    ...
    disable_irq(ctrl->irq_phase1);
    ...

Because otto_wdt_restart() acts as a system restart handler, it is executed
via machine_restart() in an atomic context with local interrupts disabled and
other CPUs halted.

Calling disable_irq() invokes synchronize_irq(), which waits for any
in-progress interrupt handler to complete. If the otto_wdt_phase1_isr handler
was running on another CPU that was just halted via smp_send_stop(),
synchronize_irq() will spin indefinitely, deadlocking the restart process.

Would it be safer to use disable_irq_nosync() here instead to avoid waiting?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260519182329.24472-2-adilov@disroot.org?part=1

  reply	other threads:[~2026-05-19 18:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19 18:23 [PATCH v2 0/1] watchdog: realtek-otto: Make use of regmap API Rustam Adilov
2026-05-19 18:23 ` [PATCH v2 1/1] watchdog: realtek-otto: Change to use " Rustam Adilov
2026-05-19 18:56   ` sashiko-bot [this message]
2026-05-19 19:00   ` Sander Vanheule
2026-05-19 19:25     ` Guenter Roeck
2026-05-26 20:23       ` Rustam Adilov

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=20260519185634.A77AD1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=adilov@disroot.org \
    --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