usb: dwc3: gadget: make starting isoc transfers more robust
authorMichael Olbrich <m.olbrich@pengutronix.de>
Wed, 1 Jul 2020 18:24:52 +0000 (20:24 +0200)
committerFelipe Balbi <balbi@kernel.org>
Fri, 24 Jul 2020 13:45:15 +0000 (16:45 +0300)
commitc5a7092f401535d8a9159be963b0c318393c2a78
tree66c907e9f679ff3feca66231ccbe4c9992586e3e
parentca14378560db5440893404a639d69846f46eb70e
usb: dwc3: gadget: make starting isoc transfers more robust

Currently __dwc3_gadget_start_isoc must be called very shortly after
XferNotReady. Otherwise the frame number is outdated and start transfer
will fail, even with several retries.

DSTS provides the lower 14 bit of the frame number. Use it in combination
with the frame number provided by XferNotReady to guess the current frame
number. This will succeed unless more than one 14 rollover has happened
since XferNotReady.

Start transfer might still fail if the frame number is increased
immediately after DSTS is read. So retries are still needed.
Don't drop the current request if this happens. This way it is not lost and
can be used immediately to try again with the next frame number.

With this change, __dwc3_gadget_start_isoc is still not successfully in all
cases bit it increases the acceptable delay after XferNotReady
significantly.

Reviewed-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
drivers/usb/dwc3/gadget.c