2.6.24-rc4: pci_remove_bus_device() => pci_scan_child_bus() => pci_bus_add_devicesbug?

From: Eran Liberty
Date: Wed Jun 18 2008 - 10:50:36 EST


Short:
1. Calling pci_remove_bus_device() on some of the devices on a bus will remove them. (ok)
2. Calling pci_scan_child_bus() on that bus will scan the bus for devices and add them all. even the ones already in the bus device list, which will now be duplicated in the bus device list! (no so ok)
3. Calling pci_bus_add_devices() Will try to add the device, assign resource, and create procfs files. The devices which were not originally removed are were being assigned resource they don't need and procfs files already exist and will collide (Bug)

Background:
I have a programmable component which implements a pci device. Upon warm update i need to remove my devices from the bus, upgrade, and add them back.
I have bashed my head against pci.h API for the last week trying to make this work with no success. Right now I have devised a hideous hack to circumvent pci.h and directly remap the pci device registers.

demo code:

reload_my_hardware_design() {
struct pci_dev *dev = NULL;
struct pci_bus *bus = NULL;

while ((dev = pci_get_device(PCI_VENDOR_ID_MY_ID,PCI_ANY_ID,NULL))) {
pci_remove_bus_device(dev);
}

...
reload the hardware
...

bus = pci_find_bus(0,0); /* though hard coded in this example this is the right bus*/
pci_scan_child_bus(bus);
pci_bus_add_devices(bus);
}


Is this a bug or am I doing something wrong?

Liberty
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/