Loading drivers/usb/host/xhci-plat.c +26 −25 Original line number Diff line number Diff line Loading @@ -417,33 +417,21 @@ static int xhci_plat_remove(struct platform_device *dev) return 0; } static int __maybe_unused xhci_plat_suspend(struct device *dev) static int __maybe_unused xhci_plat_runtime_idle(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); /* * 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. * When pm_runtime_put_autosuspend() is called on this device, * after this idle callback returns the PM core will schedule the * autosuspend if there is any remaining time until expiry. However, * when reaching this point because the child_count becomes 0, the * core does not honor autosuspend in that case and results in * idle/suspend happening immediately. In order to have a delay * before suspend we have to call pm_runtime_autosuspend() manually. */ return xhci_suspend(xhci, device_may_wakeup(dev)); } static int __maybe_unused xhci_plat_resume(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); int ret; ret = xhci_priv_resume_quirk(hcd); if (ret) return ret; return xhci_resume(xhci, 0); pm_runtime_mark_last_busy(dev); pm_runtime_autosuspend(dev); return -EBUSY; } static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev) Loading @@ -458,12 +446,25 @@ static int __maybe_unused xhci_plat_runtime_resume(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); int ret; if (!xhci) return 0; dev_dbg(dev, "xhci-plat runtime resume\n"); return xhci_resume(xhci, 0); ret = xhci_priv_resume_quirk(hcd); if (ret) return ret; ret = xhci_resume(xhci, false); pm_runtime_mark_last_busy(dev); return ret; } static const struct dev_pm_ops xhci_plat_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(xhci_plat_suspend, xhci_plat_resume) SET_SYSTEM_SLEEP_PM_OPS(NULL, NULL) SET_RUNTIME_PM_OPS(xhci_plat_runtime_suspend, xhci_plat_runtime_resume, Loading Loading
drivers/usb/host/xhci-plat.c +26 −25 Original line number Diff line number Diff line Loading @@ -417,33 +417,21 @@ static int xhci_plat_remove(struct platform_device *dev) return 0; } static int __maybe_unused xhci_plat_suspend(struct device *dev) static int __maybe_unused xhci_plat_runtime_idle(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); /* * 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. * When pm_runtime_put_autosuspend() is called on this device, * after this idle callback returns the PM core will schedule the * autosuspend if there is any remaining time until expiry. However, * when reaching this point because the child_count becomes 0, the * core does not honor autosuspend in that case and results in * idle/suspend happening immediately. In order to have a delay * before suspend we have to call pm_runtime_autosuspend() manually. */ return xhci_suspend(xhci, device_may_wakeup(dev)); } static int __maybe_unused xhci_plat_resume(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); int ret; ret = xhci_priv_resume_quirk(hcd); if (ret) return ret; return xhci_resume(xhci, 0); pm_runtime_mark_last_busy(dev); pm_runtime_autosuspend(dev); return -EBUSY; } static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev) Loading @@ -458,12 +446,25 @@ static int __maybe_unused xhci_plat_runtime_resume(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); int ret; if (!xhci) return 0; dev_dbg(dev, "xhci-plat runtime resume\n"); return xhci_resume(xhci, 0); ret = xhci_priv_resume_quirk(hcd); if (ret) return ret; ret = xhci_resume(xhci, false); pm_runtime_mark_last_busy(dev); return ret; } static const struct dev_pm_ops xhci_plat_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(xhci_plat_suspend, xhci_plat_resume) SET_SYSTEM_SLEEP_PM_OPS(NULL, NULL) SET_RUNTIME_PM_OPS(xhci_plat_runtime_suspend, xhci_plat_runtime_resume, Loading