From: Guenter Roeck <linux@roeck-us.net>
To: Cong Nguyen <congnt264@gmail.com>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] watchdog: shwdt: register device only after full driver init
Date: Wed, 16 Sep 2026 17:23:20 -0700 [thread overview]
Message-ID: <9c91a7c7-c6ff-4002-b2e3-ce609ed2401a@roeck-us.net> (raw)
In-Reply-To: <20260914123609.2186477-1-congnt264@gmail.com>
On Mon, Sep 14, 2026 at 07:36:09PM +0700, Cong Nguyen wrote:
> sh_wdt_probe() calls watchdog_register_device() -- exposing
> /dev/watchdogN -- before timer_setup() and pm_runtime_enable() run. A
> start command landing in that window calls mod_timer() on an
> uninitialized timer (NULL ->function) and resumes via
> pm_runtime_get_sync() before PM is enabled.
>
> Move timer_setup() and pm_runtime_enable() before the register call,
> matching the order already used by rzg2l_wdt.c/rzv2h_wdt.c. Add
> pm_runtime_disable() on the now-possible post-enable register-failure
> path.
>
> Fixes: 8f5585ec3d17 ("watchdog: shwdt: driver model conversion.")
> Assisted-by: Claude:claude-opus-4
> Signed-off-by: Cong Nguyen <congnt264@gmail.com>
The other problems in this driver make me wonder if this change
is worth the trouble. Is this an actually observed problem ?
Because if not it would be better to leave the driver alone.
If this _is_ an actually observed problem, the code should be
rearranged to depend on the watchdog core for timer handling.
Thanks,
Guenter
> ---
> drivers/watchdog/shwdt.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/watchdog/shwdt.c b/drivers/watchdog/shwdt.c
> index 719f100aae60..c22b8e760476 100644
> --- a/drivers/watchdog/shwdt.c
> +++ b/drivers/watchdog/shwdt.c
> @@ -263,19 +263,20 @@ static int sh_wdt_probe(struct platform_device *pdev)
> dev_info(&pdev->dev, "configured with heartbeat=%d sec (nowayout=%d)\n",
> sh_wdt_dev.timeout, nowayout);
>
> + timer_setup(&wdt->timer, sh_wdt_ping, 0);
> + wdt->timer.expires = next_ping_period(clock_division_ratio);
> +
> + pm_runtime_enable(&pdev->dev);
> +
> rc = watchdog_register_device(&sh_wdt_dev);
> if (unlikely(rc)) {
> dev_err(&pdev->dev, "Can't register watchdog (err=%d)\n", rc);
> + pm_runtime_disable(&pdev->dev);
> return rc;
> }
>
> - timer_setup(&wdt->timer, sh_wdt_ping, 0);
> - wdt->timer.expires = next_ping_period(clock_division_ratio);
> -
> dev_info(&pdev->dev, "initialized.\n");
>
> - pm_runtime_enable(&pdev->dev);
> -
> return 0;
> }
>
prev parent reply other threads:[~2026-09-17 0:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 12:36 Cong Nguyen
2026-09-17 0:23 ` Guenter Roeck [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=9c91a7c7-c6ff-4002-b2e3-ce609ed2401a@roeck-us.net \
--to=linux@roeck-us.net \
--cc=congnt264@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--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
all inboxes | Powered by JetHome®