DWC3 must check for the BUFSIZ and update the req->remaining
regardless of transfer alignment. Returning early from transfer OUT
unalignment will skip updating the req->remaining.

Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize")
Signed-off-by: Thinh Nguyen <thi...@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 032ea7d709ba..a5b8387a37ba 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2246,6 +2246,9 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct 
dwc3_ep *dep,
        if (chain && (trb->ctrl & DWC3_TRB_CTRL_HWO))
                trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
 
+       count = trb->size & DWC3_TRB_SIZE_MASK;
+       req->remaining += count;
+
        /*
         * If we're dealing with unaligned size OUT transfer, we will be left
         * with one TRB pending in the ring. We need to manually clear HWO bit
@@ -2256,9 +2259,6 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct 
dwc3_ep *dep,
                return 1;
        }
 
-       count = trb->size & DWC3_TRB_SIZE_MASK;
-       req->remaining += count;
-
        if ((trb->ctrl & DWC3_TRB_CTRL_HWO) && status != -ESHUTDOWN)
                return 1;
 
-- 
2.11.0

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