Skip to content

Commit f2c710f

Browse files
Henry Lingregkh
authored andcommitted
usb: xhci: only set D3hot for pci device
Xhci driver cannot call pci_set_power_state() on non-pci xhci host controllers. For example, NVIDIA Tegra XHCI host controller which acts as platform device with XHCI_SPURIOUS_WAKEUP quirk set in some platform hits this issue during shutdown. Cc: <[email protected]> Fixes: 638298d ("xhci: Fix spurious wakeups after S5 on Haswell") Signed-off-by: Henry Lin <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 057d476 commit f2c710f

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

drivers/usb/host/xhci-pci.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,18 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
521521
}
522522
#endif /* CONFIG_PM */
523523

524+
static void xhci_pci_shutdown(struct usb_hcd *hcd)
525+
{
526+
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
527+
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
528+
529+
xhci_shutdown(hcd);
530+
531+
/* Yet another workaround for spurious wakeups at shutdown with HSW */
532+
if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
533+
pci_set_power_state(pdev, PCI_D3hot);
534+
}
535+
524536
/*-------------------------------------------------------------------------*/
525537

526538
/* PCI driver selection metadata; PCI hotplugging uses this */
@@ -556,6 +568,7 @@ static int __init xhci_pci_init(void)
556568
#ifdef CONFIG_PM
557569
xhci_pci_hc_driver.pci_suspend = xhci_pci_suspend;
558570
xhci_pci_hc_driver.pci_resume = xhci_pci_resume;
571+
xhci_pci_hc_driver.shutdown = xhci_pci_shutdown;
559572
#endif
560573
return pci_register_driver(&xhci_pci_driver);
561574
}

drivers/usb/host/xhci.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ static void xhci_stop(struct usb_hcd *hcd)
770770
*
771771
* This will only ever be called with the main usb_hcd (the USB3 roothub).
772772
*/
773-
static void xhci_shutdown(struct usb_hcd *hcd)
773+
void xhci_shutdown(struct usb_hcd *hcd)
774774
{
775775
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
776776

@@ -789,11 +789,8 @@ static void xhci_shutdown(struct usb_hcd *hcd)
789789
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
790790
"xhci_shutdown completed - status = %x",
791791
readl(&xhci->op_regs->status));
792-
793-
/* Yet another workaround for spurious wakeups at shutdown with HSW */
794-
if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
795-
pci_set_power_state(to_pci_dev(hcd->self.sysdev), PCI_D3hot);
796792
}
793+
EXPORT_SYMBOL_GPL(xhci_shutdown);
797794

798795
#ifdef CONFIG_PM
799796
static void xhci_save_registers(struct xhci_hcd *xhci)

drivers/usb/host/xhci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,6 +2050,7 @@ int xhci_start(struct xhci_hcd *xhci);
20502050
int xhci_reset(struct xhci_hcd *xhci);
20512051
int xhci_run(struct usb_hcd *hcd);
20522052
int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
2053+
void xhci_shutdown(struct usb_hcd *hcd);
20532054
void xhci_init_driver(struct hc_driver *drv,
20542055
const struct xhci_driver_overrides *over);
20552056
int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id);

0 commit comments

Comments
 (0)