From nobody Fri Oct 10 09:15:00 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B2651E3DEB; Sat, 14 Jun 2025 11:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749900018; cv=none; b=ay7CgnkT9QPTB3l1hUyouGI9YaFdsr9hykKGdA0CziJZG9ABSpVmS0lB4jEwFLpGWeY5wuAN0vf6AQIkFGhpJX63cXAD0FGDCnUENM2xLnPVLosYokSkEJIrVgxpUXDIDkrKSwsdRjhY31JM42bWoL/lLVduJ6ml3/9A7X39oJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749900018; c=relaxed/simple; bh=4bC7wWm1elb5ro8Z0EDJQKlP7Skj63lJVgMYbIWM9vs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PWtx4iPA/rci1eQQTnBwikpa6t563Mm/NNLe+5FGcfjVAHtOtVmVYHn+MVs8q6kgbJSMVE5+DFOiGBhgJ4/dTTQTE1mGWyDgL3DzYEtOgn/Dx1sjkPaNyGicU3pZsi7lb51kNoH17LYaRhJN0t1PAf3GkXZfR0btpsPNLwceOjg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SlOf8gBR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SlOf8gBR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4ADF8C4CEEB; Sat, 14 Jun 2025 11:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749900018; bh=4bC7wWm1elb5ro8Z0EDJQKlP7Skj63lJVgMYbIWM9vs=; h=From:To:Cc:Subject:Date:From; b=SlOf8gBR9d8vqcxgXAcRRblhZuepfQSg7TOPVpUpVJetAyA7BPxAh2AZG0YeZt4T7 hLWck6hsiWD2XEfqVj1XEvfbkESjcySq5hA90gMTtm0N8oY+918tB3XZdqeKgp0BPC 1u9KlkxDUH0/IHbTShoAcunmfzJQN/sen6/gzGTPeUCfQD26kTTGkN1GiQdlT6/dfn lgJ+3bSpJ1sITQtF8E/d+aZuJp6qPeFfEpbmAGInvS3ijJHvWeUm0sFpLNYL2U3yEp EJoyn2waEfwMx6Ycj93XfC8YtxGZyXeCVQCJodgbcaAQQvMRguVsFX7MJIfMord/AQ Ap9UGJhJXihyA== From: Manivannan Sadhasivam To: bhelgaas@google.com, brgl@bgdev.pl Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, lukas@wunner.de, Manivannan Sadhasivam , Jim Quinlan , Bjorn Helgaas Subject: [PATCH v2] PCI/pwrctrl: Move pci_pwrctrl_create_device() definition to drivers/pci/pwrctrl/ Date: Sat, 14 Jun 2025 16:50:09 +0530 Message-ID: <20250614112009.6478-1-mani@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" pci_pwrctrl_create_device() is a PWRCTRL framework API. So it should be built only when CONFIG_PWRCTRL is enabled. Currently, it is built independently of CONFIG_PWRCTRL. This creates enumeration failure on platforms like brcmstb using out-of-tree devicetree that describes the power supplies for endpoints in the PCIe child node, but doesn't use PWRCTRL framework to manage the supplies. The controller driver itself manages the supplies. But in any case, the API should be built only when CONFIG_PWRCTRL is enabled. So move its definition to drivers/pci/pwrctrl/core.c and provide a stub in drivers/pci/pci.h when CONFIG_PWRCTRL is not enabled. This also fixes the enumeration issues on the affected platforms. Fixes: 957f40d039a9 ("PCI/pwrctrl: Move creation of pwrctrl devices to pci_= scan_device()") Reported-by: Jim Quinlan Closes: https://lore.kernel.org/r/CA+-6iNwgaByXEYD3j=3D-+H_PKAxXRU78svPMRHD= KKci8AGXAUPg@mail.gmail.com Suggested-by: Bjorn Helgaas Signed-off-by: Manivannan Sadhasivam --- Changes in v2: * Dropped the unused headers from probe.c (Lukas) drivers/pci/pci.h | 8 ++++++++ drivers/pci/probe.c | 32 -------------------------------- drivers/pci/pwrctrl/core.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 12215ee72afb..c5efd8b9c96a 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -1159,4 +1159,12 @@ static inline int pci_msix_write_tph_tag(struct pci_= dev *pdev, unsigned int inde (PCI_CONF1_ADDRESS(bus, dev, func, reg) | \ PCI_CONF1_EXT_REG(reg)) =20 +#ifdef CONFIG_PCI_PWRCTRL +struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, + int devfn); +#else +static inline struct platform_device * +pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) { return NULL; } +#endif + #endif /* DRIVERS_PCI_H */ diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4b8693ec9e4c..478e217928a6 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -9,8 +9,6 @@ #include #include #include -#include -#include #include #include #include @@ -2508,36 +2506,6 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus,= int devfn, u32 *l, } EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); =20 -static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *b= us, int devfn) -{ - struct pci_host_bridge *host =3D pci_find_host_bridge(bus); - struct platform_device *pdev; - struct device_node *np; - - np =3D of_pci_find_child_device(dev_of_node(&bus->dev), devfn); - if (!np || of_find_device_by_node(np)) - return NULL; - - /* - * First check whether the pwrctrl device really needs to be created or - * not. This is decided based on at least one of the power supplies - * being defined in the devicetree node of the device. - */ - if (!of_pci_supply_present(np)) { - pr_debug("PCI/pwrctrl: Skipping OF node: %s\n", np->name); - return NULL; - } - - /* Now create the pwrctrl device */ - pdev =3D of_platform_device_create(np, NULL, &host->dev); - if (!pdev) { - pr_err("PCI/pwrctrl: Failed to create pwrctrl device for node: %s\n", np= ->name); - return NULL; - } - - return pdev; -} - /* * Read the config data for a PCI device, sanity-check it, * and fill in the dev structure. diff --git a/drivers/pci/pwrctrl/core.c b/drivers/pci/pwrctrl/core.c index 6bdbfed584d6..20585b2c3681 100644 --- a/drivers/pci/pwrctrl/core.c +++ b/drivers/pci/pwrctrl/core.c @@ -6,11 +6,47 @@ #include #include #include +#include +#include +#include #include #include +#include #include #include =20 +#include "../pci.h" + +struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int= devfn) +{ + struct pci_host_bridge *host =3D pci_find_host_bridge(bus); + struct platform_device *pdev; + struct device_node *np; + + np =3D of_pci_find_child_device(dev_of_node(&bus->dev), devfn); + if (!np || of_find_device_by_node(np)) + return NULL; + + /* + * First check whether the pwrctrl device really needs to be created or + * not. This is decided based on at least one of the power supplies + * being defined in the devicetree node of the device. + */ + if (!of_pci_supply_present(np)) { + pr_debug("PCI/pwrctrl: Skipping OF node: %s\n", np->name); + return NULL; + } + + /* Now create the pwrctrl device */ + pdev =3D of_platform_device_create(np, NULL, &host->dev); + if (!pdev) { + pr_err("PCI/pwrctrl: Failed to create pwrctrl device for node: %s\n", np= ->name); + return NULL; + } + + return pdev; +} + static int pci_pwrctrl_notify(struct notifier_block *nb, unsigned long act= ion, void *data) { --=20 2.43.0