From: Guenter Roeck <linux@roeck-us.net>
To: linux-watchdog@vger.kernel.org
Cc: Guenter Roeck <linux@roeck-us.net>,
Xingyu Wu <xingyu.wu@starfivetech.com>,
Ziv Xu <ziv.xu@starfivetech.com>
Subject: [PATCH 0/5] watchdog: starfive-wdt: Fix runtime PM and unclocked register access bugs
Date: Wed, 4 Nov 2026 08:44:40 -0800 [thread overview]
Message-ID: <20261104164445.3209560-1-linux@roeck-us.net> (raw)
The StarFive watchdog driver (drivers/watchdog/starfive-wdt.c) gates its
APB and core clocks via runtime PM callbacks, but has several runtime PM
reference-counting, ordering, and unclocked MMIO access bugs across
probe, remove, start/stop, shutdown, and system sleep paths:
1. In starfive_wdt_pm_start(), if starfive_wdt_start() fails after
pm_runtime_resume_and_get() succeeds, the acquired runtime PM
reference is leaked because the watchdog core does not call the stop
callback when start fails.
2. In starfive_wdt_probe(), early returns on pm_runtime_resume_and_get()
or starfive_wdt_enable_clock() failure bypass pm_runtime_disable(),
leaving the runtime PM disable_depth counter unbalanced.
3. When runtime PM has suspended an idle watchdog and gated its clocks,
starfive_wdt_remove(), starfive_wdt_shutdown(), starfive_wdt_suspend(),
and starfive_wdt_resume() unconditionally read and write hardware
registers, causing unclocked MMIO bus faults. In addition,
starfive_wdt_pm_stop() propagates non-zero idle return codes from
pm_runtime_put_sync() as errors to watchdog_stop().
4. Probe error paths after pm_runtime_resume_and_get() disable clocks
manually without releasing the runtime PM reference (and without
stopping an early_enable watchdog if registration fails), and
starfive_wdt_remove() never drops the active runtime PM reference
retained when watchdog_hw_running() is still set (e.g. early_enable).
5. In starfive_wdt_probe(), watchdog_register_device() is called before
pm_runtime_put_sync() drops the probe-time reference, and non-zero
idle return values such as -EAGAIN (triggered if userspace opens
/dev/watchdog immediately upon registration) are treated as fatal
probe errors.
These bugs have been reported by Sashiko.
This 5-patch series fixes each of these issues cleanly in sequence.
Note on tooling and testing:
This series was generated with an AI coding assistant (Jetski / Gemini)
following analysis of reported runtime PM and lifecycle bugs in
starfive-wdt.c. All patches were build-tested with make allmodconfig and
make W=1 with zero warnings, verified with scripts/checkpatch.pl
--strict, and validated against a state-machine simulation harness
covering runtime PM, clock gating, and concurrent open paths; they were
not tested on physical StarFive JH7100/JH7110 hardware.
Guenter Roeck (5):
watchdog: starfive-wdt: Drop runtime PM reference if starting watchdog
fails
watchdog: starfive-wdt: Balance pm_runtime_enable() on probe error
paths
watchdog: starfive-wdt: Avoid unclocked register access in remove and
PM paths
watchdog: starfive-wdt: Fix runtime PM usage count leaks in probe and
remove
watchdog: starfive-wdt: Drop runtime PM reference before registering
watchdog
drivers/watchdog/starfive-wdt.c | 75 +++++++++++++++++++++------------
1 file changed, 48 insertions(+), 27 deletions(-)
Cc: Xingyu Wu <xingyu.wu@starfivetech.com>
Cc: Ziv Xu <ziv.xu@starfivetech.com>
--
2.56.0
next reply other threads:[~2026-11-04 16:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 16:44 Guenter Roeck [this message]
2026-11-04 16:44 ` [PATCH 1/5] watchdog: starfive-wdt: Drop runtime PM reference if starting watchdog fails Guenter Roeck
2026-11-05 13:46 ` Tzung-Bi Shih
2026-11-05 14:49 ` Guenter Roeck
2026-11-05 14:52 ` Guenter Roeck
2026-11-05 15:21 ` Tzung-Bi Shih
2026-11-04 16:44 ` [PATCH 2/5] watchdog: starfive-wdt: Balance pm_runtime_enable() on probe error paths Guenter Roeck
2026-11-05 13:46 ` Tzung-Bi Shih
2026-11-04 16:44 ` [PATCH 3/5] watchdog: starfive-wdt: Avoid unclocked register access in remove and PM paths Guenter Roeck
2026-11-04 17:02 ` sashiko-bot
2026-11-04 17:58 ` Guenter Roeck
2026-11-04 16:44 ` [PATCH 4/5] watchdog: starfive-wdt: Fix runtime PM usage count leaks in probe and remove Guenter Roeck
2026-11-05 15:15 ` Tzung-Bi Shih
2026-11-04 16:44 ` [PATCH 5/5] watchdog: starfive-wdt: Drop runtime PM reference before registering watchdog Guenter Roeck
2026-11-05 15:15 ` Tzung-Bi Shih
2026-11-06 14:22 ` Tzung-Bi Shih
2026-11-06 15:13 ` 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=20261104164445.3209560-1-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-watchdog@vger.kernel.org \
--cc=xingyu.wu@starfivetech.com \
--cc=ziv.xu@starfivetech.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.