linux-brain/drivers/usb
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
..
atm USB: atm: ueagle-atm: add missing endpoint check 2019-12-17 19:55:44 +01:00
c67x00 USB: c67x00: fix use after free in c67x00_giveback_urb 2020-07-22 09:33:09 +02:00
cdns3 usb: cdns3: gadget: suspicious implicit sign extension 2020-11-10 12:37:31 +01:00
chipidea usb: chipidea: ci_hdrc_imx: add missing put_device() call in usbmisc_get_init_data() 2021-01-12 20:16:18 +01:00
class USB: usblp: don't call usb_set_interface if there's a single alt 2021-02-10 09:25:28 +01:00
common usb: common: usb-conn-gpio: Don't log an error on probe deferral 2019-12-17 19:55:39 +01:00
core USB: add RESET_RESUME quirk for Snapscan 1212 2020-12-21 13:27:05 +01:00
dwc2 usb: dwc2: Fix endpoint direction check in ep_from_windex 2021-02-10 09:25:29 +01:00
dwc3 usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based one 2021-02-17 10:35:18 +01:00
early USB: early: Handle AMD's spec-compliant identifiers, too 2020-04-29 16:33:13 +02:00
gadget USB: gadget: legacy: fix an error code in eth_bind() 2021-02-10 09:25:28 +01:00
host usb: host: xhci: mvebu: make USB 3.0 PHY optional for Armada 3720 2021-02-10 09:25:33 +01:00
image USB: microtek: fix info-leak at probe 2019-10-04 11:02:58 +02:00
isp1760 usb: add a HCD_DMA flag instead of guestimating DMA capabilities 2019-08-21 10:03:35 -07:00
misc USB: yurex: fix control-URB timeout handling 2021-01-12 20:16:20 +01:00
mon usb: mon: Fix a deadlock in usbmon between mmap and read 2019-12-17 19:55:49 +01:00
mtu3 usb: mtu3: fix memory corruption in mtu3_debugfs_regset() 2020-12-30 11:50:58 +01:00
musb usb: musb: Fix runtime PM imbalance on error 2020-06-10 20:24:56 +02:00
phy usb: phy: twl6030-usb: Fix a resource leak in an error handling path in 'twl6030_usb_probe()' 2020-06-03 08:21:12 +02:00
renesas_usbhs usb: renesas_usbhs: Clear pipe running flag in usbhs_pkt_pop() 2021-02-10 09:25:28 +01:00
roles usb: roles: fix a potential use after free 2019-12-17 19:55:46 +01:00
serial USB: serial: option: Adding support for Cinterion MV31 2021-02-10 09:25:26 +01:00
storage usb: uas: Add PNY USB Portable SSD to unusual_uas 2021-01-12 20:16:19 +01:00
typec usb: typec: Fix copy paste error for NVIDIA alt-mode description 2021-01-19 18:26:16 +01:00
usbip usb: usbip: vhci_hcd: protect shift size 2021-01-12 20:16:19 +01:00
Kconfig usb: common: create Kconfig file 2019-09-03 19:00:39 +02:00
Makefile USB: Changes for v5.4 merge window 2019-09-02 19:20:57 +02:00
usb-skeleton.c USB: usb-skeleton: drop redundant in-urb check 2019-10-10 12:41:19 +02:00