From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A071DCCA473 for ; Wed, 15 Jun 2022 23:31:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=0KGwJHewApgv+ioscJ6XoZ0WbRa0jtGOcAKwgeKdecQ=; b=wbGIgAKhhu7Ieh 35hLeohnLuedvPWD/CKYFWSG4d3JTeOwSs6EI1dzxHP6CYOFTbu+x8u3Y7pGEUaUS9Z+kFciUILG3 V7KWTZAz/OZcqcL+DRhEJvVGeRWUWGePKbzF7RyfjOw4Zqkqg+TzcegeCdqvszKsdjrJDojVxxKW5 1EkpFd/0qsRVOd+wq0U0D03RMUbwCLN4JAQ0aG5NqW8W4YTQ1RW6XPr/LKmbC16j+MQ0WcRqurZIB p+p6ZPQqecjplPZ5sF4S9OERQrncG8J/IK0hIUzeYJeDfogygYnsX5SuoYLIWBo2N4pTTvsxPC+XR SBTT0mJ6wfbY8MW9aMWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1cTD-00Gv6G-FF; Wed, 15 Jun 2022 23:30:43 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1cT9-00Gv5D-Pr for linux-arm-kernel@lists.infradead.org; Wed, 15 Jun 2022 23:30:41 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4509CB821F6; Wed, 15 Jun 2022 23:30:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 896C9C3411A; Wed, 15 Jun 2022 23:30:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655335836; bh=NkGdwcHxieMFTnxcLUDpVG1NsmlVZE1ng59v2HePfHs=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=fZ7NOe2wEdNeY2Sxi+NzxnePqsVz7AOn0lEgBd27kAkCQHO2AHr3vjNKWatx4cUkt zdDdDuuH0Vdx98KO07Ctd40jiedhbAT0EPsD9HDTkJUXz1TLf7ubc7aSghroYa8E/8 g/ARZ+xDANnbeM0p3tjWpFW96jTqvv+CdtKUaFvN/qlMiUOSx0zkbh7k3Ff6N/57UY lbZAz6B/xhCZupXRGzNtFkCVEClabozaXN9iuKWPwwsBwqVqWSStWekLlsmKjN2DOB AeuOuZ1rPo4D6Xuw4BmTpMI8hwOccMoIcSyJ0K0Nz/Nr+K7u2VNf5Bn9WOLmJjj6qH MaunSnULKDWZQ== Date: Wed, 15 Jun 2022 18:30:34 -0500 From: Bjorn Helgaas To: Richard Zhu , Lucas Stach , Rob Herring , Mark Brown , Lorenzo Pieralisi , Fabio Estevam , Francesco Dolcini Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, linux-imx@nxp.com, Bjorn Helgaas Subject: Re: [PATCH v12 09/13] PCI: imx6: Turn off regulator when system is in suspend mode Message-ID: <20220615233034.GA1056086@bhelgaas> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220615231551.1054753-10-helgaas@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220615_163040_201806_63BB9F1A X-CRM114-Status: GOOD ( 28.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jun 15, 2022 at 06:15:47PM -0500, Bjorn Helgaas wrote: > From: Richard Zhu > > The driver should undo any enables it did itself. The regulator disable > shouldn't be basing decisions on regulator_is_enabled(). > > Move the regulator_disable to the suspend function, turn off regulator when > the system is in suspend mode. > > To keep the balance of the regulator usage counter, disable the regulator > in shutdown. > > Link: https://lore.kernel.org/r/1655189942-12678-6-git-send-email-hongxing.z > hu@nxp.com > Signed-off-by: Richard Zhu > Signed-off-by: Bjorn Helgaas > --- > drivers/pci/controller/dwc/pci-imx6.c | 19 +++++++------------ > 1 file changed, 7 insertions(+), 12 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index 6eddd0b5f628..537b8a2e0e3b 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -670,8 +670,6 @@ static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie) > > static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) > { > - struct device *dev = imx6_pcie->pci->dev; > - > switch (imx6_pcie->drvdata->variant) { > case IMX7D: > case IMX8MQ: > @@ -702,14 +700,6 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) > break; > } > > - if (imx6_pcie->vpcie && regulator_is_enabled(imx6_pcie->vpcie) > 0) { > - int ret = regulator_disable(imx6_pcie->vpcie); > - > - if (ret) > - dev_err(dev, "failed to disable vpcie regulator: %d\n", > - ret); > - } > - > /* Some boards don't have PCIe reset GPIO. */ > if (gpio_is_valid(imx6_pcie->reset_gpio)) > gpio_set_value_cansleep(imx6_pcie->reset_gpio, > @@ -722,7 +712,7 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) > struct device *dev = pci->dev; > int ret, err; > > - if (imx6_pcie->vpcie && !regulator_is_enabled(imx6_pcie->vpcie)) { > + if (imx6_pcie->vpcie) { > ret = regulator_enable(imx6_pcie->vpcie); > if (ret) { > dev_err(dev, "failed to enable vpcie regulator: %d\n", > @@ -796,7 +786,7 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) > return 0; > > err_clks: > - if (imx6_pcie->vpcie && regulator_is_enabled(imx6_pcie->vpcie) > 0) { > + if (imx6_pcie->vpcie) { > ret = regulator_disable(imx6_pcie->vpcie); > if (ret) > dev_err(dev, "failed to disable vpcie regulator: %d\n", > @@ -1023,6 +1013,9 @@ static int imx6_pcie_suspend_noirq(struct device *dev) > break; > } > > + if (imx6_pcie->vpcie) > + regulator_disable(imx6_pcie->vpcie); This is a little bit ugly because imx6_pcie_suspend_noirq() and imx6_pcie_resume_noirq() are not symmetric. We call regulator_disable() directly here in imx6_pcie_suspend_noirq(), but the corresponding regulator_enable() is buried in imx6_pcie_deassert_core_reset(). It would be nicer if the suspend and resume paths looked more similar, as rockchip_pcie_suspend_noirq() and rockchip_pcie_resume_noirq() do, for example. > return 0; > } > > @@ -1269,6 +1262,8 @@ static void imx6_pcie_shutdown(struct platform_device *pdev) > > /* bring down link, so bootloader gets clean state in case of reboot */ > imx6_pcie_assert_core_reset(imx6_pcie); > + if (imx6_pcie->vpcie) > + regulator_disable(imx6_pcie->vpcie); > } > > static const struct imx6_pcie_drvdata drvdata[] = { > -- > 2.25.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel