mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-11 12:44:49 -04:00
xhci: disable U3 suspended ports in S4 hibernate poweroff_late stage
Disable U3 suspended ports in hibernate S4 poweroff_late for systems with XHCI_RESET_TO_DEFAULT quirk, if wakeup is not enabled. This reduces the number of self-powered usb devices from surviving in U3 suspended state into next reboot. Bootloader/firmware on these systems can't handle usb ports in U3, and will timeout, causing extra delay during reboot/restore from S4. Add pci_poweroff_late() callback to struct usb_hcd to get this done at the correct stage in hibernate. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20221130091944.2171610-5-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
705c333a7a
commit
c3bbacd61b
@@ -622,6 +622,57 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int xhci_pci_poweroff_late(struct usb_hcd *hcd, bool do_wakeup)
|
||||
{
|
||||
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
|
||||
struct xhci_port *port;
|
||||
struct usb_device *udev;
|
||||
unsigned int slot_id;
|
||||
u32 portsc;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Systems with XHCI_RESET_TO_DEFAULT quirk have boot firmware that
|
||||
* cause significant boot delay if usb ports are in suspended U3 state
|
||||
* during boot. Some USB devices survive in U3 state over S4 hibernate
|
||||
*
|
||||
* Disable ports that are in U3 if remote wake is not enabled for either
|
||||
* host controller or connected device
|
||||
*/
|
||||
|
||||
if (!(xhci->quirks & XHCI_RESET_TO_DEFAULT))
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) {
|
||||
port = &xhci->hw_ports[i];
|
||||
portsc = readl(port->addr);
|
||||
|
||||
if ((portsc & PORT_PLS_MASK) != XDEV_U3)
|
||||
continue;
|
||||
|
||||
slot_id = xhci_find_slot_id_by_port(port->rhub->hcd, xhci,
|
||||
port->hcd_portnum + 1);
|
||||
if (!slot_id || !xhci->devs[slot_id]) {
|
||||
xhci_err(xhci, "No dev for slot_id %d for port %d-%d in U3\n",
|
||||
slot_id, port->rhub->hcd->self.busnum, port->hcd_portnum + 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
udev = xhci->devs[slot_id]->udev;
|
||||
|
||||
/* if wakeup is enabled then don't disable the port */
|
||||
if (udev->do_remote_wakeup && do_wakeup)
|
||||
continue;
|
||||
|
||||
xhci_dbg(xhci, "port %d-%d in U3 without wakeup, disable it\n",
|
||||
port->rhub->hcd->self.busnum, port->hcd_portnum + 1);
|
||||
portsc = xhci_port_state_to_neutral(portsc);
|
||||
writel(portsc | PORT_PE, port->addr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void xhci_pci_shutdown(struct usb_hcd *hcd)
|
||||
{
|
||||
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
|
||||
@@ -689,6 +740,7 @@ static int __init xhci_pci_init(void)
|
||||
#ifdef CONFIG_PM
|
||||
xhci_pci_hc_driver.pci_suspend = xhci_pci_suspend;
|
||||
xhci_pci_hc_driver.pci_resume = xhci_pci_resume;
|
||||
xhci_pci_hc_driver.pci_poweroff_late = xhci_pci_poweroff_late;
|
||||
xhci_pci_hc_driver.shutdown = xhci_pci_shutdown;
|
||||
#endif
|
||||
return pci_register_driver(&xhci_pci_driver);
|
||||
|
||||
Reference in New Issue
Block a user