Skip to contentSkip to conversation

usb: xhci: wait for controller ready when resume with reinit_xhc

PATCH In review David Wang 1 participant 2 messages Sep 1, 2024

Subsystems (2)
lore
Share & tools
lore

David Wang

author
#0 lore raw

PATCH 1/1 usb: xhci: wait for controller ready when resume with reinit_xhc

When resume system with reinit_xhc true, PM would report kernel warning about device parent:

Quoted 3 lines

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

Move the code waiting for controller ready out, and make it carry out work no matter reinit_xhc is true or false. The error is ignored when reinit_xhc is true.

---
 drivers/usb/host/xhci.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/usb/host/xhci.c +8 -6
index efdf4c228b8c..8aeb1b34cdbf 100644
@@ -1032,13 +1032,15 @@ int xhci_resume(struct xhci_hcd *xhci, pm_message_t msg)
 	if (hibernated || xhci->quirks & XHCI_RESET_ON_RESUME || xhci->broken_suspend)
 		reinit_xhc = true;
 
+	/*
+	 * Some controllers might lose power during suspend, so wait
+	 * for controller not ready bit to clear, just as in xHC init.
+	 * Ignore retval if reinit_xhc is true, since the device would
+	 * be reinited.
+	 */
+	retval = xhci_handshake(&xhci->op_regs->status,
+				STS_CNR, 0, 10 * 1000 * 1000);
 	if (!reinit_xhc) {
-		/*
-		 * Some controllers might lose power during suspend, so wait
-		 * for controller not ready bit to clear, just as in xHC init.
-		 */
-		retval = xhci_handshake(&xhci->op_regs->status,
-					STS_CNR, 0, 10 * 1000 * 1000);
 		if (retval) {
 			xhci_warn(xhci, "Controller not ready at resume %d\n",
 				  retval);
Signature · 1 line
2.39.2
author
#1 lore raw

Oops... Just find out the warning " ep_81: PM: parent 3-1.1:1.1 should not be sleeping" shows up when I suspend my system with USB camera on, and this patch could not fix it.
Please ignore the patch, sorry bothering...

David

Quoted 44 lines · David Wang

When resume system with reinit_xhc true, PM would report kernel warning about device parent:

Quoted 3 lines

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

Move the code waiting for controller ready out, and make it carry out work no matter reinit_xhc is true or false. The error is ignored when reinit_xhc is true.

---
drivers/usb/host/xhci.c | 14 ++++++++------

1 file changed, 8 insertions(+), 6 deletions(-)
drivers/usb/host/xhci.c +8 -6
index efdf4c228b8c..8aeb1b34cdbf 100644
@@ -1032,13 +1032,15 @@ int xhci_resume(struct xhci_hcd *xhci, pm_message_t msg)
 	if (hibernated || xhci->quirks & XHCI_RESET_ON_RESUME || xhci->broken_suspend)
 		reinit_xhc = true;
 
+	/*
+	 * Some controllers might lose power during suspend, so wait
+	 * for controller not ready bit to clear, just as in xHC init.
+	 * Ignore retval if reinit_xhc is true, since the device would
+	 * be reinited.
+	 */
+	retval = xhci_handshake(&xhci->op_regs->status,
+				STS_CNR, 0, 10 * 1000 * 1000);
 	if (!reinit_xhc) {
-		/*
-		 * Some controllers might lose power during suspend, so wait
-		 * for controller not ready bit to clear, just as in xHC init.
-		 */
-		retval = xhci_handshake(&xhci->op_regs->status,
-					STS_CNR, 0, 10 * 1000 * 1000);
 		if (retval) {
 			xhci_warn(xhci, "Controller not ready at resume %d\n",
 				  retval);
Signature · 1 line
2.39.2