aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci-hcd.c
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2009-07-27 15:03:15 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-07-28 17:31:11 -0400
commita1587d97ce3e53816c88b513a2038f6c5e5babd7 (patch)
tree3deb2b83974a9cfa61def8f8ab248cafbbb9809f /drivers/usb/host/xhci-hcd.c
parentf9dc68fe7ad390428c6bc5d7ff582cdb5d92fcb8 (diff)
USB: xhci: Deal with stalled endpoints.
When an endpoint on a device under an xHCI host controller stalls, the host controller driver must let the hardware know that the USB core has successfully cleared the halt condition. The HCD submits a Reset Endpoint Command, which will clear the toggle bit for USB 2.0 devices, and set the sequence number to zero for USB 3.0 devices. The xHCI urb_enqueue will accept new URBs while the endpoint is halted, and will queue them to the hardware rings. However, the endpoint doorbell will not be rung until the Reset Endpoint Command completes. Don't queue a reset endpoint command for root hubs. khubd clears halt conditions on the roothub during the initialization process, but the roothub isn't a real device, so the xHCI host controller doesn't need to know about the cleared halt. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/xhci-hcd.c')
-rw-r--r--drivers/usb/host/xhci-hcd.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c
index dba3e07ccd09..1c5901ad6eb8 100644
--- a/drivers/usb/host/xhci-hcd.c
+++ b/drivers/usb/host/xhci-hcd.c
@@ -787,8 +787,11 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
787 int ret = 0; 787 int ret = 0;
788 788
789 ret = xhci_check_args(hcd, udev, ep, 1, __func__); 789 ret = xhci_check_args(hcd, udev, ep, 1, __func__);
790 if (ret <= 0) 790 if (ret <= 0) {
791 /* So we won't queue a reset ep command for a root hub */
792 ep->hcpriv = NULL;
791 return ret; 793 return ret;
794 }
792 xhci = hcd_to_xhci(hcd); 795 xhci = hcd_to_xhci(hcd);
793 796
794 added_ctxs = xhci_get_endpoint_flag(&ep->desc); 797 added_ctxs = xhci_get_endpoint_flag(&ep->desc);
@@ -851,6 +854,9 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
851 } 854 }
852 new_slot_info = in_ctx->slot.dev_info; 855 new_slot_info = in_ctx->slot.dev_info;
853 856
857 /* Store the usb_device pointer for later use */
858 ep->hcpriv = udev;
859
854 xhci_dbg(xhci, "add ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x, new slot info = %#x\n", 860 xhci_dbg(xhci, "add ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x, new slot info = %#x\n",
855 (unsigned int) ep->desc.bEndpointAddress, 861 (unsigned int) ep->desc.bEndpointAddress,
856 udev->slot_id, 862 udev->slot_id,
@@ -1026,6 +1032,42 @@ void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
1026 xhci_zero_in_ctx(virt_dev); 1032 xhci_zero_in_ctx(virt_dev);
1027} 1033}
1028 1034
1035/* Deal with stalled endpoints. The core should have sent the control message
1036 * to clear the halt condition. However, we need to make the xHCI hardware
1037 * reset its sequence number, since a device will expect a sequence number of
1038 * zero after the halt condition is cleared.
1039 * Context: in_interrupt
1040 */
1041void xhci_endpoint_reset(struct usb_hcd *hcd,
1042 struct usb_host_endpoint *ep)
1043{
1044 struct xhci_hcd *xhci;
1045 struct usb_device *udev;
1046 unsigned int ep_index;
1047 unsigned long flags;
1048 int ret;
1049
1050 xhci = hcd_to_xhci(hcd);
1051 udev = (struct usb_device *) ep->hcpriv;
1052 /* Called with a root hub endpoint (or an endpoint that wasn't added
1053 * with xhci_add_endpoint()
1054 */
1055 if (!ep->hcpriv)
1056 return;
1057 ep_index = xhci_get_endpoint_index(&ep->desc);
1058
1059 xhci_dbg(xhci, "Queueing reset endpoint command\n");
1060 spin_lock_irqsave(&xhci->lock, flags);
1061 ret = xhci_queue_reset_ep(xhci, udev->slot_id, ep_index);
1062 if (!ret) {
1063 xhci_ring_cmd_db(xhci);
1064 }
1065 spin_unlock_irqrestore(&xhci->lock, flags);
1066
1067 if (ret)
1068 xhci_warn(xhci, "FIXME allocate a new ring segment\n");
1069}
1070
1029/* 1071/*
1030 * At this point, the struct usb_device is about to go away, the device has 1072 * At this point, the struct usb_device is about to go away, the device has
1031 * disconnected, and all traffic has been stopped and the endpoints have been 1073 * disconnected, and all traffic has been stopped and the endpoints have been