PM: sleep: core: Clear is_prepared if both no_pm_callbacks and direct_complete is set
Subsystems (5)
PATCH v3 1/1 PM: sleep: core: Clear is_prepared if both no_pm_callbacks and direct_complete is set
Currently, if power.no_callbacks is true for a device, device_prepare() will also set power.direct_complete to true. When device_resume() check power.direct_complete, setting power.is_prepared will be skipped if it can directly complete. This will cause a warning when add new devices during resume() stage.
Although power.is_prepared should be cleared in complete() state, commit (f76b168b6f11 PM: Rename dev_pm_info.in_suspend to is_prepared) allow clear it in earlier resume() stage. However, we need also set is_prepared to false if both power.no_callbacks and power.direct_complete are true.
Take USB as example:
The usb_interface is such a device which setting power.no_callbacks to true. Then if the user call usb_set_interface() during resume() stage, the kernel will print below warning since the system will create and add ep devices.
[ 186.461414] usb 1-1: reset high-speed USB device number 3 using ci_hdrc [ 187.102681] ep_81: PM: parent 1-1:1.1 should not be sleeping [ 187.105010] PM: resume devices took 0.936 seconds
---
v3: combined checking no_pm_callbacks and direct_complete
v2: clear is_prepared before check syscore as suggested by Rafael
--- drivers/base/power/main.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/base/power/main.c +7 -0
@@ -930,6 +930,13 @@ static void device_resume(struct device *dev, pm_message_t state, bool async) goto Complete;if (dev->power.direct_complete) { +/* +* Allow new children to be added in the resume stage for +* devices with no PM callbacks and can be completed directly. +*/ +if (dev->power.no_pm_callbacks) + dev->power.is_prepared = false; +/* Match the pm_runtime_disable() in device_suspend(). */ pm_runtime_enable (dev); goto Complete;
Signature · 1 line
2.34.1
Quoted 41 lines · Xu Yang
Currently, if power.no_callbacks is true for a device,
device_prepare()will also set power.direct_complete to true. Whendevice_resume()check power.direct_complete, setting power.is_prepared will be skipped if it can directly complete. This will cause a warning when add new devices duringresume()stage.Although power.is_prepared should be cleared in
complete()state, commit (f76b168b6f11PM: Rename dev_pm_info.in_suspend tois_prepared) allow clear it in earlierresume()stage. However, we need also setis_preparedto false if both power.no_callbacks and power.direct_complete are true.Take USB as example:
Theusb_interfaceis such a device which setting power.no_callbacks to true. Then if the user callusb_set_interface()duringresume()stage, the kernel will print below warning since the system will create and add ep devices.[ 186.461414] usb 1-1: reset high-speed USB device number 3 using ci_hdrc [ 187.102681] ep_81: PM: parent 1-1:1.1 should not be sleeping [ 187.105010] PM: resume devices took 0.936 secondsSuggested-by Rafael J. Wysocki <[email protected]>Signed-off-by Xu Yang <[email protected]>---
v3: combined checkingno_pm_callbacksanddirect_complete
v2: clearis_preparedbefore check syscore as suggested by Rafael--- drivers/base/power/main.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/base/power/main.c +1
-0@@ -930,6 +930,13 @@ static void device_resume(struct device *dev, pm_message_t state, bool async) goto Complete;if (dev->power.direct_complete) { +/*
drivers/base/power/main.c static void device_resume(struct device *dev, pm_message_t state, bool async)
Quoted 10 lines
drivers/base/power/main.c +6
-1+* Allow new children to be added in the resume stage for +* devices with no PM callbacks and can be completed directly. +*/ +if (dev->power.no_pm_callbacks) + dev->power.is_prepared = false; +/* Match the pm_runtime_disable() in device_suspend(). */ pm_runtime_enable (dev); goto Complete; --
Applied as 6.15 material under a new subject and with edits in the changelog.
Thanks!