Sfoglia il codice sorgente

usb: dwc3: gadget: early giveback if End Transfer already completed

commit 9f45581f5eec6786c6eded2b3c85345d82a910c9 upstream.

There is a rare race condition that may happen during a Disconnect
Interrupt if we have a started request that happens to be
dequeued *after* completion of End Transfer command. If that happens,
that request will be left waiting for completion of an End Transfer
command that will never happen.

If End Transfer command has already completed before, we are safe to
giveback the request straight away.

Tested-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Felipe Balbi 6 anni fa
parent
commit
fb9717a972
1 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  1. 5 1
      drivers/usb/dwc3/gadget.c

+ 5 - 1
drivers/usb/dwc3/gadget.c

@@ -1400,7 +1400,10 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
 				goto out0;
 
 			dwc3_gadget_move_cancelled_request(req);
-			goto out0;
+			if (dep->flags & DWC3_EP_TRANSFER_STARTED)
+				goto out0;
+			else
+				goto out1;
 		}
 		dev_err(dwc->dev, "request %pK was not queued to %s\n",
 				request, ep->name);
@@ -1408,6 +1411,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
 		goto out0;
 	}
 
+out1:
 	dwc3_gadget_giveback(dep, req, -ECONNRESET);
 
 out0: