kernel: bump 4.19 to 4.19.108
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-4.19 / 950-0666-xhci-Use-more-event-ring-segment-table-entries.patch
1 From c2e02902a3b75b24306dac06cb6f75b683fa0267 Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.org>
3 Date: Tue, 13 Aug 2019 15:53:29 +0100
4 Subject: [PATCH] xhci: Use more event ring segment table entries
5
6 Users have reported log spam created by "Event Ring Full" xHC event
7 TRBs. These are caused by interrupt latency in conjunction with a very
8 busy set of devices on the bus. The errors are benign, but throughput
9 will suffer as the xHC will pause processing of transfers until the
10 event ring is drained by the kernel. Expand the number of event TRB slots
11 available by increasing the number of event ring segments in the ERST.
12
13 Controllers have a hardware-defined limit as to the number of ERST
14 entries they can process, so make the actual number in use
15 min(ERST_MAX_SEGS, hw_max).
16
17 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
18 ---
19 drivers/usb/host/xhci-mem.c | 8 +++++---
20 drivers/usb/host/xhci.h | 4 ++--
21 2 files changed, 7 insertions(+), 5 deletions(-)
22
23 --- a/drivers/usb/host/xhci-mem.c
24 +++ b/drivers/usb/host/xhci-mem.c
25 @@ -2516,9 +2516,11 @@ int xhci_mem_init(struct xhci_hcd *xhci,
26 * Event ring setup: Allocate a normal ring, but also setup
27 * the event ring segment table (ERST). Section 4.9.3.
28 */
29 + val2 = 1 << HCS_ERST_MAX(xhci->hcs_params2);
30 + val2 = min_t(unsigned int, ERST_MAX_SEGS, val2);
31 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Allocating event ring");
32 - xhci->event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, 1, TYPE_EVENT,
33 - 0, flags);
34 + xhci->event_ring = xhci_ring_alloc(xhci, val2, 1, TYPE_EVENT,
35 + 0, flags);
36 if (!xhci->event_ring)
37 goto fail;
38 if (xhci_check_trb_in_td_math(xhci) < 0)
39 @@ -2531,7 +2533,7 @@ int xhci_mem_init(struct xhci_hcd *xhci,
40 /* set ERST count with the number of entries in the segment table */
41 val = readl(&xhci->ir_set->erst_size);
42 val &= ERST_SIZE_MASK;
43 - val |= ERST_NUM_SEGS;
44 + val |= val2;
45 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
46 "// Write ERST size = %i to ir_set 0 (some bits preserved)",
47 val);
48 --- a/drivers/usb/host/xhci.h
49 +++ b/drivers/usb/host/xhci.h
50 @@ -1643,8 +1643,8 @@ struct urb_priv {
51 * Each segment table entry is 4*32bits long. 1K seems like an ok size:
52 * (1K bytes * 8bytes/bit) / (4*32 bits) = 64 segment entries in the table,
53 * meaning 64 ring segments.
54 - * Initial allocated size of the ERST, in number of entries */
55 -#define ERST_NUM_SEGS 1
56 + * Maximum number of segments in the ERST */
57 +#define ERST_MAX_SEGS 8
58 /* Initial allocated size of the ERST, in number of entries */
59 #define ERST_SIZE 64
60 /* Initial number of event segment rings allocated */