From patchwork Wed May 8 10:52:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 10934937 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 134C91515 for ; Wed, 8 May 2019 10:52:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0355A2018E for ; Wed, 8 May 2019 10:52:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 019F928515; Wed, 8 May 2019 10:52:43 +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 06E3D2018E for ; Wed, 8 May 2019 10:52:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727090AbfEHKwl (ORCPT ); Wed, 8 May 2019 06:52:41 -0400 Received: from mail-eopbgr20081.outbound.protection.outlook.com ([40.107.2.81]:61670 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726281AbfEHKwk (ORCPT ); Wed, 8 May 2019 06:52:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IEwdnRNb0dQnFatowUgaozQwav2yrmUA9bOT5poJmlg=; b=SCRQyE2OlTAFevdaWvI9f/wySvivukaLWWutPuuoVt2TKHjoxtaAURN9bRLW9W6r9mRjGReU3I9+7y1D6RNIyL0Jx3g7Fk1EHK9tuzNLKn6Soi0f57ft3OB1uldlndtK1rmJC1zBx8sytTjwSHEVCFrVbXpdLVHU5DuhqMXf4+8= Received: from VI1PR04MB4558.eurprd04.prod.outlook.com (20.177.55.216) by VI1PR04MB4046.eurprd04.prod.outlook.com (10.171.182.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1856.11; Wed, 8 May 2019 10:52:37 +0000 Received: from VI1PR04MB4558.eurprd04.prod.outlook.com ([fe80::7c70:2812:86ad:7e1c]) by VI1PR04MB4558.eurprd04.prod.outlook.com ([fe80::7c70:2812:86ad:7e1c%3]) with mapi id 15.20.1856.012; Wed, 8 May 2019 10:52:37 +0000 From: Jun Li To: "balbi@kernel.org" , "gregkh@linuxfoundation.org" CC: "thinhn@synopsys.com" , "linux-usb@vger.kernel.org" , dl-linux-imx Subject: [PATCH v2] usb: dwc3: move core validation to be after clks enable Thread-Topic: [PATCH v2] usb: dwc3: move core validation to be after clks enable Thread-Index: AQHVBYwmwgoFIPzeoU+y0VWKj8yWsw== Date: Wed, 8 May 2019 10:52:37 +0000 Message-ID: <1557311367-5863-1-git-send-email-jun.li@nxp.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HK0PR03CA0032.apcprd03.prod.outlook.com (2603:1096:203:2f::20) To VI1PR04MB4558.eurprd04.prod.outlook.com (2603:10a6:803:6f::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=jun.li@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.71] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 53a6f603-1a3b-4e00-4a9a-08d6d3a348b5 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020);SRVR:VI1PR04MB4046; x-ms-traffictypediagnostic: VI1PR04MB4046: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-forefront-prvs: 0031A0FFAF x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(376002)(136003)(396003)(366004)(346002)(189003)(199004)(44832011)(14454004)(36756003)(68736007)(256004)(14444005)(7736002)(6486002)(486006)(478600001)(2616005)(476003)(6436002)(6116002)(2906002)(4326008)(2501003)(3846002)(54906003)(110136005)(25786009)(316002)(6512007)(53936002)(66066001)(8936002)(386003)(50226002)(6506007)(102836004)(186003)(81166006)(26005)(8676002)(81156014)(99286004)(305945005)(52116002)(66476007)(66556008)(66446008)(64756008)(86362001)(66946007)(73956011)(5660300002)(71200400001)(71190400001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB4046;H:VI1PR04MB4558.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Ce4FDakzlEP/ZJlrLU6Ji5O158CGm2+Jy39GPY/xXet1Fhvfc8NkbuOpLrgShdZpU3rTdUo4sNVB2mNv7rJNH2fI6A+tH1X61wFEe1rGwpWXTOSPGzkyy2G5I0it/tR8UDzpFwdDAlWOqP5+obCTL38ZZGiKQ8ufsW29iAJIOOimUQQZP9NZ3R13F5VRNhekptoKgbUJ8n8ZK81zZliBRzG/YiRbo9Vn6MDPlafc9kZ6v54JyZvMD5FQ2GKLwd0YP0S4+a0IM48wzJyd5Y7lS5Jf601Zy40/UU3NqTEZ+4qVAAeq+v17QmygqwRjcZLS941A2WBU6kQ26MAIC7OLq2GLV93BcsOzHGaUYBHWRGC7fJJdITk9dNmWMU3lgQEEjF+mSI9bIQoWM3CsdIzWyzInfINz0RUTUzFLxv71srM= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53a6f603-1a3b-4e00-4a9a-08d6d3a348b5 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 May 2019 10:52:37.5176 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4046 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 From: Jun Li Register access in core validation may hang before the bulk clks are enabled. Fixes: b873e2d0ea1e ("usb: dwc3: Do core validation early on probe") Signed-off-by: Jun Li Tested-by: Baruch Siach --- Change for v2: - Update ret to be -ENODEV in case dwc3_core_is_valid() fail. drivers/usb/dwc3/core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 4aff1d8..93b96e6 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); @@ -1524,7 +1525,7 @@ static int dwc3_probe(struct platform_device *pdev) err1: 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);