CHROMIUM: usb: dwc: rockchip: Fix xhci access problems

If the system is in runtime suspended state, and the system is running
on battery, removing HCDs results in a crash with the following
backtrace.

[<ffffffc000666e98>] xhci_quiesce+0x20/0x64
[<ffffffc000666f14>] xhci_halt+0x38/0x98
[<ffffffc00066769c>] xhci_stop+0x74/0x1bc
[<ffffffc00063ad70>] usb_remove_hcd+0x104/0x1e0
[<ffffffc000651494>] dwc3_rockchip_otg_extcon_evt_work+0x54/0x158
[<ffffffc000239200>] process_one_work+0x240/0x424

Refactor the code to remove HDCs if no cable is inserted. Also power off
PHys in that case. Reconnect HDCs on driver removal to avoid crashes
there (xhci code does not expect and thus not handle out-of-sync HCD
removal).

BUG=chrome-os-partner:57530
TEST=Connect and disconnect USB3 device while running on battery
TEST=Load and unload dwc3_rockchip module repeatedly

Change-Id: I890cb88056e07a6de8edf6bd86f3df755e316f35
Signed-off-by: Guenter Roeck <groeck@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/387005
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
1 file changed