From: Brian Norris <briannorris@chromium.org>
To: "Rafael J. Wysocki (Intel)" <rafael@kernel.org>
Cc: Linux PM <linux-pm@vger.kernel.org>,
Alan Stern <stern@rowland.harvard.edu>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Ulf Hansson <ulf.hansson@oss.qualcomm.com>,
Linux Driver Core Development <driver-core@lists.linux.dev>
Subject: Re: [PATCH v1 3/4] PM: runtime: Let devices suspend after an attempted resume
Date: Wed, 25 Nov 2026 17:12:48 -0800 [thread overview]
Message-ID: <aweHkBnEGG5f8veE@google.com> (raw)
In-Reply-To: <CAJZ5v0jgBeJkeKfzaMnSx3c7HV6EpXrUoKJCyAZNHwfkvh=PZQ@mail.gmail.com>
On Tue, Nov 24, 2026 at 05:23:52PM +0100, Rafael J. Wysocki (Intel) wrote:
> On Fri, Nov 20, 2026 at 10:04 PM Brian Norris <briannorris@chromium.org> wrote:
> >
> > On Thu, Nov 19, 2026 at 09:17:51PM +0100, Rafael J. Wysocki wrote:
> > > From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> > >
> > > On a successful runtime resume of a device, rpm_idle() is called by
> > > rpm_resume(), but only if the runtime PM status of the device was not
> > > RPM_ACTIVE when rpm_resume() was called, which is inconsistent. For
> > > instance, if the given device uses autosuspend, an autosuspend timer
> > > will most likely be started for it after it has been actually resumed
> > > by rpm_resume(), which will not happen if it is already active when it
> > > is passed to that function. This may lead to observable differences in
> > > behavior going forward.
> > >
> > > Address it by rearranging rpm_resume() to call rpm_idle() also if the
> > > device has been active to start with.
> > >
> > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > > ---
> > > drivers/base/power/runtime.c | 12 ++++++++----
> > > 1 file changed, 8 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> > > index 5a0b4600c244..1a3b32e299d8 100644
> > > --- a/drivers/base/power/runtime.c
> > > +++ b/drivers/base/power/runtime.c
> > > @@ -794,7 +794,8 @@ static int rpm_suspend(struct device *dev, int rpmflags)
> > > * suspending (deferred_resume) or wait for it to finish. If the RPM_ASYNC
> > > * flag is set then queue a resume request; otherwise run the
> > > * ->runtime_resume() callback directly. Queue an idle notification for the
> > > - * device if the resume succeeded.
> > > + * device if the resume succeeded or the device's runtime PM status was
> > > + * RPM_ACTIVE to start with.
> > > *
> > > * This function must be called under dev->power.lock with interrupts disabled.
> > > */
> > > @@ -840,7 +841,7 @@ static int rpm_resume(struct device *dev, int rpmflags)
> > > */
> > > pm_runtime_mark_last_busy(dev);
> > > retval = 1;
> > > - goto out;
> > > + goto success;
> > > }
> > >
> > > if (dev->power.runtime_status == RPM_RESUMING ||
> > > @@ -971,8 +972,11 @@ static int rpm_resume(struct device *dev, int rpmflags)
> > > }
> > > wake_up_all(&dev->power.wait_queue);
> > >
> > > - if (retval >= 0)
> > > - rpm_idle(dev, RPM_ASYNC);
> > > + if (retval < 0)
> > > + goto out;
> > > +
> > > +success:
> > > + rpm_idle(dev, RPM_ASYNC);
> >
> > It's super common for rpm_resume() to be called with a non-zero
> > usage_count (e.g., all pm_runtime_get*(), pm_runtime_forbid()). Do we
> > really want them all to turn into rpm_idle() (and predictably fail)? For
> > one, it adds a lot more trace_event noise.
> >
> > Maybe we could check RPM_GET_PUT before doing this? Or check
> > usage_count? I wouldn't want to go too far on re-implementing all the
> > rpm_idle() pre-conditions though...
>
> I'm not sure why this is an issue if the device is already active when
> rpm_resume() is called and not when the device is resumed by
> rpm_resume(). It doesn't look like this should be an issue only in
> one of those cases.
>
You're right, it's a bit spammy in existing cases too. (It's honestly
pretty hard to read rpm trace_event logs without being an expert.)
This comment was made by inspection; I think I'd have to get a feel for
how this looks on a real run to be sure. Feel free to ignore this if you
don't think it's concerning (and I don't come back with anything more
solid).
> > drivers/net/ethernet/intel/e1000e/netdev.c (no autosuspend; they use
> > .runtime_idle() to re-implement autosuspend, more or less) might see a
> > change in behavior.
>
> Everybody may see a change in behavior, but it only applies to one of
> the two cases which are handled differently now.
>
> > For example, see its watchdog, which does:
> >
> > /* Cancel scheduled suspend requests. */
> > pm_runtime_resume(netdev->dev.parent);
> >
> > For cases where the device stayed RPM_ACTIVE but usage_count == 0 (very
> > common, I think), this does indeed cancel any pending suspend timers,
>
> No, it doesn't cancel running autosuspend timers, for example.
Well, this driver doesn't use autosuspend (yet).
> > but then it immediately queues another idle request. (That idle request
> > will end up failing anyway, so no functional issue. It just means the
> > comments are a little confusing.)
>
> So the comment is confusing regardless of the $subject patch.
No, my point was that your patch changes that behavior from:
"cancel scheduled [non-auto]suspend requests" (an accurate comment)
to
"cancel scheduled [non-auto]suspend requests" and immediately run
.runtime_idle() again (and fail)
--> a somewhat misleading comment
Or perhaps I'm misunderstanding the before/after behavior here.
> > Do we really want that? Or maybe these drivers are just outliers, and
> > should be rewritten anyway.
>
> Probably.
>
> If the device is RPM_ACTIVE to start with, all of the rpm_resume()
> actions related to resuming it may be skipped, quite obviously, but
> I'm not sure why any other rpm_resume() handling of the device should
> be different in that case. This only causes the behavior to be less
> consistent and less predictable IMV. In particular, if the device
> uses autosuspend, an autosuspend timer should be started for it
> regardless of whether or not it is RPM_ACTIVE to start with. Failing
> to do so may cause it to never suspend going forward in theory.
Makes sense. Really, I was only pointing out changes (not necessarily
problems) with a few quirky non-autosuspend drivers [1], and if these
are expected, perhaps it's worth following up with the drivers in
question that were describing (if not fully depending on) corner cases
of behavior that we're changing here.
But on second look, maybe there's not much to fix for these drivers.
It's not really a "bug" to perform excess .runtime_idle() checks, even
if it's wasteful, and I don't see great alternatives.
Brian
[1] drivers/net/ethernet/intel/e1000e/netdev.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/igc/igc_main.c
next prev parent reply other threads:[~2026-11-26 1:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 20:13 [PATCH v1 0/4] PM: runtime: Close some gaps related to autosuspend Rafael J. Wysocki
2026-11-19 20:16 ` [PATCH v1 1/4] PM: runtime: Update last_busy in all rpm_idle() paths Rafael J. Wysocki
2026-11-20 20:59 ` Brian Norris
2026-11-20 21:29 ` Rafael J. Wysocki (Intel)
2026-11-21 11:22 ` Rafael J. Wysocki (Intel)
2026-11-22 11:53 ` Rafael J. Wysocki (Intel)
2026-11-19 20:17 ` [PATCH v1 2/4] PM: runtime: Drop space characters preceding labels Rafael J. Wysocki
2026-11-20 2:47 ` Alan Stern
2026-11-20 12:11 ` Rafael J. Wysocki (Intel)
2026-11-20 12:30 ` Rafael J. Wysocki (Intel)
2026-11-20 16:11 ` Alan Stern
2026-11-19 20:17 ` [PATCH v1 3/4] PM: runtime: Let devices suspend after an attempted resume Rafael J. Wysocki
2026-11-20 21:04 ` Brian Norris
2026-11-24 16:23 ` Rafael J. Wysocki (Intel)
2026-11-26 1:12 ` Brian Norris [this message]
2026-11-19 20:18 ` [PATCH v1 4/4] PM: runtime: Drop direct last_busy updates from rpm_resume() Rafael J. Wysocki
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=aweHkBnEGG5f8veE@google.com \
--to=briannorris@chromium.org \
--cc=driver-core@lists.linux.dev \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=stern@rowland.harvard.edu \
--cc=ulf.hansson@oss.qualcomm.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 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).