diff options
Diffstat (limited to 'drivers/usb/host/xhci.c')
| -rw-r--r-- | drivers/usb/host/xhci.c | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 8d45bbde3da..4549068758f 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
| @@ -375,6 +375,21 @@ void xhci_event_ring_work(unsigned long arg) | |||
| 375 | } | 375 | } |
| 376 | #endif | 376 | #endif |
| 377 | 377 | ||
| 378 | static int xhci_run_finished(struct xhci_hcd *xhci) | ||
| 379 | { | ||
| 380 | if (xhci_start(xhci)) { | ||
| 381 | xhci_halt(xhci); | ||
| 382 | return -ENODEV; | ||
| 383 | } | ||
| 384 | xhci->shared_hcd->state = HC_STATE_RUNNING; | ||
| 385 | |||
| 386 | if (xhci->quirks & XHCI_NEC_HOST) | ||
| 387 | xhci_ring_cmd_db(xhci); | ||
| 388 | |||
| 389 | xhci_dbg(xhci, "Finished xhci_run for USB3 roothub\n"); | ||
| 390 | return 0; | ||
| 391 | } | ||
| 392 | |||
| 378 | /* | 393 | /* |
| 379 | * Start the HC after it was halted. | 394 | * Start the HC after it was halted. |
| 380 | * | 395 | * |
| @@ -395,7 +410,13 @@ int xhci_run(struct usb_hcd *hcd) | |||
| 395 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | 410 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
| 396 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); | 411 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); |
| 397 | 412 | ||
| 413 | /* Start the xHCI host controller running only after the USB 2.0 roothub | ||
| 414 | * is setup. | ||
| 415 | */ | ||
| 416 | |||
| 398 | hcd->uses_new_polling = 1; | 417 | hcd->uses_new_polling = 1; |
| 418 | if (!usb_hcd_is_primary_hcd(hcd)) | ||
| 419 | return xhci_run_finished(xhci); | ||
| 399 | 420 | ||
| 400 | xhci_dbg(xhci, "xhci_run\n"); | 421 | xhci_dbg(xhci, "xhci_run\n"); |
| 401 | /* unregister the legacy interrupt */ | 422 | /* unregister the legacy interrupt */ |
| @@ -469,16 +490,23 @@ int xhci_run(struct usb_hcd *hcd) | |||
| 469 | xhci_queue_vendor_command(xhci, 0, 0, 0, | 490 | xhci_queue_vendor_command(xhci, 0, 0, 0, |
| 470 | TRB_TYPE(TRB_NEC_GET_FW)); | 491 | TRB_TYPE(TRB_NEC_GET_FW)); |
| 471 | 492 | ||
| 472 | if (xhci_start(xhci)) { | 493 | xhci_dbg(xhci, "Finished xhci_run for USB2 roothub\n"); |
| 473 | xhci_halt(xhci); | 494 | return 0; |
| 474 | return -ENODEV; | 495 | } |
| 475 | } | ||
| 476 | 496 | ||
| 477 | if (xhci->quirks & XHCI_NEC_HOST) | 497 | static void xhci_only_stop_hcd(struct usb_hcd *hcd) |
| 478 | xhci_ring_cmd_db(xhci); | 498 | { |
| 499 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | ||
| 479 | 500 | ||
| 480 | xhci_dbg(xhci, "Finished xhci_run\n"); | 501 | spin_lock_irq(&xhci->lock); |
| 481 | return 0; | 502 | xhci_halt(xhci); |
| 503 | |||
| 504 | /* The shared_hcd is going to be deallocated shortly (the USB core only | ||
| 505 | * calls this function when allocation fails in usb_add_hcd(), or | ||
| 506 | * usb_remove_hcd() is called). So we need to unset xHCI's pointer. | ||
| 507 | */ | ||
| 508 | xhci->shared_hcd = NULL; | ||
| 509 | spin_unlock_irq(&xhci->lock); | ||
| 482 | } | 510 | } |
| 483 | 511 | ||
| 484 | /* | 512 | /* |
| @@ -495,7 +523,15 @@ void xhci_stop(struct usb_hcd *hcd) | |||
| 495 | u32 temp; | 523 | u32 temp; |
| 496 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | 524 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
| 497 | 525 | ||
| 526 | if (!usb_hcd_is_primary_hcd(hcd)) { | ||
| 527 | xhci_only_stop_hcd(xhci->shared_hcd); | ||
| 528 | return; | ||
| 529 | } | ||
| 530 | |||
| 498 | spin_lock_irq(&xhci->lock); | 531 | spin_lock_irq(&xhci->lock); |
| 532 | /* Make sure the xHC is halted for a USB3 roothub | ||
| 533 | * (xhci_stop() could be called as part of failed init). | ||
| 534 | */ | ||
| 499 | xhci_halt(xhci); | 535 | xhci_halt(xhci); |
| 500 | xhci_reset(xhci); | 536 | xhci_reset(xhci); |
| 501 | spin_unlock_irq(&xhci->lock); | 537 | spin_unlock_irq(&xhci->lock); |
| @@ -528,6 +564,8 @@ void xhci_stop(struct usb_hcd *hcd) | |||
| 528 | * This is called when the machine is rebooting or halting. We assume that the | 564 | * This is called when the machine is rebooting or halting. We assume that the |
| 529 | * machine will be powered off, and the HC's internal state will be reset. | 565 | * machine will be powered off, and the HC's internal state will be reset. |
| 530 | * Don't bother to free memory. | 566 | * Don't bother to free memory. |
| 567 | * | ||
| 568 | * This will only ever be called with the main usb_hcd (the USB3 roothub). | ||
| 531 | */ | 569 | */ |
| 532 | void xhci_shutdown(struct usb_hcd *hcd) | 570 | void xhci_shutdown(struct usb_hcd *hcd) |
| 533 | { | 571 | { |
| @@ -694,10 +732,12 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) | |||
| 694 | struct usb_hcd *hcd = xhci_to_hcd(xhci); | 732 | struct usb_hcd *hcd = xhci_to_hcd(xhci); |
| 695 | int retval; | 733 | int retval; |
| 696 | 734 | ||
| 697 | /* Wait a bit if the bus needs to settle from the transistion to | 735 | /* Wait a bit if either of the roothubs need to settle from the |
| 698 | * suspend. | 736 | * transistion into bus suspend. |
| 699 | */ | 737 | */ |
| 700 | if (time_before(jiffies, xhci->bus_state[0].next_statechange)) | 738 | if (time_before(jiffies, xhci->bus_state[0].next_statechange) || |
| 739 | time_before(jiffies, | ||
| 740 | xhci->bus_state[1].next_statechange)) | ||
| 701 | msleep(100); | 741 | msleep(100); |
| 702 | 742 | ||
| 703 | spin_lock_irq(&xhci->lock); | 743 | spin_lock_irq(&xhci->lock); |
