]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PCI/pwrctrl: Move pci_pwrctrl_unregister() to pci_destroy_dev()
authorManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Thu, 16 Jan 2025 14:09:12 +0000 (19:39 +0530)
committerKrzysztof Wilczyński <kwilczynski@kernel.org>
Thu, 20 Feb 2025 10:59:10 +0000 (10:59 +0000)
The PCI core will try to access the devices even after pci_stop_dev()
for things like Data Object Exchange (DOE), ASPM, etc.

So, move pci_pwrctrl_unregister() to the near end of pci_destroy_dev()
to make sure that the devices are powered down only after the PCI core
is done with them.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Tested-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20250116-pci-pwrctrl-slot-v3-2-827473c8fbf4@linaro.org
[kwilczynski: commit log]
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
drivers/pci/remove.c

index efc37fcb73e24da1abd5989e82bc93e2e5153194..58859f9d92f734ec4101f90b68a04bdfefb98287 100644 (file)
@@ -41,7 +41,6 @@ static void pci_stop_dev(struct pci_dev *dev)
        if (!pci_dev_test_and_clear_added(dev))
                return;
 
-       pci_pwrctrl_unregister(&dev->dev);
        device_release_driver(&dev->dev);
        pci_proc_detach_device(dev);
        pci_remove_sysfs_dev_files(dev);
@@ -64,6 +63,7 @@ static void pci_destroy_dev(struct pci_dev *dev)
        pci_doe_destroy(dev);
        pcie_aspm_exit_link_state(dev);
        pci_bridge_d3_update(dev);
+       pci_pwrctrl_unregister(&dev->dev);
        pci_free_resources(dev);
        put_device(&dev->dev);
 }