Hello.

On 02/22/2015 12:56 AM, Aleksander Morgado wrote:

When a control transfer has a short data stage, the xHCI controller generates
two transfer events: a COMP_SHORT_TX event that specifies the untransferred
amount, and a COMP_SUCCESS event. But when the data stage is not short, only the
COMP_SUCCESS event occurs. Therefore, xhci-hcd must set urb->actual_length to
urb->transfer_buffer_length while processing the COMP_SUCCESS event, unless
urb->actual_length was set already by a previous COMP_SHORT_TX event.

The driver checks this by seeing whether urb->actual_length == 0, but this alone
is the wrong test, as it is entirely possible for a short transfer to have an
urb->actual_length = 0.

This patch changes the xhci driver to rely not only on the urb->actual_length,
but also on the ep_ring->last_td_was_short flag, which is set to true when a
COMP_SHORT_TX event is received.

This fixes a bug which affected the HSO plugin, which relies on URBs with
urb->actual_length == 0 to halt re-submitting the RX URB in the control
endpoint.

Signed-off-by: Aleksander Morgado <[email protected]>
---
  drivers/usb/host/xhci-ring.c | 14 +++++++++-----
  1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 88da8d6..6b050f1 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
[...]
@@ -2484,6 +2480,14 @@ static int handle_tx_event(struct xhci_hcd *xhci,
                        ret = process_bulk_intr_td(xhci, td, event_trb, event,
                                                 ep, &status);

+               /* Flag whether the just processed TRB was short. Do it after
+                * processing, so that the processor methods can also use this
+                * flag. */

   The preferred multi-line comment style is this:

/*
 * bla
 * bla
 */

[...]

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to