Skip to content

Commit

Permalink
PM / core: Fix direct_complete handling for devices with no callbacks
Browse files Browse the repository at this point in the history
Commit 08810a4 (PM / core: Add NEVER_SKIP and SMART_PREPARE
driver flags) inadvertently prevented the power.direct_complete flag
from being set for devices without PM callbacks and with disabled
runtime PM which also prevents power.direct_complete from being set
for their parents.  That led to problems including a resume crash on
HP ZBook 14u.

Restore the previous behavior by causing power.direct_complete to be
set for those devices again, but do that in a more direct way to
avoid overlooking that case in the future.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=199693
Fixes: 08810a4 (PM / core: Add NEVER_SKIP and SMART_PREPARE driver flags)
Reported-by: Thomas Martitz <[email protected]>
Tested-by: Thomas Martitz <[email protected]>
Cc: 4.15+ <[email protected]> # 4.15+
Signed-off-by: Rafael J. Wysocki <[email protected]>
Reviewed-by: Ulf Hansson <[email protected]>
Reviewed-by: Johan Hovold <[email protected]>
  • Loading branch information
rafaeljw committed May 22, 2018
1 parent 771c577 commit c62ec46
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/base/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1923,10 +1923,8 @@ static int device_prepare(struct device *dev, pm_message_t state)

dev->power.wakeup_path = false;

if (dev->power.no_pm_callbacks) {
ret = 1; /* Let device go direct_complete */
if (dev->power.no_pm_callbacks)
goto unlock;
}

if (dev->pm_domain)
callback = dev->pm_domain->ops.prepare;
Expand Down Expand Up @@ -1960,7 +1958,8 @@ static int device_prepare(struct device *dev, pm_message_t state)
*/
spin_lock_irq(&dev->power.lock);
dev->power.direct_complete = state.event == PM_EVENT_SUSPEND &&
pm_runtime_suspended(dev) && ret > 0 &&
((pm_runtime_suspended(dev) && ret > 0) ||
dev->power.no_pm_callbacks) &&
!dev_pm_test_driver_flags(dev, DPM_FLAG_NEVER_SKIP);
spin_unlock_irq(&dev->power.lock);
return 0;
Expand Down

0 comments on commit c62ec46

Please sign in to comment.