]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
usb: dwc3: gadget: don't clear EP_BUSY too early
authorFelipe Balbi <balbi@ti.com>
Fri, 29 May 2015 15:06:38 +0000 (10:06 -0500)
committerLuis Henriques <luis.henriques@canonical.com>
Wed, 15 Jul 2015 09:00:14 +0000 (10:00 +0100)
commit e18b7975c885bc3a938b9a76daf32957ea0235fa upstream.

In case of non-Isochronous transfers, we don't
want to clear DWC3_EP_BUSY flag until XferComplete
event. That's because XferInProgress was only enabled
so we can recycle TRBs and usb_requests quicker, but
there are still other pending requests being transferred.

In order to make sure we don't allow for another StartTransfer
command while the HW is still processing other transfers,
we must keep DWC3_EP_BUSY flag set and this what this patch
does.

Fixes: f3af36511e60 (usb: dwc3: gadget: always enable IOC on
bulk/interrupt transfers)
Reported-by: sundeep subbaraya <sundeep.lkml@gmail.com>
Tested-by: sundeep subbaraya <sundeep.lkml@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
drivers/usb/dwc3/gadget.c

index 0c4a7aba42cb1833bc5537e1f7479feeac5ab1ff..18d2ffcc462b6bb8934021a2b91d3be10ad15919 100644 (file)
@@ -1987,12 +1987,16 @@ static void dwc3_endpoint_transfer_complete(struct dwc3 *dwc,
 {
        unsigned                status = 0;
        int                     clean_busy;
+       u32                     is_xfer_complete;
+
+       is_xfer_complete = (event->endpoint_event == DWC3_DEPEVT_XFERCOMPLETE);
 
        if (event->status & DEPEVT_STATUS_BUSERR)
                status = -ECONNRESET;
 
        clean_busy = dwc3_cleanup_done_reqs(dwc, dep, event, status);
-       if (clean_busy)
+       if (clean_busy && (is_xfer_complete ||
+                               usb_endpoint_xfer_isoc(dep->endpoint.desc)))
                dep->flags &= ~DWC3_EP_BUSY;
 
        /*