Skip to content

Commit cf3287f

Browse files
Mani-Sadhasivambjorn-helgaas
authored andcommitted
PCI/pwrctrl: Ensure that remote endpoint node parent has supply requirement
If OF graph is used in the PCI device node, the pwrctrl core creates a pwrctrl device even if the remote endpoint doesn't have 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: 9db8262 ("PCI/pwrctrl: Create pwrctrl device if graph port is found") Reported-by: Raj Kumar Bhagat <raj.bhagat@oss.qualcomm.com> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Raj Kumar Bhagat <raj.bhagat@oss.qualcomm.com> Reviewed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Link: https://patch.msgid.link/20260223-pwrctrl-fixes-7-0-v2-1-97566dfb1809@oss.qualcomm.com
1 parent 6de23f8 commit cf3287f

1 file changed

Lines changed: 34 additions & 13 deletions

File tree

drivers/pci/pwrctrl/core.c

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,39 @@ int pci_pwrctrl_power_on_devices(struct device *parent)
268268
}
269269
EXPORT_SYMBOL_GPL(pci_pwrctrl_power_on_devices);
270270

271+
/*
272+
* Check whether the pwrctrl device really needs to be created or not. The
273+
* pwrctrl device will only be created if the node satisfies below requirements:
274+
*
275+
* 1. Presence of compatible property to match against the pwrctrl driver (AND)
276+
* 2. At least one of the power supplies defined in the devicetree node of the
277+
* device (OR) in the remote endpoint parent node to indicate pwrctrl
278+
* requirement.
279+
*/
280+
static bool pci_pwrctrl_is_required(struct device_node *np)
281+
{
282+
struct device_node *endpoint;
283+
284+
if (!of_property_present(np, "compatible"))
285+
return false;
286+
287+
if (of_pci_supply_present(np))
288+
return true;
289+
290+
if (of_graph_is_present(np)) {
291+
for_each_endpoint_of_node(np, endpoint) {
292+
struct device_node *remote __free(device_node) =
293+
of_graph_get_remote_port_parent(endpoint);
294+
if (remote) {
295+
if (of_pci_supply_present(remote))
296+
return true;
297+
}
298+
}
299+
}
300+
301+
return false;
302+
}
303+
271304
static int pci_pwrctrl_create_device(struct device_node *np,
272305
struct device *parent)
273306
{
@@ -287,19 +320,7 @@ static int pci_pwrctrl_create_device(struct device_node *np,
287320
return 0;
288321
}
289322

290-
/*
291-
* Sanity check to make sure that the node has the compatible property
292-
* to allow driver binding.
293-
*/
294-
if (!of_property_present(np, "compatible"))
295-
return 0;
296-
297-
/*
298-
* Check whether the pwrctrl device really needs to be created or not.
299-
* This is decided based on at least one of the power supplies defined
300-
* in the devicetree node of the device or the graph property.
301-
*/
302-
if (!of_pci_supply_present(np) && !of_graph_is_present(np)) {
323+
if (!pci_pwrctrl_is_required(np)) {
303324
dev_dbg(parent, "Skipping OF node: %s\n", np->name);
304325
return 0;
305326
}

0 commit comments

Comments
 (0)