USB: xhci: Bulk transfer support

Allow device drivers to submit URBs to bulk endpoints on devices under an
xHCI host controller.  Share code between the control and bulk enqueueing
functions when it makes sense.

To get the best performance out of bulk transfers, SuperSpeed devices must
have the bMaxBurst size copied from their endpoint companion controller
into the xHCI device context.  This allows the host controller to "burst"
up to 16 packets before it has to wait for the device to acknowledge the
first packet.

The buffers in Transfer Request Blocks (TRBs) can cross page boundaries,
but they cannot cross 64KB boundaries.  The buffer must be broken into
multiple TRBs if a 64KB boundary is crossed.

The sum of buffer lengths in all the TRBs in a Transfer Descriptor (TD)
cannot exceed 64MB.  To work around this, the enqueueing code must enqueue
multiple TDs.  The transfer event handler may incorrectly give back the
URB in this case, if it gets a transfer event that points somewhere in the
first TD.  FIXME later.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c
index 50ab525..e5fbdcd 100644
--- a/drivers/usb/host/xhci-hcd.c
+++ b/drivers/usb/host/xhci-hcd.c
@@ -589,12 +589,6 @@
 
 	slot_id = urb->dev->slot_id;
 	ep_index = xhci_get_endpoint_index(&urb->ep->desc);
-	/* Only support ep 0 control transfers for now */
-	if (ep_index != 0) {
-		xhci_dbg(xhci, "WARN: urb submitted to unsupported ep %x\n",
-				urb->ep->desc.bEndpointAddress);
-		return -ENOSYS;
-	}
 
 	spin_lock_irqsave(&xhci->lock, flags);
 	if (!xhci->devs || !xhci->devs[slot_id]) {
@@ -608,7 +602,12 @@
 		ret = -ESHUTDOWN;
 		goto exit;
 	}
-	ret = queue_ctrl_tx(xhci, mem_flags, urb, slot_id, ep_index);
+	if (usb_endpoint_xfer_control(&urb->ep->desc))
+		ret = queue_ctrl_tx(xhci, mem_flags, urb, slot_id, ep_index);
+	else if (usb_endpoint_xfer_bulk(&urb->ep->desc))
+		ret = queue_bulk_tx(xhci, mem_flags, urb, slot_id, ep_index);
+	else
+		ret = -EINVAL;
 exit:
 	spin_unlock_irqrestore(&xhci->lock, flags);
 	return ret;