linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Unloading drivers, start-up, shut-down and some clean-ups (a problem)
@ 2001-10-02  2:00 stamit
  2001-10-03  1:41 ` Keith Owens
  0 siblings, 1 reply; 2+ messages in thread
From: stamit @ 2001-10-02  2:00 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 1489 bytes --]

(please don't hate me for this... :-)

There are two obvious problems with the previous patch...

1. From the beginning  I tried to verbosely comment the scripts (so they 
can be self-explanatory and easy to read) and, apparently, I forgot to 
update the comments in the "uhci.agent" after reorganizing the scripts 
(to experiment with), so... the comments in /etc/hotplug/pci/uhci.agent 
are wrong, misleading and confusing (ouch)!

2. Only after posting that previous patch I realised that the way in 
which the "start" and "stop" events are passed down from policy agents 
to driver agents was, well, not so good. "start" was passed if a kernel 
module was already loaded and "stop" was passed if a module was already 
unloaded. Well, it turns out that the right thing is to handle 
start/stop in the same (almost) way that add/remove events are handled. 
The only difference is that, for start/stop, $MODULE is also exported 
and is the name of the currently loaded kernel module ("-" if none, "#" 
if undetermined).

Now, the final thing that remains for unloading to be complete is 
reference counting. I tried to do it with bash (by storing counts in 
*.ref files in the driver directories) and guess what I stumbled to... a 
race condition! Multiple hotplug events can be processed by the scripts 
at the same time. So I took it back. Isn't there a way to use modutils 
programs to play with the module's real refrence counts? It would make 
things a whole lot easier (and safer).

[-- Attachment #2: hotplug-2001_04_24-patch.diff.gz --]
[-- Type: application/x-gzip, Size: 33259 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Unloading drivers, start-up, shut-down and some clean-ups (a problem)
  2001-10-02  2:00 Unloading drivers, start-up, shut-down and some clean-ups (a problem) stamit
@ 2001-10-03  1:41 ` Keith Owens
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Owens @ 2001-10-03  1:41 UTC (permalink / raw)
  To: linux-hotplug

On Tue, 02 Oct 2001 03:00:00 +0100, 
stamit <ewstam@softhome.net> wrote:
>Now, the final thing that remains for unloading to be complete is 
>reference counting. I tried to do it with bash (by storing counts in 
>*.ref files in the driver directories) and guess what I stumbled to... a 
>race condition! Multiple hotplug events can be processed by the scripts 
>at the same time. So I took it back. Isn't there a way to use modutils 
>programs to play with the module's real refrence counts? It would make 
>things a whole lot easier (and safer).

Without knowing exactly what you are trying to do I am guessing but it
sounds like you need this:

* kernel/module.c registers /proc/sys/kernel/mod_use_count, mode 600.
* module.c creates a dummy module entry called mod_use_count the first
  time that /proc/sys/kernel/mod_use_count is written to.
* /proc/sys/kernel/mod_use_count recognises commands like
    up module-name
    down module-name
  and adjusts the use counts and reference chain accordingly.  Hotplug
  scripts use mod_use_count to bump the reference count before allowing
  a start event to continue and after completing a stop event.

If the module does not exist (already unloaded) then write fails with
some return code.  There is no specific code for "module does not
exist" so pick something similar, like ESRCH or ENXIO.


_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-10-03  1:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-02  2:00 Unloading drivers, start-up, shut-down and some clean-ups (a problem) stamit
2001-10-03  1:41 ` Keith Owens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).