Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3798076ybi; Mon, 29 Jul 2019 12:50:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkLP7FLtmtLImMavVSnsoeotEVfbDX217zJI+uae8t9/Gz9WfDLm6pkPPDqgXEzyivh1Sm X-Received: by 2002:a17:902:9a07:: with SMTP id v7mr4098541plp.245.1564429814313; Mon, 29 Jul 2019 12:50:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429814; cv=none; d=google.com; s=arc-20160816; b=eSH26o1DrZNAJqSceiQ5jegsAI7QuVdzkhV5L2PoyjJ13m4dVpeOta4OouuBFu/Uz0 LLMmwkRcXdjDAb3+T5MB0/V7mteN7Ngv+9Yqx5UesKoq7vkg2uQfDb+fx2VO/5nKIC0e if8CPAW3WvzVIhHxfwKW4HR8vyAP4Dy3gewyCeC9ut7npa61ZeHB1T4hWJypPLtbh4zf MctoSd7aM4xZm3/yqUD3iqqw4uSjv+JDsP7EPlq7SELV+14Azriylcns9qJM0VzO7Du3 xo/wtZnaHkoraxLQ3/byTK+Vwlz9To1t2R9xrh2ZoZow1O2EwzjvJj5GCJmpTnZCmmsv RztA== 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=vOw9GeHD08KD3znWhxTgpm4LX5nRtzsoiDNhNQMG62g=; b=p5RUzEqpq6FgXwFp3BOLd3p2iq4TPQ9nlGY+C/y0XmC/TKAvVShz/VBzje4lRUsnUw Jc8CGAO1Im7P3tj+77Dj4RvmFTgdjDkDUj+Hr6q1vNNVjJVYfWj++CtecIAcwX+hpvPp KXHGYKUedooY4SpDVQijkvH7qno6EY5Qfpz++0F1wPQnZmbYiC8qnuEAic/QLKw5NaFw IxXq+tSCxB0gPXsQcbpKLfqfSN3Vb0/vFoGYgk9/f3caTuuzeGbPH3uAUiGELVfqmU5T 6KqBz++9DMLF2EvgwKBm27vm+yaBSlap4U3yGRqLvpcHeU255IFUTdxyuC3ej6lRyHqo HRsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jy313OOk; 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 g11si55565673plm.390.2019.07.29.12.49.59; Mon, 29 Jul 2019 12:50:14 -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=Jy313OOk; 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 S2390423AbfG2Tso (ORCPT + 99 others); Mon, 29 Jul 2019 15:48:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:38982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390410AbfG2Tsj (ORCPT ); Mon, 29 Jul 2019 15:48:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 9CA68205F4; Mon, 29 Jul 2019 19:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429719; bh=Drb7JSB57DtMotOFpPRiaDsEWKfqyiq2kMzgnVjtx9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jy313OOk5zUuXc4T8FfHA6LDIRq2x/u064DtiqKNzbpm3wWnAeyjodJfoEIH1yQPL 4cgw/hX2NQFcQl43794K2JMUFdH07pLijY2i4I+q7FzYptSVEk8bkNvwtV95mi74oo cLhySnN8vtA5MHE95WdBVHxS1mDgPqkX5PFvpTXU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Enric Balletbo i Serra , Felipe Balbi , Sasha Levin Subject: [PATCH 5.2 071/215] usb: dwc3: Fix core validation in probe, move after clocks are enabled Date: Mon, 29 Jul 2019 21:21:07 +0200 Message-Id: <20190729190752.561773195@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit dc1b5d9aed1794b5a1c6b0da46e372cc09974cbc ] The required clocks needs to be enabled before the first register access. After commit fe8abf332b8f ("usb: dwc3: support clocks and resets for DWC3 core"), this happens when the dwc3_core_is_valid function is called, but the mentioned commit adds that call in the wrong place, before the clocks are enabled. So, move that call after the clk_bulk_enable() to ensure the clocks are enabled and the reset deasserted. I detected this while, as experiment, I tried to move the clocks and resets from the glue layer to the DWC3 core on a Samsung Chromebook Plus. That was not detected before because, in most cases, the glue layer initializes SoC-specific things and then populates the child "snps,dwc3" with those clocks already enabled. Fixes: b873e2d0ea1ef ("usb: dwc3: Do core validation early on probe") Signed-off-by: Enric Balletbo i Serra Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/dwc3/core.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 4aff1d8dbc4f..6e9e172010fc 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1423,11 +1423,6 @@ static int dwc3_probe(struct platform_device *pdev) dwc->regs = regs; dwc->regs_size = resource_size(&dwc_res); - if (!dwc3_core_is_valid(dwc)) { - dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n"); - return -ENODEV; - } - dwc3_get_properties(dwc); dwc->reset = devm_reset_control_get_optional_shared(dev, NULL); @@ -1460,6 +1455,12 @@ static int dwc3_probe(struct platform_device *pdev) if (ret) goto unprepare_clks; + if (!dwc3_core_is_valid(dwc)) { + dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n"); + ret = -ENODEV; + goto disable_clks; + } + platform_set_drvdata(pdev, dwc); dwc3_cache_hwparams(dwc); @@ -1525,6 +1526,7 @@ static int dwc3_probe(struct platform_device *pdev) pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); +disable_clks: clk_bulk_disable(dwc->num_clks, dwc->clks); unprepare_clks: clk_bulk_unprepare(dwc->num_clks, dwc->clks); -- 2.20.1