• S
    usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based one · c52b3fb3
    Serge Semin 提交于
    stable inclusion
    from stable-5.10.7
    commit 97abe6663fa35c40edb2efebdc3aea8bad71086c
    bugzilla: 47429
    
    --------------------------------
    
    commit fca3f138 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: 88bc9d19 ("usb: dwc3: add ULPI interface support")
    Acked-by: NHeikki Krogerus <heikki.krogerus@linux.intel.com>
    Signed-off-by: NSerge 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: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: NChen Jun <chenjun102@huawei.com>
    Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
    c52b3fb3
ulpi.c 2.5 KB