Skip to content

Commit ff0589a

Browse files
Jonathan BellPhil Elwell
Jonathan Bell
authored and
Phil Elwell
committed
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 c5a2656 commit ff0589a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

drivers/usb/host/xhci-mem.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,9 +2479,11 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
24792479
* Event ring setup: Allocate a normal ring, but also setup
24802480
* the event ring segment table (ERST). Section 4.9.3.
24812481
*/
2482+
val2 = 1 << HCS_ERST_MAX(xhci->hcs_params2);
2483+
val2 = min_t(unsigned int, ERST_MAX_SEGS, val2);
24822484
xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Allocating event ring");
2483-
xhci->event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, 1, TYPE_EVENT,
2484-
0, flags);
2485+
xhci->event_ring = xhci_ring_alloc(xhci, val2, 1, TYPE_EVENT,
2486+
0, flags);
24852487
if (!xhci->event_ring)
24862488
goto fail;
24872489
if (xhci_check_trb_in_td_math(xhci) < 0)
@@ -2494,7 +2496,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
24942496
/* set ERST count with the number of entries in the segment table */
24952497
val = readl(&xhci->ir_set->erst_size);
24962498
val &= ERST_SIZE_MASK;
2497-
val |= ERST_NUM_SEGS;
2499+
val |= val2;
24982500
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
24992501
"// Write ERST size = %i to ir_set 0 (some bits preserved)",
25002502
val);

drivers/usb/host/xhci.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,8 +1649,8 @@ struct urb_priv {
16491649
* Each segment table entry is 4*32bits long. 1K seems like an ok size:
16501650
* (1K bytes * 8bytes/bit) / (4*32 bits) = 64 segment entries in the table,
16511651
* meaning 64 ring segments.
1652-
* Initial allocated size of the ERST, in number of entries */
1653-
#define ERST_NUM_SEGS 1
1652+
* Maximum number of segments in the ERST */
1653+
#define ERST_MAX_SEGS 8
16541654
/* Initial allocated size of the ERST, in number of entries */
16551655
#define ERST_SIZE 64
16561656
/* Initial number of event segment rings allocated */

0 commit comments

Comments
 (0)