* [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; 13+ 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] 13+ 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 17:09 ` Ulf Hansson
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, 1 reply; 13+ 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] 13+ 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
2026-11-30 17:08 ` Ulf Hansson
2026-12-01 15:15 ` Ulf Hansson
1 sibling, 2 replies; 13+ 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] 13+ messages in thread
* Re: [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices
2026-11-30 15:07 ` [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices Rafael J. Wysocki
@ 2026-11-30 17:08 ` Ulf Hansson
2026-11-30 17:24 ` Rafael J. Wysocki (Intel)
2026-12-01 15:15 ` Ulf Hansson
1 sibling, 1 reply; 13+ messages in thread
From: Ulf Hansson @ 2026-11-30 17:08 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux PM, Brian Norris, Alan Stern, Sakari Ailus,
Linux Driver Core Development
On Mon, Nov 30, 2026 at 4:08 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> 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.
While I in principle agree with the change, I am slightly worried
about users that call pm_runtime_resume() and who call pm_runtime_get*
quite soon after. I can tell if this is a common behaviour, but I am
sure I have seen something like that. Did you check?
Anyway, for these cases we may end up doing an unnecessary round of
suspend/resume of the device. Maybe not a big deal, but something that
could have a negative impact on probing/boot.
>
> 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>
Kind regards
Uffe
> ---
> 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] 13+ messages in thread
* Re: [PATCH v2 1/2] PM: runtime: Drop redundant last_busy update from rpm_resume()
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 17:09 ` Ulf Hansson
0 siblings, 0 replies; 13+ messages in thread
From: Ulf Hansson @ 2026-11-30 17:09 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux PM, Brian Norris, Alan Stern, Sakari Ailus,
Linux Driver Core Development
On Mon, Nov 30, 2026 at 4:08 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> 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>
Reviewed-by: Ulf Hansson <ulfh@kernel.org>
Kind regards
Uffe
> ---
>
> 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] 13+ messages in thread
* Re: [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices
2026-11-30 17:08 ` Ulf Hansson
@ 2026-11-30 17:24 ` Rafael J. Wysocki (Intel)
2026-11-30 19:25 ` Rafael J. Wysocki (Intel)
2026-12-01 9:16 ` Ulf Hansson
0 siblings, 2 replies; 13+ messages in thread
From: Rafael J. Wysocki (Intel) @ 2026-11-30 17:24 UTC (permalink / raw)
To: Ulf Hansson
Cc: Rafael J. Wysocki, Linux PM, Brian Norris, Alan Stern,
Sakari Ailus, Linux Driver Core Development
On Mon, Nov 30, 2026 at 6:08 PM Ulf Hansson
<ulf.hansson@oss.qualcomm.com> wrote:
>
> On Mon, Nov 30, 2026 at 4:08 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> >
> > 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.
>
> While I in principle agree with the change, I am slightly worried
> about users that call pm_runtime_resume() and who call pm_runtime_get*
> quite soon after. I can tell if this is a common behaviour, but I am
> sure I have seen something like that. Did you check?
I don't know how many of them there are, if that's what you're asking,
but they should at least use an autosuspend delay.
Also note that if the initial pm_runtime_resume() resumes the device
and there is no autosuspend delay, it will suspend immediately even
without this change.
> Anyway, for these cases we may end up doing an unnecessary round of
> suspend/resume of the device. Maybe not a big deal, but something that
> could have a negative impact on probing/boot.
If this adversely affects anyone, I'd like to understand why and help
them to do the right thing because they are probably doing something
super-fragile that works incidentally.
To me, consistency in the core is more important than preserving the
existing behavior to support such fragile cases.
> > 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] 13+ messages in thread
* Re: [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices
2026-11-30 17:24 ` Rafael J. Wysocki (Intel)
@ 2026-11-30 19:25 ` Rafael J. Wysocki (Intel)
2026-12-01 0:37 ` Brian Norris
2026-12-01 9:16 ` Ulf Hansson
1 sibling, 1 reply; 13+ messages in thread
From: Rafael J. Wysocki (Intel) @ 2026-11-30 19:25 UTC (permalink / raw)
To: Ulf Hansson
Cc: Linux PM, Brian Norris, Alan Stern, Sakari Ailus,
Linux Driver Core Development
On Mon, Nov 30, 2026 at 6:24 PM Rafael J. Wysocki (Intel)
<rafael@kernel.org> wrote:
>
> On Mon, Nov 30, 2026 at 6:08 PM Ulf Hansson
> <ulf.hansson@oss.qualcomm.com> wrote:
> >
> > On Mon, Nov 30, 2026 at 4:08 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> > >
> > > 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.
> >
> > While I in principle agree with the change, I am slightly worried
> > about users that call pm_runtime_resume() and who call pm_runtime_get*
> > quite soon after. I can tell if this is a common behaviour, but I am
> > sure I have seen something like that.
Out of curiosity, where have you seen it?
There are not too many direct callers of pm_runtime_resume() in the
tree and the majority of them don't do anything like this AFAICS.
> Did you check?
>
> I don't know how many of them there are, if that's what you're asking,
> but they should at least use an autosuspend delay.
>
> Also note that if the initial pm_runtime_resume() resumes the device
> and there is no autosuspend delay, it will suspend immediately even
> without this change.
>
> > Anyway, for these cases we may end up doing an unnecessary round of
> > suspend/resume of the device. Maybe not a big deal, but something that
> > could have a negative impact on probing/boot.
>
> If this adversely affects anyone, I'd like to understand why and help
> them to do the right thing because they are probably doing something
> super-fragile that works incidentally.
>
> To me, consistency in the core is more important than preserving the
> existing behavior to support such fragile cases.
>
> > > 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] 13+ messages in thread
* Re: [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices
2026-11-30 19:25 ` Rafael J. Wysocki (Intel)
@ 2026-12-01 0:37 ` Brian Norris
2026-12-01 14:08 ` Rafael J. Wysocki (Intel)
0 siblings, 1 reply; 13+ messages in thread
From: Brian Norris @ 2026-12-01 0:37 UTC (permalink / raw)
To: Rafael J. Wysocki (Intel)
Cc: Ulf Hansson, Linux PM, Alan Stern, Sakari Ailus,
Linux Driver Core Development, Javen Xu, Andrew Lunn
+ CC Javen Xu, Andrew Lunn for r8169
On Mon, Nov 30, 2026 at 08:25:22PM +0100, Rafael J. Wysocki (Intel) wrote:
> On Mon, Nov 30, 2026 at 6:24 PM Rafael J. Wysocki (Intel)
> <rafael@kernel.org> wrote:
> >
> > On Mon, Nov 30, 2026 at 6:08 PM Ulf Hansson
> > <ulf.hansson@oss.qualcomm.com> wrote:
> > >
> > > On Mon, Nov 30, 2026 at 4:08 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> > > > 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.
> > >
> > > While I in principle agree with the change, I am slightly worried
> > > about users that call pm_runtime_resume() and who call pm_runtime_get*
> > > quite soon after. I can tell if this is a common behaviour, but I am
> > > sure I have seen something like that.
This can also be pm_request_resume(), for the record.
>
> Out of curiosity, where have you seen it?
>
> There are not too many direct callers of pm_runtime_resume() in the
> tree and the majority of them don't do anything like this AFAICS.
I'm not quite sure about the particular pattern Ulf mentions, but I see
lots of sketchy code the more I look.
e.g., the dedicated wakeirq stuff here makes me scratch my head some:
56f487c78015 PM / Runtime: Update last_busy in rpm_resume
4990d4fe327b PM / Wakeirq: Add automated device wake IRQ handling
Commit 56f487c78015 seems to suggest it's relying on a non-zero
autosuspend delay to avoid problems. (Very sketchy IMO.) I can't tell if
those are actual functional problems, or if that was just a suboptimal
behavior / performance problem.
Or maybe some Intel soundwire / intel_component_probe() (with
comments!)? And there's a lot of similar-looking code elsewhere in
sound/.
t7xx_mode_store() (drivers/net/wwan/t7xx/t7xx_pci.c) looks buggy too.
I think those tend to use autosuspend delays. But see below.
> > Did you check?
> >
> > I don't know how many of them there are, if that's what you're asking,
> > but they should at least use an autosuspend delay.
Even autosuspend delay is risky, as that's just asking for a race
condition. Any such users need refcounts, or proper failsafes in
.runtime_idle()/.runtime_suspend(). And it's quite subtle to get the
non-refcount approaches correct.
There are some strange ones that I pointed out here:
https://lore.kernel.org/all/aweHkBnEGG5f8veE@google.com/
drivers/net/ethernet/intel/e1000e/netdev.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/igc/igc_main.c
I think they're functionally correct (due to .runtime_idle()
safeguards), even if strange.
But drivers/net/ethernet/realtek/r8169_main.c is a similar one, that I
believe is functionally wrong today, and possibly made worse with your
patch.
Specifically, see:
phylink_link_up -> rtl_mac_link_up() -> pm_request_resume()
In that context, netif_carrier_on() has not yet run, and so
rtl8169_runtime_idle() may still rearm its suspend timer
(pm_schedule_suspend()). Because rtl8169_runtime_suspend() does *not*
recheck netif_carrier_ok(), this means that 10 seconds later, we may
runtime-suspend an active link.
I believe this technically regressed with commit 8a3c76523e44 ("r8169:
add support for phylink"), where the calling conditions for
pm_request_resume() changed.
I'm no netdev / phylink expert, but it feels like maybe the driver
should be doing get()/put() in .mac_link_{up,down}(), rather than
relying only on carefully crafted .runtime_idle() + pm_request_resume().
> > Also note that if the initial pm_runtime_resume() resumes the device
> > and there is no autosuspend delay, it will suspend immediately even
> > without this change.
> >
> > > Anyway, for these cases we may end up doing an unnecessary round of
> > > suspend/resume of the device. Maybe not a big deal, but something that
> > > could have a negative impact on probing/boot.
If it's "only" unnecessary suspend/resume, I think we could live with
it, or patch them up later. I'm a bit more worried about all the
functional bugs hiding around the tree.
> > If this adversely affects anyone, I'd like to understand why and help
> > them to do the right thing because they are probably doing something
> > super-fragile that works incidentally.
> >
> > To me, consistency in the core is more important than preserving the
> > existing behavior to support such fragile cases.
I agree, I think anything that's noticing this change is at best fragile
and probably buggy. It's probably worth making sure we don't completely
break obvious stuff, but I don't think we can maintain every fragile
thing that exists today.
Brian
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices
2026-11-30 17:24 ` Rafael J. Wysocki (Intel)
2026-11-30 19:25 ` Rafael J. Wysocki (Intel)
@ 2026-12-01 9:16 ` Ulf Hansson
2026-12-01 13:36 ` Rafael J. Wysocki (Intel)
1 sibling, 1 reply; 13+ messages in thread
From: Ulf Hansson @ 2026-12-01 9:16 UTC (permalink / raw)
To: Rafael J. Wysocki (Intel)
Cc: Linux PM, Brian Norris, Alan Stern, Sakari Ailus,
Linux Driver Core Development
On Mon, Nov 30, 2026 at 6:25 PM Rafael J. Wysocki (Intel)
<rafael@kernel.org> wrote:
>
> On Mon, Nov 30, 2026 at 6:08 PM Ulf Hansson
> <ulf.hansson@oss.qualcomm.com> wrote:
> >
> > On Mon, Nov 30, 2026 at 4:08 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> > >
> > > 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.
> >
> > While I in principle agree with the change, I am slightly worried
> > about users that call pm_runtime_resume() and who call pm_runtime_get*
> > quite soon after. I can tell if this is a common behaviour, but I am
> > sure I have seen something like that. Did you check?
>
> I don't know how many of them there are, if that's what you're asking,
> but they should at least use an autosuspend delay.
>
> Also note that if the initial pm_runtime_resume() resumes the device
> and there is no autosuspend delay, it will suspend immediately even
> without this change.
Okay, honestly I didn't know this was the case.
I believe the device stayed runtime resumed until there was another
explicit request arriving to runtime suspend|idle it. In that case, I
guess the impact from this change should be rather limited.
>
> > Anyway, for these cases we may end up doing an unnecessary round of
> > suspend/resume of the device. Maybe not a big deal, but something that
> > could have a negative impact on probing/boot.
>
> If this adversely affects anyone, I'd like to understand why and help
> them to do the right thing because they are probably doing something
> super-fragile that works incidentally.
>
> To me, consistency in the core is more important than preserving the
> existing behavior to support such fragile cases.
I completely agree, but just wanted to point out the potential risk
for regressions.
[...]
Kind regards
Uffe
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices
2026-12-01 9:16 ` Ulf Hansson
@ 2026-12-01 13:36 ` Rafael J. Wysocki (Intel)
0 siblings, 0 replies; 13+ messages in thread
From: Rafael J. Wysocki (Intel) @ 2026-12-01 13:36 UTC (permalink / raw)
To: Ulf Hansson
Cc: Rafael J. Wysocki (Intel), Linux PM, Brian Norris, Alan Stern,
Sakari Ailus, Linux Driver Core Development
On Tue, Dec 1, 2026 at 10:16 AM Ulf Hansson
<ulf.hansson@oss.qualcomm.com> wrote:
>
> On Mon, Nov 30, 2026 at 6:25 PM Rafael J. Wysocki (Intel)
> <rafael@kernel.org> wrote:
> >
> > On Mon, Nov 30, 2026 at 6:08 PM Ulf Hansson
> > <ulf.hansson@oss.qualcomm.com> wrote:
> > >
> > > On Mon, Nov 30, 2026 at 4:08 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> > > >
> > > > 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.
> > >
> > > While I in principle agree with the change, I am slightly worried
> > > about users that call pm_runtime_resume() and who call pm_runtime_get*
> > > quite soon after. I can tell if this is a common behaviour, but I am
> > > sure I have seen something like that. Did you check?
> >
> > I don't know how many of them there are, if that's what you're asking,
> > but they should at least use an autosuspend delay.
> >
> > Also note that if the initial pm_runtime_resume() resumes the device
> > and there is no autosuspend delay, it will suspend immediately even
> > without this change.
>
> Okay, honestly I didn't know this was the case.
>
> I believe the device stayed runtime resumed until there was another
> explicit request arriving to runtime suspend|idle it.
Which may be triggered by user space via power/control at any time anyway.
> In that case, I guess the impact from this change should be rather limited.
Yes, it should.
> >
> > > Anyway, for these cases we may end up doing an unnecessary round of
> > > suspend/resume of the device. Maybe not a big deal, but something that
> > > could have a negative impact on probing/boot.
> >
> > If this adversely affects anyone, I'd like to understand why and help
> > them to do the right thing because they are probably doing something
> > super-fragile that works incidentally.
> >
> > To me, consistency in the core is more important than preserving the
> > existing behavior to support such fragile cases.
>
> I completely agree, but just wanted to point out the potential risk
> for regressions.
I see, thanks.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices
2026-12-01 0:37 ` Brian Norris
@ 2026-12-01 14:08 ` Rafael J. Wysocki (Intel)
2026-12-01 20:13 ` Brian Norris
0 siblings, 1 reply; 13+ messages in thread
From: Rafael J. Wysocki (Intel) @ 2026-12-01 14:08 UTC (permalink / raw)
To: Brian Norris
Cc: Rafael J. Wysocki (Intel), Ulf Hansson, Linux PM, Alan Stern,
Sakari Ailus, Linux Driver Core Development, Javen Xu,
Andrew Lunn
On Tue, Dec 1, 2026 at 1:37 AM Brian Norris <briannorris@chromium.org> wrote:
>
> + CC Javen Xu, Andrew Lunn for r8169
>
> On Mon, Nov 30, 2026 at 08:25:22PM +0100, Rafael J. Wysocki (Intel) wrote:
> > On Mon, Nov 30, 2026 at 6:24 PM Rafael J. Wysocki (Intel)
> > <rafael@kernel.org> wrote:
> > >
> > > On Mon, Nov 30, 2026 at 6:08 PM Ulf Hansson
> > > <ulf.hansson@oss.qualcomm.com> wrote:
> > > >
> > > > On Mon, Nov 30, 2026 at 4:08 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> > > > > 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.
> > > >
> > > > While I in principle agree with the change, I am slightly worried
> > > > about users that call pm_runtime_resume() and who call pm_runtime_get*
> > > > quite soon after. I can tell if this is a common behaviour, but I am
> > > > sure I have seen something like that.
>
> This can also be pm_request_resume(), for the record.
Yes, it can.
> >
> > Out of curiosity, where have you seen it?
> >
> > There are not too many direct callers of pm_runtime_resume() in the
> > tree and the majority of them don't do anything like this AFAICS.
>
> I'm not quite sure about the particular pattern Ulf mentions, but I see
> lots of sketchy code the more I look.
>
> e.g., the dedicated wakeirq stuff here makes me scratch my head some:
>
> 56f487c78015 PM / Runtime: Update last_busy in rpm_resume
> 4990d4fe327b PM / Wakeirq: Add automated device wake IRQ handling
>
> Commit 56f487c78015 seems to suggest it's relying on a non-zero
> autosuspend delay to avoid problems. (Very sketchy IMO.) I can't tell if
> those are actual functional problems, or if that was just a suboptimal
> behavior / performance problem.
Wakeup IRQs are a special case to some extent because they occur
during system suspend-resume while runtime PM is disabled anyway and
their role is mostly to wake up the system as a whole rather than to
wake up a specific device.
There are also other places where pm_runtime_resume() is called in
response to a device wakeup signal, but those cases rely on the
.runtime_resume() callback to recognize whether or not the wakeup was
genuine and do something to prevent the device from suspending again.
Resuming a device without taking a reference to it doesn't guarantee
anything in any case because user space may toggle power/control to
"on" and back to "auto" at any time which will at least start an
autosuspend timer for the device. This way or another, rpm_suspend()
may run for the given device at any time and if it is not actively
prevented from suspending the device, it will do that.
> Or maybe some Intel soundwire / intel_component_probe() (with
> comments!)? And there's a lot of similar-looking code elsewhere in
> sound/.
>
> t7xx_mode_store() (drivers/net/wwan/t7xx/t7xx_pci.c) looks buggy too.
>
> I think those tend to use autosuspend delays. But see below.
>
> > > Did you check?
> > >
> > > I don't know how many of them there are, if that's what you're asking,
> > > but they should at least use an autosuspend delay.
>
> Even autosuspend delay is risky, as that's just asking for a race
> condition. Any such users need refcounts, or proper failsafes in
> .runtime_idle()/.runtime_suspend(). And it's quite subtle to get the
> non-refcount approaches correct.
>
> There are some strange ones that I pointed out here:
>
> https://lore.kernel.org/all/aweHkBnEGG5f8veE@google.com/
>
> drivers/net/ethernet/intel/e1000e/netdev.c
> drivers/net/ethernet/intel/igb/igb_main.c
> drivers/net/ethernet/intel/igc/igc_main.c
>
> I think they're functionally correct (due to .runtime_idle()
> safeguards), even if strange.
Yes, they are, AFAICS.
> But drivers/net/ethernet/realtek/r8169_main.c is a similar one, that I
> believe is functionally wrong today, and possibly made worse with your
> patch.
>
> Specifically, see:
>
> phylink_link_up -> rtl_mac_link_up() -> pm_request_resume()
>
> In that context, netif_carrier_on() has not yet run, and so
> rtl8169_runtime_idle() may still rearm its suspend timer
> (pm_schedule_suspend()). Because rtl8169_runtime_suspend() does *not*
> recheck netif_carrier_ok(), this means that 10 seconds later, we may
> runtime-suspend an active link.
That's correct.
> I believe this technically regressed with commit 8a3c76523e44 ("r8169:
> add support for phylink"), where the calling conditions for
> pm_request_resume() changed.
>
> I'm no netdev / phylink expert, but it feels like maybe the driver
> should be doing get()/put() in .mac_link_{up,down}(), rather than
> relying only on carefully crafted .runtime_idle() + pm_request_resume().
I agree.
> > > Also note that if the initial pm_runtime_resume() resumes the device
> > > and there is no autosuspend delay, it will suspend immediately even
> > > without this change.
> > >
> > > > Anyway, for these cases we may end up doing an unnecessary round of
> > > > suspend/resume of the device. Maybe not a big deal, but something that
> > > > could have a negative impact on probing/boot.
>
> If it's "only" unnecessary suspend/resume, I think we could live with
> it, or patch them up later. I'm a bit more worried about all the
> functional bugs hiding around the tree.
>
> > > If this adversely affects anyone, I'd like to understand why and help
> > > them to do the right thing because they are probably doing something
> > > super-fragile that works incidentally.
> > >
> > > To me, consistency in the core is more important than preserving the
> > > existing behavior to support such fragile cases.
>
> I agree, I think anything that's noticing this change is at best fragile
> and probably buggy. It's probably worth making sure we don't completely
> break obvious stuff, but I don't think we can maintain every fragile
> thing that exists today.
Right.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices
2026-11-30 15:07 ` [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices Rafael J. Wysocki
2026-11-30 17:08 ` Ulf Hansson
@ 2026-12-01 15:15 ` Ulf Hansson
1 sibling, 0 replies; 13+ messages in thread
From: Ulf Hansson @ 2026-12-01 15:15 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux PM, Brian Norris, Alan Stern, Sakari Ailus,
Linux Driver Core Development
On Mon, Nov 30, 2026 at 4:08 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> 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>
Reviewed-by: Ulf Hansson <ulfh@kernel.org>
Kind regards
Uffe
> ---
> 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] 13+ messages in thread
* Re: [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices
2026-12-01 14:08 ` Rafael J. Wysocki (Intel)
@ 2026-12-01 20:13 ` Brian Norris
0 siblings, 0 replies; 13+ messages in thread
From: Brian Norris @ 2026-12-01 20:13 UTC (permalink / raw)
To: Rafael J. Wysocki (Intel)
Cc: Ulf Hansson, Linux PM, Alan Stern, Sakari Ailus,
Linux Driver Core Development, Javen Xu, Andrew Lunn
On Tue, Dec 01, 2026 at 03:08:13PM +0100, Rafael J. Wysocki (Intel) wrote:
> On Tue, Dec 1, 2026 at 1:37 AM Brian Norris <briannorris@chromium.org> wrote:
> > e.g., the dedicated wakeirq stuff here makes me scratch my head some:
> >
> > 56f487c78015 PM / Runtime: Update last_busy in rpm_resume
> > 4990d4fe327b PM / Wakeirq: Add automated device wake IRQ handling
> >
> > Commit 56f487c78015 seems to suggest it's relying on a non-zero
> > autosuspend delay to avoid problems. (Very sketchy IMO.) I can't tell if
> > those are actual functional problems, or if that was just a suboptimal
> > behavior / performance problem.
>
> Wakeup IRQs are a special case to some extent because they occur
> during system suspend-resume while runtime PM is disabled anyway and
> their role is mostly to wake up the system as a whole rather than to
> wake up a specific device.
Mostly but not entirely. They clearly care about runtime-PM scenarios
too; otherwise commit 56f487c78015 wouldn't really be important. (It was
intentionally provided as a prerequiste to commit 4990d4fe327b.)
> There are also other places where pm_runtime_resume() is called in
> response to a device wakeup signal, but those cases rely on the
> .runtime_resume() callback to recognize whether or not the wakeup was
> genuine and do something to prevent the device from suspending again.
Sure. And presumably "dedicated wake IRQ" devices should also be doing
something similar, but it's not clear that they uniformly do so
correctly. And as I interpret it, I think commit 56f487c78015 implies
the use case in question did not do that.
> Resuming a device without taking a reference to it doesn't guarantee
> anything in any case because user space may toggle power/control to
> "on" and back to "auto" at any time which will at least start an
> autosuspend timer for the device. This way or another, rpm_suspend()
> may run for the given device at any time and if it is not actively
> prevented from suspending the device, it will do that.
Ack. I think we all agree there are many reasons this stuff is fragile,
if anyone is relying on it :)
> > But drivers/net/ethernet/realtek/r8169_main.c is a similar one, that I
> > believe is functionally wrong today, and possibly made worse with your
> > patch.
> >
> > Specifically, see:
> >
> > phylink_link_up -> rtl_mac_link_up() -> pm_request_resume()
> >
> > In that context, netif_carrier_on() has not yet run, and so
> > rtl8169_runtime_idle() may still rearm its suspend timer
> > (pm_schedule_suspend()). Because rtl8169_runtime_suspend() does *not*
> > recheck netif_carrier_ok(), this means that 10 seconds later, we may
> > runtime-suspend an active link.
>
> That's correct.
>
> > I believe this technically regressed with commit 8a3c76523e44 ("r8169:
> > add support for phylink"), where the calling conditions for
> > pm_request_resume() changed.
> >
> > I'm no netdev / phylink expert, but it feels like maybe the driver
> > should be doing get()/put() in .mac_link_{up,down}(), rather than
> > relying only on carefully crafted .runtime_idle() + pm_request_resume().
>
> I agree.
OK, I sent a bugfix here:
[PATCH net-next 1/2] r8169: hold runtime PM reference while link is up
https://lore.kernel.org/all/20261201115920.net-next.1.Idb20d02896f15f4a79b68a9fee4f3bed1ea49543@changeid/
and paired that with converting to autosuspend / dropping
.runtime_idle().
Brian
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-12-01 20:13 UTC | newest]
Thread overview: 13+ 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 17:09 ` Ulf Hansson
2026-11-30 15:07 ` [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices Rafael J. Wysocki
2026-11-30 17:08 ` Ulf Hansson
2026-11-30 17:24 ` Rafael J. Wysocki (Intel)
2026-11-30 19:25 ` Rafael J. Wysocki (Intel)
2026-12-01 0:37 ` Brian Norris
2026-12-01 14:08 ` Rafael J. Wysocki (Intel)
2026-12-01 20:13 ` Brian Norris
2026-12-01 9:16 ` Ulf Hansson
2026-12-01 13:36 ` Rafael J. Wysocki (Intel)
2026-12-01 15:15 ` Ulf Hansson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox