I think we should not have an assumption that PF comes first inthe list. So I think dev->is_virtfn check is needed.

On the other hand, if we add the dev->is_virtfn check,pci_stop_bus_devices() doesn't work for buses whose &bus->deviceslist have only VFs(, though I think pci_stop_bus_devices() is notused for this kind of bus currently). How about adding thepci_stop_bus_device() loop for VFs after the loop for PFs, as youdid in your first try?