]>
Commit | Line | Data |
---|---|---|
3d6a91bc GKH |
1 | From dc07c91b9b4067022210e68d914a6890a4d70622 Mon Sep 17 00:00:00 2001 |
2 | From: Andiry Xu <andiry.xu@amd.com> | |
3 | Date: Thu, 11 Nov 2010 17:43:57 +0800 | |
4 | Subject: xHCI: fix wMaxPacketSize mask | |
5 | ||
6 | From: Andiry Xu <andiry.xu@amd.com> | |
7 | ||
8 | commit dc07c91b9b4067022210e68d914a6890a4d70622 upstream. | |
9 | ||
10 | USB2.0 spec 9.6.6 says: For all endpoints, bit 10..0 specify the maximum | |
11 | packet size(in bytes). | |
12 | ||
13 | So the wMaxPacketSize mask should be 0x7ff rather than 0x3ff. | |
14 | ||
15 | This patch should be queued for the stable tree. The bug in | |
16 | xhci_endpoint_init() was present as far back as 2.6.31, and the bug in | |
17 | xhci_get_max_esit_payload() was present when the function was introduced | |
18 | in 2.6.34. | |
19 | ||
20 | Reported-by: Sander Eikelenboom <linux@eikelenboom.it> | |
21 | Signed-off-by: Andiry Xu <andiry.xu@amd.com> | |
22 | Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> | |
23 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
24 | ||
25 | --- | |
26 | drivers/usb/host/xhci-mem.c | 4 ++-- | |
27 | drivers/usb/host/xhci.h | 5 +++++ | |
28 | 2 files changed, 7 insertions(+), 2 deletions(-) | |
29 | ||
30 | --- a/drivers/usb/host/xhci-mem.c | |
31 | +++ b/drivers/usb/host/xhci-mem.c | |
32 | @@ -1043,7 +1043,7 @@ static inline u32 xhci_get_max_esit_payl | |
33 | if (udev->speed == USB_SPEED_SUPER) | |
34 | return ep->ss_ep_comp.wBytesPerInterval; | |
35 | ||
36 | - max_packet = ep->desc.wMaxPacketSize & 0x3ff; | |
37 | + max_packet = GET_MAX_PACKET(ep->desc.wMaxPacketSize); | |
38 | max_burst = (ep->desc.wMaxPacketSize & 0x1800) >> 11; | |
39 | /* A 0 in max burst means 1 transfer per ESIT */ | |
40 | return max_packet * (max_burst + 1); | |
41 | @@ -1133,7 +1133,7 @@ int xhci_endpoint_init(struct xhci_hcd * | |
42 | /* Fall through */ | |
43 | case USB_SPEED_FULL: | |
44 | case USB_SPEED_LOW: | |
45 | - max_packet = ep->desc.wMaxPacketSize & 0x3ff; | |
46 | + max_packet = GET_MAX_PACKET(ep->desc.wMaxPacketSize); | |
47 | ep_ctx->ep_info2 |= MAX_PACKET(max_packet); | |
48 | break; | |
49 | default: | |
50 | --- a/drivers/usb/host/xhci.h | |
51 | +++ b/drivers/usb/host/xhci.h | |
52 | @@ -614,6 +614,11 @@ struct xhci_ep_ctx { | |
53 | #define MAX_PACKET_MASK (0xffff << 16) | |
54 | #define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff) | |
55 | ||
56 | +/* Get max packet size from ep desc. Bit 10..0 specify the max packet size. | |
57 | + * USB2.0 spec 9.6.6. | |
58 | + */ | |
59 | +#define GET_MAX_PACKET(p) ((p) & 0x7ff) | |
60 | + | |
61 | /* tx_info bitmasks */ | |
62 | #define AVG_TRB_LENGTH_FOR_EP(p) ((p) & 0xffff) | |
63 | #define MAX_ESIT_PAYLOAD_FOR_EP(p) (((p) & 0xffff) << 16) |