Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1194833rwi; Thu, 3 Nov 2022 02:15:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4sKRV5Sq+iDKOkvDbzNciqgq9HXDd/g8v7zbTktcKgdn5fx58v7beGWneTLPSMrso2MQ+w X-Received: by 2002:a17:902:7294:b0:187:146c:316f with SMTP id d20-20020a170902729400b00187146c316fmr23423865pll.149.1667466905624; Thu, 03 Nov 2022 02:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667466905; cv=none; d=google.com; s=arc-20160816; b=G8BONf4cVJ9ssfvT/qzDQqinouvOg8obWUWBE+OyuAckP5xhzB33fwwexiy3HNN8mC A1BSdnKDTz0ZLvYSfAMNyD1/geGc2xqLPQhhJ9qst3V94iPGjTI4xiKYsQpcnG6f+hgQ DUCPxJ7KyRJ8W9qaVQgPkX21Y7ERMLvrxSo1esPTafHBjQnSGRI5rXdPBaMwg+RAK5h8 TG0L73mQo4ZgJzt5ewI6QGkHXq5k5PesQOEvqPWFy0A7LmnluicaSJwAd74GVeAh6H2H 2Glgfi1w/WbvNm0jn74wlqBQuYcnaph0Sx19NUr/7eGZSLXIGbPtfQZXtu+OwvFNT5Mw uKDA== 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:date:cc:to:from:subject :message-id; bh=QR1ZzGP6qdI7XHVv44ffXTaMTfIqC4GxXLnxupGe3G4=; b=F3jJtOxkUSj3bex3rJkOyvHOhTvrXJgUi09uC191hweK80f53/aKFISj42v2UxuHVz QrrAxmDuJoi1WF/HoTtAFX6qbS+ln4m9K80n3c4lQgOWEfrMRlMQw5ycobRXY1qIlR0k 2ei5k9afUweE3ux00A9ulv/dn+m0JPGeywG/BpIE3MdGmgbMkh2UCAPYP+XArJ2pNxPY HcjbQ/kPqEJAEltd1Wy78kDRBQsrSmSbLcl2l6tdbjOAYBqgVJVZrhxy9VwOQ8hzVvo8 3bvOp3GXGeE698giBzkc1KlsZNDVxowt1EGBISYMytBp8TSJuGnHn5JsrodqgpCy8OPL s/UA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id az14-20020a17090b028e00b0021332d10601si499895pjb.183.2022.11.03.02.14.53; Thu, 03 Nov 2022 02:15:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbiKCJLp (ORCPT + 97 others); Thu, 3 Nov 2022 05:11:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiKCJLl (ORCPT ); Thu, 3 Nov 2022 05:11:41 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE95C10DF for ; Thu, 3 Nov 2022 02:11:40 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[IPv6:::1]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oqWG6-0004Sh-Fm; Thu, 03 Nov 2022 10:11:34 +0100 Message-ID: <8561d5ac952d39bf3d1923ca9e3fa651ab1bb531.camel@pengutronix.de> Subject: Re: [PATCH v1] PCI: imx6: Keep the GPIO regulator always on From: Lucas Stach To: Richard Zhu , bhelgaas@google.com, lorenzo.pieralisi@arm.com Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, linux-imx@nxp.com Date: Thu, 03 Nov 2022 10:11:33 +0100 In-Reply-To: <1667455698-14578-1-git-send-email-hongxing.zhu@nxp.com> References: <1667455698-14578-1-git-send-email-hongxing.zhu@nxp.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Donnerstag, dem 03.11.2022 um 14:08 +0800 schrieb Richard Zhu: > Since vpcie regulator is one GPIO regulator, used to control the > VPCIe_3V3 and power up remote PCIe EP device. > > Some WIFI modules load their firmware once in probe, and can't be > powered off during suspend. Otherwise, these WIFI modules wouldn't be > functional anymore after resume back. I would call this a bug in the WiFi driver. I think we need to walk down the PCIe hierarchy to see if it is safe to disable the PCIe regulator. When all devices in the hierarchy are in D3hot state, we can safely put the whole hierarchy into D3cold by removing power. When any of the devices connected to the RC are in a state other than D3hot, we need to keep the regulator enabled, as those devices may need power in suspend to implement wakeups or other functionality that should be available during suspend. Regards, Lucas > > So, keep this regulator always on in the probe. > > Fixes: a4bb720eeb1e ("PCI: imx6: Turn off regulator when system is in suspend mode") > Signed-off-by: Richard Zhu > --- > drivers/pci/controller/dwc/pci-imx6.c | 24 ++++++++---------------- > 1 file changed, 8 insertions(+), 16 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index 2616585ca5f8..94a89bbf381d 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -926,22 +926,13 @@ static int imx6_pcie_host_init(struct dw_pcie_rp *pp) > struct imx6_pcie *imx6_pcie = to_imx6_pcie(pci); > int ret; > > - if (imx6_pcie->vpcie) { > - ret = regulator_enable(imx6_pcie->vpcie); > - if (ret) { > - dev_err(dev, "failed to enable vpcie regulator: %d\n", > - ret); > - return ret; > - } > - } > - > imx6_pcie_assert_core_reset(imx6_pcie); > imx6_pcie_init_phy(imx6_pcie); > > ret = imx6_pcie_clk_enable(imx6_pcie); > if (ret) { > dev_err(dev, "unable to enable pcie clocks: %d\n", ret); > - goto err_reg_disable; > + return ret; > } > > if (imx6_pcie->phy) { > @@ -974,9 +965,6 @@ static int imx6_pcie_host_init(struct dw_pcie_rp *pp) > phy_exit(imx6_pcie->phy); > err_clk_disable: > imx6_pcie_clk_disable(imx6_pcie); > -err_reg_disable: > - if (imx6_pcie->vpcie) > - regulator_disable(imx6_pcie->vpcie); > return ret; > } > > @@ -991,9 +979,6 @@ static void imx6_pcie_host_exit(struct dw_pcie_rp *pp) > phy_exit(imx6_pcie->phy); > } > imx6_pcie_clk_disable(imx6_pcie); > - > - if (imx6_pcie->vpcie) > - regulator_disable(imx6_pcie->vpcie); > } > > static const struct dw_pcie_host_ops imx6_pcie_host_ops = { > @@ -1263,6 +1248,13 @@ static int imx6_pcie_probe(struct platform_device *pdev) > if (PTR_ERR(imx6_pcie->vpcie) != -ENODEV) > return PTR_ERR(imx6_pcie->vpcie); > imx6_pcie->vpcie = NULL; > + } else { > + ret = regulator_enable(imx6_pcie->vpcie); > + if (ret) { > + dev_err(dev, "failed to enable vpcie regulator: %d\n", > + ret); > + return ret; > + } > } > > imx6_pcie->vph = devm_regulator_get_optional(&pdev->dev, "vph");