]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
db0fa10485cc209cc54b9d540cf51dba68ee9958
[thirdparty/kernel/stable-queue.git] /
1 From de92803f50c2a5a42003f6314bad570e6961b678 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Tue, 31 Mar 2020 01:40:42 -0700
4 Subject: usb: dwc3: gadget: Continue to process pending requests
5
6 From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
7
8 [ Upstream commit d9feef974e0d8cb6842533c92476a1b32a41ba31 ]
9
10 If there are still pending requests because no TRB was available,
11 prepare more when started requests are completed.
12
13 Introduce dwc3_gadget_ep_should_continue() to check for incomplete and
14 pending requests to resume updating new TRBs to the controller's TRB
15 cache.
16
17 Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
18 Signed-off-by: Felipe Balbi <balbi@kernel.org>
19 Signed-off-by: Sasha Levin <sashal@kernel.org>
20 ---
21 drivers/usb/dwc3/gadget.c | 24 +++++++++++++++++++++---
22 1 file changed, 21 insertions(+), 3 deletions(-)
23
24 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
25 index 1d65de84464d5..b6a454211329b 100644
26 --- a/drivers/usb/dwc3/gadget.c
27 +++ b/drivers/usb/dwc3/gadget.c
28 @@ -2644,10 +2644,8 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
29
30 req->request.actual = req->request.length - req->remaining;
31
32 - if (!dwc3_gadget_ep_request_completed(req)) {
33 - __dwc3_gadget_kick_transfer(dep);
34 + if (!dwc3_gadget_ep_request_completed(req))
35 goto out;
36 - }
37
38 dwc3_gadget_giveback(dep, req, status);
39
40 @@ -2671,6 +2669,24 @@ static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep,
41 }
42 }
43
44 +static bool dwc3_gadget_ep_should_continue(struct dwc3_ep *dep)
45 +{
46 + struct dwc3_request *req;
47 +
48 + if (!list_empty(&dep->pending_list))
49 + return true;
50 +
51 + /*
52 + * We only need to check the first entry of the started list. We can
53 + * assume the completed requests are removed from the started list.
54 + */
55 + req = next_request(&dep->started_list);
56 + if (!req)
57 + return false;
58 +
59 + return !dwc3_gadget_ep_request_completed(req);
60 +}
61 +
62 static void dwc3_gadget_endpoint_frame_from_event(struct dwc3_ep *dep,
63 const struct dwc3_event_depevt *event)
64 {
65 @@ -2700,6 +2716,8 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep,
66
67 if (stop)
68 dwc3_stop_active_transfer(dep, true, true);
69 + else if (dwc3_gadget_ep_should_continue(dep))
70 + __dwc3_gadget_kick_transfer(dep);
71
72 /*
73 * WORKAROUND: This is the 2nd half of U1/U2 -> U0 workaround.
74 --
75 2.27.0
76