This time with the new version of the code.
It's possible that a driver's probe function could be called twice for the
same device.
CPU A CPU B
----- -----
pci_register_driver() pci_insert_device()
Add driver to the list Add device to the list
foreach(device) foreach(driver)
driver->probe; driver->probe;
That's not particularly evil, I suppose, as long as the driver writers know
that it could happen. What's nastier is the one which can leave a driver
thinking it's attached to a device which no longer exists.
CPU A CPU B
----- -----
pci_register_driver() pci_remove_device()
Add driver to list
if (dev->driver)
driver->remove;
foreach(device)
driver->probe(dev);
Remove device from list
The answer seems to be to put a lock around all four functions. As the
probe functions are permitted to sleep, that lock should probably be a
semaphore.
There are other options, but we discussed an almost identical situation
the other day, and I believe the term used to describe the semaphore option
was "highest probability of correctness". It's hardly on the critical path.
-- dwmw2- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Jun 15 2000 - 21:00:34 EST