linux-brain/drivers/usb/dwc3
Serge Semin b90e8d5d28 usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based one
commit fca3f138105727c3a22edda32d02f91ce1bf11c9 upstream

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>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-02-17 10:35:18 +01:00
..
core.c usb: dwc3: fix clock issue during resume in OTG mode 2021-02-10 09:25:29 +01:00
core.h usb: dwc3: ulpi: Use VStsDone to detect PHY regs access completion 2021-01-12 20:16:18 +01:00
debug.h usb: dwc3: debug: fix string position formatting mixup with ret and len 2020-02-28 17:22:16 +01:00
debugfs.c usb: dwc3: debugfs: Print/set link state for peripheral mode 2018-11-26 09:06:31 +02:00
drd.c usb: dwc3: Remove dev_err() on platform_get_irq() failure 2019-10-07 12:52:44 +02:00
dwc3-exynos.c usb: dwc3: exynos: Fix error handling of clk_prepare_enable 2019-01-28 15:31:11 +02:00
dwc3-haps.c usb: dwc3: haps: Workaround matching VID PID 2019-02-07 13:17:19 +02:00
dwc3-keystone.c USB: Changes for v5.4 merge window 2019-09-02 19:20:57 +02:00
dwc3-meson-g12a.c usb: dwc3: meson-g12a: fix suspend resume regulator unbalanced disables 2019-08-28 13:04:59 +03:00
dwc3-of-simple.c usb: dwc3: simple: add support for Hikey 970 2020-10-29 09:58:05 +01:00
dwc3-omap.c USB: Changes for v5.4 merge window 2019-09-02 19:20:57 +02:00
dwc3-pci.c usb: dwc3: pci: add support for the Intel Alder Lake-S 2020-11-18 19:20:21 +01:00
dwc3-qcom.c usb: dwc3: qcom: Use of_clk_get_parent_count() 2019-06-18 11:58:29 +03:00
dwc3-st.c usb: dwc3: st: Add of_dev_put() in probe function 2019-08-28 13:04:58 +03:00
ep0.c usb: dwc3: ep0: Fix delay status handling 2020-11-10 12:37:33 +01:00
gadget.c usb: dwc3: gadget: Reclaim extra TRBs after request completion 2020-11-18 19:20:16 +01:00
gadget.h usb: dwc3: gadget: END_TRANSFER before CLEAR_STALL command 2020-11-05 11:43:28 +01:00
host.c usb: dwc3: use proper initializers for property entries 2020-02-24 08:36:44 +01:00
io.h USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
Kconfig usb: dwc3: select CONFIG_REGMAP_MMIO 2019-10-27 08:58:44 +02:00
Makefile usb: dwc3: Add Amlogic G12A DWC3 glue 2019-05-03 09:13:47 +03:00
trace.c USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
trace.h usb: common: Separated decoding functions from dwc3 driver. 2019-08-29 10:52:27 +03:00
ulpi.c usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based one 2021-02-17 10:35:18 +01:00