Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4150169pxb; Mon, 27 Sep 2021 10:24:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXQhwPbxXxraYfIi/ljF16zje2z7OtktmuKnarxwon0QBn+dpoUj4ZPGiPrGqtKgVDQEEC X-Received: by 2002:aa7:d490:: with SMTP id b16mr1361384edr.189.1632763475535; Mon, 27 Sep 2021 10:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632763475; cv=none; d=google.com; s=arc-20160816; b=MStKiY5hCo/GNSy7STNRASdb9GH7HlMMwDIA0+gFX351ZM9njx7c7w/+aPh65PCO8f 9RxPdLpHj6b+sjuWL23mLjjnY2n5o8EPWdoNSKVNXqNhk3mxO13r+4O2eH2qOLRPWDd1 66I8+lkkfVgTC3DAgjpX47+V7a+QetUB0EQkYuK9ApEinpRFnARXVAetveybGRJ6Nwv1 2B3Qqp4T17P4UaXmcyI21f5lB64pm9pU2F6E7utMkkWN4QqYx+gnGW2mkI6KUcE8LBg7 +IwYEnE3TxeL/a8Fa6jkMaPzx3Q9JhzzDRSj11cgcRJfnRoZTkvClLRM40sIONfe9EkK mpjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=woNIvahgD/iVMLmJP+bWQbdScNWXOFlT2WVLgLbJwp8=; b=hLI5KGIRsoKn6GNKF1syGQXaCQxXG2zNwVo2BBqPg9qv1cepC2czSbBbA2nHeQHUCS ZDzZ8j/YBRde5qJUq+WNUx7Ju/R33jqXFCYQT9hnLosQAJsUe5iygLfAxYIf9hXwIafo yYi2dn2mKyc0F2E+8himf/JaRgQhVpMdC3fDYtRoCOWeOcRq/n2aDXAJlv+JWMhuIMBy CMoDU+/4256W7VakdT23RSOZXwEOwye77+JjTFJJ0zZp/PipRWyqi/3K6TznBqYo6FRe ifP8eXwWwqTUjcV2Az7gZwFgrgYSP5/4BReHRlfx4TJvLh6RzsUgeBbJ2f4YEXGPqUGO YInQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gNGgvwli; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l26si18157865edj.201.2021.09.27.10.24.09; Mon, 27 Sep 2021 10:24:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gNGgvwli; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237695AbhI0RX1 (ORCPT + 99 others); Mon, 27 Sep 2021 13:23:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:38056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237085AbhI0RUb (ORCPT ); Mon, 27 Sep 2021 13:20:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B14CA61352; Mon, 27 Sep 2021 17:13:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632762801; bh=7eUByvsj/1mdEFb3Hz3uRC21VtGbqzQdNjbxs1bahFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gNGgvwliIwyUwfrQi7MsdvfdjuoSXBFuvQXloIo2E7hr/c+Jm9mM092Nnyow/OBzB 6/w2zFH4NfQxqnIL8PC1YO5C2NKZdtmpMPJ2DIWQkD7h4KB8vBSJ/IXtKX10h61Lix IKQei+3TZuVDUjGi0n2BaBTy27jD7iU2u4rA14xo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "faqiang.zhu" , Felipe Balbi , Li Jun , John Stultz Subject: [PATCH 5.14 023/162] usb: dwc3: core: balance phy init and exit Date: Mon, 27 Sep 2021 19:01:09 +0200 Message-Id: <20210927170234.262917900@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210927170233.453060397@linuxfoundation.org> References: <20210927170233.453060397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Li Jun commit 8cfac9a6744fcb143cb3e94ce002f09fd17fadbb upstream. After we start to do core soft reset while usb role switch, the phy init is invoked at every switch to device mode, but its counter part de-init is missing, this causes the actual phy init can not be done when we really want to re-init phy like system resume, because the counter maintained by phy core is not 0. considering phy init is actually redundant for role switch, so move out the phy init from core soft reset to dwc3 core init where is the only place required. Fixes: f88359e1588b ("usb: dwc3: core: Do core softreset when switch mode") Cc: Tested-by: faqiang.zhu Tested-by: John Stultz #HiKey960 Acked-by: Felipe Balbi Signed-off-by: Li Jun Link: https://lore.kernel.org/r/1631068099-13559-1-git-send-email-jun.li@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/core.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -264,19 +264,6 @@ static int dwc3_core_soft_reset(struct d { u32 reg; int retries = 1000; - int ret; - - usb_phy_init(dwc->usb2_phy); - usb_phy_init(dwc->usb3_phy); - ret = phy_init(dwc->usb2_generic_phy); - if (ret < 0) - return ret; - - ret = phy_init(dwc->usb3_generic_phy); - if (ret < 0) { - phy_exit(dwc->usb2_generic_phy); - return ret; - } /* * We're resetting only the device side because, if we're in host mode, @@ -310,9 +297,6 @@ static int dwc3_core_soft_reset(struct d udelay(1); } while (--retries); - phy_exit(dwc->usb3_generic_phy); - phy_exit(dwc->usb2_generic_phy); - return -ETIMEDOUT; done: @@ -982,9 +966,21 @@ static int dwc3_core_init(struct dwc3 *d dwc->phys_ready = true; } + usb_phy_init(dwc->usb2_phy); + usb_phy_init(dwc->usb3_phy); + ret = phy_init(dwc->usb2_generic_phy); + if (ret < 0) + goto err0a; + + ret = phy_init(dwc->usb3_generic_phy); + if (ret < 0) { + phy_exit(dwc->usb2_generic_phy); + goto err0a; + } + ret = dwc3_core_soft_reset(dwc); if (ret) - goto err0a; + goto err1; if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD && !DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) {