From 93cc5ae4c34cfee4e4244721d2a665781ce6a79a Mon Sep 17 00:00:00 2001 From: Ziyue Zhang Date: Thu, 16 Apr 2026 19:57:57 +0800 Subject: [PATCH] WORKAROUND: PCI/pwrctrl: Skip power on/off for nodes without compatible or supply The pci_pwrctrl_create_device() already guards against creating pwrctrl platform devices for DT nodes that lack a "compatible" property or have no power-supply defined. However, pci_pwrctrl_power_off_device() and pci_pwrctrl_power_on_device() do not apply the same checks, so they attempt to look up a platform device for every child node regardless of whether one was ever created. Add the same two early-return guards to both power-on and power-off paths: 1. Skip nodes that have no "compatible" property, since no platform device will have been registered for them. 2. Skip nodes for which of_pci_supply_present() returns false, since pci_pwrctrl_create_device() would have skipped those nodes too. This mirrors the logic already present in pci_pwrctrl_create_device() and avoids spurious of_find_device_by_node() lookups for nodes that were never registered as pwrctrl devices. Signed-off-by: mokkprad Signed-off-by: Ziyue Zhang --- drivers/pci/pwrctrl/core.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/pci/pwrctrl/core.c b/drivers/pci/pwrctrl/core.c index 1b91375738a08..cb50792ceec99 100644 --- a/drivers/pci/pwrctrl/core.c +++ b/drivers/pci/pwrctrl/core.c @@ -160,6 +160,22 @@ static void pci_pwrctrl_power_off_device(struct device_node *np) if (!pdev) return; + /* + * Sanity check to make sure that the node has the compatible property + * to allow driver binding. + */ + if (!of_property_present(np, "compatible")) + return; + + /* + * 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)) { + //dev_dbg(parent, "Skipping OF node: %s\n", np->name); + return; + } if (device_is_bound(&pdev->dev)) { ret = __pci_pwrctrl_power_off_device(&pdev->dev); if (ret) @@ -216,6 +232,23 @@ static int pci_pwrctrl_power_on_device(struct device_node *np) if (!pdev) return 0; + /* + * Sanity check to make sure that the node has the compatible property + * to allow driver binding. + */ + if (!of_property_present(np, "compatible")) + return 0; + + /* + * 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)) { + //dev_dbg(parent, "Skipping OF node: %s\n", np->name); + return 0; + } + if (device_is_bound(&pdev->dev)) { ret = __pci_pwrctrl_power_on_device(&pdev->dev); } else {