aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2009-11-11 13:28:44 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 14:55:23 -0500
commitbcef3fd57019e5fc0c8df402b040a52826422a4b (patch)
treeab98ded86bd3bcfc2f03629d421bcdfd8462c13a /drivers/usb
parent5ad6a529c28db36010ec56c5ee8120addc712b51 (diff)
USB: xhci: Handle errors that cause endpoint halts.
The xHCI 0.95 and 0.96 specification defines several transfer buffer request completion codes that indicate a USB transaction error occurred. When a stall, babble, transaction, or split transaction error completion code is set, the xHCI has halted that endpoint ring. Software must issue a Reset Endpoint command and a Set Transfer Ring Dequeue Pointer command to clean up the halted ring. The USB device driver is supposed to call into usb_reset_endpoint() when an endpoint stalls. That calls into the xHCI driver to issue the proper commands. However, drivers don't call that function for the other errors that cause the xHC to halt the endpoint ring. If a babble, transaction, or split transaction error occurs, check if the endpoint context reports a halted condition, and clean up the endpoint ring if it does. 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')
-rw-r--r--drivers/usb/host/xhci-ring.c79
1 files changed, 60 insertions, 19 deletions
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 1549b9ceb91a..2e346334a363 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1037,6 +1037,45 @@ struct xhci_segment *trb_in_td(struct xhci_segment *start_seg,
1037 return 0; 1037 return 0;
1038} 1038}
1039 1039
1040static void xhci_cleanup_halted_endpoint(struct xhci_hcd *xhci,
1041 unsigned int slot_id, unsigned int ep_index,
1042 struct xhci_td *td, union xhci_trb *event_trb)
1043{
1044 struct xhci_virt_ep *ep = &xhci->devs[slot_id]->eps[ep_index];
1045 ep->ep_state |= EP_HALTED;
1046 ep->stopped_td = td;
1047 ep->stopped_trb = event_trb;
1048 xhci_queue_reset_ep(xhci, slot_id, ep_index);
1049 xhci_cleanup_stalled_ring(xhci, td->urb->dev, ep_index);
1050 xhci_ring_cmd_db(xhci);
1051}
1052
1053/* Check if an error has halted the endpoint ring. The class driver will
1054 * cleanup the halt for a non-default control endpoint if we indicate a stall.
1055 * However, a babble and other errors also halt the endpoint ring, and the class
1056 * driver won't clear the halt in that case, so we need to issue a Set Transfer
1057 * Ring Dequeue Pointer command manually.
1058 */
1059static int xhci_requires_manual_halt_cleanup(struct xhci_hcd *xhci,
1060 struct xhci_ep_ctx *ep_ctx,
1061 unsigned int trb_comp_code)
1062{
1063 /* TRB completion codes that may require a manual halt cleanup */
1064 if (trb_comp_code == COMP_TX_ERR ||
1065 trb_comp_code == COMP_BABBLE ||
1066 trb_comp_code == COMP_SPLIT_ERR)
1067 /* The 0.96 spec says a babbling control endpoint
1068 * is not halted. The 0.96 spec says it is. Some HW
1069 * claims to be 0.95 compliant, but it halts the control
1070 * endpoint anyway. Check if a babble halted the
1071 * endpoint.
1072 */
1073 if ((ep_ctx->ep_info & EP_STATE_MASK) == EP_STATE_HALTED)
1074 return 1;
1075
1076 return 0;
1077}
1078
1040/* 1079/*
1041 * If this function returns an error condition, it means it got a Transfer 1080 * If this function returns an error condition, it means it got a Transfer
1042 * event with a corrupted Slot ID, Endpoint ID, or TRB DMA address. 1081 * event with a corrupted Slot ID, Endpoint ID, or TRB DMA address.
@@ -1191,15 +1230,14 @@ static int handle_tx_event(struct xhci_hcd *xhci,
1191 else 1230 else
1192 status = 0; 1231 status = 0;
1193 break; 1232 break;
1194 case COMP_BABBLE: 1233
1195 /* The 0.96 spec says a babbling control endpoint 1234 default:
1196 * is not halted. The 0.96 spec says it is. Some HW 1235 if (!xhci_requires_manual_halt_cleanup(xhci,
1197 * claims to be 0.95 compliant, but it halts the control 1236 ep_ctx, trb_comp_code))
1198 * endpoint anyway. Check if a babble halted the
1199 * endpoint.
1200 */
1201 if (ep_ctx->ep_info != EP_STATE_HALTED)
1202 break; 1237 break;
1238 xhci_dbg(xhci, "TRB error code %u, "
1239 "halted endpoint index = %u\n",
1240 trb_comp_code, ep_index);
1203 /* else fall through */ 1241 /* else fall through */
1204 case COMP_STALL: 1242 case COMP_STALL:
1205 /* Did we transfer part of the data (middle) phase? */ 1243 /* Did we transfer part of the data (middle) phase? */
@@ -1211,15 +1249,9 @@ static int handle_tx_event(struct xhci_hcd *xhci,
1211 else 1249 else
1212 td->urb->actual_length = 0; 1250 td->urb->actual_length = 0;
1213 1251
1214 ep->stopped_td = td; 1252 xhci_cleanup_halted_endpoint(xhci,
1215 ep->stopped_trb = event_trb; 1253 slot_id, ep_index, td, event_trb);
1216 xhci_queue_reset_ep(xhci, slot_id, ep_index);
1217 xhci_cleanup_stalled_ring(xhci, td->urb->dev, ep_index);
1218 xhci_ring_cmd_db(xhci);
1219 goto td_cleanup; 1254 goto td_cleanup;
1220 default:
1221 /* Others already handled above */
1222 break;
1223 } 1255 }
1224 /* 1256 /*
1225 * Did we transfer any data, despite the errors that might have 1257 * Did we transfer any data, despite the errors that might have
@@ -1357,16 +1389,25 @@ static int handle_tx_event(struct xhci_hcd *xhci,
1357 ep->stopped_td = td; 1389 ep->stopped_td = td;
1358 ep->stopped_trb = event_trb; 1390 ep->stopped_trb = event_trb;
1359 } else { 1391 } else {
1360 if (trb_comp_code == COMP_STALL || 1392 if (trb_comp_code == COMP_STALL) {
1361 trb_comp_code == COMP_BABBLE) {
1362 /* The transfer is completed from the driver's 1393 /* The transfer is completed from the driver's
1363 * perspective, but we need to issue a set dequeue 1394 * perspective, but we need to issue a set dequeue
1364 * command for this stalled endpoint to move the dequeue 1395 * command for this stalled endpoint to move the dequeue
1365 * pointer past the TD. We can't do that here because 1396 * pointer past the TD. We can't do that here because
1366 * the halt condition must be cleared first. 1397 * the halt condition must be cleared first. Let the
1398 * USB class driver clear the stall later.
1367 */ 1399 */
1368 ep->stopped_td = td; 1400 ep->stopped_td = td;
1369 ep->stopped_trb = event_trb; 1401 ep->stopped_trb = event_trb;
1402 } else if (xhci_requires_manual_halt_cleanup(xhci,
1403 ep_ctx, trb_comp_code)) {
1404 /* Other types of errors halt the endpoint, but the
1405 * class driver doesn't call usb_reset_endpoint() unless
1406 * the error is -EPIPE. Clear the halted status in the
1407 * xHCI hardware manually.
1408 */
1409 xhci_cleanup_halted_endpoint(xhci,
1410 slot_id, ep_index, td, event_trb);
1370 } else { 1411 } else {
1371 /* Update ring dequeue pointer */ 1412 /* Update ring dequeue pointer */
1372 while (ep_ring->dequeue != td->last_trb) 1413 while (ep_ring->dequeue != td->last_trb)