Problems with ide-cs.c
I've run into an issue when working on pcmcia support for a device with a CF socket.
With CF you can remove the card without ejecting it first. Removal results in a call to ide_release() in ide-cs.c which in turn calls ide_unregister. This all looks quite sensible.
If the usage count for the device is non-zero ide_unregister will fail which is likely if you just pull the card out. This silent failure leads to all kinds of problems which break the device until it's rebooted - quite a serious bug. There is a fixme in ide-cs.c relating to this.
There are several issues on different levels here. If ide_unregister can fail, it should really return a value. Two solutions: Either make it so ide_unregister can't fail or return a failure value.
That latter seems quite simple but if a failure value is returned, there is not a lot ide-cs.c can do other than retry the ide_unregister call periodically until it succeeds. As the hardware has gone, it should really be possible to point this out the ide system and have it act accordingly. The user shouldn't really have to see any timeouts/kernel whinging etc. as it is know the device is gone.
If ide_unregister marked the hwif "gone" and fails any and all new requests passed to IDE drives associated with the hwif immediately, that would solve some of the problems.
Unfortunately, I don't know a lot about the ide system. I'm open to suggestions as to how this bug can be resolved though.
Thanks,
Richard
Quoted 4 lines · I wrote:
If the usage count for the device is non-zero
ide_unregisterwill fail which is likely if you just pull the card out. This silent failure leads to all kinds of problems which break the device until it's rebooted - quite a serious bug. There is a fixme inide-cs.crelating to this.
I've been looking into this. I think the simplest approach is to make sure ide_unregister() succeeds regardless of any busy/usage status.
In order to make it succeed, I found I needed to add some checks on various functions to see if drives were dead or interface's present. I've made a working patch available at http://www.rpsys.net/openzaurus/ide.patch . If someone who knows more about the ide system could have a look at this, I'd appreciate it. If a patch along these lines could be included, it would unbreak ide_unregister() and hence the ide_cs module.
Thanks,
Richard