diff options
Diffstat (limited to 'drivers/usb/host/xhci-ring.c')
-rw-r--r-- | drivers/usb/host/xhci-ring.c | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 882875465301..1969c001b3f9 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -1599,14 +1599,20 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
1599 | max_ports = HCS_MAX_PORTS(xhci->hcs_params1); | 1599 | max_ports = HCS_MAX_PORTS(xhci->hcs_params1); |
1600 | if ((port_id <= 0) || (port_id > max_ports)) { | 1600 | if ((port_id <= 0) || (port_id > max_ports)) { |
1601 | xhci_warn(xhci, "Invalid port id %d\n", port_id); | 1601 | xhci_warn(xhci, "Invalid port id %d\n", port_id); |
1602 | bogus_port_status = true; | 1602 | inc_deq(xhci, xhci->event_ring); |
1603 | goto cleanup; | 1603 | return; |
1604 | } | 1604 | } |
1605 | 1605 | ||
1606 | /* Figure out which usb_hcd this port is attached to: | 1606 | /* Figure out which usb_hcd this port is attached to: |
1607 | * is it a USB 3.0 port or a USB 2.0/1.1 port? | 1607 | * is it a USB 3.0 port or a USB 2.0/1.1 port? |
1608 | */ | 1608 | */ |
1609 | major_revision = xhci->port_array[port_id - 1]; | 1609 | major_revision = xhci->port_array[port_id - 1]; |
1610 | |||
1611 | /* Find the right roothub. */ | ||
1612 | hcd = xhci_to_hcd(xhci); | ||
1613 | if ((major_revision == 0x03) != (hcd->speed == HCD_USB3)) | ||
1614 | hcd = xhci->shared_hcd; | ||
1615 | |||
1610 | if (major_revision == 0) { | 1616 | if (major_revision == 0) { |
1611 | xhci_warn(xhci, "Event for port %u not in " | 1617 | xhci_warn(xhci, "Event for port %u not in " |
1612 | "Extended Capabilities, ignoring.\n", | 1618 | "Extended Capabilities, ignoring.\n", |
@@ -1629,10 +1635,6 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
1629 | * into the index into the ports on the correct split roothub, and the | 1635 | * into the index into the ports on the correct split roothub, and the |
1630 | * correct bus_state structure. | 1636 | * correct bus_state structure. |
1631 | */ | 1637 | */ |
1632 | /* Find the right roothub. */ | ||
1633 | hcd = xhci_to_hcd(xhci); | ||
1634 | if ((major_revision == 0x03) != (hcd->speed == HCD_USB3)) | ||
1635 | hcd = xhci->shared_hcd; | ||
1636 | bus_state = &xhci->bus_state[hcd_index(hcd)]; | 1638 | bus_state = &xhci->bus_state[hcd_index(hcd)]; |
1637 | if (hcd->speed == HCD_USB3) | 1639 | if (hcd->speed == HCD_USB3) |
1638 | port_array = xhci->usb3_ports; | 1640 | port_array = xhci->usb3_ports; |
@@ -2027,8 +2029,8 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2027 | if (event_trb != ep_ring->dequeue && | 2029 | if (event_trb != ep_ring->dequeue && |
2028 | event_trb != td->last_trb) | 2030 | event_trb != td->last_trb) |
2029 | td->urb->actual_length = | 2031 | td->urb->actual_length = |
2030 | td->urb->transfer_buffer_length | 2032 | td->urb->transfer_buffer_length - |
2031 | - TRB_LEN(le32_to_cpu(event->transfer_len)); | 2033 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); |
2032 | else | 2034 | else |
2033 | td->urb->actual_length = 0; | 2035 | td->urb->actual_length = 0; |
2034 | 2036 | ||
@@ -2060,7 +2062,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2060 | /* Maybe the event was for the data stage? */ | 2062 | /* Maybe the event was for the data stage? */ |
2061 | td->urb->actual_length = | 2063 | td->urb->actual_length = |
2062 | td->urb->transfer_buffer_length - | 2064 | td->urb->transfer_buffer_length - |
2063 | TRB_LEN(le32_to_cpu(event->transfer_len)); | 2065 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); |
2064 | xhci_dbg(xhci, "Waiting for status " | 2066 | xhci_dbg(xhci, "Waiting for status " |
2065 | "stage event\n"); | 2067 | "stage event\n"); |
2066 | return 0; | 2068 | return 0; |
@@ -2096,7 +2098,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2096 | /* handle completion code */ | 2098 | /* handle completion code */ |
2097 | switch (trb_comp_code) { | 2099 | switch (trb_comp_code) { |
2098 | case COMP_SUCCESS: | 2100 | case COMP_SUCCESS: |
2099 | if (TRB_LEN(le32_to_cpu(event->transfer_len)) == 0) { | 2101 | if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) == 0) { |
2100 | frame->status = 0; | 2102 | frame->status = 0; |
2101 | break; | 2103 | break; |
2102 | } | 2104 | } |
@@ -2141,7 +2143,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2141 | len += TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])); | 2143 | len += TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])); |
2142 | } | 2144 | } |
2143 | len += TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) - | 2145 | len += TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) - |
2144 | TRB_LEN(le32_to_cpu(event->transfer_len)); | 2146 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); |
2145 | 2147 | ||
2146 | if (trb_comp_code != COMP_STOP_INVAL) { | 2148 | if (trb_comp_code != COMP_STOP_INVAL) { |
2147 | frame->actual_length = len; | 2149 | frame->actual_length = len; |
@@ -2199,7 +2201,7 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2199 | case COMP_SUCCESS: | 2201 | case COMP_SUCCESS: |
2200 | /* Double check that the HW transferred everything. */ | 2202 | /* Double check that the HW transferred everything. */ |
2201 | if (event_trb != td->last_trb || | 2203 | if (event_trb != td->last_trb || |
2202 | TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) { | 2204 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) { |
2203 | xhci_warn(xhci, "WARN Successful completion " | 2205 | xhci_warn(xhci, "WARN Successful completion " |
2204 | "on short TX\n"); | 2206 | "on short TX\n"); |
2205 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | 2207 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) |
@@ -2227,18 +2229,18 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2227 | "%d bytes untransferred\n", | 2229 | "%d bytes untransferred\n", |
2228 | td->urb->ep->desc.bEndpointAddress, | 2230 | td->urb->ep->desc.bEndpointAddress, |
2229 | td->urb->transfer_buffer_length, | 2231 | td->urb->transfer_buffer_length, |
2230 | TRB_LEN(le32_to_cpu(event->transfer_len))); | 2232 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len))); |
2231 | /* Fast path - was this the last TRB in the TD for this URB? */ | 2233 | /* Fast path - was this the last TRB in the TD for this URB? */ |
2232 | if (event_trb == td->last_trb) { | 2234 | if (event_trb == td->last_trb) { |
2233 | if (TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) { | 2235 | if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) { |
2234 | td->urb->actual_length = | 2236 | td->urb->actual_length = |
2235 | td->urb->transfer_buffer_length - | 2237 | td->urb->transfer_buffer_length - |
2236 | TRB_LEN(le32_to_cpu(event->transfer_len)); | 2238 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); |
2237 | if (td->urb->transfer_buffer_length < | 2239 | if (td->urb->transfer_buffer_length < |
2238 | td->urb->actual_length) { | 2240 | td->urb->actual_length) { |
2239 | xhci_warn(xhci, "HC gave bad length " | 2241 | xhci_warn(xhci, "HC gave bad length " |
2240 | "of %d bytes left\n", | 2242 | "of %d bytes left\n", |
2241 | TRB_LEN(le32_to_cpu(event->transfer_len))); | 2243 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len))); |
2242 | td->urb->actual_length = 0; | 2244 | td->urb->actual_length = 0; |
2243 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | 2245 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) |
2244 | *status = -EREMOTEIO; | 2246 | *status = -EREMOTEIO; |
@@ -2280,7 +2282,7 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2280 | if (trb_comp_code != COMP_STOP_INVAL) | 2282 | if (trb_comp_code != COMP_STOP_INVAL) |
2281 | td->urb->actual_length += | 2283 | td->urb->actual_length += |
2282 | TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) - | 2284 | TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) - |
2283 | TRB_LEN(le32_to_cpu(event->transfer_len)); | 2285 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); |
2284 | } | 2286 | } |
2285 | 2287 | ||
2286 | return finish_td(xhci, td, event_trb, event, ep, status, false); | 2288 | return finish_td(xhci, td, event_trb, event, ep, status, false); |
@@ -2368,7 +2370,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
2368 | * transfer type | 2370 | * transfer type |
2369 | */ | 2371 | */ |
2370 | case COMP_SUCCESS: | 2372 | case COMP_SUCCESS: |
2371 | if (TRB_LEN(le32_to_cpu(event->transfer_len)) == 0) | 2373 | if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) == 0) |
2372 | break; | 2374 | break; |
2373 | if (xhci->quirks & XHCI_TRUST_TX_LENGTH) | 2375 | if (xhci->quirks & XHCI_TRUST_TX_LENGTH) |
2374 | trb_comp_code = COMP_SHORT_TX; | 2376 | trb_comp_code = COMP_SHORT_TX; |
@@ -2461,14 +2463,21 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
2461 | * TD list. | 2463 | * TD list. |
2462 | */ | 2464 | */ |
2463 | if (list_empty(&ep_ring->td_list)) { | 2465 | if (list_empty(&ep_ring->td_list)) { |
2464 | xhci_warn(xhci, "WARN Event TRB for slot %d ep %d " | 2466 | /* |
2465 | "with no TDs queued?\n", | 2467 | * A stopped endpoint may generate an extra completion |
2466 | TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), | 2468 | * event if the device was suspended. Don't print |
2467 | ep_index); | 2469 | * warnings. |
2468 | xhci_dbg(xhci, "Event TRB with TRB type ID %u\n", | 2470 | */ |
2469 | (le32_to_cpu(event->flags) & | 2471 | if (!(trb_comp_code == COMP_STOP || |
2470 | TRB_TYPE_BITMASK)>>10); | 2472 | trb_comp_code == COMP_STOP_INVAL)) { |
2471 | xhci_print_trb_offsets(xhci, (union xhci_trb *) event); | 2473 | xhci_warn(xhci, "WARN Event TRB for slot %d ep %d with no TDs queued?\n", |
2474 | TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), | ||
2475 | ep_index); | ||
2476 | xhci_dbg(xhci, "Event TRB with TRB type ID %u\n", | ||
2477 | (le32_to_cpu(event->flags) & | ||
2478 | TRB_TYPE_BITMASK)>>10); | ||
2479 | xhci_print_trb_offsets(xhci, (union xhci_trb *) event); | ||
2480 | } | ||
2472 | if (ep->skip) { | 2481 | if (ep->skip) { |
2473 | ep->skip = false; | 2482 | ep->skip = false; |
2474 | xhci_dbg(xhci, "td_list is empty while skip " | 2483 | xhci_dbg(xhci, "td_list is empty while skip " |