From: Marc Zyngier <maz@kernel.org>
To: Yureka Lilian <yureka@cyberchaos.dev>
Cc: "Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Sven Peter" <sven@kernel.org>, "Janne Grunau" <j@jannau.net>,
"Neal Gompa" <neal@gompa.dev>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <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
Subject: Re: [PATCH 1/2] PCI: apple: Integrate pwrctrl API
Date: Tue, 07 Jul 2026 14:58:39 +0100 [thread overview]
Message-ID: <865x2qq4ts.wl-maz@kernel.org> (raw)
In-Reply-To: <8a80a170-a508-4a9e-8090-27cfcedb1cd4@cyberchaos.dev>
On Tue, 07 Jul 2026 13:04:21 +0100,
Yureka Lilian <yureka@cyberchaos.dev> wrote:
>
> On 7/7/26 11:25, Marc Zyngier wrote:
> > On Mon, 06 Jul 2026 23:38:27 +0100,
> > Yureka Lilian <yureka@cyberchaos.dev> 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 <yureka@cyberchaos.dev>
> >> ---
> >> 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 <linux/msi.h>
> >> #include <linux/of_irq.h>
> >> #include <linux/pci-ecam.h>
> >> +#include <linux/pci-pwrctrl.h>
> >> #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.
next prev parent reply other threads:[~2026-07-07 13:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 22:38 [PATCH 0/2] PCI: apple: Integrate pwrctrl API Yureka Lilian
2026-07-06 22:38 ` [PATCH 1/2] " Yureka Lilian
2026-07-06 22:59 ` sashiko-bot
2026-07-07 9:25 ` Marc Zyngier
2026-07-07 12:04 ` Yureka Lilian
2026-07-07 13:58 ` Marc Zyngier [this message]
2026-07-06 22:38 ` [PATCH 2/2] arm64: dts: apple: t600x: Add PCIe pwren gpios Yureka Lilian
2026-07-06 22:58 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=865x2qq4ts.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=asahi@lists.linux.dev \
--cc=bhelgaas@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=j@jannau.net \
--cc=krzk+dt@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=neal@gompa.dev \
--cc=robh@kernel.org \
--cc=sven@kernel.org \
--cc=yureka@cyberchaos.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox