Skip to content

Commit f81dfa3

Browse files
matnymangregkh
authored andcommitted
xhci: Set quirky xHC PCI hosts to D3 _after_ stopping and freeing them.
PCI xHC host should be stopped and xhci driver memory freed before putting host to PCI D3 state during PCI remove callback. Hosts with XHCI_SPURIOUS_WAKEUP quirk did this the wrong way around and set the host to D3 before calling usb_hcd_pci_remove(dev), which will access the host to stop it, and then free xhci. Fixes: f1f6d9a ("xhci: don't dereference a xhci member after removing xhci") Cc: [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 da6a6dc commit f81dfa3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/usb/host/xhci-pci.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
657657
void xhci_pci_remove(struct pci_dev *dev)
658658
{
659659
struct xhci_hcd *xhci;
660+
bool set_power_d3;
660661

661662
xhci = hcd_to_xhci(pci_get_drvdata(dev));
663+
set_power_d3 = xhci->quirks & XHCI_SPURIOUS_WAKEUP;
662664

663665
xhci->xhc_state |= XHCI_STATE_REMOVING;
664666

@@ -671,11 +673,11 @@ void xhci_pci_remove(struct pci_dev *dev)
671673
xhci->shared_hcd = NULL;
672674
}
673675

676+
usb_hcd_pci_remove(dev);
677+
674678
/* Workaround for spurious wakeups at shutdown with HSW */
675-
if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
679+
if (set_power_d3)
676680
pci_set_power_state(dev, PCI_D3hot);
677-
678-
usb_hcd_pci_remove(dev);
679681
}
680682
EXPORT_SYMBOL_NS_GPL(xhci_pci_remove, xhci);
681683

0 commit comments

Comments
 (0)