Trying to remove cardbus dependence on ds
rmk at arm.linux.org.uk
Tue Jun 17 21:17:01 BST 2003
I've been playing with one of our objectives, which is to try to remove
the dependence of cardbus devices on the ds module. However, I've hit
deadlock in the device model while trying to achieve this.
Note that the same deadlock occurs today in 2.5.72 given the right
conditions (start up pcmcia, kill cardmgr, insert cardbus card, remove
ds module, remove socket driver... or even just insert pcmcia modules
and then try to remove them with a cardbus card in the socket.)
The problem is this:
- when a PCI cardbus socket driver is unloaded, the pci driver's unload
function is called with the pci bus type semaphore write-locked.
- we ask the pccard daemon for the socket to shut down, and wait for it
to do so.
- the pccard daemon shuts down the socket, which involves unregistering
the cardbus devices and turning the power off.
Ah. "unregistering the cardbus devices". Well, those are PCI devices.
To unregister these, we need to obtain a write lock on the pci bus type
semaphore. Okay, but we're already holding it for the unload of the PCI
cardbus socket driver.
So, we can't call other pci device add/remove functions from within a
driver probe/remove callback.
This makes it pretty hard for cardbus bridges because they need a driver
to tell decide when to add/remove their subordinate devices.
My best thoughts so far on the subject is to provide some way to warn
stuff that its going to be unloaded so we can shut down what we need to
without the driver model getting in the way (eg via a writeable sysfs
file?) and use the module count to lock the module into the kernel until
its safe to unload.
The alternative is we never allow socket drivers to be unloaded once
they have initialised.
Russell King (rmk at arm.linux.org.uk) The developer of ARM Linux
More information about the linux-pcmcia