diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockchip.c index e267a65ebaca..afdb6cb1f437 100644 --- a/drivers/usb/dwc3/dwc3-rockchip.c +++ b/drivers/usb/dwc3/dwc3-rockchip.c @@ -408,7 +408,8 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work) unsigned long flags; int ret; int val; - u32 reg, count; + u32 reg; + u32 count = 0; mutex_lock(&rockchip->lock); @@ -442,6 +443,16 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work) udelay(1); reset_control_deassert(rockchip->otg_rst); + /* Wait until dwc3 core resume from PM suspend */ + while (dwc->dev->power.is_suspended) { + if (++count > 1000) { + dev_err(rockchip->dev, + "wait for dwc3 core resume timeout!\n"); + goto out; + } + usleep_range(100, 200); + } + pm_runtime_get_sync(rockchip->dev); pm_runtime_get_sync(dwc->dev); } else { @@ -574,7 +585,6 @@ disconnect: if (hcd->state != HC_STATE_HALT) { xhci->xhc_state |= XHCI_STATE_REMOVING; - count = 0; /* * Wait until XHCI controller resume from