On Tue, 23 Jul 2013, Mathias Nyman wrote:

> Make the Linux xHCI driver automatically try to switchover the EHCI ports to
> xHCI when an Intel xHCI host is detected, and it also finds an Intel EHCI 
> host.
> 
> This means we will no longer have to add Intel xHCI hosts to a quirks list 
> when
> the PCI device IDs change.  Simply continuing to add new Intel xHCI PCI device
> IDs to the quirks list is not sustainable.
> 
> During suspend ports may be swicthed back to EHCI by BIOS and not properly
> restored to xHCI at resume. Previously both EHCI and xHCI resume functions
> switched ports back to XHCI, but it's enough to do it in xHCI only
> because the hub driver doesn't start running again until after both hosts are 
> resumed.
> 
> Signed-off-by: Mathias Nyman <[email protected]>

> -void usb_enable_xhci_ports(struct pci_dev *xhci_pdev)
> +void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
>  {
>       u32             ports_available;
> +     bool            ehci_found = false;
> +     struct pci_dev  *companion = NULL;
> +
> +     /* make sure an intel EHCI controller exists */
> +     for_each_pci_dev(companion) {
> +             if (companion->class == PCI_CLASS_SERIAL_USB_EHCI &&
> +                 companion->vendor == PCI_VENDOR_ID_INTEL) {
> +                     ehci_found = true;
> +                     break;
> +             }
> +     }
> +
> +     if (!ehci_found)
> +             return;
>  
>       /* Don't switchover the ports if the user hasn't compiled the xHCI
>        * driver.  Otherwise they will see "dead" USB ports that don't power

> --- a/drivers/usb/host/xhci-pci.c
> +++ b/drivers/usb/host/xhci-pci.c
> @@ -250,13 +250,15 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool 
> hibernated)
>        * writers.
>        *
>        * Unconditionally switch the ports back to xHCI after a system resume.
> -      * We can't tell whether the EHCI or xHCI controller will be resumed
> -      * first, so we have to do the port switchover in both drivers.  Writing
> -      * a '1' to the port switchover registers should have no effect if the
> -      * port was already switched over.
> +      * It should not matter whether the EHCI or xHCI controller is
> +      * resumed first. It's enough to do the switchover in xHCI because
> +      * USB core won't notice anything as the hub driver doesn't start
> +      * running again until after all the devices (including both EHCI and
> +      * xHCI host controllers) have been resumed.
>        */
> -     if (usb_is_intel_switchable_xhci(pdev))
> -             usb_enable_xhci_ports(pdev);
> +
> +     if (pdev->vendor == PCI_VENDOR_ID_INTEL)
> +             usb_enable_intel_xhci_ports(pdev);

Short and sweet; I like it!

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to