On Wed, Apr 26, 2017 at 03:56:09PM -0700, Kyle Gale wrote: > Can someone help me understand why I need to remove my stale PCI > device files from the tree if I want to properly get my device > re-initialized after unplugging and reinserting? > > For example, I turn on my system with my PCI device plugged in. All is > fine. I unplug it, plug it back in, and rescan (echo 1 > > /sys/bus/pci/devices/rescan) and end up in this state where my BAR0 is > not set, and other things are not entirely correct. > > But if I do a remove (echo 1 > /sys/bus/pci/devices/xxxx/xx.x/remove) > of the port, it then properly re-initializes my device when I do a > rescan. > > Why does it not suffice to simply do a rescan? Does the rescan skip > some step if it finds that the device is already in the PCI tree? It's > not as if the rescan completely skips the device if I don't do a > remove, it just doesn't do all of the initialization. Initiating a rescan via sysfs results in a call to pci_rescan_bus(), which only adds devices but doesn't remove any. I guess it can be argued that this behavior is counter-intuitive and should be changed. Thanks, Lukas