* [PATCH v2 0/2] PM: runtime: Consolidation of last_busy updates and calling rpm_idle() in rpm_resume() @ 2026-11-30 15:01 Rafael J. Wysocki 2026-11-30 15:04 ` [PATCH v2 1/2] PM: runtime: Drop redundant last_busy update from rpm_resume() Rafael J. Wysocki 2026-11-30 15:07 ` [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices Rafael J. Wysocki 0 siblings, 2 replies; 3+ messages in thread From: Rafael J. Wysocki @ 2026-11-30 15:01 UTC (permalink / raw) To: Linux PM Cc: Brian Norris, Alan Stern, Sakari Ailus, Ulf Hansson, Linux Driver Core Development Hi All, This is a follow-up series for https://web.git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/commit/?h=linux-next&id=26236a3e8803f7e1ace104020d7f006edb220116 which is in linux-next and it replaces https://lore.kernel.org/linux-pm/10954171.nUPlyArG6x@rafael.j.wysocki/ and https://lore.kernel.org/linux-pm/2062233.PYKUYFuaPT@rafael.j.wysocki/ (hence v2). It makes essentially the same changes as the two patches above, but in a different order and with somewhat (hopefully) more convincing explanation. It requires this series to be applied: https://lore.kernel.org/linux-pm/4779892.LvFx2qVVIh@rafael.j.wysocki/ The first patch simply drops a direct pm_runtime_mark_last_busy() call from rpm_resume() that becomes redundant after apply the above series. The second patch causes rpm_resume() to call rpm_idle() in the case when the given device is active to start with which is already done in the case when the device needs to be resumed. The goal is to make the behavior of rpm_resume() more consistent and more predictable. Thanks! ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] PM: runtime: Drop redundant last_busy update from rpm_resume() 2026-11-30 15:01 [PATCH v2 0/2] PM: runtime: Consolidation of last_busy updates and calling rpm_idle() in rpm_resume() Rafael J. Wysocki @ 2026-11-30 15:04 ` Rafael J. Wysocki 2026-11-30 15:07 ` [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices Rafael J. Wysocki 1 sibling, 0 replies; 3+ messages in thread From: Rafael J. Wysocki @ 2026-11-30 15:04 UTC (permalink / raw) To: Linux PM Cc: Brian Norris, Alan Stern, Sakari Ailus, Ulf Hansson, Linux Driver Core Development From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Since rpm_idle() updates the last_busy timestamp of the device unconditionally and rpm_resume() calls it after resuming the device successfully, the direct last_busy update after changing the runtime PM status of the device to RPM_ACTIVE is redundant. Drop it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- Applies on top of https://lore.kernel.org/linux-pm/4779892.LvFx2qVVIh@rafael.j.wysocki/ --- drivers/base/power/runtime.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1004,7 +1004,6 @@ static int rpm_resume(struct device *dev } else { no_callback: __update_runtime_status(dev, RPM_ACTIVE); - pm_runtime_mark_last_busy(dev); if (parent) atomic_inc(&parent->power.child_count); } ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices 2026-11-30 15:01 [PATCH v2 0/2] PM: runtime: Consolidation of last_busy updates and calling rpm_idle() in rpm_resume() Rafael J. Wysocki 2026-11-30 15:04 ` [PATCH v2 1/2] PM: runtime: Drop redundant last_busy update from rpm_resume() Rafael J. Wysocki @ 2026-11-30 15:07 ` Rafael J. Wysocki 1 sibling, 0 replies; 3+ messages in thread From: Rafael J. Wysocki @ 2026-11-30 15:07 UTC (permalink / raw) To: Linux PM Cc: Brian Norris, Alan Stern, Sakari Ailus, Ulf Hansson, Linux Driver Core Development From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> If rpm_resume() actually resumes the device successfully (that is, the device's runtime resume callback is invoked and does not fail), it calls rpm_idle() to check whether or not the device really is in use and possibly start an autosuspend timer for it or advance its last_busy timestamp. However, rpm_idle() is not called by rpm_resume() if the runtime PM status of the device is RPM_ACTIVE to start with, which is inconsistent and may be confusing. Most importantly, if no runtime PM references to the given device are held when rpm_resume() is about to return, skipping the rpm_idle() invocation means missing an opportunity to suspend the device that is not otherwise prevented from suspending. If autosuspend is used by the device, an autosuspend timer can be expected to be started for it when rpm_resume() is about to return, but that will not happen if the device's runtime PM status is RPM_ACTIVE to start with. The next opportunity to start an autosuspend timer for the device may not appear at any time soon. Address this by rearranging rpm_resume() to call rpm_idle() also if the device was already active and drop the direct last_busy update carried out in that case as it is not necessary any more because rpm_idle() updates last_busy. Also make the rpm_resume() kerneldoc comment match the new code flow. Note that if the device is prevented from suspending when rpm_idle() is called, the overhead of calling rpm_idle() boils down to checking that the device in fact cannot be suspended, so it should not be significant. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- drivers/base/power/runtime.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -833,7 +833,8 @@ static int rpm_suspend(struct device *de * 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. */ @@ -872,14 +873,8 @@ static int rpm_resume(struct device *dev pm_runtime_deactivate_timer(dev); if (dev->power.runtime_status == RPM_ACTIVE) { - /* - * The attempt to resume the device means that it is needed for - * something, so update its last_busy timestamp as in the case - * in which it actually resumes below. - */ - pm_runtime_mark_last_busy(dev); retval = 1; - goto out; + goto success; } if (dev->power.runtime_status == RPM_RESUMING || @@ -1009,8 +1004,11 @@ static int rpm_resume(struct device *dev } 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); out: if (parent && !dev->power.irq_safe) { ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-30 15:08 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-30 15:01 [PATCH v2 0/2] PM: runtime: Consolidation of last_busy updates and calling rpm_idle() in rpm_resume() Rafael J. Wysocki 2026-11-30 15:04 ` [PATCH v2 1/2] PM: runtime: Drop redundant last_busy update from rpm_resume() Rafael J. Wysocki 2026-11-30 15:07 ` [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices Rafael J. Wysocki
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox