usb: dwc3: fix runtime pm when current_dr_role is not set

The current runtime suspend/resume do nothing when the
current_dr_role is not set. It may fail to do core init
in some scenes.

Test on RK3588 EVB2 or NVR Demo which have Type-A OTG
port, without this patch, the USB ADB enumeration failed
occasionally. When this error happens, we can find that
the register GUSB2PHYCFG(0) isn't initialized correctly.

It's because that during dwc3 probe, if the drd_work which
called from dwc3_drd_init() is scheduled behind the runtime
suspend process, the current_dr_role will be uninitialized,
this cause the runtime resume process doing nothing and put
the dwc3 phy in uninitialized status.

This patch add dwc3_core_init and dwc3_core_exit operation
for runtime suspend/resume when the current_dr_role is not
initialized.

Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: I294bcf2ad68136e9eb24a9e4a1ad389e73c974d2
This commit is contained in:
William Wu
2022-02-28 20:09:41 +08:00
committed by Tao Huang
parent a521e711b1
commit 223064da40

View File

@@ -1841,7 +1841,8 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
dwc3_core_exit(dwc);
break;
default:
/* do nothing */
if (!pm_runtime_suspended(dwc->dev))
dwc3_core_exit(dwc);
break;
}
@@ -1908,7 +1909,9 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
break;
default:
/* do nothing */
ret = dwc3_core_init_for_resume(dwc);
if (ret)
return ret;
break;
}