Skip to content

Commit 2acd0c2

Browse files
Epicuriusgregkh
authored andcommitted
usb: xhci: move untargeted transfer event handling to a separate function
Move handling transfer events without a target transfer TRB into handle_transferless_tx_event(), this type of event does not utilize the rest of handle_tx_event() and as a result it's better to separate it into a dedicated function. Additionally, this change reduces handle_tx_event()'s size and makes it more readable. [Mathias: Simplify code to return helper function value directly. This removes the second xhci_err() message for untargeted and unexpected event completion types] Signed-off-by: Niklas Neronin <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bbdd82c commit 2acd0c2

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

drivers/usb/host/xhci-ring.c

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,6 +2562,33 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep,
25622562
return finish_td(xhci, ep, ep_ring, td, trb_comp_code);
25632563
}
25642564

2565+
/* Transfer events which don't point to a transfer TRB, see xhci 4.17.4 */
2566+
static int handle_transferless_tx_event(struct xhci_hcd *xhci, struct xhci_virt_ep *ep,
2567+
u32 trb_comp_code)
2568+
{
2569+
switch (trb_comp_code) {
2570+
case COMP_STALL_ERROR:
2571+
case COMP_USB_TRANSACTION_ERROR:
2572+
case COMP_INVALID_STREAM_TYPE_ERROR:
2573+
case COMP_INVALID_STREAM_ID_ERROR:
2574+
xhci_dbg(xhci, "Stream transaction error ep %u no id\n", ep->ep_index);
2575+
if (ep->err_count++ > MAX_SOFT_RETRY)
2576+
xhci_handle_halted_endpoint(xhci, ep, NULL, EP_HARD_RESET);
2577+
else
2578+
xhci_handle_halted_endpoint(xhci, ep, NULL, EP_SOFT_RESET);
2579+
break;
2580+
case COMP_RING_UNDERRUN:
2581+
case COMP_RING_OVERRUN:
2582+
case COMP_STOPPED_LENGTH_INVALID:
2583+
break;
2584+
default:
2585+
xhci_err(xhci, "ERROR Transfer event for unknown stream ring slot %u ep %u\n",
2586+
ep->vdev->slot_id, ep->ep_index);
2587+
return -ENODEV;
2588+
}
2589+
return 0;
2590+
}
2591+
25652592
/*
25662593
* If this function returns an error condition, it means it got a Transfer
25672594
* event with a corrupted Slot ID, Endpoint ID, or TRB DMA address.
@@ -2605,33 +2632,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
26052632
goto err_out;
26062633
}
26072634

2608-
/* Some transfer events don't always point to a trb, see xhci 4.17.4 */
2609-
if (!ep_ring) {
2610-
switch (trb_comp_code) {
2611-
case COMP_STALL_ERROR:
2612-
case COMP_USB_TRANSACTION_ERROR:
2613-
case COMP_INVALID_STREAM_TYPE_ERROR:
2614-
case COMP_INVALID_STREAM_ID_ERROR:
2615-
xhci_dbg(xhci, "Stream transaction error ep %u no id\n",
2616-
ep_index);
2617-
if (ep->err_count++ > MAX_SOFT_RETRY)
2618-
xhci_handle_halted_endpoint(xhci, ep, NULL,
2619-
EP_HARD_RESET);
2620-
else
2621-
xhci_handle_halted_endpoint(xhci, ep, NULL,
2622-
EP_SOFT_RESET);
2623-
break;
2624-
case COMP_RING_UNDERRUN:
2625-
case COMP_RING_OVERRUN:
2626-
case COMP_STOPPED_LENGTH_INVALID:
2627-
break;
2628-
default:
2629-
xhci_err(xhci, "ERROR Transfer event for unknown stream ring slot %u ep %u\n",
2630-
slot_id, ep_index);
2631-
goto err_out;
2632-
}
2633-
return 0;
2634-
}
2635+
if (!ep_ring)
2636+
return handle_transferless_tx_event(xhci, ep, trb_comp_code);
26352637

26362638
/* Count current td numbers if ep->skip is set */
26372639
if (ep->skip)

0 commit comments

Comments
 (0)