diff options
author | Thinh Nguyen <Thinh.Nguyen@synopsys.com> | 2020-09-30 17:44:32 -0700 |
---|---|---|
committer | Felipe Balbi <balbi@kernel.org> | 2020-10-02 09:57:46 +0300 |
commit | 346a15cdf65263d8a8dfdbc5d2702471a2dcef6c (patch) | |
tree | 7ff47793daf89205902ee534ee655fb74d0120cf | |
parent | 8dbbe48c7a9989c75e39bfb2a886e163fa21660a (diff) | |
download | lwn-346a15cdf65263d8a8dfdbc5d2702471a2dcef6c.tar.gz lwn-346a15cdf65263d8a8dfdbc5d2702471a2dcef6c.zip |
usb: dwc3: gadget: Keep TRBs in request order
If we couldn't finish preparing all the TRBs of a request, don't prepare
the next request. Otherwise, the TRBs order will be mixed up and the
controller will process the wrong TRB. This is a corner case where
there's not enough TRBs for a request that needs the extra TRB but
there's still 1 available TRB in the pool.
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
-rw-r--r-- | drivers/usb/dwc3/gadget.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 327cd556e8db..ff924656f690 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1274,7 +1274,7 @@ static int dwc3_prepare_trbs(struct dwc3_ep *dep) list_for_each_entry(req, &dep->started_list, list) { if (req->num_pending_sgs > 0) { ret = dwc3_prepare_trbs_sg(dep, req); - if (!ret) + if (!ret || req->num_pending_sgs) return ret; } @@ -1303,10 +1303,13 @@ static int dwc3_prepare_trbs(struct dwc3_ep *dep) req->num_queued_sgs = 0; req->num_pending_sgs = req->request.num_mapped_sgs; - if (req->num_pending_sgs > 0) + if (req->num_pending_sgs > 0) { ret = dwc3_prepare_trbs_sg(dep, req); - else + if (req->num_pending_sgs) + return ret; + } else { ret = dwc3_prepare_trbs_linear(dep, req); + } if (!ret || !dwc3_calc_trbs_left(dep)) return ret; |