Thread (61 messages) 61 messages, 2 authors, 2024-02-14

[PATCH v15 08/50] xhci: Don't check if the event ring is valid before every event TRB

flat view
STALE985d SUPERSEDED

From: Wesley Cheng <hidden>
Date: 2024-02-13 00:54:57
Also in: alsa-devel, linux-arm-msm, linux-doc, linux-sound, linux-usb, lkml
Subsystem: the rest, usb subsystem, usb xhci driver · Maintainers: Linus Torvalds, Greg Kroah-Hartman, Mathias Nyman

Status: Superseded by v38 (posted 2025-04-09). [go to v38]

Revision v15 (38 revisions archived).

Revisions (38)
  1. rfc
  2. v2 [diff against previous]
  3. v3 [diff against previous]
  4. v4 [diff against previous]
  5. v5 [diff against previous]
  6. v6 [diff against previous]
  7. v7 [diff against previous]
  8. v8 [diff against previous]
  9. v9 [diff against previous]
  10. v10 [diff against previous]
  11. v11 [diff against previous]
  12. v12 [diff against previous]
  13. v13 [diff against previous]
  14. v14 [diff against previous]
  15. v15 current [diff against previous]
  16. v16 [diff against previous]
  17. v17 [diff against previous]
  18. v18 [diff against previous]
  19. v19 [diff against previous]
  20. v20 [diff against previous]
  21. v21 [diff against previous]
  22. v22 [diff against previous]
  23. v23 [diff against previous]
  24. v24 [diff against previous]
  25. v25 [diff against previous]
  26. v26 [diff against previous]
  27. v27 [diff against previous]
  28. v28 [diff against previous] re-posted go to this post re-posted go to this post
  29. v29 [diff against previous]
  30. v30 [diff against previous]
  31. v31 [diff against previous]
  32. v32 [diff against previous]
  33. v33 [diff against previous]
  34. v34 [diff against previous]
  35. v35 [diff against previous]
  36. v36 [diff against previous]
  37. v37 [diff against previous]
  38. v38 [diff against previous]
From: Mathias Nyman <redacted>

Check if the event ring exists and is valid once when the event handler
is called, not before every individual event TRB.

At this point the interrupter is valid, so no need to check that.

Signed-off-by: Mathias Nyman <redacted>
Signed-off-by: Wesley Cheng <redacted>
---
 drivers/usb/host/xhci-ring.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 48388bc16b24..293239d8fab0 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2922,12 +2922,6 @@ static int xhci_handle_event(struct xhci_hcd *xhci, struct xhci_interrupter *ir)
 	union xhci_trb *event;
 	u32 trb_type;
 
-	/* Event ring hasn't been allocated yet. */
-	if (!ir || !ir->event_ring || !ir->event_ring->dequeue) {
-		xhci_err(xhci, "ERROR interrupter not ready\n");
-		return -ENOMEM;
-	}
-
 	event = ir->event_ring->dequeue;
 
 	if (!unhandled_event_trb(ir->event_ring))
@@ -3031,6 +3025,12 @@ static int xhci_handle_events(struct xhci_hcd *xhci, struct xhci_interrupter *ir
 
 	xhci_clear_interrupt_pending(xhci, ir);
 
+	/* Event ring hasn't been allocated yet. */
+	if (!ir->event_ring || !ir->event_ring->dequeue) {
+		xhci_err(xhci, "ERROR interrupter event ring not ready\n");
+		return -ENOMEM;
+	}
+
 	if (xhci->xhc_state & XHCI_STATE_DYING ||
 	    xhci->xhc_state & XHCI_STATE_HALTED) {
 		xhci_dbg(xhci, "xHCI dying, ignoring interrupt. Shouldn't IRQs be disabled?\n");
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help