Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3699353imm; Wed, 5 Sep 2018 04:42:00 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb2gjyHSNjUXCLaEPGxqeYz+Ro860ATe85LMfLxt5btou/e1jhyQg4teooP06TZXX4s79bw X-Received: by 2002:a63:6a89:: with SMTP id f131-v6mr18927293pgc.165.1536147720539; Wed, 05 Sep 2018 04:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536147720; cv=none; d=google.com; s=arc-20160816; b=bjsP1nCEY+gKpzoGxO0Xy0DpogxSz4IvMcg/QfEEaUf5k9fN0yThGnvEdbxVx/etjk bzljroRazdpF/YC1uCYIBvh7NCDMdQftvP1jBTYp8vjnyw4H5ikyxTpYBdPyhScMX0VB SEGOJC/2QX2kCoA0JMPx69dOGn/UGf40bv6FCRsyebGHOOXob7cIA9HyWMTVPDl57CfW 5JilycbWArr42neM2um/FLCN9nnKzY4P1/wOhRXyuVsH9fOFZSjwYs2y4bIkofV16m3K aNM9ueaKRwEmURltlhq+GCY1wVwrBcQBvrELi6vIeIg59wfmILzXHE8P/7Pgan0LSP3x HMCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=BvCJ4Dd0OwGgbqzFyYq4X4Q5hrVUEkfDxxHPK/fZUzk=; b=qhSA+ddlIjb/RObgnTNFGQdtxykh7sRP8chg096KEd9Tw7cTGHBzAwTJzTalzkPwuh jb4XMTFtwg+g6K4ckH4g7rIEyQPAvDUdLcidKdLzkyCfY/mG+69nPJs9V0PanBjlsAcz bvR/oQHCUSQT5DPBILb+ZhTIznLMFxAcoCwwEp3VzytJeAsjnxSw+Yumi35GokeZiOiK gUMzp5ZLzE6vhGCK/UyDs1zmpQU71bvqZIjW1LikAcCKApCxzs6B8/OZ3xqB2D/zMwO8 1r2ox7SIFYtaiKT3Vm/Ip9FHxUt5LSfBM5X6i/Jn8B0NHPHpbr1u8eSM+DGzoOw2Pm8T dQYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id az1-v6si1575900plb.513.2018.09.05.04.41.43; Wed, 05 Sep 2018 04:42:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727565AbeIEQKX (ORCPT + 99 others); Wed, 5 Sep 2018 12:10:23 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:40662 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726046AbeIEQKV (ORCPT ); Wed, 5 Sep 2018 12:10:21 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w85BYIgO004475; Wed, 5 Sep 2018 13:40:25 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2m7g7wxh5x-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 05 Sep 2018 13:40:25 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C5A4A31; Wed, 5 Sep 2018 11:40:24 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A364E2B7E; Wed, 5 Sep 2018 11:40:24 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by SAFEX1HUBCAS23.st.com (10.75.90.46) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 5 Sep 2018 13:40:24 +0200 Received: from localhost (10.201.20.5) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 5 Sep 2018 13:40:24 +0200 From: Amelie Delaunay To: Minas Harutyunyan , Felipe Balbi , Greg Kroah-Hartman CC: , , , Fabrice Gasnier , Amelie Delaunay Subject: [PATCH 2/4] usb: dwc2: fix a race with external vbus supply Date: Wed, 5 Sep 2018 13:40:03 +0200 Message-ID: <1536147605-26279-3-git-send-email-amelie.delaunay@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536147605-26279-1-git-send-email-amelie.delaunay@st.com> References: <1536147605-26279-1-git-send-email-amelie.delaunay@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.201.20.5] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-05_07:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabrice Gasnier There's a race with root hub resume, when using external vbus supply. Root hub gets resumed, but runtime pm autosuspend runs as external vbus supply isn't enabled. So, host never exit from power down properly. Initialize vbus external supply before, rater that after hub resume. Fixes: 531ef5ebea96 ("usb: dwc2: add support for host mode external vbus supply") Signed-off-by: Fabrice Gasnier Signed-off-by: Amelie Delaunay --- drivers/usb/dwc2/hcd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index c205cfa..bb72517 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4387,6 +4387,7 @@ static int _dwc2_hcd_start(struct usb_hcd *hcd) struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); struct usb_bus *bus = hcd_to_bus(hcd); unsigned long flags; + int ret; dev_dbg(hsotg->dev, "DWC OTG HCD START\n"); @@ -4402,6 +4403,13 @@ static int _dwc2_hcd_start(struct usb_hcd *hcd) dwc2_hcd_reinit(hsotg); + /* enable external vbus supply before resuming root hub */ + spin_unlock_irqrestore(&hsotg->lock, flags); + ret = dwc2_vbus_supply_init(hsotg); + if (ret) + return ret; + spin_lock_irqsave(&hsotg->lock, flags); + /* Initialize and connect root hub if one is not already attached */ if (bus->root_hub) { dev_dbg(hsotg->dev, "DWC OTG HCD Has Root Hub\n"); @@ -4411,7 +4419,7 @@ static int _dwc2_hcd_start(struct usb_hcd *hcd) spin_unlock_irqrestore(&hsotg->lock, flags); - return dwc2_vbus_supply_init(hsotg); + return 0; } /* -- 2.7.4