]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
usb: dwc3: gadget: Allow restarting a transfer
authorThinh Nguyen <Thinh.Nguyen@synopsys.com>
Tue, 29 Sep 2020 07:18:48 +0000 (00:18 -0700)
committerFelipe Balbi <balbi@kernel.org>
Fri, 2 Oct 2020 06:57:46 +0000 (09:57 +0300)
It's possible that there's no new TRBs prepared when kicking a transfer.
This happens when we need to stop and restart a transfer such as in the
case of reinitiating a stream or retrying isoc transfer. For streams,
sometime host may reject a stream and the device may need to reinitiate
that stream by stopping and restarting a transfer. In this case, all the
TRBs may have already been prepared. Allow the function
__dwc3_gadget_kick_transfer() to go through even though there's no new
TRB.

Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
drivers/usb/dwc3/gadget.c

index 359824c871cd47a097979e4b6da00eaa20a654ed..76c383eecfd3850ed60eadfd61c4de3373a6feaf 100644 (file)
@@ -1326,8 +1326,13 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep)
        int                             ret;
        u32                             cmd;
 
+       /*
+        * Note that it's normal to have no new TRBs prepared (i.e. ret == 0).
+        * This happens when we need to stop and restart a transfer such as in
+        * the case of reinitiating a stream or retrying an isoc transfer.
+        */
        ret = dwc3_prepare_trbs(dep);
-       if (ret <= 0)
+       if (ret < 0)
                return ret;
 
        starting = !(dep->flags & DWC3_EP_TRANSFER_STARTED);