This series addresses runtime PM correctness issues in the StarFive
watchdog driver. v3 fixes three issues that were raised against v2:
Changes in v3:
- 2/6 (pm_runtime_put_sync positive return): the v2 commit message
and code comment described the semantics of a "1" return as "the
device is still in use", which is wrong — that case is signalled
by -EAGAIN. A positive return indicates a non-error condition such
as the device already being in the requested state. Reword both
the commit message and the in-function comment to describe this
correctly. No code change beyond that.
- 3/6 (probe error path restructure): the v2 patch left a path that
put the runtime PM usage counter twice. When the success-path
pm_runtime_put_sync() (line ~513) returns an error, the function
jumps to err_unregister_wdt. In v2 that label fell through to
err_put_pm, which called pm_runtime_put_sync() a second time on a
counter that had already been decremented by the first put.
Insert an explicit "goto err_pm_disable;" after the unregister so
the post-register error path skips the second put.
- 4/6 (system suspend/resume guard): the v2 patch added a
pm_runtime_status_suspended() check on the resume path but kept
the final restart predicate as watchdog_active(). For watchdogs
started via early_enable, the framework state is WDOG_HW_RUNNING
without WDOG_ACTIVE, so the existing predicate left the hardware
permanently stopped after a system suspend/resume cycle (the
matching suspend path had already stopped it). Extend the
predicate to also accept watchdog_hw_running().
Patches 1, 5, and 6 are unchanged from v2.
Several pre-existing issues in adjacent code paths were flagged
during v2 review (hardware access during driver unbind, possible
races between device_shutdown() and the watchdog reboot notifier,
SETTIMEOUT/GETTIMELEFT ioctls touching gated registers). They are
not addressed in this series; each is a separate logical change
that deserves its own patch and its own justification. Happy to
follow up on any the maintainers want addressed first.
The whole series builds cleanly with CONFIG_STARFIVE_WATCHDOG=m on
x86_64 defconfig. Runtime testing would require StarFive JH7100 /
JH7110 hardware and has not been performed.
William Theesfeld (6):
watchdog: starfive: balance PM refcount when start operation fails
watchdog: starfive: treat pm_runtime_put_sync() positive return as
success
watchdog: starfive: balance PM refcount and disable in probe error
paths
watchdog: starfive: guard system suspend/resume hardware access
watchdog: starfive: avoid PM refcount underflow in shutdown
watchdog: starfive: release early_enable PM refcount on remove
drivers/watchdog/starfive-wdt.c | 109 ++++++++++++++++++++++++++------
1 file changed, 89 insertions(+), 20 deletions(-)
--
2.54.0