PM: runtime: Update last_busy in rpm_resume() for active devices
Subsystems (4)
Rafael J. Wysocki
maintainerPATCH 1/1 PM: runtime: Update last_busy in rpm_resume() for active devices
From: "Rafael J. Wysocki" <[email protected]>
Setting an autosuspend delay for a device can be expected to cause a runtime suspend of the device after calling, say, pm_runtime_put() to be deferred, so the time between the last successful attempt to resume the device and its subsequent suspend is at least equal to the autosuspend delay.
However, that expectation is only met after the device has been actually resumed in rpm_resume() by invoking its runtime resume callback. If the runtime PM status of the device is already "active" when rpm_resume() runs for it, the device's last_busy timestamp is not updated which may allow a subsequent pm_runtime_put() invocation (or similar) to suspend it right away.
This is arguably inconsistent and confusing, so make rpm_resume() also update the device's last_busy timestamp when it finds that the device is already "active" and it is about to return 1 early.
--- drivers/base/power/runtime.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/base/power/runtime.c +6 -0
@@ -819,6 +819,12 @@ static int rpm_resume(struct device *devpm_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; }
Quoted 19 lines · Rafael J. Wysocki
From: "Rafael J. Wysocki" <[email protected]>
Setting an autosuspend delay for a device can be expected to cause a runtime suspend of the device after calling, say,
pm_runtime_put()to be deferred, so the time between the last successful attempt to resume the device and its subsequent suspend is at least equal to the autosuspend delay.However, that expectation is only met after the device has been actually resumed in
rpm_resume()by invoking its runtime resume callback. If the runtime PM status of the device is already "active" whenrpm_resume()runs for it, the device'slast_busytimestamp is not updated which may allow a subsequentpm_runtime_put()invocation (or similar) to suspend it right away.This is arguably inconsistent and confusing, so make
rpm_resume()also update the device'slast_busytimestamp when it finds that the device is already "active" and it is about to return 1 early.
Quoted 5 lines
Fixes 56f487c78015 ("PM / Runtime: Update last_busy in rpm_resume")Link https://lore.kernel.org/linux-pm/CAJZ5v0jTX1FgeS9FCV=+V4uacSgLQBVsSPnU27ybgUGg57GUOA@mail.gmail.com/ open hereReported-by Brian Norris <[email protected]>Cc All applicable <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 19 lines
--- drivers/base/power/runtime.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/base/power/runtime.c +6
-0@@ -819,6 +819,12 @@ static int rpm_resume(struct device *devpm_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; }
Quoted 15 lines · Rafael J. Wysocki
From: "Rafael J. Wysocki" <[email protected]>
Setting an autosuspend delay for a device can be expected to cause a runtime suspend of the device after calling, say,
pm_runtime_put()to be deferred, so the time between the last successful attempt to resume the device and its subsequent suspend is at least equal to the autosuspend delay.However, that expectation is only met after the device has been actually resumed in
rpm_resume()by invoking its runtime resume callback. If the runtime PM status of the device is already "active" whenrpm_resume()runs for it, the device'slast_busytimestamp is not updated which may allow a subsequentpm_runtime_put()invocation (or similar) to suspend it right away.
Quoted 7 lines
This is arguably inconsistent and confusing, so make
rpm_resume()also update the device'slast_busytimestamp when it finds that the device is already "active" and it is about to return 1 early.Fixes 56f487c78015 ("PM / Runtime: Update last_busy in rpm_resume")Link https://lore.kernel.org/linux-pm/CAJZ5v0jTX1FgeS9FCV=+V4uacSgLQBVsSPnU27ybgUGg57GUOA@mail.gmail.com/ open hereReported-by Brian Norris <[email protected]>
Ha, I suppose you can call it Reported-by, even if it's somewhat of a tangent IMO :)
Quoted 2 lines
Cc All applicable <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 20 lines · Rafael J. Wysocki
From: "Rafael J. Wysocki" <[email protected]>
Setting an autosuspend delay for a device can be expected to cause a runtime suspend of the device after calling, say,
pm_runtime_put()to be deferred, so the time between the last successful attempt to resume the device and its subsequent suspend is at least equal to the autosuspend delay.However, that expectation is only met after the device has been actually resumed in
rpm_resume()by invoking its runtime resume callback. If the runtime PM status of the device is already "active" whenrpm_resume()runs for it, the device'slast_busytimestamp is not updated which may allow a subsequentpm_runtime_put()invocation (or similar) to suspend it right away.This is arguably inconsistent and confusing, so make
rpm_resume()also update the device'slast_busytimestamp when it finds that the device is already "active" and it is about to return 1 early.
Quoted 5 lines
Fixes 56f487c78015 ("PM / Runtime: Update last_busy in rpm_resume")Link https://lore.kernel.org/linux-pm/CAJZ5v0jTX1FgeS9FCV=+V4uacSgLQBVsSPnU27ybgUGg57GUOA@mail.gmail.com/ open hereReported-by Brian Norris <[email protected]>Cc All applicable <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>
I guess I may be too late, but in any case, this makes perfect sense to me!
Quoted 22 lines
--- drivers/base/power/runtime.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/base/power/runtime.c +6
-0@@ -819,6 +819,12 @@ static int rpm_resume(struct device *devpm_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; }