Skip to content

Commit b82d126

Browse files
Jonathan Bellpopcornmix
Jonathan Bell
authored andcommitted
xhci: Use more event ring segment table entries
Users have reported log spam created by "Event Ring Full" xHC event TRBs. These are caused by interrupt latency in conjunction with a very busy set of devices on the bus. The errors are benign, but throughput will suffer as the xHC will pause processing of transfers until the event ring is drained by the kernel. Expand the number of event TRB slots available by increasing the number of event ring segments in the ERST. Controllers have a hardware-defined limit as to the number of ERST entries they can process, so make the actual number in use min(ERST_MAX_SEGS, hw_max). Signed-off-by: Jonathan Bell <[email protected]>
1 parent 3351aeb commit b82d126

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

drivers/usb/host/xhci-mem.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -2499,9 +2499,11 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
24992499
* Event ring setup: Allocate a normal ring, but also setup
25002500
* the event ring segment table (ERST). Section 4.9.3.
25012501
*/
2502+
val2 = 1 << HCS_ERST_MAX(xhci->hcs_params2);
2503+
val2 = min_t(unsigned int, ERST_MAX_SEGS, val2);
25022504
xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Allocating event ring");
2503-
xhci->event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, 1, TYPE_EVENT,
2504-
0, flags);
2505+
xhci->event_ring = xhci_ring_alloc(xhci, val2, 1, TYPE_EVENT,
2506+
0, flags);
25052507
if (!xhci->event_ring)
25062508
goto fail;
25072509
if (xhci_check_trb_in_td_math(xhci) < 0)
@@ -2514,7 +2516,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
25142516
/* set ERST count with the number of entries in the segment table */
25152517
val = readl(&xhci->ir_set->erst_size);
25162518
val &= ERST_SIZE_MASK;
2517-
val |= ERST_NUM_SEGS;
2519+
val |= val2;
25182520
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
25192521
"// Write ERST size = %i to ir_set 0 (some bits preserved)",
25202522
val);

drivers/usb/host/xhci.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1673,8 +1673,8 @@ struct urb_priv {
16731673
* Each segment table entry is 4*32bits long. 1K seems like an ok size:
16741674
* (1K bytes * 8bytes/bit) / (4*32 bits) = 64 segment entries in the table,
16751675
* meaning 64 ring segments.
1676-
* Initial allocated size of the ERST, in number of entries */
1677-
#define ERST_NUM_SEGS 1
1676+
* Maximum number of segments in the ERST */
1677+
#define ERST_MAX_SEGS 8
16781678
/* Poll every 60 seconds */
16791679
#define POLL_TIMEOUT 60
16801680
/* Stop endpoint command timeout (secs) for URB cancellation watchdog timer */

0 commit comments

Comments
 (0)