Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1535910pxb; Sun, 12 Sep 2021 23:06:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/a0lkShB0Ee6UKcDxmhSaptPt4ueXwEJQyCbxcspXIuCa9p+BIl45Ih8R6MGzsC05+PkG X-Received: by 2002:a5e:9603:: with SMTP id a3mr4613692ioq.158.1631513177079; Sun, 12 Sep 2021 23:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631513177; cv=none; d=google.com; s=arc-20160816; b=eJTipA23FlUTs9+gnAO5o/64rZfY7CLiFovGQQ7f2tvQr18L8HjzwNbNKwvT23aB6N Xezfq5m0YJJf5u5daRPRbTd+3oCvZkVEwHDTjFxhU9NBvirXWjexXE84uRSoV14ACXQ9 wMNEVZtKKlIBZEhzn5DfOQ6fnFHwvbNZ1dYhq44KGkR1bd0p17JwSjzeWn7KbYYl38LX X8Ck41Wr4vWn2sTfVSJZkAS72bA9nOu2Y/g8U82ZJSGGEj+oWD6Q8qiDMDUpKLA3ndmg Lu9yjAbncnjnVGdmbxmiZorh1kXI5vHeLOXxvPDMI7Nwq5wj45zMmzXSMatZek4FjDT5 mYMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=+5Xs0J4Mr+muGFCKM/M0tfvw1V4aiPopFCIWFjx+D7w=; b=tKxSsYoaNZCtwZ3QurKr7w6Va1+MgBJGRxUU1GU0bQVwlZfPqHBiZ/WmFDGRAmD8qR UHGUMfs7sX4pY0O5RVj4fhGmFBbga63NhlGQMVY6V2wfuqm2cdD0CalOllaEKy2hvVFr 0oC4chHrniiYic2lcjZK9PNmDyy23u8axsEnztbYENKqMTpFoVDLxaAkqZCb6fSq82YO YZSSf7yeGyDjKl4P6gON7t1Mbx66w3Ob5aFvSzaY1UVdwj/HKYIRkgwPvFW6erkaWQXW x1ie2qUWXttcMbNTb5pSxH+HErm35FEHDF+cbdJJknnHbv1pukUOSoMJmllMJdwcGLhz U8ww== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j4si5874129jaa.83.2021.09.12.23.06.06; Sun, 12 Sep 2021 23:06:17 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237462AbhIMGFt (ORCPT + 99 others); Mon, 13 Sep 2021 02:05:49 -0400 Received: from inva020.nxp.com ([92.121.34.13]:56708 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237328AbhIMGFj (ORCPT ); Mon, 13 Sep 2021 02:05:39 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E8F2A1A28C1; Mon, 13 Sep 2021 08:04:22 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id AC2D61A2058; Mon, 13 Sep 2021 08:04:22 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 53DF1183AC88; Mon, 13 Sep 2021 14:04:21 +0800 (+08) From: Richard Zhu To: l.stach@pengutronix.de, bhelgaas@google.com, lorenzo.pieralisi@arm.com Cc: linux-pci@vger.kernel.org, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, Richard Zhu Subject: [PATCH v2 4/5] PCI: imx6: Fix the clock reference handling unbalance when link never came up Date: Mon, 13 Sep 2021 13:41:09 +0800 Message-Id: <1631511670-30164-5-git-send-email-hongxing.zhu@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1631511670-30164-1-git-send-email-hongxing.zhu@nxp.com> References: <1631511670-30164-1-git-send-email-hongxing.zhu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When link never came up, driver probe would be failed with error -110. To keep usage counter balance of the clocks, disable the previous enabled clocks when link is down. Move definitions of the imx6_pcie_clk_disable() function to the proper place. Because it wouldn't be used in imx6_pcie_suspend_noirq() only. Signed-off-by: Richard Zhu --- drivers/pci/controller/dwc/pci-imx6.c | 47 ++++++++++++++------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 1729a77caffd..ab292d9cd528 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -514,6 +514,29 @@ static int imx6_pcie_clk_enable(struct imx6_pcie *imx6_pcie) return ret; } +static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie) +{ + clk_disable_unprepare(imx6_pcie->pcie); + clk_disable_unprepare(imx6_pcie->pcie_phy); + clk_disable_unprepare(imx6_pcie->pcie_bus); + + switch (imx6_pcie->drvdata->variant) { + case IMX6SX: + clk_disable_unprepare(imx6_pcie->pcie_inbound_axi); + break; + case IMX7D: + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, + IMX7D_GPR12_PCIE_PHY_REFCLK_SEL); + break; + case IMX8MQ: + clk_disable_unprepare(imx6_pcie->pcie_aux); + break; + default: + break; + } +} + static void imx7d_pcie_wait_for_phy_pll_lock(struct imx6_pcie *imx6_pcie) { u32 val; @@ -853,6 +876,7 @@ static int imx6_pcie_start_link(struct dw_pcie *pci) dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG0), dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG1)); imx6_pcie_reset_phy(imx6_pcie); + imx6_pcie_clk_disable(imx6_pcie); if (imx6_pcie->vpcie && regulator_is_enabled(imx6_pcie->vpcie) > 0) regulator_disable(imx6_pcie->vpcie); return ret; @@ -941,29 +965,6 @@ static void imx6_pcie_pm_turnoff(struct imx6_pcie *imx6_pcie) usleep_range(1000, 10000); } -static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie) -{ - clk_disable_unprepare(imx6_pcie->pcie); - clk_disable_unprepare(imx6_pcie->pcie_phy); - clk_disable_unprepare(imx6_pcie->pcie_bus); - - switch (imx6_pcie->drvdata->variant) { - case IMX6SX: - clk_disable_unprepare(imx6_pcie->pcie_inbound_axi); - break; - case IMX7D: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, - IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, - IMX7D_GPR12_PCIE_PHY_REFCLK_SEL); - break; - case IMX8MQ: - clk_disable_unprepare(imx6_pcie->pcie_aux); - break; - default: - break; - } -} - static int imx6_pcie_suspend_noirq(struct device *dev) { struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); -- 2.25.1