diff options
-rw-r--r-- | drivers/usb/host/xhci-ring.c | 40 | ||||
-rw-r--r-- | drivers/usb/host/xhci.c | 65 |
2 files changed, 25 insertions, 80 deletions
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index fbd0342af286..06433aec81d7 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -1822,22 +1822,13 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1822 | ep->stopped_td = td; | 1822 | ep->stopped_td = td; |
1823 | return 0; | 1823 | return 0; |
1824 | } else { | 1824 | } else { |
1825 | if (trb_comp_code == COMP_STALL) { | 1825 | if (trb_comp_code == COMP_STALL || |
1826 | /* The transfer is completed from the driver's | 1826 | xhci_requires_manual_halt_cleanup(xhci, ep_ctx, |
1827 | * perspective, but we need to issue a set dequeue | 1827 | trb_comp_code)) { |
1828 | * command for this stalled endpoint to move the dequeue | 1828 | /* Issue a reset endpoint command to clear the host side |
1829 | * pointer past the TD. We can't do that here because | 1829 | * halt, followed by a set dequeue command to move the |
1830 | * the halt condition must be cleared first. Let the | 1830 | * dequeue pointer past the TD. |
1831 | * USB class driver clear the stall later. | 1831 | * The class driver clears the device side halt later. |
1832 | */ | ||
1833 | ep->stopped_td = td; | ||
1834 | ep->stopped_stream = ep_ring->stream_id; | ||
1835 | } else if (xhci_requires_manual_halt_cleanup(xhci, | ||
1836 | ep_ctx, trb_comp_code)) { | ||
1837 | /* Other types of errors halt the endpoint, but the | ||
1838 | * class driver doesn't call usb_reset_endpoint() unless | ||
1839 | * the error is -EPIPE. Clear the halted status in the | ||
1840 | * xHCI hardware manually. | ||
1841 | */ | 1832 | */ |
1842 | xhci_cleanup_halted_endpoint(xhci, | 1833 | xhci_cleanup_halted_endpoint(xhci, |
1843 | slot_id, ep_index, ep_ring->stream_id, | 1834 | slot_id, ep_index, ep_ring->stream_id, |
@@ -1957,9 +1948,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1957 | else | 1948 | else |
1958 | td->urb->actual_length = 0; | 1949 | td->urb->actual_length = 0; |
1959 | 1950 | ||
1960 | xhci_cleanup_halted_endpoint(xhci, | 1951 | return finish_td(xhci, td, event_trb, event, ep, status, false); |
1961 | slot_id, ep_index, 0, td, event_trb); | ||
1962 | return finish_td(xhci, td, event_trb, event, ep, status, true); | ||
1963 | } | 1952 | } |
1964 | /* | 1953 | /* |
1965 | * Did we transfer any data, despite the errors that might have | 1954 | * Did we transfer any data, despite the errors that might have |
@@ -2518,17 +2507,8 @@ cleanup: | |||
2518 | if (ret) { | 2507 | if (ret) { |
2519 | urb = td->urb; | 2508 | urb = td->urb; |
2520 | urb_priv = urb->hcpriv; | 2509 | urb_priv = urb->hcpriv; |
2521 | /* Leave the TD around for the reset endpoint function | 2510 | |
2522 | * to use(but only if it's not a control endpoint, | 2511 | xhci_urb_free_priv(xhci, urb_priv); |
2523 | * since we already queued the Set TR dequeue pointer | ||
2524 | * command for stalled control endpoints). | ||
2525 | */ | ||
2526 | if (usb_endpoint_xfer_control(&urb->ep->desc) || | ||
2527 | (trb_comp_code != COMP_STALL && | ||
2528 | trb_comp_code != COMP_BABBLE)) | ||
2529 | xhci_urb_free_priv(xhci, urb_priv); | ||
2530 | else | ||
2531 | kfree(urb_priv); | ||
2532 | 2512 | ||
2533 | usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb); | 2513 | usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb); |
2534 | if ((urb->actual_length != urb->transfer_buffer_length && | 2514 | if ((urb->actual_length != urb->transfer_buffer_length && |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 2a5d45b4cb15..4d0d2407b71c 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -2912,68 +2912,33 @@ void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, | |||
2912 | } | 2912 | } |
2913 | } | 2913 | } |
2914 | 2914 | ||
2915 | /* Deal with stalled endpoints. The core should have sent the control message | 2915 | /* Called when clearing halted device. The core should have sent the control |
2916 | * to clear the halt condition. However, we need to make the xHCI hardware | 2916 | * message to clear the device halt condition. The host side of the halt should |
2917 | * reset its sequence number, since a device will expect a sequence number of | 2917 | * already be cleared with a reset endpoint command issued when the STALL tx |
2918 | * zero after the halt condition is cleared. | 2918 | * event was received. |
2919 | * | ||
2919 | * Context: in_interrupt | 2920 | * Context: in_interrupt |
2920 | */ | 2921 | */ |
2922 | |||
2921 | void xhci_endpoint_reset(struct usb_hcd *hcd, | 2923 | void xhci_endpoint_reset(struct usb_hcd *hcd, |
2922 | struct usb_host_endpoint *ep) | 2924 | struct usb_host_endpoint *ep) |
2923 | { | 2925 | { |
2924 | struct xhci_hcd *xhci; | 2926 | struct xhci_hcd *xhci; |
2925 | struct usb_device *udev; | ||
2926 | unsigned int ep_index; | ||
2927 | unsigned long flags; | ||
2928 | int ret; | ||
2929 | struct xhci_virt_ep *virt_ep; | ||
2930 | struct xhci_command *command; | ||
2931 | 2927 | ||
2932 | xhci = hcd_to_xhci(hcd); | 2928 | xhci = hcd_to_xhci(hcd); |
2933 | udev = (struct usb_device *) ep->hcpriv; | ||
2934 | /* Called with a root hub endpoint (or an endpoint that wasn't added | ||
2935 | * with xhci_add_endpoint() | ||
2936 | */ | ||
2937 | if (!ep->hcpriv) | ||
2938 | return; | ||
2939 | ep_index = xhci_get_endpoint_index(&ep->desc); | ||
2940 | virt_ep = &xhci->devs[udev->slot_id]->eps[ep_index]; | ||
2941 | if (!virt_ep->stopped_td) { | ||
2942 | xhci_dbg_trace(xhci, trace_xhci_dbg_reset_ep, | ||
2943 | "Endpoint 0x%x not halted, refusing to reset.", | ||
2944 | ep->desc.bEndpointAddress); | ||
2945 | return; | ||
2946 | } | ||
2947 | if (usb_endpoint_xfer_control(&ep->desc)) { | ||
2948 | xhci_dbg_trace(xhci, trace_xhci_dbg_reset_ep, | ||
2949 | "Control endpoint stall already handled."); | ||
2950 | return; | ||
2951 | } | ||
2952 | |||
2953 | command = xhci_alloc_command(xhci, false, false, GFP_ATOMIC); | ||
2954 | if (!command) | ||
2955 | return; | ||
2956 | 2929 | ||
2957 | xhci_dbg_trace(xhci, trace_xhci_dbg_reset_ep, | ||
2958 | "Queueing reset endpoint command"); | ||
2959 | spin_lock_irqsave(&xhci->lock, flags); | ||
2960 | ret = xhci_queue_reset_ep(xhci, command, udev->slot_id, ep_index); | ||
2961 | /* | 2930 | /* |
2962 | * Can't change the ring dequeue pointer until it's transitioned to the | 2931 | * We might need to implement the config ep cmd in xhci 4.8.1 note: |
2963 | * stopped state, which is only upon a successful reset endpoint | 2932 | * The Reset Endpoint Command may only be issued to endpoints in the |
2964 | * command. Better hope that last command worked! | 2933 | * Halted state. If software wishes reset the Data Toggle or Sequence |
2934 | * Number of an endpoint that isn't in the Halted state, then software | ||
2935 | * may issue a Configure Endpoint Command with the Drop and Add bits set | ||
2936 | * for the target endpoint. that is in the Stopped state. | ||
2965 | */ | 2937 | */ |
2966 | if (!ret) { | ||
2967 | xhci_cleanup_stalled_ring(xhci, udev, ep_index); | ||
2968 | kfree(virt_ep->stopped_td); | ||
2969 | xhci_ring_cmd_db(xhci); | ||
2970 | } | ||
2971 | virt_ep->stopped_td = NULL; | ||
2972 | virt_ep->stopped_stream = 0; | ||
2973 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
2974 | 2938 | ||
2975 | if (ret) | 2939 | /* For now just print debug to follow the situation */ |
2976 | xhci_warn(xhci, "FIXME allocate a new ring segment\n"); | 2940 | xhci_dbg(xhci, "Endpoint 0x%x ep reset callback called\n", |
2941 | ep->desc.bEndpointAddress); | ||
2977 | } | 2942 | } |
2978 | 2943 | ||
2979 | static int xhci_check_streams_endpoint(struct xhci_hcd *xhci, | 2944 | static int xhci_check_streams_endpoint(struct xhci_hcd *xhci, |