Skip to contentSkip to conversation

maybe race condition & alsa

DISCUSSION Francisco Lobo 3 participants 5 messages Apr 7, 2004 – Apr 9, 2004

lore
Share & tools
lore
#0 lore raw

SALVE

After a couple of days... Success! I now have linux-2.6 + udev, and finally got rid of the devfs names. Thanks to everyone!

I just have ONE device node on the physical filesystem: /dev/console (i.e. mknod /dev/console c 5 1), because init must have it at boot. Then, rc.sysinit has this before any real work (fs checks):

/bin/mount -n /dev
/bin/mount -n /proc
/bin/mount -n /sys
mkdir /dev/pts
mkdir /dev/shm
/sbin/udevstart
ln -snf /proc/self/fd /dev/fd
ln -snf /proc/self/fd/0 /dev/stdin
ln -snf /proc/self/fd/1 /dev/stdout
ln -snf /proc/self/fd/2 /dev/stderr
ln -snf /proc/kcore /dev/core

PRONTO!

Maybe the documentation for udev should hint that /dev/console is the only device needed to boot (or maybe I didn't read it well).

Getting alsa to work was a very different story! Although this problem might just be alsa related (alsactl in particular), I though the following info should help people migrate to udev, so:

1. with udev the following modprobe.conf lines are not working for me

install snd-card-0 /sbin/modprobe --ignore-install snd-card-0 && \
	{ /usr/sbin/alsactl restore >/dev/null 2>&1 || :; }
remove snd-card-0 { /usr/sbin/alsactl store >/dev/null 2>&1 || :; } ; \
	/sbin/modprobe -r --ignore-remove snd-card-0

2. although there are no error messages, the fact is the alsactl cannot find the sound card (/dev entries), so when one tries to play something the sound is mute

The solution I found is:

1. replace hotplug init script with:

echo "/sbin/udev" > /proc/sys/kernel/hotplug

2. immediately after that load the snd-card-0 and other module(s) in a modules init script

3. then in a later init script do the alsactl part, and by "later" I mean after a few other ones, or else same problem as above - you might use some adequate sleep value before alsactl command (but?)

What I mean by a possible race condition is that alsactl will not find the /dev entries if this procedure is not exactly followed. Also, this will ONLY work with udev as the hotplug program! The hotplug scripts are simply too slow to respond (I've tried sleep 2 before alsactl and nothing, at least with hotplug-2004_01_05 - NOTE: I don't have pcimodules, yet hotplug should use sysfs shouldn't it?)

Of course, alsactl could/should do more to find the sound card... I did not check its sources to see how this is done... But it seems plausible that it is only doing a stat on /dev entries, and maybe it could ask the kernel for sound devices, which might then make the modprobe / udev / hotplug processes to finish whatever they have to do. (I don't know much about this, it just feels that something like it could sort things out.)

The obvious problem with this solution is that one always has the sound modules, even if we're not going to jam!

Salu!

Francisco.

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 3 lines · Francisco Lobo

Maybe the documentation for udev should hint that /dev/console is the only device needed to boot (or maybe I didn't read it well).

It's not needed for me. It all depends on your distro's needs.

Quoted 3 lines

1. replace hotplug init script with:

echo "/sbin/udev" > /proc/sys/kernel/hotplug

Ick, ick, ick. NO. do not do this. Lots of other stuff will not work properly in your system if you do this.

The problem is that you need to wait a bit of time before running alsactl for the device nodes to show up. So call out to a shell script instead to do this wait, instead of trying to do it all in a modprobe.conf line.

That's what works for me.

thanks,

greg k-h

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Francisco Lobo
Quoted 6 lines · Greg KH

The problem is that you need to wait a bit of time before running alsactl for the device nodes to show up. So call out to a shell script instead to do this wait, instead of trying to do it all in a modprobe.conf line.

That's what works for me.

I'm using this:

/etc/dev.d/snd/controlC0/alsa.dev:

#!/bin/sh -e
exec /usr/sbin/alsactl restore 0

Signature · 13 lines
ciao, |
Marco | [5624 caqcc7nk9K4Dg]


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#3 lore raw
In reply to Francisco Lobo
Quoted 7 lines · Marco d'Itri
Quoted 5 lines · Greg KH

The problem is that you need to wait a bit of time before running alsactl for the device nodes to show up. So call out to a shell script instead to do this wait, instead of trying to do it all in a modprobe.conf line.

Quoted 7 lines
Quoted 1 line

That's what works for me.

I'm using this:

/etc/dev.d/snd/controlC0/alsa.dev:

#!/bin/sh -e
exec /usr/sbin/alsactl restore 0

That's a great example. I think I'll go add it to the scripts...

But wait, that really works? Heh, I guess when the DEVNAME includes a directory, that's what is needed, pretty funny.

thanks,

greg k-h

Quoted 4 lines
Signature · 3 lines
-- 
ciao, |
Marco | [5624 caqcc7nk9K4Dg]

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#4 lore raw
In reply to Francisco Lobo
Quoted 8 lines · Marco d'Itri

I'm using this:

/etc/dev.d/snd/controlC0/alsa.dev:

#!/bin/sh -e
exec /usr/sbin/alsactl restore 0

Brilliant !!!
I must start thinking in udev ways from now on...

Greg KH wrote: (about /dev/console)

Quoted 3 lines

It's not needed for me. It all depends on your distro's needs.

I don't really understand: at present I am running Arch Linux, but I can't see anything special with their boot setup, it's a plain BSD style init; and their init compilation is very much LFS style, no special hacks.

Do you mean using a /linuxrc to start udev, before init? (Maybe I should try that someday...) The init manpage says it defaults the system console to /dev/console or inherits the CONSOLE var from the kernel command-line; it needs it to report its messages I guess.

Well... I would really like to know how you did it.

Greg KH wrote: (about hotplug)

Quoted 4 lines

Ick, ick, ick. NO. do not do this. Lots of other stuff will not work properly in your system if you do this.

Hum... I see everything (I use) working... Although I have to confess that I don't use usb devices, or plug and unplug any hardware regularly.

What will not work?
Is there any specific problem with using /sbin/udev as the hotplug program?

As far as I understand (and for my simple needs), I only require the correct device nodes to be created after I insert a kernel module. I shouldn't need a script that calls a script that calls a script..., every time I load a module. But this is my personal point of view, and I understand that a general all-scenarios solution cannot be done in another way.

Thank you both!
Francisco.

PS:
I did try the latest hotplug in the meantime, which now does a good job of discovering hardware via sysfs!

Yet I have some reservations with respect to its init script. I don't want to configure all my hardware at boot but only as I need it, so I am force to blacklist a lot of modules. Also, it is curious that my alsa sound card module does not get loaded, because the oss one comes first in modules.pcimap and I put it on the blacklist (from what I could understand from the scripts), so I cannot have several modules for the same device(?).

Of course, this is not related to using hotplug as the "hotplug program"; these are simply examples, which I think begin to support my notion that what the hotplug scripts try to automate is in fact something that is very specific to system/user preference (i.e. like init scripts). Without having the time to get familiar with all the scripts at the moment, I would rather do without it.

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel