public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pm: sleep: do not set is_prepared when no_pm_callbacks is set
@ 2024-09-02 12:59 David Wang
  2024-09-03 10:23 ` Greg KH
  2024-09-03 12:31 ` Rafael J. Wysocki
  0 siblings, 2 replies; 7+ messages in thread
From: David Wang @ 2024-09-02 12:59 UTC (permalink / raw)
  To: rafael, pavel, gregkh; +Cc: linux-pm, linux-kernel, David Wang

When resume, a parent device with no pm callbacks
would have "is_prepared" and "direct_complete" bit
set, and skip the "fib" chance to unset "is_prepared"
in device_resume because of the direct_complete bit.
This will trigger a kernel warning when resume its child
For example, when suspend system with an USB webcam
opened, following warning would show up during resume:

 >usb 3-1.1: reset high-speed USB device number 4 using xhci_hcd
 >..
 >ep_81: PM: parent 3-1.1:1.1 should not be sleeping

The device parenting relationships are:
[usb 3-1.1] << [uvcvideo 3-1.1:1.1] << [ep_81].
When resume, since the virtual [uvcvideo 3-1.1:1.1] device
has no pm callbacks, it would not clear "is_prepared"
once set.  Then, when resume [ep_81], pm module would
yield a warn seeing [ep_81]'s parent [uvcvideo 3-1.1:1.1]
having "is_prepared".

Do not set "is_prepared" for virtual devices having
no pm callbacks can clear those kernel warnings.

Signed-off-by: David Wang <00107082@163.com>
---
 drivers/base/power/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 934e5bb61f13..e2149ccf2c3e 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1880,7 +1880,8 @@ int dpm_prepare(pm_message_t state)
 		mutex_lock(&dpm_list_mtx);
 
 		if (!error) {
-			dev->power.is_prepared = true;
+			if (!dev->power.no_pm_callbacks)
+				dev->power.is_prepared = true;
 			if (!list_empty(&dev->power.entry))
 				list_move_tail(&dev->power.entry, &dpm_prepared_list);
 		} else if (error == -EAGAIN) {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-09-03 17:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-02 12:59 [PATCH] pm: sleep: do not set is_prepared when no_pm_callbacks is set David Wang
2024-09-03 10:23 ` Greg KH
2024-09-03 11:26   ` David Wang
2024-09-03 12:32   ` Rafael J. Wysocki
2024-09-03 17:30     ` David Wang
2024-09-03 12:31 ` Rafael J. Wysocki
2024-09-03 17:09   ` David Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox