From 4849e6cab6aef1fa466e18f3b96090f05b33ca07 Mon Sep 17 00:00:00 2001 From: Jianwei Zheng Date: Thu, 19 Sep 2024 10:29:46 +0800 Subject: [PATCH] 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: c74c26f6e398 ("usb: dwc2: Fix partial power down exiting by system resume") Change-Id: I34d449f1286c8122883aedcd830f2744f1a2267d Signed-off-by: Jianwei Zheng --- drivers/usb/dwc2/hcd.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 35d855272030..771e734f808b 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -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,