[PATCH 2/3] xhci: Set URB actual length for stopped control transfers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A control transfer that stopped at the status stage incorrectly
warned about a "unexpected TRB Type 4", and did not set the
tranferred actual_length for the URB.

The tranferred actual_length should be set the same way for
COMP_STOPPED control tranfers as in the generic cases.

generic case if we get an event at:

TRB_SETUP stage:
  length = 0;

TRB_DATA/TRB_NORMAL state:
  length = requested - remaining;

TRB_STATUS stage:
  length = requested

The URB actual_length for control transfers doesn't care about sent
bytes of the SETUP stage, or remaining bytes of the  STATUS stage.

Cc: <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx>
---
 drivers/usb/host/xhci-ring.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index d9936c7..0aca4c9 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1961,6 +1961,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
 	requested = td->urb->transfer_buffer_length;
 	remaining = EVENT_TRB_LEN(le32_to_cpu(event->transfer_len));
 
+
 	switch (trb_comp_code) {
 	case COMP_SUCCESS:
 		if (trb_type != TRB_STATUS) {
@@ -1975,25 +1976,15 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
 		*status = 0;
 		break;
 	case COMP_STOPPED_SHORT_PACKET:
-		if (trb_type == TRB_DATA || trb_type == TRB_NORMAL)
+		if (trb_type == TRB_DATA || trb_type == TRB_NORMAL) {
+			td->urb_length_set = true;
 			td->urb->actual_length = remaining;
-		else
+		} else {
 			xhci_warn(xhci, "WARN: Stopped Short Packet on ctrl setup or status TRB\n");
+		}
 		goto finish_td;
 	case COMP_STOPPED:
-		switch (trb_type) {
-		case TRB_SETUP:
-			td->urb->actual_length = 0;
-			goto finish_td;
-		case TRB_DATA:
-		case TRB_NORMAL:
-			td->urb->actual_length = requested - remaining;
-			goto finish_td;
-		default:
-			xhci_warn(xhci, "WARN: unexpected TRB Type %d\n",
-				  trb_type);
-			goto finish_td;
-		}
+		break;
 	case COMP_STOPPED_LENGTH_INVALID:
 		goto finish_td;
 	default:
-- 
1.9.1

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



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux