2.6.24-rc4: pci_remove_bus_device() => pci_scan_child_bus() => pci_bus_add_devices bug?

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eran Liberty
Date: Wednesday, June 18, 2008 - 7:18 am

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
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
2.6.24-rc4: pci_remove_bus_device() => pci_scan_child_bus( ..., Eran Liberty, (Wed Jun 18, 7:18 am)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Mathieu Desnoyers, (Mon Aug 18, 8:47 am)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Mathieu Desnoyers, (Mon Aug 18, 10:04 am)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Mathieu Desnoyers, (Mon Aug 18, 11:41 am)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Benjamin Herrenschmidt, (Mon Aug 18, 6:51 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Benjamin Herrenschmidt, (Mon Aug 18, 6:53 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Benjamin Herrenschmidt, (Mon Aug 18, 6:54 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Benjamin Herrenschmidt, (Mon Aug 18, 7:39 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Mathieu Desnoyers, (Mon Aug 18, 7:47 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Benjamin Herrenschmidt, (Mon Aug 18, 7:56 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Mathieu Desnoyers, (Mon Aug 18, 8:36 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Benjamin Herrenschmidt, (Mon Aug 18, 9:17 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Mathieu Desnoyers, (Tue Aug 19, 6:02 am)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Mathieu Desnoyers, (Tue Aug 19, 6:05 am)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Mathieu Desnoyers, (Tue Aug 19, 7:42 am)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Mathieu Desnoyers, (Tue Aug 19, 10:34 am)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Benjamin Herrenschmidt, (Tue Aug 19, 2:46 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Benjamin Herrenschmidt, (Tue Aug 19, 2:47 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Jeremy Fitzhardinge, (Tue Aug 19, 4:58 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Benjamin Herrenschmidt, (Tue Aug 19, 6:17 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Benjamin Herrenschmidt, (Wed Aug 20, 12:18 am)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Benjamin Herrenschmidt, (Wed Aug 20, 2:36 pm)
Re: ftrace introduces instability into kernel 2.6.27(-rc2, ..., Benjamin Herrenschmidt, (Wed Aug 20, 2:37 pm)