linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: xhci-plat: fix usb disconnect issue after s4
@ 2023-08-02  9:06 Yinbo Zhu
  2023-08-02  9:39 ` Greg Kroah-Hartman
  2023-08-08 23:41 ` kernel test robot
  0 siblings, 2 replies; 8+ messages in thread
From: Yinbo Zhu @ 2023-08-02  9:06 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, linux-usb, linux-kernel
  Cc: Jianmin Lv, wanghongliang, Liu Peibao, loongson-kernel, Yinbo Zhu

The xhci retaining bogus hardware states cause usb disconnect devices
connected before hibernation(s4) and refer to the commit '547d55fa83
("usb: ohci-platform: fix usb disconnect issue after s4")' which set
flag "hibernated" as true when resume-from-hibernation and that the
drivers will reset the hardware to get rid of any existing state and
make sure resume from hibernation re-enumerates everything for xhci.

Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
---
 drivers/usb/host/xhci-plat.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 28218c8f1837..41a213070435 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -451,7 +451,7 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused xhci_plat_resume(struct device *dev)
+static int __maybe_unused xhci_plat_resume_common(struct device *dev, struct pm_message pmsg)
 {
 	struct usb_hcd	*hcd = dev_get_drvdata(dev);
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
@@ -466,7 +466,7 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
 	if (ret)
 		return ret;
 
-	ret = xhci_resume(xhci, PMSG_RESUME);
+	ret = xhci_resume(xhci, pmsg);
 	if (ret)
 		return ret;
 
@@ -477,6 +477,16 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
 	return 0;
 }
 
+static int __maybe_unused xhci_plat_resume(struct device *dev)
+{
+	return xhci_plat_resume_common(dev, PMSG_RESUME);
+}
+
+static int __maybe_unused xhci_plat_restore(struct device *dev)
+{
+	return xhci_plat_resume_common(dev, PMSG_RESTORE);
+}
+
 static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev)
 {
 	struct usb_hcd  *hcd = dev_get_drvdata(dev);
@@ -499,7 +509,12 @@ static int __maybe_unused xhci_plat_runtime_resume(struct device *dev)
 }
 
 const struct dev_pm_ops xhci_plat_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(xhci_plat_suspend, xhci_plat_resume)
+	.suspend = xhci_plat_suspend,
+	.resume = xhci_plat_resume,
+	.freeze = xhci_plat_suspend,
+	.thaw = xhci_plat_resume,
+	.poweroff = xhci_plat_suspend,
+	.restore = xhci_plat_restore,
 
 	SET_RUNTIME_PM_OPS(xhci_plat_runtime_suspend,
 			   xhci_plat_runtime_resume,
-- 
2.31.1


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

end of thread, other threads:[~2023-08-09  9:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-02  9:06 [PATCH] usb: xhci-plat: fix usb disconnect issue after s4 Yinbo Zhu
2023-08-02  9:39 ` Greg Kroah-Hartman
2023-08-02  9:58   ` Yinbo Zhu
2023-08-02 10:06     ` Greg Kroah-Hartman
2023-08-03  2:19       ` Yinbo Zhu
2023-08-03  2:54       ` Yinbo Zhu
2023-08-08 23:41 ` kernel test robot
2023-08-09  9:28   ` Yinbo Zhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).