From: Guenter Roeck <linux@roeck-us.net>
To: Sander Vanheule <sander@svanheule.net>,
Rustam Adilov <adilov@disroot.org>,
sashiko@lists.linux.dev
Cc: linux-watchdog@vger.kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org, robh@kernel.org, krzk+dt@kernel.org,
Wim Van Sebroeck <wim@linux-watchdog.org>
Subject: Re: [PATCH 1/3] watchdog: realtek-otto: Change to use regmap API
Date: Sat, 16 May 2026 11:33:05 -0700 [thread overview]
Message-ID: <3dfcec0e-3ce9-440b-9377-deba8fa9f2eb@roeck-us.net> (raw)
In-Reply-To: <173f0f7d804d3b0f33b6584b8a592d2079c593e9.camel@svanheule.net>
On 5/15/26 14:10, Sander Vanheule wrote:
> Adding back Guenter (and Wim) in Cc
>
> On Fri, 2026-05-15 at 20:48 +0000, Rustam Adilov wrote:
>> On 2026-05-09 17:16, sashiko-bot@kernel.org wrote:
>>> Thank you for your contribution! Sashiko AI review found 1 potential
>>> issue(s) to consider:
>>> - [High] Deadlock risk in the atomic restart handler due to regmap's
>>> internal spinlock.
>>> --
>>>
>>> commit a520c8e2203154ba331a6ae28f00daec074e62ee
>>> 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
>>> instead of direct mmio accesses. It replaces direct read/modify/write
>>> sequences with regmap functions and selects REGMAP_MMIO.
>>>
>>>> diff --git a/drivers/watchdog/realtek_otto_wdt.c
>>>> b/drivers/watchdog/realtek_otto_wdt.c
>>>> index 2c30ddd574c59..e5e9cb480f4f9 100644
>>>> --- a/drivers/watchdog/realtek_otto_wdt.c
>>>> +++ b/drivers/watchdog/realtek_otto_wdt.c
>>> [ ... ]
>>>> @@ -199,7 +189,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);
>>>
>>> Could this regmap_write() cause a deadlock during system restart?
>>>
>>> The restart handler is often called during system shutdown or kernel panic
>>> in an atomic context with local interrupts disabled. Since
>>> devm_regmap_init_mmio() configures the regmap to use a spinlock by default,
>>> if a panic occurs while another cpu holds the regmap lock (e.g., during
>>> a ping or timeout update) and that cpu is halted by smp_send_stop(), this
>>> regmap_write() could spin endlessly and prevent the system from rebooting.
>>>
>>> Additionally, on preempt-rt kernels, the regmap spinlock becomes a sleepable
>>> rt_mutex, which could cause a sleeping in atomic context bug when acquired
>>> with interrupts disabled.
>>>
>>>> mdelay(3 * otto_wdt_tick_ms(ctrl, 0));
>>>>
>>
>> Hi Sander,
>>
>> I hope it is alright if i CCd you for this as i am not an expert on watchdog
>> stuff.
>> Wonna make sure this issue applies here before i proceed with the suggested
>> solution
>> to add .disable_locking to regmap_config without understanding the
>> consequences of it.
>
> I'm no expert either, but AFAICT using .disable_locking would essentially mean
> all accesses are only protected by the watchdog subsystem. Which is also the
> case now, so that would mean feature parity.
>
> I'll leave it up to Guenter to decide if this refactor is worthwhile or not.
>
I don't mind the refactor, but it must not introduce a regression.
As Sashiko points out, either regmap needs to be configured with
.disable_locking set, or regmap can not be used in the restart handler.
Guenter
next prev parent reply other threads:[~2026-05-16 18:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-09 16:30 [PATCH 0/3] watchdog: realtek-otto: Make use of regmap API and add RTL9607C support Rustam Adilov
2026-05-09 16:30 ` [PATCH 1/3] watchdog: realtek-otto: Change to use regmap API Rustam Adilov
2026-05-09 17:16 ` sashiko-bot
2026-05-15 20:48 ` Rustam Adilov
2026-05-15 21:10 ` Sander Vanheule
2026-05-16 18:33 ` Guenter Roeck [this message]
2026-05-09 16:31 ` [PATCH 2/3] dt-bindings: watchdog: realtek,otto-wdt: add compatible for RTL9607C Rustam Adilov
2026-05-09 18:13 ` Conor Dooley
2026-05-10 8:19 ` Rustam Adilov
2026-05-11 15:52 ` Conor Dooley
2026-05-13 18:27 ` Rustam Adilov
2026-05-10 19:23 ` Sander Vanheule
2026-05-09 16:31 ` [PATCH 3/3] watchdog: realtek-otto: add RTL9607C support Rustam Adilov
2026-05-09 17:27 ` sashiko-bot
2026-05-10 18:12 ` Sander Vanheule
2026-05-17 10:39 ` Sander Vanheule
2026-05-10 15:13 ` [PATCH 0/3] watchdog: realtek-otto: Make use of regmap API and " Guenter Roeck
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=3dfcec0e-3ce9-440b-9377-deba8fa9f2eb@roeck-us.net \
--to=linux@roeck-us.net \
--cc=adilov@disroot.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sander@svanheule.net \
--cc=sashiko@lists.linux.dev \
--cc=wim@linux-watchdog.org \
/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;
as well as URLs for NNTP newsgroup(s).