Skip to contentSkip to conversation

usb: host: xhci: avoid calling contineous two times for xhci_suspend

PATCH New Peter Chen 1 participant 3 messages Jul 15, 2020

Subsystems (2)
lore
Share & tools
lore

Peter Chen

author
#0 lore raw

PATCH 1/3 usb: host: xhci: avoid calling contineous two times for xhci_suspend

If the xhci-plat.c is the platform driver, after the runtime pm is enabled, the xhci_suspend is called if nothing is connected on the port. When the system goes to suspend, it will call xhci_suspend again if USB wakeup is enabled.

Since the runtime suspend wakeup setting is not always the same with system suspend wakeup setting, eg, at runtime suspend, we always need wakeup if the controller is in low power mode; but at suspend system, we may not need wakeup. So, we move the judgement after changing wakeup setting.

---
 drivers/usb/host/xhci.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.c +5 -2
index 159e084cfd2f..6e7e2419bf85 100644
@@ -982,12 +982,15 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
 			xhci->shared_hcd->state != HC_STATE_SUSPENDED)
 		return -EINVAL;
 
-	xhci_dbc_suspend(xhci);
-
 	/* Clear root port wake on bits if wakeup not allowed. */
 	if (!do_wakeup)
 		xhci_disable_port_wake_on_bits(xhci);
 
+	if (!HCD_HW_ACCESSIBLE(hcd))
+		return 0;
+
+	xhci_dbc_suspend(xhci);
+
 	/* Don't poll the roothubs on bus suspend. */
 	xhci_dbg(xhci, "%s: stopping port polling.\n", __func__);
 	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/3 usb: host: xhci-plat: initialize device wakeup default enabled

It initializes the controller wakeup setting as default enabled unless the user changes it, whether the controller responds the wakeup event depends on roothub's wakeup setting since the wakeup occurs at the bus not the controller itself.

With this change, the controller uses this driver could have wakeup capability due to device_may_wakeup(dev) at xhci_plat_suspend is default true; without this change, this value is always false.

---
 drivers/usb/host/xhci-plat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-plat.c +1 -1
index 53e6f8f69ce0..4bf03aa0143d 100644
@@ -287,7 +287,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 		*priv = *priv_match;
 	}
 
-	device_wakeup_enable(hcd->self.controller);
+	device_init_wakeup(hcd->self.controller, true);
 
 	xhci->main_hcd = hcd;
 	xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 3/3 usb: host: xhci-plat: improve the comments for xhci_plat_suspend

In reply to Peter Chen

To reflect the current code status.

---
 drivers/usb/host/xhci-plat.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/usb/host/xhci-plat.c +1 -5
index 4bf03aa0143d..abfa85145712 100644
@@ -425,11 +425,7 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)
 		return ret;
 	/*
 	 * xhci_suspend() needs `do_wakeup` to know whether host is allowed
-	 * to do wakeup during suspend. Since xhci_plat_suspend is currently
-	 * only designed for system suspend, device_may_wakeup() is enough
-	 * to dertermine whether host is allowed to do wakeup. Need to
-	 * reconsider this when xhci_plat_suspend enlarges its scope, e.g.,
-	 * also applies to runtime suspend.
+	 * to do wakeup during suspend, the wakeup is enabled by default.
 	 */
 	return xhci_suspend(xhci, device_may_wakeup(dev));
 }
Signature · 1 line
2.17.1