From patchwork Fri Apr 19 11:24:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Petrosyan X-Patchwork-Id: 10909745 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4EB721850 for ; Fri, 19 Apr 2019 20:05:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 404EC1FF83 for ; Fri, 19 Apr 2019 20:05:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3493725223; Fri, 19 Apr 2019 20:05:55 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 7EC431FFB1 for ; Fri, 19 Apr 2019 20:05:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728107AbfDSUFw (ORCPT ); Fri, 19 Apr 2019 16:05:52 -0400 Received: from dc8-smtprelay2.synopsys.com ([198.182.47.102]:36768 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727648AbfDSUFw (ORCPT ); Fri, 19 Apr 2019 16:05:52 -0400 Received: from mailhost.synopsys.com (dc2-mailhost2.synopsys.com [10.12.135.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 6E32FC1204; Fri, 19 Apr 2019 11:24:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1555673051; bh=mDfjAdqkxm57zYxGNUScbQgq9XZasF4HeMVlaQdfjyE=; h=From:To:CC:Subject:Date:References:In-Reply-To:From; b=lxf5zJhPy03d/HFG0ogt6HcnIFTkpqjNZ0wD0We7qdduMjCk+/GBUQ8ne9Gb5mNSm svAaM4Mi4+agvGigucyB8Z8J+svA2h0O507k+sET0LcQu3HsLcrB5ruNP5jvAJ3CXU 8ftQuSqTvnc/6tb/rUjxfoy+Ug5FK+t6rXmkBRqLIb06VB25KuC/L4BAKePsBv/xQa B9JEdt0kvfDmy1BTMrBuy6hw1cawMrzXmYr5qbsNjrwMhqF3pA/8xo9e2Hpz5NzJuX 1Y9riIWdIygqf3XwFtP6lN7SK2XVUAKvu/bpGF+3MYYY+ViRW4IXqV5JA3FtCPeApQ A2QO1YQWZVikw== Received: from US01WEHTC2.internal.synopsys.com (us01wehtc2.internal.synopsys.com [10.12.239.237]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPS id 9711EA0096; Fri, 19 Apr 2019 11:24:10 +0000 (UTC) Received: from US01HYBRID2.internal.synopsys.com (10.15.246.24) by US01WEHTC2.internal.synopsys.com (10.12.239.237) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 19 Apr 2019 04:24:10 -0700 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (10.13.134.195) by mrs.synopsys.com (10.15.246.24) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 19 Apr 2019 04:24:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=synopsys.onmicrosoft.com; s=selector1-synopsys-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mDfjAdqkxm57zYxGNUScbQgq9XZasF4HeMVlaQdfjyE=; b=QLAdtW8RpqC+TynmpOxThHaks+lS7qXHhWlYAGwlCqynnQLoIIDMZrNSsEorFxlGwcZaFCQ4sp84Ay1uUT12QkjNl8492uFLi4l2kezXsSadReDIBEuSFX6M2+H6EwOebxnu2hhUqWfsuMECqSMv5FbehDiNm/JzXnWJk/pd5J0= Received: from SN1PR12MB2431.namprd12.prod.outlook.com (52.132.195.146) by SN1PR12MB2383.namprd12.prod.outlook.com (52.132.194.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.14; Fri, 19 Apr 2019 11:24:08 +0000 Received: from SN1PR12MB2431.namprd12.prod.outlook.com ([fe80::5ca6:ee5f:1147:df5a]) by SN1PR12MB2431.namprd12.prod.outlook.com ([fe80::5ca6:ee5f:1147:df5a%4]) with mapi id 15.20.1813.013; Fri, 19 Apr 2019 11:24:08 +0000 From: Artur Petrosyan To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , "linux-usb@vger.kernel.org" CC: John Youn , Artur Petrosyan Subject: [PATCH v1 04/14] usb: dwc2: Fix suspend state in host mode for partial power down. Thread-Topic: [PATCH v1 04/14] usb: dwc2: Fix suspend state in host mode for partial power down. Thread-Index: AQHU9qJndp/MtkcCnkCl/ua6u6qX5g== Date: Fri, 19 Apr 2019 11:24:08 +0000 Message-ID: <0dc725c7e9956eedaf03bb5d68a7d5e856d8cb5a.1555672441.git.arturp@synopsys.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR02CA0049.eurprd02.prod.outlook.com (2603:10a6:802:14::20) To SN1PR12MB2431.namprd12.prod.outlook.com (2603:10b6:802:27::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=arturp@synopsys.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [84.53.141.191] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 58d3cdbc-b86d-467d-a049-08d6c4b98956 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600141)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020);SRVR:SN1PR12MB2383; x-ms-traffictypediagnostic: SN1PR12MB2383: x-microsoft-antispam-prvs: x-forefront-prvs: 0012E6D357 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(396003)(39850400004)(346002)(136003)(366004)(199004)(189003)(110136005)(316002)(2616005)(54906003)(68736007)(99286004)(15650500001)(478600001)(8936002)(2501003)(64756008)(52116002)(73956011)(66946007)(118296001)(66446008)(3846002)(6116002)(66066001)(8676002)(36756003)(14454004)(386003)(186003)(305945005)(2906002)(4326008)(102836004)(6436002)(26005)(486006)(256004)(25786009)(53936002)(14444005)(476003)(71200400001)(71190400001)(6512007)(86362001)(107886003)(5660300002)(97736004)(81156014)(446003)(76176011)(6506007)(7736002)(6486002)(11346002)(66476007)(66556008)(81166006);DIR:OUT;SFP:1102;SCL:1;SRVR:SN1PR12MB2383;H:SN1PR12MB2431.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: synopsys.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: v37jbZOe+wBG6RU87uMpVFSbg+czv1/zwYNIuWe9QSNqktAEaLCwxmACAVr/lQeLrCQ3dFgLajCIMe88lMgSjyYWUzAyxogbW7qGzXx3SDorj4APjNtQlsvZexsCWsU+Kcxsm6LVB/z+isNQJ9ep2FVTihHBxxg7YXapLdce6/G97NEt/LDmlHGRvD5n7bxF4Ajp1k5uxPWTcwlb7j3PqFHdMa4CU6JF3R9QEEinZA97sTbMsmVDiap0DD8GWuWBirc2iGkKs0iueT9nbd+Q37L/ue0oZH0vP4glwrL++YsALeucYj/oo5a3RavEhCITXHDzP0+At2YT9GNdOLJpvbEi7E/ff1WGlp5sH5M2Y7raqqjqsxTBM8tILLsxhEW44H4XPIv4ZVTeklCKBLi+Wh7CRl0+bnnKXZretD5lgw4= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 58d3cdbc-b86d-467d-a049-08d6c4b98956 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Apr 2019 11:24:08.3892 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: c33c9f88-1eb7-4099-9700-16013fd9e8aa X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2383 X-OriginatorOrg: synopsys.com Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP - In dwc2_port_suspend() function added waiting for the HPRT0.PrtSusp register field to be set. - In _dwc2_hcd_suspend() function added checking of "hsotg->flags.b.port_connect_status" port connection status if port connection status is 0 then skipping power saving (entering partial power down mode). Because if there is no device connected there would be no need to enter partial power down mode. - Added "hsotg->bus_suspended = true" beceuse after entering partial power down in host mode the bus_suspended flag must be set. Signed-off-by: Artur Petrosyan --- drivers/usb/dwc2/hcd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index dd82fa516f3f..1d18258b5ff8 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3479,6 +3479,10 @@ static void dwc2_port_suspend(struct dwc2_hsotg *hsotg, u16 windex) hprt0 |= HPRT0_SUSP; dwc2_writel(hsotg, hprt0, HPRT0); + /* Wait for the HPRT0.PrtSusp register field to be set */ + if (dwc2_hsotg_wait_bit_set(hsotg, HPRT0, HPRT0_SUSP, 3000)) + dev_warn(hsotg->dev, "Suspend wasn't generated\n"); + hsotg->bus_suspended = true; /* @@ -4488,7 +4492,8 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd) if (hsotg->op_state == OTG_STATE_B_PERIPHERAL) goto unlock; - if (hsotg->params.power_down != DWC2_POWER_DOWN_PARAM_PARTIAL) + if (hsotg->params.power_down != DWC2_POWER_DOWN_PARAM_PARTIAL || + hsotg->flags.b.port_connect_status == 0) goto skip_power_saving; /* @@ -4514,6 +4519,8 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd) goto skip_power_saving; } + hsotg->bus_suspended = true; + /* Ask phy to be suspended */ if (!IS_ERR_OR_NULL(hsotg->uphy)) { spin_unlock_irqrestore(&hsotg->lock, flags);