Skip to content

Commit 40d3b40

Browse files
Charan Teja Kallarafaeljw
authored andcommitted
PM: runtime: fix denying of auto suspend in pm_suspend_timer_fn()
pm_runtime_put_autosuspend() schedules a hrtimer to expire at "dev->power.timer_expires". If the hrtimer's callback, pm_suspend_timer_fn(), observes that the current time equals "dev->power.timer_expires", it unexpectedly bails out instead of proceeding with runtime suspend. pm_suspend_timer_fn(): if (expires > 0 && expires < ktime_get_mono_fast_ns()) { dev->power.timer_expires = 0; rpm_suspend(..) } Additionally, as ->timer_expires is not cleared, all the future auto suspend requests will not schedule hrtimer to perform auto suspend. rpm_suspend(): if ((rpmflags & RPM_AUTO) &&...) { if (!(dev->power.timer_expires && ...) { <-- this will fail. hrtimer_start_range_ns(&dev->power.suspend_timer,...); } } Fix this by as well checking if current time reaches the set expiration. Co-developed-by: Patrick Daly <quic_pdaly@quicinc.com> Signed-off-by: Patrick Daly <quic_pdaly@quicinc.com> Signed-off-by: Charan Teja Kalla <quic_charante@quicinc.com> Link: https://patch.msgid.link/20250515064125.1211561-1-quic_charante@quicinc.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 495e7a6 commit 40d3b40

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/base/power/runtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ static enum hrtimer_restart pm_suspend_timer_fn(struct hrtimer *timer)
10111011
* If 'expires' is after the current time, we've been called
10121012
* too early.
10131013
*/
1014-
if (expires > 0 && expires < ktime_get_mono_fast_ns()) {
1014+
if (expires > 0 && expires <= ktime_get_mono_fast_ns()) {
10151015
dev->power.timer_expires = 0;
10161016
rpm_suspend(dev, dev->power.timer_autosuspends ?
10171017
(RPM_ASYNC | RPM_AUTO) : RPM_ASYNC);

0 commit comments

Comments
 (0)