We can infer Update Transfer by the fact that
req_queue is empty and DWC3_EP_BUSY isn't set.

This let's us a) rely on Update Transfer more often
(should be good for deeper queue lengths) and b) remove
the extra start_new parameter (done on a follow-up
patch)

Signed-off-by: Felipe Balbi <ba...@ti.com>
---
 drivers/usb/dwc3/gadget.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index d28dc6df4e55..6df473427b6d 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -950,24 +950,20 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep 
*dep, u16 cmd_param,
        }
        dep->flags &= ~DWC3_EP_PENDING_REQUEST;
 
+       cmd = DWC3_DEPCMD_UPDATETRANSFER |
+               DWC3_DEPCMD_PARAM(cmd_param);
+
        /*
         * If we are getting here after a short-out-packet we don't enqueue any
         * new requests as we try to set the IOC bit only on the last request.
         */
-       if (start_new) {
-               if (list_empty(&dep->req_queued))
-                       dwc3_prepare_trbs(dep, start_new);
-
-               /* req points to the first request which will be sent */
-               req = next_request(&dep->req_queued);
-       } else {
+       if (list_empty(&dep->req_queued) &&
+                       !(dep->flags & DWC3_EP_BUSY)) {
                dwc3_prepare_trbs(dep, start_new);
-
-               /*
-                * req points to the first request where HWO changed from 0 to 1
-                */
-               req = next_request(&dep->req_queued);
+               cmd = DWC3_DEPCMD_STARTTRANSFER;
        }
+
+       req = next_request(&dep->req_queued);
        if (!req) {
                dep->flags |= DWC3_EP_PENDING_REQUEST;
                return 0;
@@ -975,15 +971,11 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep 
*dep, u16 cmd_param,
 
        memset(&params, 0, sizeof(params));
 
-       if (start_new) {
+       if (cmd == DWC3_DEPCMD_STARTTRANSFER) {
                params.param0 = upper_32_bits(req->trb_dma);
                params.param1 = lower_32_bits(req->trb_dma);
-               cmd = DWC3_DEPCMD_STARTTRANSFER;
-       } else {
-               cmd = DWC3_DEPCMD_UPDATETRANSFER;
        }
 
-       cmd |= DWC3_DEPCMD_PARAM(cmd_param);
        ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, &params);
        if (ret < 0) {
                dev_dbg(dwc->dev, "failed to send STARTTRANSFER command\n");
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to