We can offset the latency of a full Start Transfer
command - where we _must_ poll for its completion -
to usb_ep_enable() time. This means that once
requests start showing up from the gadget driver, we
can rely on No Response Update Transfer command -
where we don't need to poll for completion.

This patch, starts implementing this method for Bulk
endpoints, even though, technically, we could extend
it to all other endpoints in future commits.

Signed-off-by: Felipe Balbi <felipe.ba...@linux.intel.com>
---
 drivers/usb/dwc3/gadget.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 4d191c8acb59..c692aafa7397 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -617,6 +617,35 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
                trb_link->ctrl |= DWC3_TRB_CTRL_HWO;
        }
 
+       /*
+        * Issue StartTransfer here with no-op TRB so we can always rely on No
+        * Response Update Transfer command.
+        */
+       if (usb_endpoint_xfer_bulk(desc)) {
+               struct dwc3_gadget_ep_cmd_params params;
+               struct dwc3_trb *trb;
+               dma_addr_t trb_dma;
+               u32 cmd;
+
+               memset(&params, 0, sizeof(params));
+               trb = &dep->trb_pool[0];
+               trb_dma = dwc3_trb_dma_offset(dep, trb);
+
+               params.param0 = upper_32_bits(trb_dma);
+               params.param1 = lower_32_bits(trb_dma);
+
+               cmd = DWC3_DEPCMD_STARTTRANSFER;
+
+               ret = dwc3_send_gadget_ep_cmd(dep, cmd, &params);
+               if (ret < 0)
+                       return ret;
+
+               dep->flags |= DWC3_EP_BUSY;
+
+               dep->resource_index = dwc3_gadget_ep_get_transfer_index(dep);
+               WARN_ON_ONCE(!dep->resource_index);
+       }
+
        return 0;
 }
 
-- 
2.10.1

--
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