usb: dwc3: gadget: Stop TRB preparation after limit is reached
authorAmit Virdi <amit.virdi@st.com>
Tue, 13 Jan 2015 08:57:21 +0000 (14:27 +0530)
committerJiri Slaby <jslaby@suse.cz>
Thu, 29 Jan 2015 14:44:36 +0000 (15:44 +0100)
commit51a63126581d4f0527ec2d3157d03b889ea0a991
tree75c648f7fedaa4f5ffb83fe4211e06134ee66895
parent71ea1da778a37f26d3d697e222d97cf0227cb700
usb: dwc3: gadget: Stop TRB preparation after limit is reached

commit 39e60635a01520e8c8ed3946a28c2b98e6a46f79 upstream.

DWC3 gadget sets up a pool of 32 TRBs for each EP during initialization. This
means, the max TRBs that can be submitted for an EP is fixed to 32. Since the
request queue for an EP is a linked list, any number of requests can be queued
to it by the gadget layer.  However, the dwc3 driver must not submit TRBs more
than the pool it has created for. This limit wasn't respected when SG was used
resulting in submitting more than the max TRBs, eventually leading to
non-transfer of the TRBs submitted over the max limit.

Root cause:
When SG is used, there are two loops iterating to prepare TRBs:
 - Outer loop over the request_list
 - Inner loop over the SG list
The code was missing break to get out of the outer loop.

Fixes: eeb720fb21d6 (usb: dwc3: gadget: add support for SG lists)
Signed-off-by: Amit Virdi <amit.virdi@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/usb/dwc3/gadget.c