From patchwork Tue Jan 16 06:26:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manu Gautam X-Patchwork-Id: 10166077 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8EF56601E7 for ; Tue, 16 Jan 2018 06:27:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B87520501 for ; Tue, 16 Jan 2018 06:27:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F1B92821F; Tue, 16 Jan 2018 06:27:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE5E72623D for ; Tue, 16 Jan 2018 06:27:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750725AbeAPG1D (ORCPT ); Tue, 16 Jan 2018 01:27:03 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:43290 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750716AbeAPG1C (ORCPT ); Tue, 16 Jan 2018 01:27:02 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9FA9A6021C; Tue, 16 Jan 2018 06:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516084021; bh=3YLtX9Ff+4gNxxiNGrx5efYJd7BAh6OBYhqfoQsB6RQ=; h=From:To:Cc:Subject:Date:From; b=Wbkw5XGT9QBezZ2eONurj933ymz5ncgQySVuTkvLbm522mOehWHqh4uZTo/enAGrC YsjQoHv6VSfMyeHSMI2w79DYwCgk5tB+H1wPuVyDp54+pyyzr7SesY57Zsw80NW7OM UYY5JjnQE9JnVl+x5FiEqeXgNuidsxargeoJGCpI= Received: from mgautam-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4B9206021C; Tue, 16 Jan 2018 06:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516084021; bh=3YLtX9Ff+4gNxxiNGrx5efYJd7BAh6OBYhqfoQsB6RQ=; h=From:To:Cc:Subject:Date:From; b=Wbkw5XGT9QBezZ2eONurj933ymz5ncgQySVuTkvLbm522mOehWHqh4uZTo/enAGrC YsjQoHv6VSfMyeHSMI2w79DYwCgk5tB+H1wPuVyDp54+pyyzr7SesY57Zsw80NW7OM UYY5JjnQE9JnVl+x5FiEqeXgNuidsxargeoJGCpI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4B9206021C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mgautam@codeaurora.org From: Manu Gautam To: Felipe Balbi Cc: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, Roger Quadros , Manu Gautam Subject: [PATCH] usb: dwc3: core: Power-off core/PHYs on system_suspend in host mode Date: Tue, 16 Jan 2018 11:56:29 +0530 Message-Id: <1516083989-2129-1-git-send-email-mgautam@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Fixes: 689bf72c6e0d ("usb: dwc3: Don't reinitialize core during host bus-suspend/resume") Signed-off-by: Manu Gautam --- drivers/usb/dwc3/core.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 0783250..e9fbee9 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -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;