Skip to content

Commit eeb87d1

Browse files
committed
PM: sleep: Adjust check before setting power.must_resume
The check before setting power.must_resume in device_suspend_noirq() does not take power.child_count into account, but it should do that, so use pm_runtime_need_not_resume() in it for this purpose and adjust the comment next to it accordingly. Fixes: 107d47b ("PM: sleep: core: Simplify the SMART_SUSPEND flag handling") Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Ulf Hansson <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 630d55e commit eeb87d1

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

drivers/base/power/main.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,14 +1277,13 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state, bool asy
12771277
dev->power.is_noirq_suspended = true;
12781278

12791279
/*
1280-
* Skipping the resume of devices that were in use right before the
1281-
* system suspend (as indicated by their PM-runtime usage counters)
1282-
* would be suboptimal. Also resume them if doing that is not allowed
1283-
* to be skipped.
1280+
* Devices must be resumed unless they are explicitly allowed to be left
1281+
* in suspend, but even in that case skipping the resume of devices that
1282+
* were in use right before the system suspend (as indicated by their
1283+
* runtime PM usage counters and child counters) would be suboptimal.
12841284
*/
1285-
if (atomic_read(&dev->power.usage_count) > 1 ||
1286-
!(dev_pm_test_driver_flags(dev, DPM_FLAG_MAY_SKIP_RESUME) &&
1287-
dev->power.may_skip_resume))
1285+
if (!(dev_pm_test_driver_flags(dev, DPM_FLAG_MAY_SKIP_RESUME) &&
1286+
dev->power.may_skip_resume) || !pm_runtime_need_not_resume(dev))
12881287
dev->power.must_resume = true;
12891288

12901289
if (dev->power.must_resume)

drivers/base/power/runtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,7 @@ void pm_runtime_drop_link(struct device_link *link)
19061906
pm_request_idle(link->supplier);
19071907
}
19081908

1909-
static bool pm_runtime_need_not_resume(struct device *dev)
1909+
bool pm_runtime_need_not_resume(struct device *dev)
19101910
{
19111911
return atomic_read(&dev->power.usage_count) <= 1 &&
19121912
(atomic_read(&dev->power.child_count) == 0 ||

include/linux/pm_runtime.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static inline bool queue_pm_work(struct work_struct *work)
6666

6767
extern int pm_generic_runtime_suspend(struct device *dev);
6868
extern int pm_generic_runtime_resume(struct device *dev);
69+
extern bool pm_runtime_need_not_resume(struct device *dev);
6970
extern int pm_runtime_force_suspend(struct device *dev);
7071
extern int pm_runtime_force_resume(struct device *dev);
7172

@@ -244,6 +245,7 @@ static inline bool queue_pm_work(struct work_struct *work) { return false; }
244245

245246
static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
246247
static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
248+
static inline bool pm_runtime_need_not_resume(struct device *dev) {return true; }
247249
static inline int pm_runtime_force_suspend(struct device *dev) { return 0; }
248250
static inline int pm_runtime_force_resume(struct device *dev) { return 0; }
249251

0 commit comments

Comments
 (0)