Messages in this thread | | | Date | Sun, 27 Jul 2008 14:01:04 +0300 | From | Eran Liberty <> | Subject | Re: [PATCH 2.6.26] PCI: refuse to re-add a device to a bus upon pci_scan_child_bus() |
| |
Eran Liberty wrote:
> Soooo ... > > If I really wanted to make it, working my way around the current code, I would have done something like this. > > bus = null; > > while ((bus = pci_find_next_bus(bus)) != NULL) { > > for (devfn = 0; devfn < 0x100; devfn += 8) { > > for (func = 0; func < 8; func++) { > > struct pci_dev *dev = <http://liberty/lxr/ident?v=e500-linux-2.6.26-rc4;i=pci_get_slot>pci_get_slot(struct pci_bus *bus, unsigned int devfn); > > if (dev) > continue; > > dev = pci_scan_single_device(bus, devfn); > > if (!dev) > > continue; > > pci_device_add(dev, bus); > > } > > } > > pci_bus_assign_resources(bus); > > pci_bus_add_devices(bus); > > } > Found some time to test my own idea... it seems to work. :)
Its final version looks like this:
Before reloading the programmable unit, remove all the device implemented by it
struct pci_dev *dev; while ((dev = pci_get_device(PCI_VENDOR_ID_MYCOMP,PCI_DEVICE_ID_MYCOMP_MYDEV,NULL)) != NULL) { pci_remove_bus_device(dev); pci_dev_put(dev); }
After the programmable unit is loaded, scan and add only newly added device!
struct pci_bus *bus = NULL; while ((bus = pci_find_next_bus(bus)) != NULL) { int devfn; for (devfn = 0; devfn < 0x100; devfn++) { struct pci_dev *dev=pci_get_slot(bus,devfn); if (dev) continue; // <---- do not scan devices already present on the bus. Missing magic line :) (void)pci_scan_single_device(bus, devfn); } pci_bus_assign_resources(bus); pci_bus_add_devices(bus); }
So... no need for patch after all. Unless... Hey whats this... behind it... on the side.... naaa, no need of patch... :(
Liberty
| |