Bug 150311

Summary: powersave does not restart sound daemon
Product: [openSUSE] SUSE Linux 10.1 Reporter: Axel Braun <axel.braun>
Component: BasesystemAssignee: Forgotten User ZhJd0F0L3x <forgotten_ZhJd0F0L3x>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: tiwai
Version: Final   
Target Milestone: ---   
Hardware: i686   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: suspend2disk-state.resume
suspend2disk.log
/var/log/suspend2disk.log
suspend2disk-state.resume
/var/log/suspend2disk.log
/var/lib/suspend2disk-state.resume

Description Axel Braun 2006-02-13 08:53:38 UTC
After a suspend to disk, no sound is available (ThinkPad A30). I tried to work around this by adding
SUSPEND2DISK_RESTART_SERVICES="alsasound"
SUSPEND2RAM_RESTART_SERVICES="alsasound"
STANDBY_RESTART_SERVICES="alsasound"
in /etc/sysconfig/powersave/sleep. According to the description it should restart alsa.
Anyway, after a suspend always a manual 'rcalsasound restart' is required. Noticed this with powersave 0.10.21-0.1 as well as with 0.11.10
Comment 1 Thomas Renninger 2006-02-14 11:28:45 UTC
best you add a:
touch /tmp/alsastarted
into /etc/init.d/alsasound
short after the
start:
switch

To verify whether it is really not restarted or just does not work because it needs to be restartet later...
After resume check with ls -al /tmp/alsastarted whether the date of the file corresponds with your resume...
Comment 2 Forgotten User ZhJd0F0L3x 2006-02-14 14:19:52 UTC
please provide /var/log/suspend2disk.log
and /var/lib/suspend2disk-state.resume before fuzzing around with the alsa start script.
Comment 3 Axel Braun 2006-02-14 18:43:54 UTC
Created attachment 68430 [details]
suspend2disk-state.resume
Comment 4 Axel Braun 2006-02-14 18:45:36 UTC
Created attachment 68432 [details]
suspend2disk.log

looks like alsasound is started again, but as you assumed earlier, maybe too early. Pls let me know if you think whether the change of the alsasound script is required
Comment 5 Axel Braun 2006-02-15 06:53:49 UTC
Anyway, changed the startscript of alsasound (/usr/bin/touch), and the new file shows up at time of wake-up. But still no sound. So you might be right that this is too early.
Comment 6 Holger Macht 2006-02-22 09:59:36 UTC
Ok, but I doubt that we can do much about it. Seife, any idea?

Axel, maybe you can try with a beta version of SUSE Linux OSS 10.1 and tell us if it still does not work?
Comment 7 Axel Braun 2006-02-22 20:19:38 UTC
Can't promise this: The HD is quite full, I have to see how I can free up 3G for a test
Comment 8 Holger Macht 2006-03-17 23:38:24 UTC
Axel, I'm closing this bug as WORKSFORME for now, please reopen if you get a SUSE 10.1 Beta8 or newer installed.
Comment 9 Axel Braun 2006-07-19 16:27:36 UTC
Gents,
After installing 10.1 I have the same problem. Following the above instructions, it shows
18:12 tp-a30:/home/axel # ls -al /tmp/alsastar*
-rw-r--r--  1 root root 0 2006-07-19 18:14 /tmp/alsastarted
18:15 tp-a30:/home/axel # ps ax |grep alsa
 9100 pts/1    R+     0:00 /bin/grep --color=auto alsa
18:15 tp-a30:/home/axel # rcalsasound restart
Starting sound driver:  intel8x0                                      done
18:19 tp-a30:/home/axel #                                                   

- the file is created, but alsasound is not restarted
I'll attach the logs as well
Comment 10 Axel Braun 2006-07-19 16:28:53 UTC
Created attachment 94005 [details]
/var/log/suspend2disk.log
Comment 11 Axel Braun 2006-07-19 16:29:30 UTC
Created attachment 94006 [details]
suspend2disk-state.resume
Comment 12 Forgotten User ZhJd0F0L3x 2006-07-20 09:17:44 UTC
Ok, Takashi, i think this is a bug in /etc/init.d/alsasound start.

We start it this way:
if [ "$SERVICES_TO_RESTART" -a -s "${STATE}.resume" ]; then
  for X in `tac ${STATE}.resume | awk '/^stopped:/ { if (($2!="hotplug")&&($2!="boot.hotplug")) print $2 }'`; do
    echo "starting $X:" >> $LSMOD_LOG
    /etc/init.d/$X start 2>&1 | awk '{print "##  "$0}' >> $LSMOD_LOG
    DEBUG "Service $X started again" DIAG
  done
fi

but in the logfile is nothing from "/etc/init.d/alsasound start".

It works fine during suspend:
|Stopping services: ('alsasound' configured)
|stopping alsasound:
|##  Shutting down sound driver..done

but not during resume:
|Restarting services:
|starting alsasound:
|
|Remounting filesystems:

Maybe there is something going wrong if alsasound start has no controlling terminal?

Axel, can you try to change the line 508 in /usr/lib/powersave/scripts/sleep_helper_functions (might be some lines off, maybe i already messed around with the script here :-) from:

   /etc/init.d/$X start 2>&1 | awk '{print "##  "$0}' >> $LSMOD_LOG

to:
   /etc/init.d/$X start </dev/null 2>&1 | awk '{print "##  "$0}' >> $LSMOD_LOG

which will provide stdin from /dev/null instead of having it probably closed by the daemon.
If this does not help, you might even try
   /etc/init.d/$X start </dev/null >/dev/null 2>&1

This will remove the output from the logfile, but if this works, it might give us some hints on where the error is.
Comment 13 Takashi Iwai 2006-07-20 22:17:00 UTC
This is because alsasound init script checks $PREVLEVEL for fast boots.  If $PREVLEVEL=N, it skips the manual loading of modules because they must be already loaded beforehand.

The problem is that powersave daemon keeps this environment variable (and probably $RUNLEVEL, too), and it confuses the restart condition.
Comment 14 Forgotten User ZhJd0F0L3x 2006-07-21 15:12:48 UTC
ok, so we probably have to fix this in the powersaved start script (there is some option to startproc to unset almost all environment variables that should be used)
Comment 15 Axel Braun 2006-07-31 16:04:52 UTC
Stefan,
I changed the line (508 was a good guess), but couldnt see a difference. Reading on, it seems that the change is not really required. Anything I could do for the moment?
Ax
Comment 16 Forgotten User ZhJd0F0L3x 2006-07-31 16:56:26 UTC
Well, the fix is probably to add "unset RUNLEVEL PREVLEVEL" in /etc/init.d/powersaved, before line 263 (the line with "startproc -e $powersaved_BIN ...").

restart powersaved and try again, it should work after that.
Comment 17 Axel Braun 2006-10-08 12:23:02 UTC
Sorry for the late reply, the machine was in repair.
I had to set up a new 10.1, change the line as recommended in comment 16, but it did not help. Still no sound.
Comment 18 Forgotten User ZhJd0F0L3x 2006-10-08 18:59:41 UTC
Check the logfile (/var/log/suspend2disk.log) if there is something from the alsasound init script after resume (check comment #12)
Comment 19 Axel Braun 2006-10-09 08:33:19 UTC
Nothing so far:
[...]
prepare_sleep finished for suspend2disk
------------------------------------------------------------------------------
preparing boot-loader: selecting entry 0, kernel /boot/2.6.16.21-0.25-default
running '/usr/sbin/grubonce 0'
  time needed for sync: 5.3 seconds, time needed for grub: 0.6 seconds.
calculated image_size: 500
========we are back from suspend, cleaning up.========

== restore_after_sleep: restart and reload everything ==

Resuming:
---------

Reloading modules:
  uhci_hcd

Restarting services:

Remounting filesystems:
  mounted '/dev/hda1' to '/windows/c', options '-o rw,noexec,nosuid,nodev,gid=100,umask=0002,utf8=true'
  mounted '/dev/hda5' to '/windows/d', options '-o rw,noexec,nosuid,nodev,gid=100,umask=0002,utf8=true'

=======================================
restore_after_suspend_to_disk: finished
Comment 20 Forgotten User ZhJd0F0L3x 2006-10-09 09:09:09 UTC
ok, this looks like it has not even been stopped, so it won't be started either of course.
Up in the logfile, is there something like "stopping alsasound"? also the contents of /var/lib/suspend2disk-state.resume would be interesting.

Sorry that this is a bit tedious to debug :-)
Comment 21 Axel Braun 2006-10-09 11:08:48 UTC
Sorry, attached the wrong log, but that does not change the results. I will attach the new logs
Comment 22 Axel Braun 2006-10-09 11:10:06 UTC
Created attachment 100955 [details]
/var/log/suspend2disk.log
Comment 23 Axel Braun 2006-10-09 11:10:42 UTC
Created attachment 100958 [details]
/var/lib/suspend2disk-state.resume
Comment 24 Axel Braun 2006-10-09 11:12:20 UTC
although it claims to have started the driver, it obviously isn't:

a30:/home/axel # aplay /opt/kde3/share/sounds/k3b_error1.wav
ALSA lib confmisc.c:672:(snd_func_card_driver) cannot find card '0'
ALSA lib conf.c:3492:(_snd_config_evaluate) function snd_func_card_driver returned error: Kein passendes Gerät gefunden
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:3492:(_snd_config_evaluate) function snd_func_concat returned error: Kein passendes Gerät gefunden
ALSA lib confmisc.c:1072:(snd_func_refer) error evaluating name
ALSA lib conf.c:3492:(_snd_config_evaluate) function snd_func_refer returned error: Kein passendes Gerät gefunden
ALSA lib conf.c:3961:(snd_config_expand) Evaluate error: Kein passendes Gerät gefunden
ALSA lib pcm.c:2111:(snd_pcm_open_noupdate) Unknown PCM default
aplay: main:547: audio open error: Kein passendes Gerät gefunden
a30:/home/axel # rcalsasound restart
Starting sound driver:  intel8x0                                      done
Comment 25 Michael Lashkevich 2006-10-20 21:57:16 UTC
I encountered the same problem and solved it on my computer by a simple substitution in "/usr/lib/powersave/scripts/sleep_helper_functions". I substituted the lines

            echo "starting $X:" >> $LSMOD_LOG
            /etc/init.d/$X start 2>&1 | awk '{print "##  "$0}' >> $LSMOD_LOG

to

            echo "starting $X:" >> $LSMOD_LOG
            /etc/init.d/$X restart 2>&1 | awk '{print "##  "$0}' >> $LSMOD_LOG
                           ^^

(i.e. changed "start" to "restart").
Comment 26 Axel Braun 2006-10-22 08:35:30 UTC
Works for me as well. Thanks!
Comment 30 Forgotten User ZhJd0F0L3x 2007-06-06 10:38:17 UTC
I am pretty sure this is working with the pm-utils infrastructure used in 10.2 onwards.
Since this is the only bugreport i got for this issue, i'm setting this to "fixed in 10.3" (the two affected customers, have already implemented a workaround :-)

Thanks for reporting and helping to debug this.
Comment 31 Axel Braun 2007-06-07 06:19:20 UTC
(In reply to comment #30)
> I am pretty sure this is working with the pm-utils infrastructure used in 10.2
> onwards.

you lost the bet ;-)
10.2 has the same problem.

> Since this is the only bugreport i got for this issue, i'm setting this to
> "fixed in 10.3" (the two affected customers, have already implemented a
> workaround :-)

I intended to install 10.3 beta1 once it is out, I will follow up then.

Cheers
Axel
Comment 32 Forgotten User ZhJd0F0L3x 2007-06-07 09:26:11 UTC
So in 10.2, with a hook for pm-utils that does

. /etc/pm/functions
case $1 in
   suspend|hibernate)
      stopservice alsasound ;;
   resume|thaw)
      restartservice alsasound ;;
esac

does not work? (see also http://en.opensuse.org/Pm-utils_10.2) This would be bad and warrant a (separate, since it is a different package) bugreport against pm-utils.
Comment 33 Axel Braun 2007-06-11 19:59:35 UTC
stopservice and startservice seem not to be known commands, but

case $1 in
   suspend|hibernate)
      /etc/init.d/alsasound stop ;;
   resume|thaw)
      /etc/init.d/alsasound start ;;
esac

does a pretty good job as well.
Thanks
Axel