]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI/pwrctrl: Do not try to power on/off devices that don't need pwrctrl
authorManivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Tue, 21 Apr 2026 10:41:01 +0000 (16:11 +0530)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 27 Apr 2026 14:47:15 +0000 (09:47 -0500)
pci_pwrctrl_is_required() detects whether a device needs PCI pwrctrl
support. It is currently used in pci_pwrctrl_create_device(), but not in
pci_pwrctrl_power_{on/off}_device() APIs. This leads to pwrctrl core trying
to power on/off incompatible devices like USB hub downstream ports defined
in DT.

Add this check to prevent pwrctrl core from poking at wrong devices.

Fixes: b35cf3b6aa1e ("PCI/pwrctrl: Add APIs to power on/off pwrctrl devices")
Reported-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
[bhelgaas: split pci_pwrctrl_is_required() move to separate patch]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260421104102.12322-1-manivannan.sadhasivam@oss.qualcomm.com
drivers/pci/pwrctrl/core.c

index a692aeaee81a0acc97f4966b608032f44c4c47be..b5a0a14d316e90f2521776fae200ad8394dbecb4 100644 (file)
@@ -199,6 +199,9 @@ static void pci_pwrctrl_power_off_device(struct device_node *np)
        for_each_available_child_of_node_scoped(np, child)
                pci_pwrctrl_power_off_device(child);
 
+       if (!pci_pwrctrl_is_required(np))
+               return;
+
        pdev = of_find_device_by_node(np);
        if (!pdev)
                return;
@@ -255,6 +258,9 @@ static int pci_pwrctrl_power_on_device(struct device_node *np)
                        return ret;
        }
 
+       if (!pci_pwrctrl_is_required(np))
+               return 0;
+
        pdev = of_find_device_by_node(np);
        if (!pdev)
                return 0;