usb: dwc2: fix dwc2 resume failed when device is connected

Current code if the device is connected and do _dwc2_hcd_resume(),
it will goto unlock and exit this function, cause some dwc2
controllers that does not support Partial Power Down mode resume
failed and perform the following error log:

    usb 2-1: reset high-speed USB device number 2 using dwc2
    usb 2-1: device descriptor read/64, error -110
    usb 2-1: device descriptor read/64, error -110

Fixes: c74c26f6e3 ("usb: dwc2: Fix partial power down exiting by
system resume")
Change-Id: I34d449f1286c8122883aedcd830f2744f1a2267d
Signed-off-by: Jianwei Zheng <jianwei.zheng@rock-chips.com>
This commit is contained in:
Jianwei Zheng
2024-09-19 10:29:46 +08:00
committed by Tao Huang
parent 8dd21a945d
commit 4849e6cab6

View File

@@ -4447,20 +4447,19 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd)
if (hsotg->lx_state != DWC2_L2)
goto unlock;
hprt0 = dwc2_read_hprt0(hsotg);
/*
* Added port connection status checking which prevents exiting from
* Partial Power Down mode from _dwc2_hcd_resume() if not in Partial
* Power Down mode.
*/
if (hprt0 & HPRT0_CONNSTS) {
hsotg->lx_state = DWC2_L0;
goto unlock;
}
switch (hsotg->params.power_down) {
case DWC2_POWER_DOWN_PARAM_PARTIAL:
hprt0 = dwc2_read_hprt0(hsotg);
/*
* Added port connection status checking which prevents exiting from
* Partial Power Down mode from _dwc2_hcd_resume() if not in Partial
* Power Down mode.
*/
if (hprt0 & HPRT0_CONNSTS) {
hsotg->lx_state = DWC2_L0;
goto unlock;
}
ret = dwc2_exit_partial_power_down(hsotg, 0, true);
if (ret)
dev_err(hsotg->dev,