diff options
Diffstat (limited to 'drivers/usb/host/xhci.c')
-rw-r--r-- | drivers/usb/host/xhci.c | 123 |
1 files changed, 122 insertions, 1 deletions
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index c59d5b5b6c7d..6ece0ed288d4 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/moduleparam.h> | 27 | #include <linux/moduleparam.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/dmi.h> | ||
29 | 30 | ||
30 | #include "xhci.h" | 31 | #include "xhci.h" |
31 | 32 | ||
@@ -398,6 +399,95 @@ static void xhci_msix_sync_irqs(struct xhci_hcd *xhci) | |||
398 | 399 | ||
399 | #endif | 400 | #endif |
400 | 401 | ||
402 | static void compliance_mode_recovery(unsigned long arg) | ||
403 | { | ||
404 | struct xhci_hcd *xhci; | ||
405 | struct usb_hcd *hcd; | ||
406 | u32 temp; | ||
407 | int i; | ||
408 | |||
409 | xhci = (struct xhci_hcd *)arg; | ||
410 | |||
411 | for (i = 0; i < xhci->num_usb3_ports; i++) { | ||
412 | temp = xhci_readl(xhci, xhci->usb3_ports[i]); | ||
413 | if ((temp & PORT_PLS_MASK) == USB_SS_PORT_LS_COMP_MOD) { | ||
414 | /* | ||
415 | * Compliance Mode Detected. Letting USB Core | ||
416 | * handle the Warm Reset | ||
417 | */ | ||
418 | xhci_dbg(xhci, "Compliance Mode Detected->Port %d!\n", | ||
419 | i + 1); | ||
420 | xhci_dbg(xhci, "Attempting Recovery routine!\n"); | ||
421 | hcd = xhci->shared_hcd; | ||
422 | |||
423 | if (hcd->state == HC_STATE_SUSPENDED) | ||
424 | usb_hcd_resume_root_hub(hcd); | ||
425 | |||
426 | usb_hcd_poll_rh_status(hcd); | ||
427 | } | ||
428 | } | ||
429 | |||
430 | if (xhci->port_status_u0 != ((1 << xhci->num_usb3_ports)-1)) | ||
431 | mod_timer(&xhci->comp_mode_recovery_timer, | ||
432 | jiffies + msecs_to_jiffies(COMP_MODE_RCVRY_MSECS)); | ||
433 | } | ||
434 | |||
435 | /* | ||
436 | * Quirk to work around issue generated by the SN65LVPE502CP USB3.0 re-driver | ||
437 | * that causes ports behind that hardware to enter compliance mode sometimes. | ||
438 | * The quirk creates a timer that polls every 2 seconds the link state of | ||
439 | * each host controller's port and recovers it by issuing a Warm reset | ||
440 | * if Compliance mode is detected, otherwise the port will become "dead" (no | ||
441 | * device connections or disconnections will be detected anymore). Becasue no | ||
442 | * status event is generated when entering compliance mode (per xhci spec), | ||
443 | * this quirk is needed on systems that have the failing hardware installed. | ||
444 | */ | ||
445 | static void compliance_mode_recovery_timer_init(struct xhci_hcd *xhci) | ||
446 | { | ||
447 | xhci->port_status_u0 = 0; | ||
448 | init_timer(&xhci->comp_mode_recovery_timer); | ||
449 | |||
450 | xhci->comp_mode_recovery_timer.data = (unsigned long) xhci; | ||
451 | xhci->comp_mode_recovery_timer.function = compliance_mode_recovery; | ||
452 | xhci->comp_mode_recovery_timer.expires = jiffies + | ||
453 | msecs_to_jiffies(COMP_MODE_RCVRY_MSECS); | ||
454 | |||
455 | set_timer_slack(&xhci->comp_mode_recovery_timer, | ||
456 | msecs_to_jiffies(COMP_MODE_RCVRY_MSECS)); | ||
457 | add_timer(&xhci->comp_mode_recovery_timer); | ||
458 | xhci_dbg(xhci, "Compliance Mode Recovery Timer Initialized.\n"); | ||
459 | } | ||
460 | |||
461 | /* | ||
462 | * This function identifies the systems that have installed the SN65LVPE502CP | ||
463 | * USB3.0 re-driver and that need the Compliance Mode Quirk. | ||
464 | * Systems: | ||
465 | * Vendor: Hewlett-Packard -> System Models: Z420, Z620 and Z820 | ||
466 | */ | ||
467 | static bool compliance_mode_recovery_timer_quirk_check(void) | ||
468 | { | ||
469 | const char *dmi_product_name, *dmi_sys_vendor; | ||
470 | |||
471 | dmi_product_name = dmi_get_system_info(DMI_PRODUCT_NAME); | ||
472 | dmi_sys_vendor = dmi_get_system_info(DMI_SYS_VENDOR); | ||
473 | |||
474 | if (!(strstr(dmi_sys_vendor, "Hewlett-Packard"))) | ||
475 | return false; | ||
476 | |||
477 | if (strstr(dmi_product_name, "Z420") || | ||
478 | strstr(dmi_product_name, "Z620") || | ||
479 | strstr(dmi_product_name, "Z820")) | ||
480 | return true; | ||
481 | |||
482 | return false; | ||
483 | } | ||
484 | |||
485 | static int xhci_all_ports_seen_u0(struct xhci_hcd *xhci) | ||
486 | { | ||
487 | return (xhci->port_status_u0 == ((1 << xhci->num_usb3_ports)-1)); | ||
488 | } | ||
489 | |||
490 | |||
401 | /* | 491 | /* |
402 | * Initialize memory for HCD and xHC (one-time init). | 492 | * Initialize memory for HCD and xHC (one-time init). |
403 | * | 493 | * |
@@ -421,6 +511,12 @@ int xhci_init(struct usb_hcd *hcd) | |||
421 | retval = xhci_mem_init(xhci, GFP_KERNEL); | 511 | retval = xhci_mem_init(xhci, GFP_KERNEL); |
422 | xhci_dbg(xhci, "Finished xhci_init\n"); | 512 | xhci_dbg(xhci, "Finished xhci_init\n"); |
423 | 513 | ||
514 | /* Initializing Compliance Mode Recovery Data If Needed */ | ||
515 | if (compliance_mode_recovery_timer_quirk_check()) { | ||
516 | xhci->quirks |= XHCI_COMP_MODE_QUIRK; | ||
517 | compliance_mode_recovery_timer_init(xhci); | ||
518 | } | ||
519 | |||
424 | return retval; | 520 | return retval; |
425 | } | 521 | } |
426 | 522 | ||
@@ -629,6 +725,11 @@ void xhci_stop(struct usb_hcd *hcd) | |||
629 | del_timer_sync(&xhci->event_ring_timer); | 725 | del_timer_sync(&xhci->event_ring_timer); |
630 | #endif | 726 | #endif |
631 | 727 | ||
728 | /* Deleting Compliance Mode Recovery Timer */ | ||
729 | if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && | ||
730 | (!(xhci_all_ports_seen_u0(xhci)))) | ||
731 | del_timer_sync(&xhci->comp_mode_recovery_timer); | ||
732 | |||
632 | if (xhci->quirks & XHCI_AMD_PLL_FIX) | 733 | if (xhci->quirks & XHCI_AMD_PLL_FIX) |
633 | usb_amd_dev_put(); | 734 | usb_amd_dev_put(); |
634 | 735 | ||
@@ -659,7 +760,7 @@ void xhci_shutdown(struct usb_hcd *hcd) | |||
659 | { | 760 | { |
660 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | 761 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
661 | 762 | ||
662 | if (xhci->quirks && XHCI_SPURIOUS_REBOOT) | 763 | if (xhci->quirks & XHCI_SPURIOUS_REBOOT) |
663 | usb_disable_xhci_ports(to_pci_dev(hcd->self.controller)); | 764 | usb_disable_xhci_ports(to_pci_dev(hcd->self.controller)); |
664 | 765 | ||
665 | spin_lock_irq(&xhci->lock); | 766 | spin_lock_irq(&xhci->lock); |
@@ -806,6 +907,16 @@ int xhci_suspend(struct xhci_hcd *xhci) | |||
806 | } | 907 | } |
807 | spin_unlock_irq(&xhci->lock); | 908 | spin_unlock_irq(&xhci->lock); |
808 | 909 | ||
910 | /* | ||
911 | * Deleting Compliance Mode Recovery Timer because the xHCI Host | ||
912 | * is about to be suspended. | ||
913 | */ | ||
914 | if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && | ||
915 | (!(xhci_all_ports_seen_u0(xhci)))) { | ||
916 | del_timer_sync(&xhci->comp_mode_recovery_timer); | ||
917 | xhci_dbg(xhci, "Compliance Mode Recovery Timer Deleted!\n"); | ||
918 | } | ||
919 | |||
809 | /* step 5: remove core well power */ | 920 | /* step 5: remove core well power */ |
810 | /* synchronize irq when using MSI-X */ | 921 | /* synchronize irq when using MSI-X */ |
811 | xhci_msix_sync_irqs(xhci); | 922 | xhci_msix_sync_irqs(xhci); |
@@ -938,6 +1049,16 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) | |||
938 | usb_hcd_resume_root_hub(hcd); | 1049 | usb_hcd_resume_root_hub(hcd); |
939 | usb_hcd_resume_root_hub(xhci->shared_hcd); | 1050 | usb_hcd_resume_root_hub(xhci->shared_hcd); |
940 | } | 1051 | } |
1052 | |||
1053 | /* | ||
1054 | * If system is subject to the Quirk, Compliance Mode Timer needs to | ||
1055 | * be re-initialized Always after a system resume. Ports are subject | ||
1056 | * to suffer the Compliance Mode issue again. It doesn't matter if | ||
1057 | * ports have entered previously to U0 before system's suspension. | ||
1058 | */ | ||
1059 | if (xhci->quirks & XHCI_COMP_MODE_QUIRK) | ||
1060 | compliance_mode_recovery_timer_init(xhci); | ||
1061 | |||
941 | return retval; | 1062 | return retval; |
942 | } | 1063 | } |
943 | #endif /* CONFIG_PM */ | 1064 | #endif /* CONFIG_PM */ |