aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2013-05-08 11:18:05 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-15 13:41:39 -0400
commite4f47e3675e6f1f40906b785b934ce963e9f2eb3 (patch)
treeab22d874a67160c6bcab91dc5c8c312cd54da902 /drivers/usb/host
parent4089ffd7665fabfbceb8bbbdce458fcc416f3733 (diff)
USB: xHCI: override bogus bulk wMaxPacketSize values
This patch shortens the logic in xhci_endpoint_init() by moving common calculations involving max_packet and max_burst outside the switch statement, rather than repeating the same code in multiple case-specific statements. It also replaces two usages of max_packet which were clearly intended to be max_burst all along. More importantly, it compensates for a common bug in high-speed bulk endpoint descriptors. In many devices there is a bulk endpoint having a wMaxPacketSize value smaller than 512, which is forbidden by the USB spec. Some xHCI controllers can't handle this and refuse to accept the endpoint. This patch changes the max_packet value to 512, which allows the controller to use the endpoint properly. In practice the bogus maxpacket size doesn't matter, because none of the transfers sent via these endpoints are longer than the maxpacket value anyway. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-and-tested-by: "Aurélien Leblond" <blablack@gmail.com> CC: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/xhci-mem.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 965b539bc474..2cfc465925bd 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1423,15 +1423,17 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1423 ep_ctx->ep_info2 |= cpu_to_le32(xhci_get_endpoint_type(udev, ep)); 1423 ep_ctx->ep_info2 |= cpu_to_le32(xhci_get_endpoint_type(udev, ep));
1424 1424
1425 /* Set the max packet size and max burst */ 1425 /* Set the max packet size and max burst */
1426 max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc));
1427 max_burst = 0;
1426 switch (udev->speed) { 1428 switch (udev->speed) {
1427 case USB_SPEED_SUPER: 1429 case USB_SPEED_SUPER:
1428 max_packet = usb_endpoint_maxp(&ep->desc);
1429 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet));
1430 /* dig out max burst from ep companion desc */ 1430 /* dig out max burst from ep companion desc */
1431 max_packet = ep->ss_ep_comp.bMaxBurst; 1431 max_burst = ep->ss_ep_comp.bMaxBurst;
1432 ep_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(max_packet));
1433 break; 1432 break;
1434 case USB_SPEED_HIGH: 1433 case USB_SPEED_HIGH:
1434 /* Some devices get this wrong */
1435 if (usb_endpoint_xfer_bulk(&ep->desc))
1436 max_packet = 512;
1435 /* bits 11:12 specify the number of additional transaction 1437 /* bits 11:12 specify the number of additional transaction
1436 * opportunities per microframe (USB 2.0, section 9.6.6) 1438 * opportunities per microframe (USB 2.0, section 9.6.6)
1437 */ 1439 */
@@ -1439,17 +1441,16 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1439 usb_endpoint_xfer_int(&ep->desc)) { 1441 usb_endpoint_xfer_int(&ep->desc)) {
1440 max_burst = (usb_endpoint_maxp(&ep->desc) 1442 max_burst = (usb_endpoint_maxp(&ep->desc)
1441 & 0x1800) >> 11; 1443 & 0x1800) >> 11;
1442 ep_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(max_burst));
1443 } 1444 }
1444 /* Fall through */ 1445 break;
1445 case USB_SPEED_FULL: 1446 case USB_SPEED_FULL:
1446 case USB_SPEED_LOW: 1447 case USB_SPEED_LOW:
1447 max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc));
1448 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet));
1449 break; 1448 break;
1450 default: 1449 default:
1451 BUG(); 1450 BUG();
1452 } 1451 }
1452 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet) |
1453 MAX_BURST(max_burst));
1453 max_esit_payload = xhci_get_max_esit_payload(xhci, udev, ep); 1454 max_esit_payload = xhci_get_max_esit_payload(xhci, udev, ep);
1454 ep_ctx->tx_info = cpu_to_le32(MAX_ESIT_PAYLOAD_FOR_EP(max_esit_payload)); 1455 ep_ctx->tx_info = cpu_to_le32(MAX_ESIT_PAYLOAD_FOR_EP(max_esit_payload));
1455 1456