From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F0A2606A31B for ; Wed, 4 Nov 2026 13:41:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=yzFRImCh; dkim=pass (2048-bit key, unprotected) header.d=jannau.net header.i=@jannau.net header.a=rsa-sha256 header.s=fm1 header.b=D+HmIwUw; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=vCvhrDvr 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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=I4MrJ0us0cyVl7cuFGdkMVaNQnyIC3GHJZjZ2WZ4bC8=; b=yzFRImCh4h4KH/mXZhFtJ7vKn+ RBIpicM3WR1mKNs8sro85aseVlfRaI7VwSwLC5ji93zbr3wn7orjT+xg5uhcd9Z5GL8dMwWiIBTEN /OSf1SvdEUX9HWydIy4stFYv8xj/xDP/LRZzr9uLVAL1gEk6GzfXYA7QxjEoL7l6aBs34TrfEu00k yLkIOrAlz+SosAn/zGExmT56Gi/IeWoEiRxV8husleHzHMuysACUL7T1jsWRbV0VYMMotAsepkYhO 3t2LY771rS6XaWRaZ+LPN/YimbUIbR6EJQjtBJG5gDFYPOSTHxfiFsGDaNtqPvXkiha03ha0H8o8J ucSbE9ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xObFI-00000005VHc-0M42; Wed, 04 Nov 2026 13:41:44 +0000 Received: from fhigh-b7-smtp.messagingengine.com ([202.12.124.158]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xObFF-00000005VGL-3Ch6 for linux-arm-kernel@lists.infradead.org; Wed, 04 Nov 2026 13:41:43 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 5FEF37A0167 for ; Wed, 4 Nov 2026 08:41:38 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Wed, 04 Nov 2026 08:41:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jannau.net; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1793799695; x=1793886095; bh=I4MrJ0us0c yVl7cuFGdkMVaNQnyIC3GHJZjZ2WZ4bC8=; b=D+HmIwUwPxSkAgYq97euIVpaVk pb85DgJrUPm3owN2cUP7z7hAqlWWIiMMFAAeW91CrZ2nDI5hvzn1PXQ56JVpjA/X V2G15tzcNrUK1Olupqm6n9+g0MCUsHh1G14wC1il9Zgi8HBGJSRn2ttJI8hqLYPt WIlPQsyfDkQfhaBrPsNhA43ozhs2wR93JcDmg1r6RYuS8259//nNrLpTyK4Esve4 huiywvAPrz+Tn150hsJH9S0XOnVYJCsoUxIxi2fAgjxO0xz4ExLP2p7VfiRikUsN YDjiEZvjSsDRmI/GQerdEohfeOV62iNdg9ahB0ToDYtfg01sPMjvD1KiEe6A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1793799695; x=1793886095; bh=I4MrJ0us0cyVl7cuFGdkMVaNQnyIC3GHJZj Z2WZ4bC8=; b=vCvhrDvrELQ9UKx0dx7NpVOUb0B0UVL0n2JbKguTUtYYxk/8UrU h5P3fZRGgz8jQaWyWkt9co88K9dnejZwA4AIVmbThDKPZew/d8cGCPPdT14BC7D/ WWm1OyPk5MMu6KCG1TgFhxsPLIk1Nzu3yksu/sN+ZpgDDFsi3fEDZfTcLCUdZrtL /JMpP3Ej63+gdcLmgwFs0rSZPf2gpS+X+DLiYyptx3SxPuZaohUeoybqxxjxOXOS v+ae2GjtfDH4n5GtRh1HYOTsN6BoYvALX1uXlV0FEVN6n+68p8XTF+Ujk+TQ034T BfETYGD2041wzm8eZqlVUd6Mi/a0r/uLLQw== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-08; repo=github.com/dkim2wg/interop; date=2026-10-28; sw=lmtpprox; action=sign d=jannau.net a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1793799695; d=jannau.net; mf=PGpAamFubmF1Lm5ldD4=; rt=PGxpbnV4LWFybS1rZXJuZWxAbGlzdHMuaW5mcmFkZWFkLm9yZz4=; s=fm1:rsa-sha256:DvSTF6/Kzv9euSjGTqQFptJuPzMeEUW/gyqzBaOnTyhvsfC 2lGhszZMjugFlGLaGoLS21/1K0pcSMHgKVJxXjwFEREN5Vy86BXArriUGujjq70G nL8WQGKB/yW6moj5G2cec1TXgIDy7Cqle8+b5VpshqWr9LzDnGp80bPXZV2MmjRh LRQ+RhTttZoccs5tuepjWaRG9prwMOjrMgDJs+lngHXuV/P4KZfy8kHmz1/4IqvV NsUFfGLx6+BM5qYzIhLja+vB/+hQflKPOtrVytUNAF3u3wzqk/CAUx50MEePJhZT j77VBe3Eo/G6INVUO+hQhZ5fXYM1F8RKM5QZOBw==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-08; repo=github.com/dkim2wg/interop; date=2026-10-28; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:EN7Cd8aiweMGl5lHrs2+4ANErcvjvC2KutppetHvMv0=:S98jBY3/ksFURwsVuG+I1Wx0g75J28yvU2mCrNKvD+0=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGfAP7AcWTt7GSuE9cecOERqrNYgIUKwhLeSq+w+fwSyelYEqmcbQvAwFer7F/mE1 PEpvxOME6dPfjCLp8Qigws1yULz0Wwf2BWE3Vvd7RsEIfU52IeZ9O9eEWHI/FJJlm/63Vr Q078hKiAl8k8Dc/19fKH+O2MKTgaX2GHpSclPxdmHaoCWfF+tjJOc7H4spAMAresvHH1nL Jz4T/QHWPL7ZtzAVf7SCpdBye4DhZLMBZmLQU+hGR0IpZYHQJxo1S0CLTr4jOG6DBLmAJE sR8O5nm4cb6ZIeuWQHOEpFf5R7CT6vFUMHgunron6jQaPRGVriUzoUC0U+LGnfzo7UL1LV lfhjvQdBNIXLYe2T1kVM9kJ7XfHozMyaD/rinhqZG/tsRPIPyO4CwUaBbleQ6EZoua00dc WVHRRQ1AnEZJk7AocDB8+w6K2nKIN+CuNFmuwGFaG7HKqwRvXmFHRFKpHR20yvolyLacal HmgE/KXswW3bf1h5+AzuvlYRrHgPyEvM+O50CGWE8bmmgg3zaR4+qTwj3WCoe/d7pY6Bgz QDerj1Dhk7jkuDGzypho+lNkQRzudP7J5vBMco0NJuq4XWSBaZT8pALwfU9kWSmeoAxOO8 vCZWI/MuSOXohmvPUh8HFfzXmrHjQeT8qvvV9Kjl/M/YhpZ3ZMdcvCszukkA X-ME-Proxy: Feedback-ID: i47b949f6:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 4 Nov 2026 08:41:35 -0500 (EST) Date: Wed, 4 Nov 2026 14:41:33 +0100 From: Janne Grunau To: Yureka Lilian Cc: Bartosz Golaszewski , Manivannan Sadhasivam , Bjorn Helgaas , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Marc Zyngier , Sven Peter , 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 v2 2/3] PCI: apple: Integrate pwrctrl API Message-ID: <20261104134133.GA756133@robin.jannau.net> References: <20261104-apple-pcie-pwren-v2-0-216a4066965f@cyberchaos.dev> <20261104-apple-pcie-pwren-v2-2-216a4066965f@cyberchaos.dev> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20261104-apple-pcie-pwren-v2-2-216a4066965f@cyberchaos.dev> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261104_054142_067790_3D4B67E1 X-CRM114-Status: GOOD ( 26.18 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Wed, Nov 04, 2026 at 12:40:30PM +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. > > Signed-off-by: Yureka Lilian > --- > drivers/pci/controller/Kconfig | 1 + > drivers/pci/controller/pcie-apple.c | 23 +++++++++++++++++++++++ > 2 files changed, 24 insertions(+) > > diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig > index d246bbe37948..791892a6c0c6 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..2d32092e2122 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,28 @@ static int apple_pcie_init(struct pci_config_window *cfg) > if (WARN_ON(!pcie)) > return -ENOENT; > > + // Ensure all ports can be powered on before attempting initialization > + for_each_available_child_of_node_scoped(dev->of_node, of_port) { > + ret = pci_pwrctrl_create_device(of_port, pcie->dev); > + if (ret) { > + dev_err(pcie->dev, "Failed to create pwrctrl device: %pe\n", ERR_PTR(ret)); This should power down devices it already powered up and destroy the created devices. As far as I can see -EINVAL is the only possible error so the platform devices should be cleaned up > + return ret; > + } > + > + ret = pci_pwrctrl_power_on_device(of_port); > + if (ret) { > + if (ret != -EPROBE_DEFER) { -EPROBE_DEFER can be persistent, devices should be powered and destroyed here as well. > + dev_err(pcie->dev, > + "Failed to power on device: %pe\n", > + ERR_PTR(ret)); > + for_each_available_child_of_node_scoped(dev->of_node, of_port) { > + pci_pwrctrl_destroy_device(of_port); this misses to power down already powered up devices. One way to avoid the need to power down devices after pci_pwrctrl_create_device() failures would be to split the loop into two. The power handling is now done on a per port basis as asked in v1 but it is more or less a re-implementation of pci_pwrctrl_create_devices(), pci_pwrctrl_destroy_devices() and pci_pwrctrl_power_on_devices(). For pcie-apple those are essentially loops over the the available ports with error handling. One annoying side effect of this change. I a single device fails to power-on we will break ethernet on desktop Macs although it does not need power control. So maybe ignoring errors except -EPROBE_DEFER would be the better implementation. -EPROBE_DEFER itself is still a problem as the power control for some ports are a optional dependency for other ports. Janne