On Wed, Jan 17, 2024 at 5:22 PM Dan Williams <dan.j.williams@xxxxxxxxx> wrote: > > Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> > > > > In order to introduce PCI power-sequencing, we need to create platform > > devices for child nodes of the port node. They will get matched against > > the pwrseq drivers (if one exists) and then the actual PCI device will > > reuse the node once it's detected on the bus. > > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> > [..] > > diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c > > index d749ea8250d6..77be0630b7b3 100644 > > --- a/drivers/pci/remove.c > > +++ b/drivers/pci/remove.c > > @@ -1,6 +1,7 @@ > > // SPDX-License-Identifier: GPL-2.0 > > #include <linux/pci.h> > > #include <linux/module.h> > > +#include <linux/of_platform.h> > > #include "pci.h" > > > > static void pci_free_resources(struct pci_dev *dev) > > @@ -18,11 +19,11 @@ static void pci_stop_dev(struct pci_dev *dev) > > pci_pme_active(dev, false); > > > > if (pci_dev_is_added(dev)) { > > - > > device_release_driver(&dev->dev); > > pci_proc_detach_device(dev); > > pci_remove_sysfs_dev_files(dev); > > of_pci_remove_node(dev); > > + of_platform_depopulate(&dev->dev); > > > > pci_dev_assign_added(dev, false); > > Why is pci_stop_dev() not in strict reverse order of > pci_bus_add_device()? I see that pci_dev_assign_added() was already not > in reverse "add" order before your change, but I otherwise would have > expected of_platform_depopulate() before of_pci_remove_node() (assumed > paired with of_pci_make_dev_node()). The naming here is confusing but the two have nothing in common. One is used by CONFIG_PCI_DYNAMIC_OF_NODES to *create* new DT nodes for detected PCI devices. The one I'm adding, creates power sequencing *devices* (no nodes) for *existing* DT nodes. So the order is not really relevant here but I can change in v2. Bartosz