Skip to content

Commit

Permalink
usb: xhci-plat: fix usb disconnect issue after s4
Browse files Browse the repository at this point in the history
The xhci retaining bogus hardware states cause usb disconnect devices
connected before hibernation(s4) and refer to the commit 'f3d478858be
("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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
YinboZhu authored and gregkh committed Jan 4, 2024
1 parent 91736d0 commit 6d6887c
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions drivers/usb/host/xhci-plat.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ void xhci_plat_remove(struct platform_device *dev)
}
EXPORT_SYMBOL_GPL(xhci_plat_remove);

static int __maybe_unused xhci_plat_suspend(struct device *dev)
static int xhci_plat_suspend(struct device *dev)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
Expand Down Expand Up @@ -464,7 +464,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 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);
Expand All @@ -486,7 +486,7 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
if (ret)
goto disable_clks;

ret = xhci_resume(xhci, PMSG_RESUME);
ret = xhci_resume(xhci, pmsg);
if (ret)
goto disable_clks;

Expand All @@ -505,6 +505,16 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
return ret;
}

static int xhci_plat_resume(struct device *dev)
{
return xhci_plat_resume_common(dev, PMSG_RESUME);
}

static int 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);
Expand All @@ -527,7 +537,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 = pm_sleep_ptr(xhci_plat_suspend),
.resume = pm_sleep_ptr(xhci_plat_resume),
.freeze = pm_sleep_ptr(xhci_plat_suspend),
.thaw = pm_sleep_ptr(xhci_plat_resume),
.poweroff = pm_sleep_ptr(xhci_plat_suspend),
.restore = pm_sleep_ptr(xhci_plat_restore),

SET_RUNTIME_PM_OPS(xhci_plat_runtime_suspend,
xhci_plat_runtime_resume,
Expand Down

0 comments on commit 6d6887c

Please sign in to comment.