From patchwork Fri Apr 12 13:38:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Petrosyan X-Patchwork-Id: 10898381 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 EDCE714DB for ; Fri, 12 Apr 2019 13:38:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC92D28A62 for ; Fri, 12 Apr 2019 13:38:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAD6028ED2; Fri, 12 Apr 2019 13:38:59 +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 57F4728A62 for ; Fri, 12 Apr 2019 13:38:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbfDLNi6 (ORCPT ); Fri, 12 Apr 2019 09:38:58 -0400 Received: from smtprelay.synopsys.com ([198.182.60.111]:41170 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726624AbfDLNi6 (ORCPT ); Fri, 12 Apr 2019 09:38:58 -0400 Received: from mailhost.synopsys.com (dc8-mailhost1.synopsys.com [10.13.135.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtprelay.synopsys.com (Postfix) with ESMTPS id 6D48A10C21A8; Fri, 12 Apr 2019 06:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1555076338; bh=oPx08AyJTpoqv0scWKB2fCluOZU2FZxMwAD3CD8Py7c=; h=From:To:CC:Subject:Date:References:In-Reply-To:From; b=LkWHbS8hCb8EfjZWKHxcV5zzmHmupPZCha5kEZJu8k2sqy7rDdSEKaWZjssrekXZB yycDZD0HmiofPU8/pP1RUViD49hJrji3PTHzVc7TjOfS7QLIY2HYu4uv8ZMUAvTyzB 4M/+OGz1Gy7zgwBZ8F4y7HZvHhfzZJqkvKr2SGWyXebA88NEDqzH3XWmURRRn+18i3 0oyebxc+fa4A/axHVzUZSx3q9MAO9wnIgQQBMtQOUzKKoJXTfgF2R+4Azw89gSSGZP jwNxIj8514tcbnwvRzOWhmxzpaN1e+YDbNkQxLVp3U0U+RdA9NfqU5W6bbXg2E7uAC NiwZBFn/IHNuA== 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 5F093A006A; Fri, 12 Apr 2019 13:38:58 +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, 12 Apr 2019 06:38:58 -0700 Received: from NAM05-BY2-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, 12 Apr 2019 06:38:58 -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=oPx08AyJTpoqv0scWKB2fCluOZU2FZxMwAD3CD8Py7c=; b=p29d3aP2pNjFwNK1r/3GD1+acsgB3rjY8mcL1zK9azgKqyIv4ohs/xsfbZrue6vufDLksyAgb0CWTXq1JSikeIeF+m086C7ePhMChS7IeEwjAEtHE7szbL+h3f5TvVClCa/fNZbQHx5WqRHE/NxJ9UDRoaFju5lPOMOHrVnGgIk= Received: from SN1PR12MB2431.namprd12.prod.outlook.com (52.132.195.146) by SN1PR12MB0589.namprd12.prod.outlook.com (10.163.208.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.19; Fri, 12 Apr 2019 13:38:56 +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.1771.021; Fri, 12 Apr 2019 13:38:56 +0000 From: Artur Petrosyan To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , "linux-usb@vger.kernel.org" CC: John Youn , Artur Petrosyan Subject: [PATCH 03/14] usb: dwc2: Fix wakeup detected and session request interrupt handlers. Thread-Topic: [PATCH 03/14] usb: dwc2: Fix wakeup detected and session request interrupt handlers. Thread-Index: AQHU8TUTrNB2kRZJNkiYNB9jBPLdtw== Date: Fri, 12 Apr 2019 13:38:56 +0000 Message-ID: <8f99e3ceb45ede4526363bd9b44d417a6b6ff5cd.1555075928.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: VI1PR0302CA0020.eurprd03.prod.outlook.com (2603:10a6:800:e9::30) 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.194] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 43e3975b-1997-430b-422b-08d6bf4c355f x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(2017052603328)(7193020);SRVR:SN1PR12MB0589; x-ms-traffictypediagnostic: SN1PR12MB0589: x-microsoft-antispam-prvs: x-forefront-prvs: 0005B05917 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(346002)(396003)(376002)(39840400004)(136003)(189003)(199004)(52116002)(256004)(76176011)(110136005)(81156014)(68736007)(2906002)(316002)(8936002)(99286004)(54906003)(81166006)(25786009)(86362001)(7736002)(106356001)(305945005)(97736004)(8676002)(71200400001)(478600001)(71190400001)(4326008)(107886003)(118296001)(14454004)(186003)(2501003)(105586002)(476003)(446003)(26005)(66066001)(486006)(386003)(5660300002)(3846002)(6506007)(6512007)(2616005)(6486002)(11346002)(36756003)(6436002)(53936002)(14444005)(6116002)(102836004);DIR:OUT;SFP:1102;SCL:1;SRVR:SN1PR12MB0589;H:SN1PR12MB2431.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A: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: +9TeNfa596dU/oQ2LvU0FVgGmfa75IzBKzAhm9VAkiHvxWn0pT5Ol7dM7+0A9FIjnMegLxtKULOvIX0qPuEsLjYEsYIBhgmZi4O6fRteud1H0iH96IkPPVvPyN8gRjVf3oLIaNr8fvsFlMfz9VMCyl5ODv4MuK/BzeEehzOmzf0kh8Qv+V0PtaHsqspFzTBfudDMg2nG8kTusMnuWMWn5LqCLiAqjenjFc5CAQXgBsN1xhd6l29tmX7V3djJF1YjqNlfVuz7z1wPI3EeZ7/9RlEC1ZaDwjqvaO0zMF/Nib8wlhE3ycaeyAB92XnCLC5HB03lilnhB8ZP2yUXiGOKGKn2hXpL3Jy67SppEN4RIQi0RHTEW+uUKwBaHjKWNcDjrBsW2CyhLX0pwtcBPyTRbwKxLD1TNDDxS7Z1KVAd3M8= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 43e3975b-1997-430b-422b-08d6bf4c355f X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Apr 2019 13:38:56.6158 (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: SN1PR12MB0589 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 host mode port power must be turned on when wakeup detected or session request interrupt is detected. Because, otherwise core wouldn't exit form partial power down. - Turned on the port power by setting HPRT0_PWR bit. - Called dwc2_hcd_connect() function after enabling the power of the port. Signed-off-by: Artur Petrosyan --- drivers/usb/dwc2/core_intr.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c index 19ae2595f1c3..ce523fd2b1b4 100644 --- a/drivers/usb/dwc2/core_intr.c +++ b/drivers/usb/dwc2/core_intr.c @@ -312,6 +312,7 @@ static void dwc2_handle_conn_id_status_change_intr(struct dwc2_hsotg *hsotg) static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg) { int ret; + u32 hprt0; /* Clear interrupt */ dwc2_writel(hsotg, GINTSTS_SESSREQINT, GINTSTS); @@ -320,7 +321,8 @@ static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg) hsotg->lx_state); if (dwc2_is_device_mode(hsotg)) { - if (hsotg->lx_state == DWC2_L2) { + if (hsotg->lx_state == DWC2_L2 && + hsotg->params.power_down == 1) { ret = dwc2_exit_partial_power_down(hsotg, true); if (ret && (ret != -ENOTSUPP)) dev_err(hsotg->dev, @@ -332,6 +334,14 @@ static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg) * established */ dwc2_hsotg_disconnect(hsotg); + } else { + /* Turn on the port power bit. */ + hprt0 = dwc2_read_hprt0(hsotg); + hprt0 |= HPRT0_PWR; + dwc2_writel(hsotg, hprt0, HPRT0); + + /* Connect hcd after port power is set. */ + dwc2_hcd_connect(hsotg); } } @@ -396,6 +406,7 @@ static void dwc2_wakeup_from_lpm_l1(struct dwc2_hsotg *hsotg) static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg) { int ret; + u32 hprt0; /* Clear interrupt */ dwc2_writel(hsotg, GINTSTS_WKUPINT, GINTSTS); @@ -426,8 +437,6 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg) /* Change to L0 state */ hsotg->lx_state = DWC2_L0; } else { - if (hsotg->params.power_down) - return; if (hsotg->lx_state != DWC2_L1) { u32 pcgcctl = dwc2_readl(hsotg, PCGCTL); @@ -435,6 +444,15 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg) /* Restart the Phy Clock */ pcgcctl &= ~PCGCTL_STOPPCLK; dwc2_writel(hsotg, pcgcctl, PCGCTL); + + /* Turn on the port power bit. */ + hprt0 = dwc2_read_hprt0(hsotg); + hprt0 |= HPRT0_PWR; + dwc2_writel(hsotg, hprt0, HPRT0); + + /* Connect hcd. */ + dwc2_hcd_connect(hsotg); + mod_timer(&hsotg->wkp_timer, jiffies + msecs_to_jiffies(71)); } else {