All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-watchdog@vger.kernel.org,
	Xingyu Wu <xingyu.wu@starfivetech.com>,
	Ziv Xu <ziv.xu@starfivetech.com>
Subject: Re: [PATCH 1/5] watchdog: starfive-wdt: Drop runtime PM reference if starting watchdog fails
Date: Thu, 5 Nov 2026 15:21:51 +0000	[thread overview]
Message-ID: <auyfDx8KnqEQUWKZ@google.com> (raw)
In-Reply-To: <0a5970d0-7b39-476c-8238-7c05ae6b6435@roeck-us.net>

On Thu, Nov 05, 2026 at 06:52:29AM -0800, Guenter Roeck wrote:
> On Thu, Nov 05, 2026 at 06:49:26AM -0800, Guenter Roeck wrote:
> > On Thu, Nov 05, 2026 at 01:46:40PM +0000, Tzung-Bi Shih wrote:
> > > On Wed, Nov 04, 2026 at 08:44:41AM -0800, Guenter Roeck wrote:
> > > > Commit 8f0ca55016a7 ("watchdog: starfive-wdt: Fix runtime PM leak in
> > > > starfive_wdt_pm_start()") switched starfive_wdt_pm_start() to
> > > > pm_runtime_resume_and_get() so the runtime PM usage counter is not
> > > > leaked when resuming the device fails. However, if starfive_wdt_start()
> > > > subsequently fails (for example, on a timeout in starfive_wdt_int_clr()),
> > > > starfive_wdt_pm_start() returns the error without releasing the runtime
> > > > PM reference acquired by pm_runtime_resume_and_get(). Because the
> > > > watchdog core does not invoke the stop callback when start fails, the
> > > > usage counter remains permanently elevated.
> > > > 
> > > > Drop the runtime PM reference with pm_runtime_put_sync() if
> > > > starfive_wdt_start() fails.
> > > > 
> > > > Fixes: db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")
> > > > Cc: Xingyu Wu <xingyu.wu@starfivetech.com>
> > > > Cc: Ziv Xu <ziv.xu@starfivetech.com>
> > > > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > > 
> > > With a nit,
> > > 
> > > Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
> > > 
> > > > @@ -372,12 +372,17 @@ static void starfive_wdt_stop(struct starfive_wdt *wdt)
> > > >  static int starfive_wdt_pm_start(struct watchdog_device *wdd)
> > > >  {
> > > >  	struct starfive_wdt *wdt = watchdog_get_drvdata(wdd);
> > > > -	int ret = pm_runtime_resume_and_get(wdd->parent);
> > > > +	int ret;
> > > >  
> > > > +	ret = pm_runtime_resume_and_get(wdd->parent);
> > > >  	if (ret < 0)
> > > >  		return ret;
> > > >  
> > > > -	return starfive_wdt_start(wdt);
> > > > +	ret = starfive_wdt_start(wdt);
> > > > +	if (ret)
> > > > +		pm_runtime_put_sync(wdd->parent);
> > > > +
> > > > +	return ret;
> > > 
> > > Or just `return 0;`.
> > > 
> > 
> > Good idea. I'll change that.
> 
> Ah, no, we still want to return the error. Difference is that
> pm_runtime_put_sync() is only called if there was an error,
> but the error must still be returned to the caller.

Ah...correct, I overlooked that.

  reply	other threads:[~2026-11-05 15:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 16:44 [PATCH 0/5] watchdog: starfive-wdt: Fix runtime PM and unclocked register access bugs Guenter Roeck
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 [this message]
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

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=auyfDx8KnqEQUWKZ@google.com \
    --to=tzungbi@kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --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.