Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1322858rwi; Thu, 3 Nov 2022 04:05:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM63cc/67fyw7XjQIrVrTej11xc08vM0rK50TMyefwdQS7IaAP05ypUUzD8lKmUt64lbmEgA X-Received: by 2002:a63:e446:0:b0:470:2c91:44c4 with SMTP id i6-20020a63e446000000b004702c9144c4mr608477pgk.536.1667473504335; Thu, 03 Nov 2022 04:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667473504; cv=none; d=google.com; s=arc-20160816; b=dHIg1YEN+u1dq/pUZnCPlnLO6Nbv8VFsgCRRSu2Rovn7sFNseFLighGcIWlevNXgMf VlP/J3PkVIayuUijczYwpcDbDgpgVMzCB9sZ3FwyhWL5KzxSWMZHGozTWZHG5y7uLBF1 drJpdMT4uC9fKLFkh5aOgJM0YAAnryJpLYxmWzwhkp7pTbk3fvkPWeQ7WhNCUF+W/v5+ oepjUYDMNfiquN/gIwbWjBjRwmTgaW1HTrAITC+y9vSZP4NX2N6/OridI3MKqKum7W1f KmXG4XSovMeCBlAS1CwgGDvBjAfB1lLhH5DKVhT8Kfh01cmrnm0vD7fQNl8+3saByAJf jRLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=SyzQAn22rU5bdpDTOD671JbEpCzeGTbfuS8q3QyiVJo=; b=wvrZWxqxg+7x7hRgh9ULn/ZL/l0upcwLEJH9TPKKxJIoc7lLt52DY2uBkTV/xkpJp6 9ZCZrtIAp/eBTQQKhw2ib9G/YYTz9F9geCiIitQqGw+u0rjkSpgbk2hXw8kLFhX0gq2X S5yxMGzpZmXybq3uFyBtZhHjVWsAeO2cPzdAgltezw6grMQkGdCzvzlyr0X4GjsaZ3BU HUjvkJ+qzRawCDkJM6bHhU2uLHwX5UZqCLKw36KcVunFH5ABtO5EXy+Ejt1foyPKqo0G hR3bFnqBEukrr5Xuw6gGg6+kq2JZGBFkCTcJ2Q5fvbMaL9fbKr19KrK2UIFmTmUIGnEo 80Hg== 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 k189-20020a633dc6000000b00438ce28758csi759351pga.136.2022.11.03.04.04.44; Thu, 03 Nov 2022 04:05:04 -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 S230383AbiKCKaB (ORCPT + 98 others); Thu, 3 Nov 2022 06:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbiKCKaA (ORCPT ); Thu, 3 Nov 2022 06:30:00 -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 0A8A4DF34 for ; Thu, 3 Nov 2022 03:29:59 -0700 (PDT) Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1oqXTv-0007JU-G1; Thu, 03 Nov 2022 11:29:55 +0100 Message-ID: Date: Thu, 3 Nov 2022 11:29:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH v1] PCI: imx6: Keep the GPIO regulator always on Content-Language: en-US To: Hongxing Zhu , "l.stach@pengutronix.de" , "bhelgaas@google.com" , "lorenzo.pieralisi@arm.com" Cc: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , dl-linux-imx , "kernel@pengutronix.de" , "linux-arm-kernel@lists.infradead.org" References: <1667455698-14578-1-git-send-email-hongxing.zhu@nxp.com> From: Ahmad Fatoum In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: a.fatoum@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,NICE_REPLY_A, 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 Hello Richard, On 03.11.22 09:05, Hongxing Zhu wrote: >> -----Original Message----- >> From: Ahmad Fatoum >> On 03.11.22 07:08, Richard Zhu wrote: >>> 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. >> >> The brcmfmac OTOH, reprobes when resuming from suspend. Before this patch, >> AFAIU, it should've been possible for the EP to go into D3cold during suspend. >> This may no longer be possible when we keep vpcie powered. >> > Oh, understood. In the other words, the EP wouldn't be in D3 mode when vpcie > is always powered on, right? > Thanks for your detailed explains. D3cold specifically, which is the state the device enters when supply voltage is cut. Devices enter D3hot programmatically and in this case device supply voltage remains powered. >> Prior to a4bb720eeb1e, vpcie was briefly toggled during PCIe core reset >> sequence, so aforementioned WiFi modules that don't reprobe over resume >> should've been broken by that too? If so, I don't see how it fixes that commit >> as everything that is broken now was broken before that commit as well. After >> this patch however, modules that can accept vpcie being toggled can't benefit >> from some of the power saving. > The WIFI modules that don't re-probe over resume are always broken, if the > vpcie is toggled during suspend/resume, I think. > > BTW, is the re-probe over resume mandatory requirements for EP devices > (for example, WIFI modules)? I only looked at brcmfmac. > I'm curious that how the WIFI remote wake up going on if the WIFI module > is totally powered off. Device may be in D3cold, but link is at L2, so there's still auxiliary power for device to support wake on (wired) LAN. No idea how prevalent this is for Wake on Wireless LAN. >> Why can't users with this issue use a regulator-always-on regulator instead? > Yes, you're right. > One regulator-always-on regulator is a good idea. That's what I do on my side as well, because we didn't want the interface to briefly disappear and reappear during suspend. Cheers, Ahmad > >> >>> 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; >>> + } >> >> Shouldn't the regulator enable be undone if the probe later fails? >> > Yes, it's required. > Thanks a lot for your comments. > > Richard Zhu > Best Regards >> Cheers, >> Ahmad >> >> -- >> Pengutronix e.K. | >> | >> Steuerwalder Str. 21 | >> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.pe >> ngutronix.de%2F&data=05%7C01%7Chongxing.zhu%40nxp.com%7C06f5 >> 363342c9464bca5a08dabd69bdb5%7C686ea1d3bc2b4c6fa92cd99c5c301635 >> %7C0%7C0%7C638030559094875195%7CUnknown%7CTWFpbGZsb3d8eyJW >> IjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3 >> 000%7C%7C%7C&sdata=36fpveVBgKraYIeEJjMSiPA10azBfhhHrNVYTaocN >> nQ%3D&reserved=0 | >> 31137 Hildesheim, Germany | Phone: >> +49-5121-206917-0 | >> Amtsgericht Hildesheim, HRA 2686 | Fax: >> +49-5121-206917-5555 | > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |