From: Brian Norris <briannorris@chromium.org>
To: "Rafael J. Wysocki" <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: Fri, 20 Nov 2026 13:04:07 -0800 [thread overview]
Message-ID: <awC1xx1Wi2BYo5rb@google.com> (raw)
In-Reply-To: <10954171.nUPlyArG6x@rafael.j.wysocki>
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...
Also: I'm not quite sure what's *really* expected here, but drivers like
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. 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,
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.)
Do we really want that? Or maybe these drivers are just outliers, and
should be rewritten anyway.
Brian
>
> out:
> if (parent && !dev->power.irq_safe) {
> --
> 2.51.0
>
>
>
>
next prev parent reply other threads:[~2026-11-20 21:04 UTC|newest]
Thread overview: 11+ 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-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 [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=awC1xx1Wi2BYo5rb@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