summaryrefslogtreecommitdiff
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorMathias Nyman <mathias.nyman@linux.intel.com>2024-02-17 03:09:33 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-02-17 18:24:37 +0300
commitfbaf1889a30f8564f1450acec8e48f5b967fb184 (patch)
tree31a87f606d87e3e4de9ae0a85d9886abd8eb5cbb /drivers/usb/host
parent84ac5e4fa517f5d1da0054547a82ce905678dc08 (diff)
downloadlinux-fbaf1889a30f8564f1450acec8e48f5b967fb184.tar.xz
xhci: add helper that checks for unhandled events on a event ring
Add unhandled_event_trb() that returns true in case xHC hardware has written new event trbs to the event ring that driver has not yet handled. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com> Link: https://lore.kernel.org/r/20240217001017.29969-8-quic_wcheng@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/xhci-ring.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index ad008a5abc81..275164dc449d 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -113,6 +113,12 @@ static bool last_td_in_urb(struct xhci_td *td)
return urb_priv->num_tds_done == urb_priv->num_tds;
}
+static bool unhandled_event_trb(struct xhci_ring *ring)
+{
+ return ((le32_to_cpu(ring->dequeue->event_cmd.flags) & TRB_CYCLE) ==
+ ring->cycle_state);
+}
+
static void inc_td_cnt(struct urb *urb)
{
struct urb_priv *urb_priv = urb->hcpriv;
@@ -2973,9 +2979,8 @@ static int xhci_handle_event(struct xhci_hcd *xhci, struct xhci_interrupter *ir)
}
event = ir->event_ring->dequeue;
- /* Does the HC or OS own the TRB? */
- if ((le32_to_cpu(event->event_cmd.flags) & TRB_CYCLE) !=
- ir->event_ring->cycle_state)
+
+ if (!unhandled_event_trb(ir->event_ring))
return 0;
trace_xhci_handle_event(ir->event_ring, &event->generic);