Skip to contentSkip to conversation

PCI/pwrctrl: A couple of fixes

PATCH Applied Manivannan Sadhasivam 2 participants 4 messages Feb 23 – Mar 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover PCI/pwrctrl: A couple of fixes

Hi,

This series fixes a couple of issues introduced in the recent pwrctrl rework for v7.0. Both issues are due to some incorrect assumptions on deciding when to create pwrctrl devices. First issue is due to assuming that all OF graph nodes require pwrctrl and another one is due to assuming that all PCI child nodes are PCI devices.

Both issues are fixed by changing the pwrctrl device creation logic in pwrctrl/core.

Testing
=======

This series is tested on Lenovo Thinkpad T14s.

Note for Bjorn H
================

Even though only patch 1 is fixing a regression on the IPQ board which was not part of the testbed of the pwrctrl rework went in for v7.0, patch 2 is also fixing an actual issue, but it is not impacting any of the current upstream supported platforms. But I'd like to get these two patches merged for v7.0 so that both the issues are fixed in the same major release where the issues originated.

---
Changes in v2:
- Used the compatible match for detecting the PCI devices in DT
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Manivannan Sadhasivam (2):
PCI/pwrctrl: Ensure that the remote endpoint node parent has the supply requirement PCI/pwrctrl: Only create pwrctrl device if the device node belongs to a PCI device

 drivers/pci/pwrctrl/core.c | 54 +++++++++++++++++++++++++++++++++++-----------
 1 file changed, 41 insertions(+), 13 deletions(-)

---
base-commit: 1c2b4a4c2bcb950f182eeeb33d94b565607608cf
change-id: 20260217-pwrctrl-fixes-7-0-b90eb30bbfe7

Best regards,

Signature · 1 line
Manivannan Sadhasivam <[email protected]>
#1 lore raw

PATCH v2 1/2 PCI/pwrctrl: Ensure that the remote endpoint node parent has the supply requirement

If OF graph is used in the PCI device node, pwrctrl core currently creates the pwrctrl device even if the remote endpoint doesn't have the power supply requirements. Since the device doesn't have any power supply requirements, there was no pwrctrl driver to probe, leading to PCI controller driver probe deferral as it waits for all pwrctrl drivers to probe before starting bus scan.

This issue happens with Qcom ath12k devices with WSI interface attached to the Qcom IPQ platforms.

Fix this issue by checking for the existence of at least one power supply property in the remote endpoint parent node. To consolidate all the checks, create a new helper pci_pwrctrl_is_required() and move all the checks there.

Fixes 9db826206f9b ("PCI/pwrctrl: Create pwrctrl device if graph port is found")
---
 drivers/pci/pwrctrl/core.c | 47 +++++++++++++++++++++++++++++++++-------------
 1 file changed, 34 insertions(+), 13 deletions(-)
drivers/pci/pwrctrl/core.c +34 -13
index 6f7dea6746e0..8325858cc379 100644
@@ -268,6 +268,39 @@ int pci_pwrctrl_power_on_devices(struct device *parent)
 }
 EXPORT_SYMBOL_GPL(pci_pwrctrl_power_on_devices);
 
+/*
+ * Check whether the pwrctrl device really needs to be created or not. The
+ * pwrctrl device will only be created if the node satisfies below requirements:
+ *
+ * 1. Presence of compatible property to match against the pwrctrl driver (AND)
+ * 2. At least one of the power supplies defined in the devicetree node of the
+ *    device (OR) in the remote endpoint parent node to indicate pwrctrl
+ *    requirement.
+ */
+static bool pci_pwrctrl_is_required(struct device_node *np)
+{
+	struct device_node *endpoint;
+
+	if (!of_property_present(np, "compatible"))
+		return false;
+
+	if (of_pci_supply_present(np))
+		return true;
+
+	if (of_graph_is_present(np)) {
+		for_each_endpoint_of_node(np, endpoint) {
+			struct device_node *remote __free(device_node) =
+				of_graph_get_remote_port_parent(endpoint);
+			if (remote) {
+				if (of_pci_supply_present(remote))
+					return true;
+			}
+		}
+	}
+
+	return false;
+}
+
 static int pci_pwrctrl_create_device(struct device_node *np,
 				     struct device *parent)
 {
@@ -287,19 +320,7 @@ static int pci_pwrctrl_create_device(struct device_node *np,
 		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 defined
-	 * in the devicetree node of the device or the graph property.
-	 */
-	if (!of_pci_supply_present(np) && !of_graph_is_present(np)) {
+	if (!pci_pwrctrl_is_required(np)) {
 		dev_dbg(parent, "Skipping OF node: %s\n", np->name);
 		return 0;
 	}
Signature · 1 line
2.51.0
#2 lore raw

PATCH v2 2/2 PCI/pwrctrl: Only create pwrctrl device if the device node belongs to a PCI device

In reply to Manivannan Sadhasivam

The PCI host bridge node can have non-PCI child nodes as well, like OPP tables, USB hub etc... So the pwrctrl core must ensure that the pwrctrl device is only created for PCI device nodes by checking for the 'pci' prefix in the compatible property.

Fixes 4c4132489201 ("PCI/pwrctrl: Add APIs to create, destroy pwrctrl devices")
---
 drivers/pci/pwrctrl/core.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/pci/pwrctrl/core.c +9 -2
index 8325858cc379..7754baed67f2 100644
@@ -272,7 +272,8 @@ EXPORT_SYMBOL_GPL(pci_pwrctrl_power_on_devices);
  * Check whether the pwrctrl device really needs to be created or not. The
  * pwrctrl device will only be created if the node satisfies below requirements:
  *
- * 1. Presence of compatible property to match against the pwrctrl driver (AND)
+ * 1. Presence of compatible property with "pci" prefix to match against the
+ *    pwrctrl driver (AND)
  * 2. At least one of the power supplies defined in the devicetree node of the
  *    device (OR) in the remote endpoint parent node to indicate pwrctrl
  *    requirement.
@@ -280,8 +281,14 @@ EXPORT_SYMBOL_GPL(pci_pwrctrl_power_on_devices);
 static bool pci_pwrctrl_is_required(struct device_node *np)
 {
 	struct device_node *endpoint;
+	const char *compat;
+	int ret;
+
+	ret = of_property_read_string(np, "compatible", &compat);
+	if (ret < 0)
+		return false;
 
-	if (!of_property_present(np, "compatible"))
+	if (!strstarts(compat, "pci"))
 		return false;
 
 	if (of_pci_supply_present(np))
Signature · 1 line
2.51.0
#3 lore raw
In reply to Manivannan Sadhasivam
Quoted 32 lines · On Mon, Feb 23, 2026 at 08:15:58PM +0530, Manivannan Sadhasivam via B4 Relay…

Hi,

This series fixes a couple of issues introduced in the recent pwrctrl rework for v7.0. Both issues are due to some incorrect assumptions on deciding when to create pwrctrl devices. First issue is due to assuming that all OF graph nodes require pwrctrl and another one is due to assuming that all PCI child nodes are PCI devices.

Both issues are fixed by changing the pwrctrl device creation logic in pwrctrl/core.

Testing
=======

This series is tested on Lenovo Thinkpad T14s.

Note for Bjorn H
================

Even though only patch 1 is fixing a regression on the IPQ board which was not part of the testbed of the pwrctrl rework went in for v7.0, patch 2 is also fixing an actual issue, but it is not impacting any of the current upstream supported platforms. But I'd like to get these two patches merged for v7.0 so that both the issues are fixed in the same major release where the issues originated.

---
Changes in v2:
- Used the compatible match for detecting the PCI devices in DT
- Link to v1: https://lore.kernel.org/r/[email protected]

Quoted 7 lines

---
Manivannan Sadhasivam (2):
PCI/pwrctrl: Ensure that the remote endpoint node parent has the supply requirement PCI/pwrctrl: Only create pwrctrl device if the device node belongs to a PCI device

 drivers/pci/pwrctrl/core.c | 54 +++++++++++++++++++++++++++++++++++-----------
 1 file changed, 41 insertions(+), 13 deletions(-)

Applied to pci/for-linus for v7.0, thanks!