[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.1 / 0043-usb-ch9-fix-up-MaxStreams-helper.patch
1 From db46f35cb2853ffa42157c7222335cae15eda7e0 Mon Sep 17 00:00:00 2001
2 From: Felipe Balbi <balbi@ti.com>
3 Date: Mon, 2 Jan 2012 13:35:41 +0200
4 Subject: [PATCH 43/49] usb: ch9: fix up MaxStreams helper
6 commit 18b7ede5f7ee2092aedcb578d3ac30bd5d4fc23c upstream.
8 [ removed the dwc3 portion of the patch as it didn't apply to
9 older kernels - gregkh]
11 According to USB 3.0 Specification Table 9-22, if
12 bmAttributes [4:0] are set to zero, it means "no
13 streams supported", but the way this helper was
14 defined on Linux, we will *always* have one stream
15 which might cause several problems.
17 For example on DWC3, we would tell the controller
18 endpoint has streams enabled and yet start transfers
19 with Stream ID set to 0, which would goof up the host
20 side.
22 While doing that, convert the macro to an inline
23 function due to the different checks we now need.
25 Signed-off-by: Felipe Balbi <balbi@ti.com>
26 Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
28 ---
29 drivers/usb/host/xhci.c | 3 +--
30 include/linux/usb/ch9.h | 20 +++++++++++++++++++-
31 2 files changed, 20 insertions(+), 3 deletions(-)
33 diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
34 index 36f9dd8..b33f059 100644
35 --- a/drivers/usb/host/xhci.c
36 +++ b/drivers/usb/host/xhci.c
37 @@ -2797,8 +2797,7 @@ static int xhci_calculate_streams_and_bitmask(struct xhci_hcd *xhci,
38 if (ret < 0)
39 return ret;
41 - max_streams = USB_SS_MAX_STREAMS(
42 - eps[i]->ss_ep_comp.bmAttributes);
43 + max_streams = usb_ss_max_streams(&eps[i]->ss_ep_comp);
44 if (max_streams < (*num_streams - 1)) {
45 xhci_dbg(xhci, "Ep 0x%x only supports %u stream IDs.\n",
46 eps[i]->desc.bEndpointAddress,
47 diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
48 index d5da6c6..61b2905 100644
49 --- a/include/linux/usb/ch9.h
50 +++ b/include/linux/usb/ch9.h
51 @@ -605,8 +605,26 @@ struct usb_ss_ep_comp_descriptor {
52 } __attribute__ ((packed));
54 #define USB_DT_SS_EP_COMP_SIZE 6
55 +
56 /* Bits 4:0 of bmAttributes if this is a bulk endpoint */
57 -#define USB_SS_MAX_STREAMS(p) (1 << ((p) & 0x1f))
58 +static inline int
59 +usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp)
60 +{
61 + int max_streams;
62 +
63 + if (!comp)
64 + return 0;
65 +
66 + max_streams = comp->bmAttributes & 0x1f;
67 +
68 + if (!max_streams)
69 + return 0;
70 +
71 + max_streams = 1 << max_streams;
72 +
73 + return max_streams;
74 +}
75 +
76 /* Bits 1:0 of bmAttributes if this is an isoc endpoint */
77 #define USB_SS_MULT(p) (1 + ((p) & 0x3))
79 --
80 1.7.7.4