]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
ee7e2e0740fcee9ca915ccde3601262b9ca17034
[thirdparty/kernel/stable-queue.git] /
1 From 875874ddf331f4a609adacc8da0b5f028e638e2c Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Thu, 24 Sep 2020 01:21:24 -0700
4 Subject: usb: dwc3: gadget: Reclaim extra TRBs after request completion
5
6 From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
7
8 [ Upstream commit 690e5c2dc29f8891fcfd30da67e0d5837c2c9df5 ]
9
10 An SG request may be partially completed (due to no available TRBs).
11 Don't reclaim extra TRBs and clear the needs_extra_trb flag until the
12 request is fully completed. Otherwise, the driver will reclaim the wrong
13 TRB.
14
15 Cc: stable@vger.kernel.org
16 Fixes: 1f512119a08c ("usb: dwc3: gadget: add remaining sg entries to ring")
17 Signed-off-by: Thinh Nguyen <Thinh.Nguyen@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 | 10 +++++-----
22 1 file changed, 5 insertions(+), 5 deletions(-)
23
24 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
25 index b6a454211329b..9269cda4c1831 100644
26 --- a/drivers/usb/dwc3/gadget.c
27 +++ b/drivers/usb/dwc3/gadget.c
28 @@ -2627,6 +2627,11 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
29 ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event,
30 status);
31
32 + req->request.actual = req->request.length - req->remaining;
33 +
34 + if (!dwc3_gadget_ep_request_completed(req))
35 + goto out;
36 +
37 if (req->needs_extra_trb) {
38 unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
39
40 @@ -2642,11 +2647,6 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
41 req->needs_extra_trb = false;
42 }
43
44 - req->request.actual = req->request.length - req->remaining;
45 -
46 - if (!dwc3_gadget_ep_request_completed(req))
47 - goto out;
48 -
49 dwc3_gadget_giveback(dep, req, status);
50
51 out:
52 --
53 2.27.0
54