diff mbox series

[v2] PM: sleep: core: Clear is_prepared if no_pm_callbacks is true before checking power.syscore

Message ID 20250213105840.2864654-1-xu.yang_2@nxp.com
State New
Headers show
Series [v2] PM: sleep: core: Clear is_prepared if no_pm_callbacks is true before checking power.syscore | expand

Commit Message

Xu Yang Feb. 13, 2025, 10:58 a.m. UTC
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 before checking syscore if the device has no pm callbacks.

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

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

---
v2: clear is_prepared before check syscore as suggested by Rafael
---
 drivers/base/power/main.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 40e1d8d8a589..5e69cfaec661 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -926,6 +926,9 @@  static void device_resume(struct device *dev, pm_message_t state, bool async)
 	TRACE_DEVICE(dev);
 	TRACE_RESUME(0);
 
+	if (dev->power.no_pm_callbacks)
+		dev->power.is_prepared = false;
+
 	if (dev->power.syscore)
 		goto Complete;