All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: xhci: Link TRB must not occur with a USB payload burst.
@ 2013-11-07 17:20 David Laight
  2013-11-08  0:18 ` Sarah Sharp
  2013-11-08 11:07 ` David Laight
  0 siblings, 2 replies; 42+ messages in thread
From: David Laight @ 2013-11-07 17:20 UTC (permalink / raw)
  To: netdev, linux-usb, Sarah Sharp


Section 4.11.7.1 of rev 1.0 of the xhci specification states that a link TRB
can only occur at a boundary between underlying USB frames (512 bytes for 480M).

If this isn't done the USB frames aren't formatted correctly and, for example,
the USB3 ethernet ax88179_178a card will stop sending (while still receiving)
when running a netperf tcp transmit test with (say) and 8k buffer.

While this change improves things a lot (it runs for 20 minutes rather than
a few seconds), there is still something else wrong.

This should be a candidate for stable, the ax88179_178a driver defaults to
gso and tso enabled so it passes a lot of fragmented skb to the USB stack.

Signed-off-by: David Laight <david.laight@aculab.com>
---

Although I've got a USB2 analyser its trigger and trace stuff is almost
unusable! In any case this fails much faster on USB3 (Intel i7 cpu).

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 5480215..23abc9b 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2927,8 +2932,43 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
 	}
 
 	while (1) {
-		if (room_on_ring(xhci, ep_ring, num_trbs))
-			break;
+		if (room_on_ring(xhci, ep_ring, num_trbs)) {
+			union xhci_trb *trb = ep_ring->enqueue;
+			unsigned int usable = ep_ring->enq_seg->trbs +
+					TRBS_PER_SEGMENT - 1 - trb;
+			u32 nop_cmd;
+
+			/*
+			 * Section 4.11.7.1 TD Fragments states that a link
+			 * TRB must only occur at the boundary between
+			 * data bursts (eg 512 bytes for 480M).
+			 * While it is possible to split a large fragment
+			 * we don't know the size yet.
+			 * Simplest solution is to fill the trb before the
+			 * LINK with nop commands.
+			 */
+			if (num_trbs == 1 || num_trbs <= usable || usable == 0)
+				break;
+
+			if (num_trbs >= TRBS_PER_SEGMENT) {
+				xhci_err(xhci, "Too many fragments %d, max %d\n",
+						num_trbs, TRBS_PER_SEGMENT - 1);
+				return -ENOMEM;
+			}
+
+			nop_cmd = cpu_to_le32(TRB_TYPE(TRB_TR_NOOP) |
+					ep_ring->cycle_state);
+			for (; !TRB_TYPE_LINK_LE32(trb->link.control); trb++) {
+				trb->generic.field[0] = 0;
+				trb->generic.field[1] = 0;
+				trb->generic.field[2] = 0;
+				trb->generic.field[3] = nop_cmd;
+				ep_ring->num_trbs_free--;
+			}
+			ep_ring->enqueue = trb;
+			if (room_on_ring(xhci, ep_ring, num_trbs))
+				break;
+		}
 
 		if (ep_ring == xhci->cmd_ring) {
 			xhci_err(xhci, "Do not support expand command ring\n");

^ permalink raw reply related	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2013-11-21  9:56 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-07 17:20 [PATCH] usb: xhci: Link TRB must not occur with a USB payload burst David Laight
2013-11-08  0:18 ` Sarah Sharp
2013-11-08 10:47   ` David Laight
2013-11-08 16:45   ` Alan Stern
     [not found]     ` <Pine.LNX.4.44L0.1311081119510.1162-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-11-08 17:39       ` David Laight
2013-11-08 18:12         ` Alan Stern
     [not found]           ` <Pine.LNX.4.44L0.1311081303460.1162-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-11-11 17:12             ` David Laight
     [not found]               ` <AE90C24D6B3A694183C094C60CF0A2F6026B73FE-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2013-11-11 20:34                 ` Alan Stern
2013-11-12  9:43                   ` David Laight
     [not found]                     ` <AE90C24D6B3A694183C094C60CF0A2F6026B73FF-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2013-11-12 16:08                       ` Alan Stern
     [not found]                         ` <Pine.LNX.4.44L0.1311121051090.1200-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-11-12 16:50                           ` David Laight
2013-11-12 19:00                             ` Alan Stern
2013-11-13  9:28                               ` David Laight
     [not found]                                 ` <AE90C24D6B3A694183C094C60CF0A2F6026B740B-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2013-11-13 16:20                                   ` Alan Stern
     [not found]                                     ` <Pine.LNX.4.44L0.1311131113090.1424-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-11-13 16:58                                       ` David Laight
     [not found]                                         ` <AE90C24D6B3A694183C094C60CF0A2F6026B741A-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2013-11-16  1:38                                           ` Ben Hutchings
     [not found]                                             ` <1384565904.29151.66.camel-/LGg1Z1CJKQ+9kgCwbf1HqK4ta4zdZpAajtMo4Cw6ucAvxtiuMwx3w@public.gmane.org>
2013-11-18  9:48                                               ` David Laight
2013-11-18 15:03                                                 ` Ben Hutchings
     [not found]                                                   ` <1384787003.10077.34.camel-nDn/Rdv9kqW9Jme8/bJn5UCKIB8iOfG2tUK59QYPAWc@public.gmane.org>
2013-11-18 15:41                                                     ` David Laight
2013-11-19 22:58                                                       ` Sarah Sharp
2013-11-20  3:09                                                         ` Alan Stern
2013-11-20  9:36                                                           ` David Laight
2013-11-20 15:03                                                             ` Eric Dumazet
     [not found]                                                               ` <1384959827.8604.141.camel-XN9IlZ5yJG9HTL0Zs8A6p/gx64E7kk8eUsxypvmhUTTZJqsBc5GL+g@public.gmane.org>
2013-11-20 15:54                                                                 ` David Laight
     [not found]                                                             ` <AE90C24D6B3A694183C094C60CF0A2F6026B7437-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2013-11-20 16:06                                                               ` Sarah Sharp
2013-11-20 17:02                                                                 ` David Laight
2013-11-20 17:16                                                                 ` David Laight
     [not found]                                                                   ` <AE90C24D6B3A694183C094C60CF0A2F6026B743D-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2013-11-20 18:39                                                                     ` Sarah Sharp
2013-11-20 21:11                                                                   ` Paul Zimmerman
2013-11-21  9:53                                                                     ` David Laight
2013-11-20  9:46                                                         ` David Laight
     [not found]                                                           ` <AE90C24D6B3A694183C094C60CF0A2F6026B7438-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2013-11-20 16:26                                                             ` Alan Stern
     [not found]                                                               ` <Pine.LNX.4.44L0.1311201121350.1826-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-11-20 17:08                                                                 ` David Laight
2013-11-20 16:50                                                           ` Sarah Sharp
     [not found]                   ` <Pine.LNX.4.44L0.1311111525480.17105-100000-pYrvlCTfrz9XsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-11-12 17:15                     ` Sarah Sharp
2013-11-12 17:33                       ` David Laight
2013-11-12 19:22                       ` Alan Stern
2013-11-13  9:45                         ` David Laight
     [not found]                           ` <AE90C24D6B3A694183C094C60CF0A2F6026B740C-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2013-11-13 16:27                             ` Alan Stern
2013-11-08 11:07 ` David Laight
     [not found]   ` <AE90C24D6B3A694183C094C60CF0A2F6026B73F1-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2013-11-12 17:15     ` Sarah Sharp
2013-11-12 17:28       ` David Laight

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.