usb: dwc3: core: Power-off core/PHYs on system_suspend in host mode
Subsystems (3)
PATCH 1/1 usb: dwc3: core: Power-off core/PHYs on system_suspend in host mode
Commit 689bf72c6e0d ("usb: dwc3: Don't reinitialize core during host bus-suspend/resume") updated suspend/resume routines to not power_off and reinit PHYs/core for host mode.
It broke platforms that rely on DWC3 core to power_off PHYs to enter low power state on system suspend.
Perform dwc3_core_exit/init only during host mode system_suspend/ resume to addresses power regression from above mentioned patch and also allow USB session to stay connected across runtime_suspend/resume in host mode.
--- drivers/usb/dwc3/core.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/usb/dwc3/core.c +15 -8
@@ -1279,7 +1279,7 @@ static int dwc3_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int dwc3_suspend_common (struct dwc3 *dwc) +static int dwc3_suspend_common (struct dwc3 *dwc,pm_message_t msg) {unsigned long flags;
@@ -1292,14 +1292,16 @@ static int dwc3_suspend_common(struct dwc3 *dwc)break ;case DWC3_GCTL_PRTCAP_HOST :default : -/* do nothing */ +/* do nothing during host runtime_suspend */ +if (!PMSG_IS_AUTO (msg)) +dwc3_core_exit (dwc);break ; }return 0 ; } -static int dwc3_resume_common (struct dwc3 *dwc) +static int dwc3_resume_common (struct dwc3 *dwc,pm_message_t msg) {unsigned long flags;int ret;
@@ -1316,7 +1318,12 @@ static int dwc3_resume_common(struct dwc3 *dwc)break ;case DWC3_GCTL_PRTCAP_HOST :default : -/* do nothing */ +/* nothing to do on host runtime_resume */ +if (!PMSG_IS_AUTO (msg)) { + ret =dwc3_core_init (dwc); +if (ret) +return ret; + }break ; }
@@ -1348,7 +1355,7 @@ static int dwc3_runtime_suspend(struct device *dev)if (dwc3_runtime_checks (dwc))return -EBUSY ; - ret =dwc3_suspend_common (dwc); + ret =dwc3_suspend_common (dwc,PMSG_AUTO_SUSPEND );if (ret)return ret;
@@ -1364,7 +1371,7 @@ static int dwc3_runtime_resume(struct device *dev)device_init_wakeup (dev, false); - ret =dwc3_resume_common (dwc); + ret =dwc3_resume_common (dwc,PMSG_AUTO_RESUME );if (ret)return ret;
@@ -1411,7 +1418,7 @@ static int dwc3_suspend(struct device *dev)struct dwc3 *dwc =dev_get_drvdata (dev);int ret; - ret =dwc3_suspend_common (dwc); + ret =dwc3_suspend_common (dwc,PMSG_SUSPEND );if (ret)return ret;
@@ -1427,7 +1434,7 @@ static int dwc3_resume(struct device *dev)pinctrl_pm_select_default_state (dev); - ret =dwc3_resume_common (dwc); + ret =dwc3_resume_common (dwc,PMSG_RESUME );if (ret)return ret;
Manu,
Quoted 31 lines · Manu Gautam
Commit
689bf72c6e0d("usb: dwc3: Don't reinitialize core during host bus-suspend/resume") updated suspend/resume routines to notpower_offand reinit PHYs/core for host mode.
It broke platforms that rely on DWC3 core topower_offPHYs to enter low power state on system suspend.Perform dwc3_core_exit/init only during host mode system_suspend/ resume to addresses power regression from above mentioned patch and also allow USB session to stay connected across runtime_suspend/resume in host mode.
Fixes 689bf72c6e0d ("usb: dwc3: Don't reinitialize core during host bus-suspend/resume")Signed-off-by Manu Gautam <[email protected]>--- drivers/usb/dwc3/core.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)drivers/usb/dwc3/core.c +1
-1@@ -1279,7 +1279,7 @@ static int dwc3_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int dwc3_suspend_common (struct dwc3 *dwc) +static int dwc3_suspend_common (struct dwc3 *dwc,pm_message_t msg) {unsigned long flags;
drivers/usb/dwc3/core.c static int dwc3_suspend_common(struct dwc3 *dwc) · line 1298
Quoted 8 lines
drivers/usb/dwc3/core.c +3
-1@@ -1292,14 +1292,16 @@ static int dwc3_suspend_common(struct dwc3 *dwc)break ;case DWC3_GCTL_PRTCAP_HOST :default : -/* do nothing */ +/* do nothing during host runtime_suspend */ +if (!PMSG_IS_AUTO (msg)) +dwc3_core_exit (dwc);break ;
since we're now doing something specific to HOST case we need to separate out the 'default' case so,
+ default:
+ break;
Quoted 12 lines
drivers/usb/dwc3/core.c +1
-1}return 0 ; } -static int dwc3_resume_common (struct dwc3 *dwc) +static int dwc3_resume_common (struct dwc3 *dwc,pm_message_t msg) {unsigned long flags;int ret;@@ -1316,7 +1318,12 @@ static int dwc3_resume_common(struct dwc3 *dwc)break ;
drivers/usb/dwc3/core.c static int dwc3_resume_common(struct dwc3 *dwc) · line 1327
Quoted 10 lines
drivers/usb/dwc3/core.c +6
-1case DWC3_GCTL_PRTCAP_HOST :default : -/* do nothing */ +/* nothing to do on host runtime_resume */ +if (!PMSG_IS_AUTO (msg)) { + ret =dwc3_core_init (dwc); +if (ret) +return ret; + }break ;
same here.
Quoted 31 lines
drivers/usb/dwc3/core.c +3
-3}@@ -1348,7 +1355,7 @@ static int dwc3_runtime_suspend(struct device *dev)if (dwc3_runtime_checks (dwc))return -EBUSY ; - ret =dwc3_suspend_common (dwc); + ret =dwc3_suspend_common (dwc,PMSG_AUTO_SUSPEND );if (ret)return ret;@@ -1364,7 +1371,7 @@ static int dwc3_runtime_resume(struct device *dev)device_init_wakeup (dev, false); - ret =dwc3_resume_common (dwc); + ret =dwc3_resume_common (dwc,PMSG_AUTO_RESUME );if (ret)return ret;@@ -1411,7 +1418,7 @@ static int dwc3_suspend(struct device *dev)struct dwc3 *dwc =dev_get_drvdata (dev);int ret; - ret =dwc3_suspend_common (dwc); + ret =dwc3_suspend_common (dwc,PMSG_SUSPEND );if (ret)return ret;
drivers/usb/dwc3/core.c static int dwc3_resume(struct device *dev) · line 1440
Quoted 8 lines
drivers/usb/dwc3/core.c +1
-1@@ -1427,7 +1434,7 @@ static int dwc3_resume(struct device *dev)pinctrl_pm_select_default_state (dev); - ret =dwc3_resume_common (dwc); + ret =dwc3_resume_common (dwc,PMSG_RESUME );if (ret)return ret;
You also need to fix-up
index e9fbee9..a213295 100644
drivers/usb/dwc3/core.c +2 -3
@@ -1333,12 +1333,11 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)static int dwc3_runtime_checks (struct dwc3 *dwc) {switch (dwc->current_dr_role) { -case USB_DR_MODE_PERIPHERAL : -case USB_DR_MODE_OTG : +case DWC3_GCTL_PRTCAP_DEVICE :if (dwc->connected)return -EBUSY ;break ; -case USB_DR_MODE_HOST : +case DWC3_GCTL_PRTCAP_HOST :default :/* do nothing */ break ;
and finally
index a213295..728955c 100644
drivers/usb/dwc3/core.c +1 -1
@@ -218,7 +218,7 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)* XHCI driver will reset the host block. If dwc3 was configured for * host-only mode, then we can return early. */ -if (dwc->dr_mode ==USB_DR_MODE_HOST ) +if (dwc->current_dr_role ==DWC3_GCTL_PRTCAP_HOST )return 0 ; reg =dwc3_readl (dwc->regs,DWC3_DCTL );
After these changes applied, I could get suspend/resume working properly on dra7x-evm for host, device and dual-role cases.
Signature · 8 lines
cheers, -roger Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Roger,
Quoted 4 lines · Roger Quadros
Manu,
On 16/01/18 08:26, Manu Gautam wrote:
[snip]
Quoted 3 lines
After these changes applied, I could get suspend/resume working properly on dra7x-evm for host, device and dual-role cases.
Thanks Roger. I will incorporate these changes as well.
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html