lkml.org 
[lkml]   [2008]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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



\
 
 \ /
  Last update: 2008-07-27 13:07    [W:0.601 / U:0.952 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site