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 9102AC43458 for ; Tue, 7 Jul 2026 13:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CJcM49RM2FlBZTuuqbu3ibPxbKkT8R770pCrHBILAwQ=; b=cVJFE8bDZkJuCLymi9cRAnPs50 W8U3GAyKmuF6X6He+NnA8mRjgKwIr8Erah3JFBcBg+7rxpgAL55tAg3IDBrn6bo4aYHcm8c2ioNFP zPioe4FvlvPTXDvsSNJ1DaFHy8DQmwbtYDuedug2vA0AUQ7gMeXNwTHKMcl1aCeGxEimKweDaYIZj o5BNInebOvQl7tquzdxuczvISbD/irkc4v4iWa7GCw3AgcTrCowTqxU4iHpZ/bahTNmNekycFuPQD XaTJzfxzljwksJuL4Ss+q1bci0CDaOEyyt6w+7R6pC+Ci9Z2sw39n47AmmGPdg+iamu52n61cPAlt NVqVO+kw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wh6Jw-0000000F6QD-14vF; Tue, 07 Jul 2026 13:58:44 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wh6Jv-0000000F6Q6-2ajp for linux-arm-kernel@lists.infradead.org; Tue, 07 Jul 2026 13:58:43 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id B2865601DE; Tue, 7 Jul 2026 13:58:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62B861F000E9; Tue, 7 Jul 2026 13:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783432722; bh=CJcM49RM2FlBZTuuqbu3ibPxbKkT8R770pCrHBILAwQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=XVcT43nVa9ADCQj7yGrCAhL2dagLOQb2tTPXVoiGP6OCfLnIXHqI4t75wsxUuaYFV LQwxhgAymxZZLG1yjbzE8tpvbtLJxkaoetuqFb5ak/JGdiuLhZrPFGVz45TFHLEqC2 esJWvK9f4YXU+3FKiIeaWCh5jS0AsbdRVG8mhFakl9Q/EeS3eriaQCawOFbZttOhE3 U+3YcIit+kC6CvdwWj2gArxUnwHyolTyVX9vDZtbH96HzbPQ5/JnOTvzFmQ7tseRix oYqJnBwCfZkv0kP0Vqix1eS3U1aUOR2ZJs/g3PnzE/sTeem+kJVnXj1MnzPYEcL1yT s6+mhJLUq2BeQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wh6Js-00000002R7k-1z9a; Tue, 07 Jul 2026 13:58:40 +0000 Date: Tue, 07 Jul 2026 14:58:39 +0100 Message-ID: <865x2qq4ts.wl-maz@kernel.org> From: Marc Zyngier To: Yureka Lilian Cc: Lorenzo Pieralisi , Krzysztof =?UTF-8?B?V2ls?= =?UTF-8?B?Y3p5xYRza2k=?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , Sven Peter , Janne Grunau , Neal Gompa , Krzysztof Kozlowski , Conor Dooley , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: Re: [PATCH 1/2] PCI: apple: Integrate pwrctrl API In-Reply-To: <8a80a170-a508-4a9e-8090-27cfcedb1cd4@cyberchaos.dev> References: <20260707-apple-pcie-pwren-v1-0-5a281b182fe2@cyberchaos.dev> <20260707-apple-pcie-pwren-v1-1-5a281b182fe2@cyberchaos.dev> <86a4s3p2vy.wl-maz@kernel.org> <8a80a170-a508-4a9e-8090-27cfcedb1cd4@cyberchaos.dev> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: yureka@cyberchaos.dev, lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org, robh@kernel.org, bhelgaas@google.com, sven@kernel.org, j@jannau.net, neal@gompa.dev, krzk+dt@kernel.org, conor+dt@kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 07 Jul 2026 13:04:21 +0100, Yureka Lilian wrote: > > On 7/7/26 11:25, Marc Zyngier wrote: > > On Mon, 06 Jul 2026 23:38:27 +0100, > > Yureka Lilian wrote: > >> Integrate the PCI pwrctrl framework into the Apple PCIe host driver to > >> provide standardized power management for PCI devices. > >> > >> Notably, this allows enabling powering on the WiFi, SD card reader on > >> various Macs by means of the pwrctrl framework before probing the ports. > >> > >> Previously, a custom solution for powering on the WiFi and SD card > >> reader was proposed[1], but we can now use the new pci-pwrctrl-generic > >> driver for this purpose. > >> > >> Link[1]: https://lore.kernel.org/lkml/20220502093832.32778-4-marcan@marcan.st/ > >> > > nit: this paragraph and the accompanying link don't belong in the > > commit message and should be moved below the --- mark or even better, > > to the cover letter. > ack, will leave it out of the commit message of the individual commit in v2 > >> Signed-off-by: Yureka Lilian > >> --- > >> drivers/pci/controller/Kconfig | 1 + > >> drivers/pci/controller/pcie-apple.c | 16 ++++++++++++++++ > >> 2 files changed, 17 insertions(+) > >> > >> diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig > >> index 2247709ef6d6..af64630d28fa 100644 > >> --- a/drivers/pci/controller/Kconfig > >> +++ b/drivers/pci/controller/Kconfig > >> @@ -46,6 +46,7 @@ config PCIE_APPLE > >> depends on OF > >> depends on PCI_MSI > >> select PCI_HOST_COMMON > >> + select PCI_PWRCTRL_GENERIC > >> select IRQ_MSI_LIB > >> help > >> Say Y here if you want to enable PCIe controller support on Apple > >> diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c > >> index c2cffc0659f4..db038a9d4831 100644 > >> --- a/drivers/pci/controller/pcie-apple.c > >> +++ b/drivers/pci/controller/pcie-apple.c > >> @@ -30,6 +30,7 @@ > >> #include > >> #include > >> #include > >> +#include > >> #include "pci-host-common.h" > >> @@ -825,6 +826,21 @@ static int apple_pcie_init(struct > >> pci_config_window *cfg) > >> if (WARN_ON(!pcie)) > >> return -ENOENT; > >> + ret = pci_pwrctrl_create_devices(pcie->dev); > >> + if (ret) { > >> + dev_err(pcie->dev, "Failed to create pwrctrl devices: %pe\n", ret); > >> + return ret; > >> + } > >> + > >> + ret = pci_pwrctrl_power_on_devices(pcie->dev); > >> + if (ret) { > >> + if (ret != -EPROBE_DEFER) { > >> + dev_err(pcie->dev, "Failed to power on devices: %pe\n", ret); > >> + pci_pwrctrl_destroy_devices(pcie->dev); > >> + } > >> + return ret; > >> + } > >> + > > Why is this done globally while the whole driver works on a per-port > > basis, and that the proposed DT updates are also per port? > > pci_pwrctrl_power_on_devices takes a struct device as parameter, but > pcie-apple does not allocate device structs for the individual ports. > This could be changed of course. But since pci_pwrctrl_* operate on > the subnodes recursively, it works just fine this way. Works fine is one thing. Being consistent with the way the rest of the driver works is another. pci_pwrctrl_create_device() and pci_pwrctrl_power_on_device() appear to do exactly what would be required for a single port. They just needs to be exported made global/exported. > Additionally, we would like to be sure all the endpoints can be powered > before we start initializing the individual ports. Otherwise we could > end up in a situation where some ports are initialized but others are > not when we realize some driver needed to power on the endpoints for > port n is not yet bound. How can a driver be bound to a device connected to a port if we haven't been through the initial link-up dance, which is what apple_pcie_setup_port() does? The power supplies are per-port for a reason. > There is no appropriate pci_pwrctrl API for checking for the > availability without changing the state, so this is an additional > reason to do it early. Availability of what? To be clear, I'm not suggesting delaying switching of the power. I'm merely suggesting managing it on a per port basis. Thanks, M. -- Without deviation from the norm, progress is not possible.