linux-stable/drivers/usb/dwc3
Serge Semin fca3f13810 usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based one
Originally the procedure of the ULPI transaction finish detection has been
developed as a simple busy-loop with just decrementing counter and no
delays. It's wrong since on different systems the loop will take a
different time to complete. So if the system bus and CPU are fast enough
to overtake the ULPI bus and the companion PHY reaction, then we'll get to
take a false timeout error. Fix this by converting the busy-loop procedure
to take the standard bus speed, address value and the registers access
mode into account for the busy-loop delay calculation.

Here is the way the fix works. It's known that the ULPI bus is clocked
with 60MHz signal. In accordance with [1] the ULPI bus protocol is created
so to spend 5 and 6 clock periods for immediate register write and read
operations respectively, and 6 and 7 clock periods - for the extended
register writes and reads. Based on that we can easily pre-calculate the
time which will be needed for the controller to perform a requested IO
operation. Note we'll still preserve the attempts counter in case if the
DWC USB3 controller has got some internals delays.

[1] UTMI+ Low Pin Interface (ULPI) Specification, Revision 1.1,
    October 20, 2004, pp. 30 - 36.

Fixes: 88bc9d194f ("usb: dwc3: add ULPI interface support")
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Link: https://lore.kernel.org/r/20201210085008.13264-3-Sergey.Semin@baikalelectronics.ru
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-28 15:55:41 +01:00
..
core.c usb: fix kernel-doc markups 2020-10-28 13:18:56 +01:00
core.h usb: dwc3: ulpi: Use VStsDone to detect PHY regs access completion 2020-12-28 15:55:37 +01:00
debug.h usb: dwc3: debug: fix checkpatch warning 2020-10-02 09:43:35 +03:00
debugfs.c usb: dwc3: debugfs: do not queue work if try to change mode on non-drd 2020-10-02 09:57:42 +03:00
drd.c usb: dwc3: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
dwc3-exynos.c Revert "usb: dwc3: exynos: Add support for Exynos5422 suspend clk" 2020-06-24 09:52:23 +03:00
dwc3-haps.c usb: dwc3: dwc3-haps: Function headers are not suitable for kerneldoc 2020-07-03 10:18:40 +02:00
dwc3-keystone.c usb: dwc3: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
dwc3-meson-g12a.c usb: dwc3: meson-g12a: disable clk on error handling path in probe 2020-12-28 15:45:14 +01:00
dwc3-of-simple.c usb: dwc3: of-simple: Add compatible string for Intel Keem Bay platform 2020-10-02 13:29:13 +03:00
dwc3-omap.c usb: dwc3: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
dwc3-pci.c usb: dwc3: pci: add support for the Intel Alder Lake-S 2020-10-27 09:02:10 +02:00
dwc3-qcom.c usb: dwc3: qcom: fix checkpatch warnings 2020-10-02 09:43:35 +03:00
dwc3-st.c usb: dwc3: convert to devm_platform_ioremap_resource_byname 2020-07-29 16:49:37 +02:00
ep0.c usb: dwc3: ep0: Fix delay status handling 2020-10-27 11:33:53 +02:00
gadget.c usb: dwc3: gadget: Support up to max stream id 2020-10-02 13:29:13 +03:00
gadget.h usb: dwc3: allocate gadget structure dynamically 2020-10-02 09:57:42 +03:00
host.c usb: dwc3: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
io.h usb: dwc3: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
Kconfig usb: dwc3: select USB_ROLE_SWITCH 2020-05-09 11:05:09 +03:00
Makefile usb: dwc3: Add Amlogic G12A DWC3 glue 2019-05-03 09:13:47 +03:00
trace.c usb: dwc3: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
trace.h usb: dwc3: trace: fix checkpatch warnings 2020-10-02 09:43:35 +03:00
ulpi.c usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based one 2020-12-28 15:55:41 +01:00