Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp170630imd; Wed, 31 Oct 2018 16:44:42 -0700 (PDT) X-Google-Smtp-Source: AJdET5eiU2+/i6GAJupsLo+RfM7se/XJv8yX9gU+MhVD5Hc9BRcPFUxZcikGvOmB/f4otebjiXHK X-Received: by 2002:a63:ce56:: with SMTP id r22-v6mr4973505pgi.217.1541029482497; Wed, 31 Oct 2018 16:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029482; cv=none; d=google.com; s=arc-20160816; b=dCibW0wtHFpOEWKJ6bGAXmNncPKpx+dJ516S8nVDCR2G3IGGu7FKObbz5MD0Z5gzdv BjR6igOv2GVSZmRIwHOu8qOZ5JDpg6Uz3KDqoI5T6Ioi2QyBfCmc1LYSMxstolWGpGaS 2miFet9MD4CO4i7/wsSgRZtkDofwtz9rHiFj4Sb53nFaSwCVM+mN/ucHIhjIBvjxGgjo Gyy1v43NygYUZTvi+bVx63qbMXlbgbGgxNjnAqFKhTPYEsMuZwiXr4s3yEwhbplebGJp 0zmKWk8Z5X1oc7zi70GIPuKVZN+shhMuOVRMY2mwpcxan4NaoIOdZlmMFH9e3HrTCVGL Tqdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=4KIjNh9n9l9nGZfxSRlQ8mxOZsQtdYcAJXSe4wKr11Q=; b=if/6LkC8Yx5Gb5phaKVAjZStlG5Oor3c4MV5XHqQqG+KURjViXd5dKg32EO8ayCFdp p5EJgUb3UaqgGZMVNjZlf58u4iulnLyCLwb8CqBsHaAQrlSVIsgXWbrGzyoWFeJ2mejU OZDUjOhwaenwktB+0+cFyHd3izgqxPKnxsj/rO7zjRnyvuyG25APnBULhAep4/09fQ2M tnxIK6XLQWusnAVAYxnmjo+rsLdqop3Xj0wf1y0ZYsvUNlNXjXffTEw2AFxB0zKiBxbp EZk0Ti47IkzYLazkm06bKVprGEFgM3h2kgwXn5zbOe7qINoO+nb0kQA6AMuOFtxkWP1d +wpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=may7O7MG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v189si17793548pgb.398.2018.10.31.16.44.28; Wed, 31 Oct 2018 16:44:42 -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; dkim=pass header.i=@kernel.org header.s=default header.b=may7O7MG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729019AbeKAIHh (ORCPT + 99 others); Thu, 1 Nov 2018 04:07:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:55538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727308AbeKAIHh (ORCPT ); Thu, 1 Nov 2018 04:07:37 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AECCE20821; Wed, 31 Oct 2018 23:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027246; bh=XVtZjroNJog4pqqkdzhBADTcruVXl7CTn5CWVT6ZmvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=may7O7MGAaIZHYV2YlynbA7pjbfCV3eDEIOf8CzUfJmcqwIwDe0S7+vyCNLb8UG+D ziS1RN1eZXgKEDe6hxhauU6z+UdZJtrB06zm+uDjhQVMsuwvGHAI0G54ndKBoW42gS nY+IQcF7L4DBvnd3BYLnXwshOwqBMOnMJl3hmOVQ= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Fabrice Gasnier , Amelie Delaunay , Felipe Balbi , Sasha Levin Subject: [PATCH AUTOSEL 4.19 115/146] usb: dwc2: fix a race with external vbus supply Date: Wed, 31 Oct 2018 19:05:10 -0400 Message-Id: <20181031230541.28822-115-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabrice Gasnier [ Upstream commit 41ee1ea21052583eaf5487dfa0d0c907c9667548 ] 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") Tested-by: Artur Petrosyan Acked-by: Minas Harutyunyan Signed-off-by: Fabrice Gasnier Signed-off-by: Amelie Delaunay Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- 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 befaf1e9d98a..260010abf9d8 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4393,6 +4393,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"); @@ -4408,6 +4409,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"); @@ -4417,7 +4425,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.17.1