aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-11 18:23:53 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-11 18:23:53 -0500
commit2991942f563c1bb22957568ef682561b17c54bff (patch)
treea5eaedd2afe98eebb2268f67640f44530992f707
parent03b56329f9bb5a1cb73d7dc659d529a9a9bf3acc (diff)
parent3d4b81eda2211f32886e2978daf6f39885042fc4 (diff)
Merge tag 'for-usb-linus-2014-02-11' of git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci into usb-linus
Sarah writes: xhci: Revert TD fragment hacks. Hi Greg, Recently, we found that commit "35773dac5f86 "usb: xhci: Link TRB must not occur within a USB payload burst" causes a userspace regression. It will cause larger transfers submitted through usbfs that would have succeeded on older kernels to be rejected. Commit 35773dac5f86 was designed to address an issue where an ASIX USB ethernet device would get wedged when it was connected to a 1.0 xHCI host. Only this particular ethernet device was impacted, because only the ax88179_178a driver implemented scatter-gather in 3.12. The xHCI driver doesn't currently support TD fragment rules, and commit 35773dac5f86 was a quick hack that partially implemented one of the rules. This is the third regression this patch has caused. There's yet another quick hack to work around the issue, but I really want to support TD fragments properly, rather than hacking around it. It will take us a kernel release or two to get it implemented, since it is a big architectural change. This patchset backs out commit 35773dac5f86, and the two bug fix patches for it. The first patch limits arbitrarily aligned scatter-gather under xHCI 1.0 hosts. As a result of this patchset: 1. usb-storage and uas will still be able to use scatter-gather, since they submit max packet sized aligned transfers. 2. usbfs will behave exactly as before, no more userspace regressions. 3. The ax88179_178a driver works fine without scatter-gather (Mark Lord confirms this). Users of the ASIX chipset may still see occasional packet loss on 1.0 xHCI hosts, if the xHCI driver needs to split a TRB across 64-KB boundaries, and a link TRB happens to fall between those two TRBs. I expect this corner case to be infrequent. Sarah Sharp
-rw-r--r--drivers/usb/host/xhci-ring.c54
-rw-r--r--drivers/usb/host/xhci.c18
-rw-r--r--drivers/usb/host/xhci.h2
-rw-r--r--include/linux/usb.h2
4 files changed, 16 insertions, 60 deletions
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 909b32a4412f..0ed64eb68e48 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2967,58 +2967,8 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
2967 } 2967 }
2968 2968
2969 while (1) { 2969 while (1) {
2970 if (room_on_ring(xhci, ep_ring, num_trbs)) { 2970 if (room_on_ring(xhci, ep_ring, num_trbs))
2971 union xhci_trb *trb = ep_ring->enqueue; 2971 break;
2972 unsigned int usable = ep_ring->enq_seg->trbs +
2973 TRBS_PER_SEGMENT - 1 - trb;
2974 u32 nop_cmd;
2975
2976 /*
2977 * Section 4.11.7.1 TD Fragments states that a link
2978 * TRB must only occur at the boundary between
2979 * data bursts (eg 512 bytes for 480M).
2980 * While it is possible to split a large fragment
2981 * we don't know the size yet.
2982 * Simplest solution is to fill the trb before the
2983 * LINK with nop commands.
2984 */
2985 if (num_trbs == 1 || num_trbs <= usable || usable == 0)
2986 break;
2987
2988 if (ep_ring->type != TYPE_BULK)
2989 /*
2990 * While isoc transfers might have a buffer that
2991 * crosses a 64k boundary it is unlikely.
2992 * Since we can't add NOPs without generating
2993 * gaps in the traffic just hope it never
2994 * happens at the end of the ring.
2995 * This could be fixed by writing a LINK TRB
2996 * instead of the first NOP - however the
2997 * TRB_TYPE_LINK_LE32() calls would all need
2998 * changing to check the ring length.
2999 */
3000 break;
3001
3002 if (num_trbs >= TRBS_PER_SEGMENT) {
3003 xhci_err(xhci, "Too many fragments %d, max %d\n",
3004 num_trbs, TRBS_PER_SEGMENT - 1);
3005 return -EINVAL;
3006 }
3007
3008 nop_cmd = cpu_to_le32(TRB_TYPE(TRB_TR_NOOP) |
3009 ep_ring->cycle_state);
3010 ep_ring->num_trbs_free -= usable;
3011 do {
3012 trb->generic.field[0] = 0;
3013 trb->generic.field[1] = 0;
3014 trb->generic.field[2] = 0;
3015 trb->generic.field[3] = nop_cmd;
3016 trb++;
3017 } while (--usable);
3018 ep_ring->enqueue = trb;
3019 if (room_on_ring(xhci, ep_ring, num_trbs))
3020 break;
3021 }
3022 2972
3023 if (ep_ring == xhci->cmd_ring) { 2973 if (ep_ring == xhci->cmd_ring) {
3024 xhci_err(xhci, "Do not support expand command ring\n"); 2974 xhci_err(xhci, "Do not support expand command ring\n");
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 3712359d18ba..6fe577d46fa2 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4730,11 +4730,8 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
4730 struct device *dev = hcd->self.controller; 4730 struct device *dev = hcd->self.controller;
4731 int retval; 4731 int retval;
4732 4732
4733 /* Limit the block layer scatter-gather lists to half a segment. */ 4733 /* Accept arbitrarily long scatter-gather lists */
4734 hcd->self.sg_tablesize = TRBS_PER_SEGMENT / 2; 4734 hcd->self.sg_tablesize = ~0;
4735
4736 /* support to build packet from discontinuous buffers */
4737 hcd->self.no_sg_constraint = 1;
4738 4735
4739 /* XHCI controllers don't stop the ep queue on short packets :| */ 4736 /* XHCI controllers don't stop the ep queue on short packets :| */
4740 hcd->self.no_stop_on_short = 1; 4737 hcd->self.no_stop_on_short = 1;
@@ -4760,6 +4757,14 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
4760 /* xHCI private pointer was set in xhci_pci_probe for the second 4757 /* xHCI private pointer was set in xhci_pci_probe for the second
4761 * registered roothub. 4758 * registered roothub.
4762 */ 4759 */
4760 xhci = hcd_to_xhci(hcd);
4761 /*
4762 * Support arbitrarily aligned sg-list entries on hosts without
4763 * TD fragment rules (which are currently unsupported).
4764 */
4765 if (xhci->hci_version < 0x100)
4766 hcd->self.no_sg_constraint = 1;
4767
4763 return 0; 4768 return 0;
4764 } 4769 }
4765 4770
@@ -4788,6 +4793,9 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
4788 if (xhci->hci_version > 0x96) 4793 if (xhci->hci_version > 0x96)
4789 xhci->quirks |= XHCI_SPURIOUS_SUCCESS; 4794 xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
4790 4795
4796 if (xhci->hci_version < 0x100)
4797 hcd->self.no_sg_constraint = 1;
4798
4791 /* Make sure the HC is halted. */ 4799 /* Make sure the HC is halted. */
4792 retval = xhci_halt(xhci); 4800 retval = xhci_halt(xhci);
4793 if (retval) 4801 if (retval)
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 9154fd6cf24c..58ed9d088e63 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1268,7 +1268,7 @@ union xhci_trb {
1268 * since the command ring is 64-byte aligned. 1268 * since the command ring is 64-byte aligned.
1269 * It must also be greater than 16. 1269 * It must also be greater than 16.
1270 */ 1270 */
1271#define TRBS_PER_SEGMENT 256 1271#define TRBS_PER_SEGMENT 64
1272/* Allow two commands + a link TRB, along with any reserved command TRBs */ 1272/* Allow two commands + a link TRB, along with any reserved command TRBs */
1273#define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3) 1273#define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3)
1274#define TRB_SEGMENT_SIZE (TRBS_PER_SEGMENT*16) 1274#define TRB_SEGMENT_SIZE (TRBS_PER_SEGMENT*16)
diff --git a/include/linux/usb.h b/include/linux/usb.h
index c716da18c668..7f6eb859873e 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1265,8 +1265,6 @@ typedef void (*usb_complete_t)(struct urb *);
1265 * @sg: scatter gather buffer list, the buffer size of each element in 1265 * @sg: scatter gather buffer list, the buffer size of each element in
1266 * the list (except the last) must be divisible by the endpoint's 1266 * the list (except the last) must be divisible by the endpoint's
1267 * max packet size if no_sg_constraint isn't set in 'struct usb_bus' 1267 * max packet size if no_sg_constraint isn't set in 'struct usb_bus'
1268 * (FIXME: scatter-gather under xHCI is broken for periodic transfers.
1269 * Do not use urb->sg for interrupt endpoints for now, only bulk.)
1270 * @num_mapped_sgs: (internal) number of mapped sg entries 1268 * @num_mapped_sgs: (internal) number of mapped sg entries
1271 * @num_sgs: number of entries in the sg list 1269 * @num_sgs: number of entries in the sg list
1272 * @transfer_buffer_length: How big is transfer_buffer. The transfer may 1270 * @transfer_buffer_length: How big is transfer_buffer. The transfer may