]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.8.16/usb-gadget-composite-always-set-ep-mult-to-a-sensible-value.patch
Drop watchdog patch
[thirdparty/kernel/stable-queue.git] / releases / 4.8.16 / usb-gadget-composite-always-set-ep-mult-to-a-sensible-value.patch
1 From eaa496ffaaf19591fe471a36cef366146eeb9153 Mon Sep 17 00:00:00 2001
2 From: Felipe Balbi <felipe.balbi@linux.intel.com>
3 Date: Wed, 28 Sep 2016 12:33:31 +0300
4 Subject: usb: gadget: composite: always set ep->mult to a sensible value
5
6 From: Felipe Balbi <felipe.balbi@linux.intel.com>
7
8 commit eaa496ffaaf19591fe471a36cef366146eeb9153 upstream.
9
10 ep->mult is supposed to be set to Isochronous and
11 Interrupt Endapoint's multiplier value. This value
12 is computed from different places depending on the
13 link speed.
14
15 If we're dealing with HighSpeed, then it's part of
16 bits [12:11] of wMaxPacketSize. This case wasn't
17 taken into consideration before.
18
19 While at that, also make sure the ep->mult defaults
20 to one so drivers can use it unconditionally and
21 assume they'll never multiply ep->maxpacket to zero.
22
23 Cc: <stable@vger.kernel.org>
24 Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26
27 ---
28 drivers/usb/gadget/composite.c | 9 +++++++--
29 drivers/usb/gadget/function/uvc_video.c | 2 +-
30 2 files changed, 8 insertions(+), 3 deletions(-)
31
32 --- a/drivers/usb/gadget/composite.c
33 +++ b/drivers/usb/gadget/composite.c
34 @@ -201,7 +201,12 @@ ep_found:
35 _ep->desc = chosen_desc;
36 _ep->comp_desc = NULL;
37 _ep->maxburst = 0;
38 - _ep->mult = 0;
39 + _ep->mult = 1;
40 +
41 + if (g->speed == USB_SPEED_HIGH && (usb_endpoint_xfer_isoc(_ep->desc) ||
42 + usb_endpoint_xfer_int(_ep->desc)))
43 + _ep->mult = usb_endpoint_maxp(_ep->desc) & 0x7ff;
44 +
45 if (!want_comp_desc)
46 return 0;
47
48 @@ -218,7 +223,7 @@ ep_found:
49 switch (usb_endpoint_type(_ep->desc)) {
50 case USB_ENDPOINT_XFER_ISOC:
51 /* mult: bits 1:0 of bmAttributes */
52 - _ep->mult = comp_desc->bmAttributes & 0x3;
53 + _ep->mult = (comp_desc->bmAttributes & 0x3) + 1;
54 case USB_ENDPOINT_XFER_BULK:
55 case USB_ENDPOINT_XFER_INT:
56 _ep->maxburst = comp_desc->bMaxBurst + 1;
57 --- a/drivers/usb/gadget/function/uvc_video.c
58 +++ b/drivers/usb/gadget/function/uvc_video.c
59 @@ -243,7 +243,7 @@ uvc_video_alloc_requests(struct uvc_vide
60
61 req_size = video->ep->maxpacket
62 * max_t(unsigned int, video->ep->maxburst, 1)
63 - * (video->ep->mult + 1);
64 + * (video->ep->mult);
65
66 for (i = 0; i < UVC_NUM_REQUESTS; ++i) {
67 video->req_buffer[i] = kmalloc(req_size, GFP_KERNEL);