]> git.baikalelectronics.ru Git - kernel.git/commit
PM-runtime: Fix deadlock when canceling hrtimer
authorVincent Guittot <vincent.guittot@linaro.org>
Thu, 21 Feb 2019 07:59:02 +0000 (08:59 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 21 Feb 2019 09:29:00 +0000 (10:29 +0100)
commit37cba112c20dd956c3b2a2f3397c1848ae0403d1
tree6d5f00f222dba81808cdde588f2660ab8163810a
parent97ee1b25b1ac2975684e596770bd817d20cc1bbd
PM-runtime: Fix deadlock when canceling hrtimer

When rpm_resume() desactivates the autosuspend timer, it should only
try to cancel hrtimer but not wait for the handler to finish, because
both rpm_resume() and pm_suspend_timer_fn() take the power.lock.

A deadlock is possible as follows:

CPU0                              CPU1
rpm_resume()
  spin_lock_irqsave
                                  pm_suspend_timer_fn()
                                    spin_lock_irqsave
  pm_runtime_deactivate_timer()
    hrtimer_cancel()

It is sufficient to call hrtimer_try_to_cancel() from
pm_runtime_deactivate_timer(), because dev->power.timer_expires
reset to 0 by it, so use that function instead of hrtimer_cancel().

Fixes: bcc05c18b16c ("PM-runtime: Switch autosuspend over to using hrtimers")
Reported-by: Sunzhaosheng Sun(Zhaosheng) <sunzhaosheng@hisilicon.com>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
[ rjw: Changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/runtime.c