Skip to content

Commit 057d51a

Browse files
committed
Merge branch 'pm-sleep'
* pm-sleep: PM: Prevent runtime suspend during system resume PM / Sleep: use resume event when call dpm_resume_early Conflicts: drivers/base/power/main.c (trivial)
2 parents 071f582 + 88d2613 commit 057d51a

2 files changed

Lines changed: 19 additions & 29 deletions

File tree

‎drivers/base/power/main.c‎

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,6 @@ static int device_resume(struct device *dev, pm_message_t state, bool async)
570570
pm_callback_t callback = NULL;
571571
char *info = NULL;
572572
int error = 0;
573-
bool put = false;
574573

575574
TRACE_DEVICE(dev);
576575
TRACE_RESUME(0);
@@ -591,7 +590,6 @@ static int device_resume(struct device *dev, pm_message_t state, bool async)
591590
goto Unlock;
592591

593592
pm_runtime_enable(dev);
594-
put = true;
595593

596594
if (dev->pm_domain) {
597595
info = "power domain ";
@@ -646,9 +644,6 @@ static int device_resume(struct device *dev, pm_message_t state, bool async)
646644

647645
TRACE_RESUME(error);
648646

649-
if (put)
650-
pm_runtime_put_sync(dev);
651-
652647
return error;
653648
}
654649

@@ -762,6 +757,8 @@ static void device_complete(struct device *dev, pm_message_t state)
762757
}
763758

764759
device_unlock(dev);
760+
761+
pm_runtime_put_sync(dev);
765762
}
766763

767764
/**
@@ -1015,7 +1012,7 @@ int dpm_suspend_end(pm_message_t state)
10151012

10161013
error = dpm_suspend_noirq(state);
10171014
if (error) {
1018-
dpm_resume_early(state);
1015+
dpm_resume_early(resume_event(state));
10191016
return error;
10201017
}
10211018

@@ -1062,12 +1059,16 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
10621059
if (async_error)
10631060
goto Complete;
10641061

1065-
pm_runtime_get_noresume(dev);
1062+
/*
1063+
* If a device configured to wake up the system from sleep states
1064+
* has been suspended at run time and there's a resume request pending
1065+
* for it, this is equivalent to the device signaling wakeup, so the
1066+
* system suspend operation should be aborted.
1067+
*/
10661068
if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
10671069
pm_wakeup_event(dev, 0);
10681070

10691071
if (pm_wakeup_pending()) {
1070-
pm_runtime_put_sync(dev);
10711072
async_error = -EBUSY;
10721073
goto Complete;
10731074
}
@@ -1133,12 +1134,10 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
11331134
Complete:
11341135
complete_all(&dev->power.completion);
11351136

1136-
if (error) {
1137-
pm_runtime_put_sync(dev);
1137+
if (error)
11381138
async_error = error;
1139-
} else if (dev->power.is_suspended) {
1139+
else if (dev->power.is_suspended)
11401140
__pm_runtime_disable(dev, false);
1141-
}
11421141

11431142
return error;
11441143
}
@@ -1234,6 +1233,14 @@ static int device_prepare(struct device *dev, pm_message_t state)
12341233
if (dev->power.syscore)
12351234
return 0;
12361235

1236+
/*
1237+
* If a device's parent goes into runtime suspend at the wrong time,
1238+
* it won't be possible to resume the device. To prevent this we
1239+
* block runtime suspend here, during the prepare phase, and allow
1240+
* it again during the complete phase.
1241+
*/
1242+
pm_runtime_get_noresume(dev);
1243+
12371244
device_lock(dev);
12381245

12391246
dev->power.wakeup_path = device_may_wakeup(dev);

‎drivers/pci/pci-driver.c‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -629,21 +629,6 @@ static int pci_pm_prepare(struct device *dev)
629629
struct device_driver *drv = dev->driver;
630630
int error = 0;
631631

632-
/*
633-
* If a PCI device configured to wake up the system from sleep states
634-
* has been suspended at run time and there's a resume request pending
635-
* for it, this is equivalent to the device signaling wakeup, so the
636-
* system suspend operation should be aborted.
637-
*/
638-
pm_runtime_get_noresume(dev);
639-
if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
640-
pm_wakeup_event(dev, 0);
641-
642-
if (pm_wakeup_pending()) {
643-
pm_runtime_put_sync(dev);
644-
return -EBUSY;
645-
}
646-
647632
/*
648633
* PCI devices suspended at run time need to be resumed at this
649634
* point, because in general it is necessary to reconfigure them for
@@ -667,8 +652,6 @@ static void pci_pm_complete(struct device *dev)
667652

668653
if (drv && drv->pm && drv->pm->complete)
669654
drv->pm->complete(dev);
670-
671-
pm_runtime_put_sync(dev);
672655
}
673656

674657
#else /* !CONFIG_PM_SLEEP */

0 commit comments

Comments
 (0)