Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3482128imu; Sun, 11 Nov 2018 16:06:21 -0800 (PST) X-Google-Smtp-Source: AJdET5feZ60gGj1PZpI++nfdjBVW8BSZJO2uwWhs7YPAwoclTqF9vsEWnO54M5Wwb5Wav+bVLAzu X-Received: by 2002:a63:2109:: with SMTP id h9mr15453990pgh.277.1541981181432; Sun, 11 Nov 2018 16:06:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981181; cv=none; d=google.com; s=arc-20160816; b=ptLZaIPtg2JTi5fZCYoJb5zmezi+FXbwXw0gcFmbyQ/p6A49JGqTQn7gxWyELmedWv ma/yP76cqxwt34FeSmp1lIklF6AKNC4d2Ikrt1KD0dJ/k36AFPbhQDBHiDt6VcVJgl+W nVSyiewg78eY67kr6i6XwOVCxAAv6OXuRQ+yh0xV/GY4Xb6G7LZDtaxso9jrdKtCiYE0 h8dDR/QKVzL2EsaruXVSa3+zj1aEQDSDzZne7HYMJPFn7N9tH/XSLoLK4VHrRyVZPZEw sk8DVtoyi5rHJiVc+hPIZQ8iof6Yb+gCuxpNNAn2GKh1f7YR7Nd1x74lEuTRSofEvGhn 4njQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Wy1cWbGS4o8yhvmbbVzTOXy5mabCsGMV9dc3DvxuCuU=; b=nQK5mKXoncLm25qkv2LJlhUfXSnDJeU27m+HD4wU7YW4jhq9xhVIvR1YZpYGQLX5Rv mCIVwnIVbEa6ZERAGxYKQk2mgkQHajqS9IEBRKxKfAaz6ZlPfFTDBbVNri26ZrmwGKGw fWe+gu+P54Sk383qLlGZtvMLL/0Ki3R+wBlRKFcDfq5yt1UbrU8Q6Rbk7Y8vCNcKkY++ cVdSYs9g8htDmUnJcjjGRQryJn3A5Z7R4QsXvJ75OfHB3dIIXGP8LX8BljHIsEeLT9tN L961GdTOvGhJvLmLs6JlsJgR8T7d3FPYGNC6Bfv71mZ4+o90/7aDt8qAPY/HoAtLK/o1 O0HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gNJfIbBz; 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 w13-v6si13552207pgj.229.2018.11.11.16.06.06; Sun, 11 Nov 2018 16:06:21 -0800 (PST) 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=gNJfIbBz; 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 S1732092AbeKLJ4L (ORCPT + 99 others); Mon, 12 Nov 2018 04:56:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:34236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731883AbeKLIRm (ORCPT ); Mon, 12 Nov 2018 03:17:42 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EE21B2175B; Sun, 11 Nov 2018 22:27:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975267; bh=jnB/hu/SX8v56LNH2lEMbXwYxzsLGyeM1rIQ8X7KxDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gNJfIbBzBCsrJ4cOHJFge2hxWkH1ZSaDA402irIGIuoY+Sg3Geouu8uli5oUAjZ0d ZpCp1aon2A3QRgLzhcwNX4qTLukn+IZgyp+kzHyTNP46PUrJzZEO9zR8ApA3d+zQFq g9o6b9ItA/1CWQgmYdZ1/CBLL6Q4taVSgOVW9DAk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Artur Petrosyan , Minas Harutyunyan , Fabrice Gasnier , Amelie Delaunay , Felipe Balbi , Sasha Levin Subject: [PATCH 4.19 159/361] usb: dwc2: fix a race with external vbus supply Date: Sun, 11 Nov 2018 14:18:26 -0800 Message-Id: <20181111221642.798047180@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/hcd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4393,6 +4393,7 @@ static int _dwc2_hcd_start(struct usb_hc 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_hc 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_hc spin_unlock_irqrestore(&hsotg->lock, flags); - return dwc2_vbus_supply_init(hsotg); + return 0; } /*