usb: dwc3: Improve erratic errors events handling

In rare cases if the controller is unable to communicate with the
PHY it will trigger an ERRATIC ERROR event, upon which it is
recommended that the controller be reset. Currently the reset
is scheduled to be performed in a workqueue, which relinquishes
the dwc3_interrupt handler to continue to process the event buffer.
Meanwhile if the reset runs concurrently, it would disable the core
clock resulting in unclocked I/O access if the gadget interrupt handler
continues to run. Fix this by bailing out from ISR and prevent further
interrupts from reading DWC3 registers until the reset sequence has
completed.
As sometimes after receiving erratic event controller is generating
interrupt storm even if driver acknowledges events generated after erratic
events. This continues until block reset happens from wq and may result in
watchdog bark. To prevent this assert core soft reset and wait until
erratic event recovery is performed which brings the core out of reset for
normal operation.
The current handling of erratic errors that occur in peripheral
mode does so by scheduling a block reset. Since this occurs
asynchronously, additional changes needed to be made to ensure
the device controller would not generate spurious events or
try to access any registers while the reset was in progress
and the clocks were off. Even after that, the controller would
still not be functional until a cable reconnect since the block
reset routine did not do anything to re-establish the peripheral
session.

Instead, improve the erratic error handling to simulate a
cable disconnection-reconnection sequence. The forced disconnect
should solve issues related to post-error events as well as
prevent any function drivers from continuing to issue endpoint
commands. This is followed with the controller entering low
power mode. If the cable is still physically connected, then
invoke a reconnection which does the full reset and power-on
initialization sequence that is more complete than the current
block reset. The USB session would then get re-enumerated.

Change-Id: I45ccb30ff12064e5410d45c423a404d97b299022
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Azhar Shaikh<azhars@codeaurora.org>
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
4 files changed