usb: dwc3: gadget: Fix request completion check
authorThinh Nguyen <Thinh.Nguyen@synopsys.com>
Tue, 31 Mar 2020 08:40:35 +0000 (01:40 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Apr 2020 14:33:23 +0000 (16:33 +0200)
commitbf996950d8deaeabc84b0b6b88134a1222cce56a
treed00efbda1ec9a46bb44a3b6c63cade2a324b62c9
parenta0f1f53ecd8d161d2e3d71a169b0971a1cbcefc4
usb: dwc3: gadget: Fix request completion check

commit 49e0590e3a60e75b493e5df879e216e5073c7663 upstream.

A request may not be completed because not all the TRBs are prepared for
it. This happens when we run out of available TRBs. When some TRBs are
completed, the driver needs to prepare the rest of the TRBs for the
request. The check dwc3_gadget_ep_request_completed() shouldn't be
checking the amount of data received but rather the number of pending
TRBs. Revise this request completion check.

Cc: stable@vger.kernel.org
Fixes: e0c42ce590fe ("usb: dwc3: gadget: simplify IOC handling")
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/gadget.c