From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 607252054F3 for ; Mon, 16 Dec 2024 13:24:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734355493; cv=none; b=XeNbb2XCY9Tk2ALVVtAW1bxXuQR98HJbbNPDYilHHK4odwzu8AeRHh0ae/UrLKqaehlNCw8PlBA5oXQny9imG6jDtVLyFSYTxo+OUcY0gRGqNriHv7+ajZ8j8rOk6my6an8aiHkXiYKqDl0205GRtGcxCBB+GkxG7FBx+29Gxgc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734355493; c=relaxed/simple; bh=2KrBqpSB2RlPtMqWx0iCUQp1GTm67K2ZGNgYmIKgjRg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=apF/g52k7nnXjqApSZi6qMdyIQKwqnKeaoLDBqeKu0xoR/UqUox1KCbcY+CVYYr2on/udupvuHYkdTkQAzG9kldW8gQepfjfs65tOQMr8NatsQB0Hsu+NtlHoR7GVepQA6IFetvXTfBIPaALGOBUpcwByHrexcv/L1ROm1Swx/M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Xe4bZQ4l; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Xe4bZQ4l" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2164b662090so31386505ad.1 for ; Mon, 16 Dec 2024 05:24:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734355489; x=1734960289; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=qQ2PcWqmGEaXJGaCT9qDrihbcy/Fp9edeGdzGz/zoDw=; b=Xe4bZQ4lYjRuavqafhcIFJC1ZgBNxFll2vrFcACFGNvJiUyOEXsznokNk+iaKX58Iv 2BiSWCG+BangmiashZaFQjFDw2Qd5zhlMEy/HwlGSRXxkuSZf4RA6We8KBUfht0ZNcq3 1+M3seV4bwK2lQPVsjiWdHa/q6W419O0YUbOlBkebRd7VLx0BDm87ZDfCEeycj2aFYSv VfDAMbPRXN3dfIFqX0pAJvVVImn1ENL13jBW4JTkWOWVUt0v5K1ysWjmmCwdkOdL351o OLacCSpiGJz2iiE3DApMsRXGf3CPV3baSRV2NjbOmkXIRR6m/PRCx6lg+orNOSjRvUBj yAcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734355489; x=1734960289; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qQ2PcWqmGEaXJGaCT9qDrihbcy/Fp9edeGdzGz/zoDw=; b=Wi07Q6ofQBV8FRbZRW5tGQR9pBqhEHXwPOzB+ly2Zl/tio8wfLCCohgHItGiRBxmKs DFlZGUiST8Ft+4GSHSPGhNMPk9iA7JgMKgLaYLKxkwL/oXqBUDvcYSynIi2rE1/6y9eF 1Bp+zWHTXAFuDYUDosVfPghoOV73zPrQa7UrXOEwKZpxs4cPfEyrYYh81gdGyfTkn55+ zjfXF+oBBUofvgRwdlvwKokiuE7swHDnucchUF86IcKob2ESqsM0d7vWzAbn4m7LPKlu mAugl7H5BjDQNR+iDztG8LdSkijUpL6lE7QcIKwwQQQWlTzyEi7HyA8F3jr7ybhGH0rn hXJg== X-Forwarded-Encrypted: i=1; AJvYcCWoXjuHeKESYRORGZZmoHNCLhbvLtv29rlGF3/JSkwjyaKLJbBgq58TGJG9iN2dYW6Xa/G3qdGVgyJyqTs=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6CEyE3bMiUKhik1o6GvfVEpEnV2wmPvXuGmnIITlx4YqnFAO0 v+Axze0Pdmg62igU/CT689Gwp6jZ6VQJDYS+5/stia+Wv2/FRJYKQo8iK5uqgA== X-Gm-Gg: ASbGncvg3XjbHkfyh6ReSxof3osGLGqp2CgLxXfg2YDovM06PtNzC1iVIi0an1Pfdfp jV6vCkaP1CgxfwLVlVe/A8VlQBMz6UjIg674+xkMiBAL9YYJsCXthqyPN5lSXT4vHDWO2kfzxTE 9O+VnQq3Y+xcGrkzIBf8C+Okp0M5U4mGjHgGCbAZdfLDD5mkl6XORZ/pVn/hr1eUhiWPdCHj5R7 aykDkdqBFE6Z77RDBX4lKYypWMOBdeSGUa/ZHLFF+WkqFT+FtJHOM3LIePMVDAGUcA6 X-Google-Smtp-Source: AGHT+IGbmUlVe8dk0ois4qkbR6zHbskbm9qvTKT+GOxinPVoLMRUvMrSVeO2Feozd+tQg8RZgRA83A== X-Received: by 2002:a17:902:d509:b0:216:4499:b836 with SMTP id d9443c01a7336-218929d6b85mr182378955ad.26.1734355489546; Mon, 16 Dec 2024 05:24:49 -0800 (PST) Received: from thinkpad ([120.56.200.168]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-218a1e50340sm42302525ad.148.2024.12.16.05.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 05:24:49 -0800 (PST) Date: Mon, 16 Dec 2024 18:54:45 +0530 From: Manivannan Sadhasivam To: Stephan Gerhold Cc: Bartosz Golaszewski , Bjorn Helgaas , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: Re: [RFT PATCH] Revert "power: sequencing: request the WLAN enable GPIO as-is" Message-ID: <20241216132445.vjkxxknvzaht2ltq@thinkpad> References: <20241203141251.11735-1-brgl@bgdev.pl> <20241216070554.ym54ozdw45zhveo7@thinkpad> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Dec 16, 2024 at 11:50:20AM +0100, Stephan Gerhold wrote: > On Mon, Dec 16, 2024 at 12:35:54PM +0530, Manivannan Sadhasivam wrote: > > On Fri, Dec 13, 2024 at 07:19:34PM +0100, Stephan Gerhold wrote: > > > On Tue, Dec 03, 2024 at 03:12:51PM +0100, Bartosz Golaszewski wrote: > > > > From: Bartosz Golaszewski > > > > > > > > This reverts commit a9aaf1ff88a8cb99a1335c9eb76de637f0cf8c10. > > > > > > > > With the changes recently merged into the PCI/pwrctrl/ we now have > > > > correct ordering between the pwrseq provider and the PCI-pwrctrl > > > > consumers. With that, the pwrseq WCN driver no longer needs to leave the > > > > GPIO state as-is and we can remove the workaround. > > > > > > > > > > Should probably revert commit d8b762070c3f ("power: sequencing: > > > qcom-wcn: set the wlan-enable GPIO to output") as well? > > > > > > > Signed-off-by: Bartosz Golaszewski > > > > --- > > > > drivers/power/sequencing/pwrseq-qcom-wcn.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/power/sequencing/pwrseq-qcom-wcn.c b/drivers/power/sequencing/pwrseq-qcom-wcn.c > > > > index 682a9beac69eb..bb8c47280b7bc 100644 > > > > --- a/drivers/power/sequencing/pwrseq-qcom-wcn.c > > > > +++ b/drivers/power/sequencing/pwrseq-qcom-wcn.c > > > > @@ -379,7 +379,7 @@ static int pwrseq_qcom_wcn_probe(struct platform_device *pdev) > > > > "Failed to get the Bluetooth enable GPIO\n"); > > > > > > > > ctx->wlan_gpio = devm_gpiod_get_optional(dev, "wlan-enable", > > > > - GPIOD_ASIS); > > > > + GPIOD_OUT_LOW); > > > > if (IS_ERR(ctx->wlan_gpio)) > > > > return dev_err_probe(dev, PTR_ERR(ctx->wlan_gpio), > > > > "Failed to get the WLAN enable GPIO\n"); > > > > -- > > > > 2.30.2 > > > > > > > > > > I'm not sure why but applying this patch brings back the error I had > > > before. It does seem like setting wlan-enable GPIO happens early enough, > > > but maybe some timing is still wrong. > > > > > > > There should be no room for timing issue now :/ > > > > > [ 17.132161] wlan_gpio, 1);> > > > [ 17.480619] ath12k_pci 0004:01:00.0: of_irq_parse_pci: failed with rc=134 > > > [ 17.491997] ath12k_pci 0004:01:00.0: pci device id mismatch: 0xffff 0x1107 > > > [ 17.492000] ath12k_pci 0004:01:00.0: failed to claim device: -5 > > > [ 17.492075] ath12k_pci 0004:01:00.0: probe with driver ath12k_pci failed with error -5 > > > > > > > Are you sure that this is the same error that you noticed before? > > > > Yes, "pci device id mismatch: 0xffff 0x1107" is definitely the same > error I saw before. > > > > Any ideas/suggestions? > > > > > > > Can you verify that the pwrctrl driver's probe is completed *before* ath12k > > driver starting to probe by adding the debug prints in both drivers? > > > > I tried booting with "modprobe.blacklist=ath12k" and manually loaded the > module several seconds after the boot completed. Error is unchanged: > > [ 16.628165] wlan_gpio, 1);> > [ 55.065794] ath12k_pci 0004:01:00.0: of_irq_parse_pci: failed with rc=134 > [ 55.073354] ath12k_pci 0004:01:00.0: pci device id mismatch: 0xffff 0x1107 > [ 55.080457] ath12k_pci 0004:01:00.0: failed to claim device: -5 > [ 55.088977] ath12k_pci 0004:01:00.0: probe with driver ath12k_pci failed with error -5 > > I played around a bit more and it looks like the problem is that the PCI > device is still being enumerated during startup, before the pwrseq > driver is loaded. Not with the ath12k driver, but the internal PCI > subsystem state. And then the PCI link dies briefly when the pwrseq > driver loads. > Ok, this seems to be the cause. There is a known issue with Qcom PCIe controllers where if the device is powered off abrubtly (without controller driver noticing) the PCIe link moves to link down state. Then we need to bring the link back by reinitializing the controller. I have it in my todo list but no one noticed this issue unless they tried powering down and powering up the device (which is rare except on hot pluggable slots). > If I add some hacks to the DT to force the wlan-enable GPIO low before > the entire PCI _controller_ is probed, then it works correctly: > > [ 16.607359] wlan_gpio, 1);> > [ 16.668533] pci 0004:01:00.0: [17cb:1107] type 00 class 0x028000 PCIe Endpoint > [ 16.668606] pci 0004:01:00.0: BAR 0 [mem 0x00000000-0x001fffff 64bit] > [ 16.669055] pci 0004:01:00.0: PME# supported from D0 D3hot D3cold > [ 16.675546] pcieport 0004:00:00.0: bridge window [mem 0x7c400000-0x7c5fffff]: assigned > [ 16.675555] pci 0004:01:00.0: BAR 0 [mem 0x7c400000-0x7c5fffff 64bit]: assigned > [ 16.862083] ath12k_pci 0004:01:00.0: BAR 0 [mem 0x7c400000-0x7c5fffff 64bit]: assigned > [ 16.870358] ath12k_pci 0004:01:00.0: enabling device (0000 -> 0002) > [ 16.888792] ath12k_pci 0004:01:00.0: MSI vectors: 16 > [ 16.893954] ath12k_pci 0004:01:00.0: Hardware name: wcn7850 hw2.0 > > Note the pci messages after enabling the GPIO, before the first > ath12k_pci messages. Without the hack, those appear already before the > pwrseq driver is being loaded (during initramfs). > > [ 5.888688] pci 0004:01:00.0: [17cb:1107] type 00 class 0x028000 PCIe Endpoint > [ 5.888758] pci 0004:01:00.0: BAR 0 [mem 0x00000000-0x001fffff 64bit] > [ 5.889207] pci 0004:01:00.0: PME# supported from D0 D3hot D3cold > [ 5.902692] pci 0004:00:00.0: bridge window [mem 0x7c400000-0x7c5fffff]: assigned > [ 5.910311] pci 0004:01:00.0: BAR 0 [mem 0x7c400000-0x7c5fffff 64bit]: assigned > ... > [ 21.227565] wlan_gpio, 1);> > [ 21.305496] ath12k_pci 0004:01:00.0: of_irq_parse_pci: failed with rc=134 > [ 21.318382] ath12k_pci 0004:01:00.0: pci device id mismatch: 0xffff 0x1107 > [ 21.338489] ath12k_pci 0004:01:00.0: failed to claim device: -5 > [ 21.338555] ath12k_pci 0004:01:00.0: probe with driver ath12k_pci failed with error -5 > > Can we skip scanning the PCI bus until the power sequencing is done? > This won't help (but a good idea anyway that I'll implement). See below... > The hack I used (see below) works, but is a bit odd since it requires > assigning the wcn7850-pmu pinctrl to the PCI bus in the DT. Otherwise > the GPIO is not forced low early enough. > Your hack is making sure that the default state of the GPIO is not changed at all after initializing the controller. So even if the pwrctrl driver probes later, it will try to enable the module by doing, 'gpiod_set_value_cansleep(ctx->wlan_gpio, 1)', which would do nothing to the device state. So the issue is not with the pwrctrl driver but with the controller implementation. Ideally, once the device is removed, the PCIe link should move to Detect state and then to Polling state once the receiver is detected on the lanes. But the DWC and Qcom glue has other logics that prevents the controller from doing so. So until the link down handling is implemented in the controller driver, we need to carry this hack that preserves the GPIO state. - Mani -- மணிவண்ணன் சதாசிவம்