From mboxrd@z Thu Jan 1 00:00:00 1970 From: Keith Owens Date: Mon, 05 Feb 2001 10:01:59 +0000 Subject: Re: Adding PCMCIA support to the kernel tree -- developers needed. Message-Id: List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org On Sun, 4 Feb 2001 19:16:00 +0100, Oliver Neukum wrote: >> Module startup automatically calls init then register. Conditional >> shutdown checks for zero use count, calls unregister then flushes any >> other cpus that had just entered the module. If the flush was > >Flushing ? How ? Black magic :-). See synchronize_kernel() in Rusty's recent patch for hotswap cpus. >> successful, call exit. If the flush was unsuccessful (somebody just >> started using the module), call register to make the services available >> again. > >Doing so means that there's a time where the device is unregistered >illegitimately. Yes, this small race is inherent in the quiesce model for module services. Worst case is a few open() calls get -ENODEV, but that can occur now during module unload and reload. >Wouldn't it be simpler to take the big kernel lock for the >check ? The unregistering would have to take it anyway. Only if the code that calls the module is also under BKL. That has not been true since 2.2, which is why module unloading has been such a problem since then. >> There is also an unconditional shutdown mode. Call unregister and even >> if the module is still in use, do not call register again. When the >> use count finally goes to zero, the exit routine is called and the >> module is removed. > >This is definitely needed, but why two calls for that ? It would be easier to >provide a callback to be called when the use count reaches zero. If you leave the services registered, other code can reenter the module. To whole point of unregistering services is to prevent any new uses of the module while we wait for the remnant use count to drop to zero. >> I think this will help hot unplugging. When the device disappears, the >> driver internally marks its hardware as unusable and schedules an >> unconditional shutdown of itself, all out of the interrupt handler. > >Is that really necessary ? Can't a kernel thread be used ? It is much easier >than coding in interrupt. Something has to mark the hardware as unusable, say a flag which can be set from the interrupt. When I said "schedules an unconditional shutdown of itself" I meant schedule the shutdown from the interrupt but run the shutdown via a kernel thread. The shutdown code could sleep so it cannot be called directly from the interrupt. _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel