# system hangs during boot when using ALSA

## sharky44

Hi.  I've recently installed Gentoo on my IBM Thinkpad A22m.

I followed the instructions on the Desktop Configuration guide for setting up ALSA.  Everything seemed to go fine.  

I had to recompile the kernel since I had compiled in support for my sound card initially, but I took that out, and now it's just soundcore support.  Ok.

I emerged alsa-driver, configured /etc/modules.autoload and /etc/modules.d/aliases for my sound card.  It's a Cirrus Logic CS4614, so I used the cs46xx drivers.  Ok.

I rebooted so all that would take effect.  Ok.  Worked fine.

Then I emerged alsa-utilities, un-muted the volume, etc.

THEN -- "rc-update add alsasound boot"

Now, when I reboot, it freezes at this point:

* Initialising ALSA.... [ok]

*   Starting sound driver: cs46xx

HANGS!  

The only way I know how to get my computer to boot again was to boot from Install CD, mount my harddrive and go: "rc-update del alsasound boot"

Then it boots OK.  Alsa seems to work OK once I unmute the volume after each reboot (How would you know if it's really working?) Because I also noticed an oddity:

# /etc/init.d/alsasound start

 * ALSA driver is already running.

# /etc/init.d/alsasound status

 * status:  stopped

# /etc/init.d/alsasound stop

 * ERROR:  "alsasound" has not yet been started.

# /etc/init.d/alsasound start

 * ALSA driver is already running.

# /etc/init.d/alsasound status

 * status:  stopped

I can recreate this anytime.

What would be causing the system to hang at boot?  Obviously ALSA, but why?  Any ideas?

Thanks in advance for your help!  I searched google & forums.gentoo.org for quite a while with no luck, so please point me to another forum if this issue has been addressed already, and if that is the case, I apologize for wasting valuable forum space  :Smile: 

----------

## delta407

Moving to Hardware forum...

----------

## w00kie

I get the same thing with the intel8x0 driver

have you found a solution???

----------

## kybber

My laptop occasionally hangs during boot at the same point. But that's only like every 4 or 5 times. My soundcard is a Maestro 3. The solution for me is simply to hit the powerbutton to reboot. It is still annoying so I'd be interested in a solution too, if you find one.

----------

## pludo

My laptop does that all the time now, too... with the intel8x0 driver.  Any idea how to fix it?

----------

## w00kie

now I'm running without alsasound in my boot runlevel and my sound modules in modules.autoload

oddly enough, ALSA works just fine even though it was never started

I just have to do an alsactl restore to get my volume back to my preferred settings

[edit]

nope, in fact alsactl restore hangs my machine  :Rolling Eyes: 

I've got to restore my sound levels by hand

[/edit]

----------

## BonezTheGoon

I'm not sure, since none of you specify, whether you are aware that you need to refer to the ALSA drivers (modules) as snd-(insert_module_name_here).

So for the intel8x0 module it becomes snd-intel8x0

for the cs46xx module it becomes snd-cs46xx.  This should also be used when referring to the card in the /etc/modules.d/aliases.  

It would appear that some of you must have the correct driver given you (w00kie) hear sounds, however others may not know this little gotcha of ALSA.

Hope that helps someone, anyone.

Regards,

BonezTheGoon

----------

## w00kie

yes

I do use snd_intel8x0 and have the 8 aliases in my /etc/modules.d/aliases

btw, my kernel is compiled with soundcore as a module and no other drivers

my modules.autoload looks like this (only showing you the sound related modules)

```
soundcore

snd-intel8x0

snd-pcm-oss

snd-mixer-oss
```

I didn't modify my /etc/modules.d/alsa file though

maybe I should try that...

----------

## Tuna

i have the same problem here.. manuallly loaded all the drives as told in the dektop guide worked pretty well. After first boot it hangs again exactly here..

* Starting sound driver: Ali5451

so.. as you can see.. different driver as the other people here (snd_ali5451)

but again.. a laptop...

either were all doing the same mistake here.. or we have a serious bug.

would be nice if someone could look into that.

thx

----------

## w00kie

I'm on a laptop too

DELL Inspiron 8200

----------

## ledents

I have got the same problem also but I am NOT running on a portable

(although I did buildin APM support into the kernel. don't know if it has to do with that?).

My sound card is also a cs46xx and I did some investigation and found

that the '/etc/init.d/alsasound start' was hanging on 'alsactl'.

I don't know how to fix it but whenever calling:

   alsactl -f /etc/asound.state restore

the machine will hang.

By the way this problem is also mentioned on another forum.

(no fix available their neither!)

----------

## cbrese

I just had the same problem my hack to fix it was to edit /etc/init.d/alsasound and comment out the part where it tries to reload the mixer setting and then I added the 2 amixer unmute commands from the desktop config guide.

It seems to be working good now.

----------

## ealfert

cbrese...thanks for the workaround!  I'm going to give more detail to your solution for the benefit of other newbies like me that need everything spelled out.

I just tried getting my sound to work on an ibm thinkpad t22 with snd-cs46xx driver and everything worked until i rebooted...then the system hanged at the same spot as y'all.

I WAS FORCED TO USE W2KPRO to search this forumn for an answer.

I booted the gentoo install cd and mounted the root partition...

edited /etc/init.d/alsasound

jumped to line 85 and commented it out...then inserted the following..

```

#        $alsactl -f $asoundcfg restore

# next section is a work around to enable sound

        eerror "Sound Level Restorer disable because of system hang problem!"

        amixer set Master 100 unmute

        amixer set PCM 100 unmute

# end of workaround

```

then i rebooted (THE SYSTEM DIDN"T HANG) and logged into KDE and I HEAR SOUND!

Since i'm on a laptop, i have volume control through the keyboard and don't need to have the os remember the volume settings... the hardware takes care of that.... i actually like to have the os set the volume to 100% and i can then raise/lower using the volume buttons on the keyboard.

Again... cbrese, thanks for the tip!

----------

## chr1z

i had the same problem

too bad i did not wait until i read this ;>

atm i'm reinstalling gentoo   :Laughing:   :Confused: 

----------

## ptheborg

My laptop config suffered from a similar problem. Besides the hang problem during booting, amixer didn't work. It gives an Assertion in simple.c and simply Aborts, so unmuting the channels manually during booting was no solution for me.

At this point ALSA was getting really on my nerves, but I didn't give up  :Wink: 

Then suddenly I got the idea to check the portage dir of alsa and discovered that I had installed 0.9.0-rc2 but there was a 0.9.0-rc1-r7 too. So I tried that ebuild script and it worked right from the start. NO hanging problems and amixer worked also as it should.

So I don't know for sure but I guess rc2 has still some bugs....???

----------

## ealfert

i just checked /var/tmp/portage and i only have alsa-driver-0.9.0_rc2 not rc7

doing a emerge -s alsa  only shows rc2

next time an update world upgrades alsa, i'll uncomment the workaround and see if the system still hangs on boot.

----------

## ptheborg

Hmmm, it's getting stranger every second... :S

Anyway, I'm very sure that the rc1-r7 is still there, even the 0.5XX ebuild script resides in that dir.

Have you tried an emerge rsync followed by an emerge clean ??

----------

## ealfert

i took your suggestion and did an emerge rsync then an emerge clean....and then my heart stopped...i say a HUGE list of packages that were being removed...for a second there i thought it was wiping out my entire harddrive...

after it finished...i did a man emerge and read up on the clean argument.... i'm glad it only removes packages that are no longer needed...i hope it doesn't make mistakes and this is true...

then i did an emerge -s alsa.... and once again...i only see rc2 only....

no problem here .... the workaround is working.... i'll just wait for the next official update to alsa and then remove the workaround... if it works....great... if not, i'll just install the workaround again...

----------

## ptheborg

Gheh, oh....ehm, sorry for that. But AFAIK emerge clean only removes not used outdated packages from the portage tree. Note: Remember to backup any modifications you've made to the portage tree by yourself....cause these will be gone...

But still very weird no alsa-driver-0.9.0-rc1-r7 shows up in your portage tree....very very weird, but maybe the rc1-r7 ebuild script is removed from the portage in an portage tree updated that occured last night. This would explain why I'm still having that script in the portage, simply because I have emerged that version.

----------

## sharky44

I tried the workaround suggested by cbrese, and thanks to ealfert for clarification.  Anyway, alsa loads fine on boot!  Yaay!

It seems to me that enough people have had difficulties that this situation might be worth a mention in the Gentoo Documentation?  

BTW, I am using alsa-driver 0.9.0-rc2; I did not try 0.9.0-rc1-r7 as ptheborg suggested.  The fact that 0.9.0-rc2 has a couple issues like this might be worth mentioning in the Gentoo docs as well.

Anyway, thanks for the help.

----------

## ptheborg

why upgrading to a later version that is broken.......???    :Cool: 

----------

## BonezTheGoon

I just gave myself this problem.  I had been using my onboard sound (snd-intel8x0) and finally bought a card.  So I changed my config to use the snd-cs46xx for my new PCI card.  Everything was fine until I rebooted.  It appears (thanks to cbrese's clue) that the problem for me was that the /etc/init.d/alsasound was loading the old values for my onboard sound and trying to get them to work for my new card.  I looked into the /etc/init.d/alsasound file and found that the file it was referencing was /etc/asound.state -- I also noticed that it checks to see if this file exists.  So I just deleted the /etc/asound.state and reboot.  Then everything was FINE!  Thanks cbrese!

Regards,

BonezTheGoon

----------

## amanset

 *ealfert wrote:*   

> 
> 
> I booted the gentoo install cd and mounted the root partition...
> 
> edited /etc/init.d/alsasound
> ...

 

I have been having MAJOR problems with my Santa Cruz. I tried the kernel drivers and they didn't work and no-one seemed to be able to help:

https://forums.gentoo.org/viewtopic.php?t=21333

I then tried to use the ALSA drivers and I got the error discussed here.

I then had to boot using the CD and edit /etc/init.d/alsasound but now I get an error on booting saying that there are syntax errors in the file and it will nto be executed!

Here's the bit in alsasound that I edited:

```

  #

  # restore driver settings

  #

  if [ -d /proc/asound ]; then

    if [ ! -r $asoundcfg ]; then

      ewarn "No mixer config in $asoundcfg, you have to unmute your card!"

    else

      if [ -x $alsactl ]; then

        # $alsactl -f $asoundcfg restore

        amixer set Master 100 unmute

        amixer set PCM 100 unmute

      else

        eerror -e "ERROR: alsactl not found!"

      fi

    fi

  fi

  #

```

Can anyone please help out as I have run out of ideas. Amixer is installed and works from the command line, so I don't think that is the problem.

----------

## amanset

Sorted out my problem, some corruption in the file at the beginning.

The sound still doesn't work though...

----------

## BonezTheGoon

 *BonezTheGoon wrote:*   

> I just gave myself this problem.  I had been using my onboard sound (snd-intel8x0) and finally bought a card.  So I changed my config to use the snd-cs46xx for my new PCI card.  Everything was fine until I rebooted.  It appears (thanks to cbrese's clue) that the problem for me was that the /etc/init.d/alsasound was loading the old values for my onboard sound and trying to get them to work for my new card.  I looked into the /etc/init.d/alsasound file and found that the file it was referencing was /etc/asound.state -- I also noticed that it checks to see if this file exists.  So I just deleted the /etc/asound.state and reboot.  Then everything was FINE!  Thanks cbrese!
> 
> Regards,
> 
> BonezTheGoon

 

False alarm.  Mine was still barely functional after making the changes I had outlined above.  Some apps worked while others didn't.  I finally decided it was time for a fresh build anyway and I am in the process of bringing my system back to life starting from a stage1 build.  I hope someone finds a more "comprehensive" fix for this in case I run into it again.  But this time I ran away from it with my tail between my legs!

Regards,

BonezTheGoon

----------

## hairyfeet

Old thread I know but I just happened to have the same weird alsa problem. 

It turns out that my /etc/asound.state was simply corrupt. So I just deleted and created a new one with alsactl store and now alsa works normally again  :Very Happy: 

HTH

----------

## gtorrico

Possible solution:

looking at the code in /etc/init.d/alsasound I noticed this line:

 CARDS="$(cat /proc/asound/cards | awk '/: / { print $1 }')"

I tried running the command in the shell and noticed that cat/proc/sound/cards would return my sound card indefinately, so CARDS would be a an infinte number of O's in my case.

The for loop would just keep cycling indefinately.

I changed that one line to this:

 CARDS="$(cat /proc/asound/cards | head -n 1 | awk '/: / { print $1 }')"

and now everything works fine in my machine, I suppose in your case you would have to examine the output of cat /proc/asound/cards and see its period, then substitue 1 with the number of lines that repeat indefinately.

good luck

----------

## hairyfeet

I haven't got the file anymore so I can not answer that  :Very Happy: 

Your workaround seems to solve the problem but I guess it should be properly solved in the Alsa source.

----------

## Shovas

This is exactly the case for me and exactly why `/etc/init.d/alsasound start` hangs at the end of loading its modules.

This definitely needs a fix in the script.

 *Quote:*   

> 
> 
> Possible solution:
> 
> looking at the code in /etc/init.d/alsasound I noticed this line:
> ...

 

----------

## Shovas

Anything in `/etc/init.d/alsasound` that reads from /proc/asound/cards needs to be fixed.

Who knows if this is the proper fix, but it needs to be fixed...

```

SEQUENCERS="snd-seq $(awk -F, '$2~/^empty$/ {print $1}' /proc/asound/seq/drivers)"

Needs to read:

SEQUENCERS="snd-seq $(cat /proc/asound/cards | head -n 1 | awk -F, '$2~/^empty$/ {print $1}')"

```

This is needed as well as the fix gtorrico mentions.

----------

## hairyfeet

@Shovas

If you want this fixed please bring it to the attention of the relevant developers by opening up a bug.

https://bugs.gentoo.org

----------

