From mboxrd@z Thu Jan 1 00:00:00 1970 From: Keith Owens Date: Sun, 04 Feb 2001 03:26:04 +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 FWIW there has been some discussion between kernel developers about redesigning the module load/unload mechanism. Rusty Russell points out that controlling module use counts by exporting the module structure via the owner field does not work when the use count needs to be manipulated from an interrupt. In Rusty's case he is thinking about netfilter, but the same point applies to hot unplugging. Current thinking is to change modules so they have four required functions, instead of the current two functions. init: Allocate resources. register: Make services available. unregister: Remove services. exit: Deallocate resources. 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 successful, call exit. If the flush was unsuccessful (somebody just started using the module), call register to make the services available again. 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. 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. Unconditional shutdown calls unregister which stops any new code entering the module. The driver returns -EIO for all outstanding requests which will eventually result in the outstanding users calling close() or its equivalent and leaving the module. When the use count finally goes to zero, exit releases the resources and the module is removed. For built in code we do almost the same, the only difference is that built in code is not removed from memory. _______________________________________________ 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