diff mbox series

[4/4] usb: dwc3: gadget: Return early if no TRB update

Message ID d6992af19d752076b77d3097b84135f11e33e70d.1601511883.git.Thinh.Nguyen@synopsys.com
State New
Headers show
Series usb: dwc3: gadget: More TRB handling cleanup | expand

Commit Message

Thinh Nguyen Oct. 1, 2020, 12:44 a.m. UTC
If the transfer had already started and there's no TRB to update, then
there's no need to go through __dwc3_gadget_kick_transfer(). There is
no problem reissuing UPDATE_TRANSFER command. This change just saves
the driver from doing a few operations. This happens when we run out of
TRB and function driver still queues for more requests.

Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index ff924656f690..da1f2ad2ad90 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1347,6 +1347,13 @@  static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep)
 
 	starting = !(dep->flags & DWC3_EP_TRANSFER_STARTED);
 
+	/*
+	 * If there's no new TRB prepared and we don't need to restart a
+	 * transfer, there's no need to update the transfer.
+	 */
+	if (!ret && !starting)
+		return ret;
+
 	req = next_request(&dep->started_list);
 	if (!req) {
 		dep->flags |= DWC3_EP_PENDING_REQUEST;