aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host/xhci.c')
-rw-r--r--drivers/usb/host/xhci.c60
1 files changed, 25 insertions, 35 deletions
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 45e4a3108cc3..34cf4e165877 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -226,7 +226,8 @@ static int xhci_setup_msi(struct xhci_hcd *xhci)
226static int xhci_setup_msix(struct xhci_hcd *xhci) 226static int xhci_setup_msix(struct xhci_hcd *xhci)
227{ 227{
228 int i, ret = 0; 228 int i, ret = 0;
229 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 229 struct usb_hcd *hcd = xhci_to_hcd(xhci);
230 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
230 231
231 /* 232 /*
232 * calculate number of msi-x vectors supported. 233 * calculate number of msi-x vectors supported.
@@ -265,6 +266,7 @@ static int xhci_setup_msix(struct xhci_hcd *xhci)
265 goto disable_msix; 266 goto disable_msix;
266 } 267 }
267 268
269 hcd->msix_enabled = 1;
268 return ret; 270 return ret;
269 271
270disable_msix: 272disable_msix:
@@ -280,7 +282,8 @@ free_entries:
280/* Free any IRQs and disable MSI-X */ 282/* Free any IRQs and disable MSI-X */
281static void xhci_cleanup_msix(struct xhci_hcd *xhci) 283static void xhci_cleanup_msix(struct xhci_hcd *xhci)
282{ 284{
283 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 285 struct usb_hcd *hcd = xhci_to_hcd(xhci);
286 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
284 287
285 xhci_free_irq(xhci); 288 xhci_free_irq(xhci);
286 289
@@ -292,6 +295,7 @@ static void xhci_cleanup_msix(struct xhci_hcd *xhci)
292 pci_disable_msi(pdev); 295 pci_disable_msi(pdev);
293 } 296 }
294 297
298 hcd->msix_enabled = 0;
295 return; 299 return;
296} 300}
297 301
@@ -508,9 +512,10 @@ void xhci_stop(struct usb_hcd *hcd)
508 spin_lock_irq(&xhci->lock); 512 spin_lock_irq(&xhci->lock);
509 xhci_halt(xhci); 513 xhci_halt(xhci);
510 xhci_reset(xhci); 514 xhci_reset(xhci);
511 xhci_cleanup_msix(xhci);
512 spin_unlock_irq(&xhci->lock); 515 spin_unlock_irq(&xhci->lock);
513 516
517 xhci_cleanup_msix(xhci);
518
514#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING 519#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
515 /* Tell the event ring poll function not to reschedule */ 520 /* Tell the event ring poll function not to reschedule */
516 xhci->zombie = 1; 521 xhci->zombie = 1;
@@ -544,9 +549,10 @@ void xhci_shutdown(struct usb_hcd *hcd)
544 549
545 spin_lock_irq(&xhci->lock); 550 spin_lock_irq(&xhci->lock);
546 xhci_halt(xhci); 551 xhci_halt(xhci);
547 xhci_cleanup_msix(xhci);
548 spin_unlock_irq(&xhci->lock); 552 spin_unlock_irq(&xhci->lock);
549 553
554 xhci_cleanup_msix(xhci);
555
550 xhci_dbg(xhci, "xhci_shutdown completed - status = %x\n", 556 xhci_dbg(xhci, "xhci_shutdown completed - status = %x\n",
551 xhci_readl(xhci, &xhci->op_regs->status)); 557 xhci_readl(xhci, &xhci->op_regs->status));
552} 558}
@@ -647,6 +653,7 @@ int xhci_suspend(struct xhci_hcd *xhci)
647 int rc = 0; 653 int rc = 0;
648 struct usb_hcd *hcd = xhci_to_hcd(xhci); 654 struct usb_hcd *hcd = xhci_to_hcd(xhci);
649 u32 command; 655 u32 command;
656 int i;
650 657
651 spin_lock_irq(&xhci->lock); 658 spin_lock_irq(&xhci->lock);
652 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 659 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
@@ -677,10 +684,15 @@ int xhci_suspend(struct xhci_hcd *xhci)
677 spin_unlock_irq(&xhci->lock); 684 spin_unlock_irq(&xhci->lock);
678 return -ETIMEDOUT; 685 return -ETIMEDOUT;
679 } 686 }
680 /* step 5: remove core well power */
681 xhci_cleanup_msix(xhci);
682 spin_unlock_irq(&xhci->lock); 687 spin_unlock_irq(&xhci->lock);
683 688
689 /* step 5: remove core well power */
690 /* synchronize irq when using MSI-X */
691 if (xhci->msix_entries) {
692 for (i = 0; i < xhci->msix_count; i++)
693 synchronize_irq(xhci->msix_entries[i].vector);
694 }
695
684 return rc; 696 return rc;
685} 697}
686 698
@@ -694,7 +706,6 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
694{ 706{
695 u32 command, temp = 0; 707 u32 command, temp = 0;
696 struct usb_hcd *hcd = xhci_to_hcd(xhci); 708 struct usb_hcd *hcd = xhci_to_hcd(xhci);
697 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
698 int old_state, retval; 709 int old_state, retval;
699 710
700 old_state = hcd->state; 711 old_state = hcd->state;
@@ -729,9 +740,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
729 xhci_dbg(xhci, "Stop HCD\n"); 740 xhci_dbg(xhci, "Stop HCD\n");
730 xhci_halt(xhci); 741 xhci_halt(xhci);
731 xhci_reset(xhci); 742 xhci_reset(xhci);
732 if (hibernated)
733 xhci_cleanup_msix(xhci);
734 spin_unlock_irq(&xhci->lock); 743 spin_unlock_irq(&xhci->lock);
744 xhci_cleanup_msix(xhci);
735 745
736#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING 746#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
737 /* Tell the event ring poll function not to reschedule */ 747 /* Tell the event ring poll function not to reschedule */
@@ -765,30 +775,6 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
765 return retval; 775 return retval;
766 } 776 }
767 777
768 spin_unlock_irq(&xhci->lock);
769 /* Re-setup MSI-X */
770 if (hcd->irq)
771 free_irq(hcd->irq, hcd);
772 hcd->irq = -1;
773
774 retval = xhci_setup_msix(xhci);
775 if (retval)
776 /* fall back to msi*/
777 retval = xhci_setup_msi(xhci);
778
779 if (retval) {
780 /* fall back to legacy interrupt*/
781 retval = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED,
782 hcd->irq_descr, hcd);
783 if (retval) {
784 xhci_err(xhci, "request interrupt %d failed\n",
785 pdev->irq);
786 return retval;
787 }
788 hcd->irq = pdev->irq;
789 }
790
791 spin_lock_irq(&xhci->lock);
792 /* step 4: set Run/Stop bit */ 778 /* step 4: set Run/Stop bit */
793 command = xhci_readl(xhci, &xhci->op_regs->command); 779 command = xhci_readl(xhci, &xhci->op_regs->command);
794 command |= CMD_RUN; 780 command |= CMD_RUN;
@@ -2445,8 +2431,12 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
2445 xhci_err(xhci, "Error while assigning device slot ID\n"); 2431 xhci_err(xhci, "Error while assigning device slot ID\n");
2446 return 0; 2432 return 0;
2447 } 2433 }
2448 /* xhci_alloc_virt_device() does not touch rings; no need to lock */ 2434 /* xhci_alloc_virt_device() does not touch rings; no need to lock.
2449 if (!xhci_alloc_virt_device(xhci, xhci->slot_id, udev, GFP_KERNEL)) { 2435 * Use GFP_NOIO, since this function can be called from
2436 * xhci_discover_or_reset_device(), which may be called as part of
2437 * mass storage driver error handling.
2438 */
2439 if (!xhci_alloc_virt_device(xhci, xhci->slot_id, udev, GFP_NOIO)) {
2450 /* Disable slot, if we can do it without mem alloc */ 2440 /* Disable slot, if we can do it without mem alloc */
2451 xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n"); 2441 xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n");
2452 spin_lock_irqsave(&xhci->lock, flags); 2442 spin_lock_irqsave(&xhci->lock, flags);