Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 16533 - problems with /etc/init.d/alsasound zap/stop/start/restart
Summary: problems with /etc/init.d/alsasound zap/stop/start/restart
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Arcady Genkin (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on: 14553
Blocks:
  Show dependency tree
 
Reported: 2003-02-28 00:10 UTC by Tom Korte
Modified: 2004-02-07 14:46 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Korte 2003-02-28 00:10:42 UTC
Doing "alsasound zap" when alsasound is running gets the system thinking that
alsasound is both running and stopped at the same time.  ie - after this
"alsasound stop" responds with 'alsa isn't running' but "alsasound start"
responds with 'alsa is already running.
Unable to shutdown or restart alsasound after this.

Reproducible: Didn't try
Steps to Reproduce:
See description above.

Actual Results:  
bart root # /etc/init.d/alsasound stop
 * ERROR:  "alsasound" has not yet been started.
bart root # /etc/init.d/alsasound start
 * ALSA driver is already running.
bart root # /etc/init.d/alsasound restart
 * ALSA driver is already running.
bart root # 



Ran into this issue when I tried to migrate from snd-emu10k1 (SBLive!) card to
snd-ice1712 (Audiophile 2496) card.  I thought it may have been linked to a
residual /etc/asound.state from the emu10k1 card but I don't think this is the
case.  In the end, the process is stuck and you can't stop it or restart it by
these means.
Comment 1 Jason Clinton 2003-04-24 09:26:24 UTC
This is a duplicate of http://bugs.gentoo.org/show_bug.cgi?id=14553
Comment 2 Arcady Genkin (RETIRED) gentoo-dev 2003-04-24 17:15:48 UTC
Tom, are you using a 2.5 kernel with the alsa driver compiled into it?
In any case, please post more info (versions of all alsa packages as a bare minimum).
Comment 3 Jason Clinton 2003-04-24 17:30:44 UTC
I'm having the same problem. I'm running Gentoo Unstable and Gentoo Kernel 2.40.20-r3. ALSA (0.9.2) is automatically loaded by the kernel BEFORE the alsasound script execs. This causes the script to fail.

I have not been able to explain it. I'm not even sure where it's loading as dmesg shows no output from the driver as it's loading in. I searched through devfsd thinking that perhaps a binding in there was causing the kernel to automatically search for a driver to fit the device but no modifications I made to devfsd.conf affected the ALSA modules loading.

What this bug specifically targets is that the alsasound init script does not know how to unload the ALSA modules if ALSA is already running, reinsert them,  load the mixer settings appropriately and reset the rc status to 'running'.

To reproduce this:

Boot your computer and allow alsasound to start normally (if not having the problem above)
'zap' the alsasound init script
try and start it again

this can also happen if you:
/etc/init.d/alsasound stop
*blah blah about driver still in use*
                                           [OK] <---- NO!
/etc/init.d/alsasound start
The ALSA driver is already loaded.

/etc/init.d/alsasound stop
alsasound isn't running.

Make sense?
That's why this and the other earlier bug are symptoms of the same problem (unless I misinterpreted Tom).
Comment 4 Arcady Genkin (RETIRED) gentoo-dev 2003-04-24 17:58:50 UTC
Do you have alsasound script added to the 'boot' runlevel, or 'default'?
What do you have in /etc/moudules.autoload?
Comment 5 Jason Clinton 2003-04-24 18:34:51 UTC
Yes, it's in boot.

Contents of /etc/modules.autoload:
# /etc/modules.autoload.d/kernel-2.4:  kernel modules to load when system boots.
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/modules.autoload.d/kernel-2.4,v 1.1 2003/03/09 09:06:23 azarah Exp $
#
# Note that this file is for 2.4 kernels.  If you need different modules
# for a 2.5 kernel, you can create /etc/modules.autoload.d/kernel-2.5
#
# Add the names of modules that you'd like to load when the system
# starts into this file, one per line.  Comments begin with # and
# are ignored.  Read man modules.autoload for additional details.

# For example:
8139too
#3c59x
#sound
#ac97_codec
#emu10k1
i2c-core
#i2c-algo-bit
i2c-proc
#tuner
#tvaudio
#tvmixer
#videodev
#btaudio
#bttv
usbvideo
ibmcam
#tiglusb
input
hid
mousedev




Contents of /etc/modules.conf:
### This file is automatically generated by modules-update
#
# Please do not edit this file directly. If you want to change or add
# anything please take a look at the files in /etc/modules.d and read
# the manpage for modules-update.
#
### modules-update: start processing /etc/modules.d/aliases
# Aliases to tell insmod/modprobe which modules to use 

# Uncomment the network protocols you don't want loaded:
# alias net-pf-1 off		# Unix
# alias net-pf-2 off		# IPv4
# alias net-pf-3 off		# Amateur Radio AX.25
# alias net-pf-4 off		# IPX
# alias net-pf-5 off		# DDP / appletalk
# alias net-pf-6 off		# Amateur Radio NET/ROM
# alias net-pf-9 off		# X.25
# alias net-pf-10 off		# IPv6
# alias net-pf-11 off		# ROSE / Amateur Radio X.25 PLP
# alias net-pf-19 off		# Acorn Econet

alias char-major-10-175	agpgart
alias char-major-10-200	tun
alias char-major-81	bttv
alias char-major-108	ppp_generic
alias /dev/ppp		ppp_generic
alias tty-ldisc-3	ppp_async
alias tty-ldisc-14	ppp_synctty
alias ppp-compress-21	bsd_comp
alias ppp-compress-24	ppp_deflate
alias ppp-compress-26	ppp_deflate

# Crypto modules (see http://www.kerneli.org/)
alias loop-xfer-gen-0	loop_gen
alias loop-xfer-3	loop_fish2
alias loop-xfer-gen-10	loop_gen
alias cipher-2		des
alias cipher-3		fish2
alias cipher-4		blowfish
alias cipher-6		idea
alias cipher-7		serp6f
alias cipher-8		mars6
alias cipher-11		rc62
alias cipher-15		dfc2
alias cipher-16		rijndael
alias cipher-17		rc5

# Support for i2c and lm_sensors
alias char-major-89    i2c-dev

# Old nvidia support ...
alias char-major-195 NVdriver 
alias /dev/nvidiactl char-major-195 

### modules-update: end processing /etc/modules.d/aliases

### modules-update: start processing /etc/modules.d/alsa
# Alsa 0.9.X kernel modules' configuration file.
# $Header: /home/cvsroot/gentoo-x86/media-sound/alsa-driver/files/alsa-modules.conf-rc,v 1.1 2002/12/21 06:31:52 agenkin Exp $

# ALSA portion
alias char-major-116 snd
# OSS/Free portion
alias char-major-14 soundcore

##
## IMPORTANT:
## You need to customise this section for your specific sound card(s)
## and then run `update-modules' command.
## Read alsa-driver's INSTALL file in /usr/share/doc for more info.
##
##  ALSA portion
alias snd-card-0 snd-emu10k1
##alias snd-card-1 snd-ens1371
##  OSS/Free portion
alias sound-slot-0 snd-card-0
##alias sound-slot-1 snd-card-1
##

# OSS/Free portion - card #1
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss
##  OSS/Free portion - card #2
## alias sound-service-1-0 snd-mixer-oss
## alias sound-service-1-3 snd-pcm-oss
## alias sound-service-1-12 snd-pcm-oss

alias /dev/mixer snd-mixer-oss
alias /dev/dsp snd-pcm-oss
alias /dev/midi snd-seq-oss

# Set this to the correct number of cards.
options snd cards_limit=1

### modules-update: end processing /etc/modules.d/alsa

### modules-update: start processing /etc/modules.d/i386
alias parport_lowlevel parport_pc
alias char-major-10-144 nvram
alias binfmt-0064 binfmt_aout
alias char-major-10-135 rtc

### modules-update: end processing /etc/modules.d/i386

### modules-update: start processing /etc/modules.d/ppp
alias char-major-108	ppp_generic
alias /dev/ppp		ppp_generic
alias tty-ldisc-3	ppp_async
alias tty-ldisc-13	n_hdlc
alias tty-ldisc-14	ppp_synctty
alias ppp-compress-21	bsd_comp
alias ppp-compress-24	ppp_deflate
alias ppp-compress-26	ppp_deflate
alias net-pf-24		pppoe

### modules-update: end processing /etc/modules.d/ppp

### modules-update: start processing /etc/modules.d/svgalib
probeall  /dev/svga  svgalib_helper

### modules-update: end processing /etc/modules.d/svgalib



Contents of /etc/devfsd.conf:
# Sample /etc/devfsd.conf configuration file.
# Richard Gooch  <rgooch@atnf.csiro.au>		3-JUL-2000
#
# The Gentoo Linux Team - http://www.gentoo.org/
#     - Many fixes, etc
#
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/devfsd.conf,v 1.15 2003/03/02 22:32:08 azarah Exp $

# Enable full compatibility mode for old device names. You may comment these
# out if you don't use the old device names. Make sure you know what you're
# doing!
REGISTER        .*           MKOLDCOMPAT
UNREGISTER      .*           RMOLDCOMPAT

# You may comment out the above and uncomment the following if you've
# configured your system to use the original "new" devfs names or the really
# new names
#REGISTER       vc/.*        MKOLDCOMPAT
#UNREGISTER     vc/.*        RMOLDCOMPAT
#REGISTER       pty/.*       MKOLDCOMPAT
#UNREGISTER     pty/.*       RMOLDCOMPAT
#REGISTER       misc         MKOLDCOMPAT
#UNREGISTER     misc         RMOLDCOMPAT

# You may comment these out if you don't use the original "new" names
REGISTER        .*           MKNEWCOMPAT
UNREGISTER      .*           RMNEWCOMPAT

# Enable module autoloading. You may comment this out if you don't use
# autoloading
LOOKUP          .*           MODLOAD

# Uncomment the following if you want to set the group to "tty" for the
# pseudo-tty devices. This is necessary so that mesg(1) can later be used to
# enable/disable talk requests and wall(1) messages.
REGISTER        ^pty/s.*     PERMISSIONS -1.tty  0600
REGISTER        ^pts/.*      PERMISSIONS -1.tty  0600

# Uncomment this if you want permissions to be saved and restored
# NB: Do NOT change the following!
# Do not do this for pseudo-terminal devices
REGISTER        ^pt[sy]/.*   IGNORE
CHANGE          ^pt[sy]/.*   IGNORE
CREATE          ^pt[sy]/.*   IGNORE
DELETE          ^pt[sy]      IGNORE
REGISTER        .*           COPY    /lib/dev-state/$devname $devpath
CHANGE          .*           COPY    $devpath /lib/dev-state/$devname
CREATE          .*           COPY    $devpath /lib/dev-state/$devname
DELETE          .*           CFUNCTION GLOBAL unlink /lib/dev-state/$devname
RESTORE         /lib/dev-state

# You can force default like this :
# PERMISSIONS owner_and_group access_mode

# Video4Linux devices
REGISTER       v4l/.*       PERMISSIONS root.video 660

# ALSA/OSS stuff
# Comment/change these if you want to change the permissions on
# the audio devices
LOOKUP          snd          MODLOAD ACTION snd
LOOKUP          dsp          MODLOAD
LOOKUP          mixer        MODLOAD
LOOKUP          midi         MODLOAD
REGISTER        sound/.*     PERMISSIONS root.audio 660
REGISTER        snd/.*       PERMISSIONS root.audio 660

# Uncomment this to let PAM manage devfs
#REGISTER        .*           CFUNCTION /lib/security/pam_console_apply_devfsd.so pam_console_apply_single $devpath

# Autoload the sg module if generic scsi driver compiled as module.
LOOKUP          ^sg$      MODLOAD ACTION sg

# Give the cdrw group write permissions to /dev/sg0
# This is done to have non root user use the burner (scan the scsi bus)
REGISTER        ^scsi/host.*/bus.*/target.*/lun.*/generic    PERMISSIONS root.cdrw 660

# General note for the following auto creation of symlinks:
#
#    If you change the device that the symlink points to,
#    you should also remove the symlink before restarting
#    devfsd

# Create /dev/cdrom for the first cdrom drive
LOOKUP          ^cdrom$          CFUNCTION GLOBAL mksymlink cdroms/cdrom0 cdrom
REGISTER        ^cdroms/cdrom0$   CFUNCTION GLOBAL mksymlink $devname cdrom
UNREGISTER      ^cdroms/cdrom0$   CFUNCTION GLOBAL unlink cdrom

# Create /dev/dvd for the second cdrom drive
# (change 'cdroms/cdrom1' to suite your setup)
# NOTE: We add the fully qualified path here, else some apps
#       have problems to resolve the true device (drip comes to mind)
LOOKUP          ^dvd$           CFUNCTION GLOBAL mksymlink ${mntpnt}/cdroms/cdrom0 dvd
REGISTER        ^cdroms/cdrom0$  CFUNCTION GLOBAL mksymlink ${devpath} dvd
UNREGISTER      ^cdroms/cdrom0$  CFUNCTION GLOBAL unlink dvd

# Create /dev/cdrw for the first cdrom on the scsi bus
# (change 'sr0' to suite your setup)
LOOKUP          ^cdrw$          CFUNCTION GLOBAL mksymlink sr0 cdrw
REGISTER        ^sr0$           CFUNCTION GLOBAL mksymlink $devname cdrw
UNREGISTER      ^sr0$           CFUNCTION GLOBAL unlink cdrw

# Create /dev/mouse
LOOKUP          ^mouse$          CFUNCTION GLOBAL mksymlink misc/psaux mouse
REGISTER        ^misc/psaux$     CFUNCTION GLOBAL mksymlink $devname mouse
UNREGISTER      ^misc/psaux$     CFUNCTION GLOBAL unlink mouse

# Manage USB mouse
REGISTER        ^input/mouse0$   CFUNCTION GLOBAL mksymlink $devname usbmouse
UNREGISTER      ^input/mouse0$   CFUNCTION GLOBAL unlink usbmouse
REGISTER        ^input/mice$     CFUNCTION GLOBAL mksymlink $devname usbmouse
UNREGISTER      ^input/mice$     CFUNCTION GLOBAL unlink usbmouse

# Support additional config installed by packages ...
INCLUDE /etc/devfs.d

# devfsd.conf ends here
Comment 6 Tom Korte 2003-04-24 22:31:52 UTC
Jason was correct in his understanding of what the intent of my bug report was.  My chief concern was the fact that the system could be easily put into an inconsistent state, i.e. - drivers loaded so alsasound can't be started but alsasound isn't running so it can't be stopped or restarted with both situations occuring simultaneously.

It would seem that both the alsasound start and stop scripts check for the presence of loaded drivers and won't proceed if said drivers are already loaded.  This is probably a good thing.  Now what is needed is for the alsasound stop script to have a way to unload those drivers even if alsasound isn't running.  Alternatively, give the alsasound start script a way to start alsasound even if the drivers are already loaded.

Perhaps the best method would be to change the restart script as that's probably what a person will be trying to do when they are messing around with drivers and whatnot.  The restart script already unloads all of the drivers and then reloads them but at present it won't run if it thinks that alsasound is stopped, even if the drivers are loaded.  This logic leaves us with a failed test (result: alsasound is not running) right at the beginning so the restart doesn't get any further and the drivers are not unloaded.

In summary, if the restart script can be modified so that it doesn't fail when alsasound is not running then it should unload the drivers and restart alsasound.  The system will not be left in an inconsistent state and this would bring the story to a (hopefully happy) end.

Any thoughts on this from those in the know?

Tom
Comment 7 Jason Clinton 2003-05-09 12:53:10 UTC
I have discovered the reason that ALSA automatically loads during boot. These lines in /etc/modules.d/alsa:

##  OSS/Free portion
##alias sound-slot-0 snd-card-0
##alias sound-slot-1 snd-card-1
##

If you uncomment the entry for your sound card per the official instructions on ALSA's site and in their documentation, a "virtual device" is created and the kernel is notified that a hotplug has occured. If you have hotplug and kernel module autoloader support in your kernel, this will cause your kernel to automatically insert the appropriate drivers.

The official ALSA instructions conflict with the ALSA install guide on the Gentoo Docs site on this point. I think that the Gentoo install guide should explicitly state that you SHOULD NOT uncomment anything in the OSS/Free section.
Should I file another bug report to get this done?

Note: this would not be a bug if bug 14553 were fixed.
Comment 8 Jeremy Huddleston (RETIRED) gentoo-dev 2004-02-07 14:46:11 UTC
This should be fixed now... grab the new init script.