Bug 447624 - sound settings not restored after resume or reboot
sound settings not restored after resume or reboot
Status: RESOLVED FIXED
: 457988 (view as bug list)
Classification: openSUSE
Product: openSUSE 11.1
Classification: openSUSE
Component: Sound
Final
x86-64 openSUSE 11.1
: P5 - None : Enhancement (vote)
: ---
Assigned To: Takashi Iwai
E-mail List
maint:released:11.1:22712
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-11-21 15:08 UTC by Lars Müller
Modified: 2009-02-26 14:32 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
/proc/asound/cards in working and non working state (105 bytes, text/plain)
2008-11-21 15:37 UTC, Lars Müller
Details
"hwinfo --all --log" output (610.61 KB, text/plain)
2008-11-21 15:45 UTC, Lars Müller
Details
"getfacl --tab -R /dev/snd" output (1.93 KB, text/plain)
2008-11-21 16:10 UTC, Lars Müller
Details
alsa-info output in the working state (15.73 KB, text/plain)
2008-11-21 17:02 UTC, Lars Müller
Details
alsa-info output in the non working state after resume (15.73 KB, text/plain)
2008-11-21 17:03 UTC, Lars Müller
Details
alsa-info output in the non working state after resume (15.73 KB, text/plain)
2008-11-21 17:03 UTC, Lars Müller
Details
alsactl output in the working state (7.81 KB, text/plain)
2008-12-16 15:54 UTC, Lars Müller
Details
Partial tar ball of /proc/asound/card0 as requested. (1.16 KB, application/x-gzip)
2008-12-16 15:56 UTC, Lars Müller
Details
alsactl output in the broken state (7.81 KB, text/plain)
2008-12-16 16:07 UTC, Lars Müller
Details
Partial tar ball of /proc/asound/card0 as requested (non working state). (1.14 KB, application/x-gzip)
2008-12-16 16:11 UTC, Lars Müller
Details
Disable 44.1kHz capture (730 bytes, patch)
2008-12-17 10:43 UTC, Takashi Iwai
Details | Diff
Fix PM register save/restore (445 bytes, patch)
2008-12-19 12:54 UTC, Takashi Iwai
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Müller 2008-11-21 15:08:48 UTC
ALSA is configured and works well.  But after a resume or a reboot I have to call alsaconf again to get it working.
Comment 1 Takashi Iwai 2008-11-21 15:18:01 UTC
Please elaborate "get it working", and a bit more detail please.

Otherwise I'd ask you like...  Is the device present in /proc/asound/cards after boot? Which desktop system are you using? KDE, GNOME, else? Which sound backend? Did it work on 11.0 without problems? Which hardware, more exactly?  How did you test with which application?
Comment 2 Lars Müller 2008-11-21 15:37:44 UTC
Created attachment 254401 [details]
/proc/asound/cards in working and non working state
Comment 3 Lars Müller 2008-11-21 15:43:31 UTC
I'm using KDE 4.  The same issue had been there in openSUSE 11.0 while running KDE 3.

For testing I call "aplay /usr/share/sounds/alsa/test.wav" as non root user.  In the non working state the command doesn't return and stays in state "SL+" in the process list.

Next I'll attach "hwinfo --all" next.
Comment 4 Lars Müller 2008-11-21 15:45:02 UTC
Created attachment 254405 [details]
"hwinfo --all --log" output
Comment 5 Takashi Iwai 2008-11-21 15:56:07 UTC
So, the driver is loaded properly at boot.  Then the problem must be the rest.

Check the following after the login without rcalsasound restart:

- check the permissions of /dev/snd/* files; usually you have to be added in ACL.
  See the output of "getfacl /dev/snd/*"
- check whether any other process (sound subsystem) is running.  Check via fuser /dev/snd/*; on KDE4, pulseaudio can be used depending on the setup
- check the mixer setup; kmix is known to screw up everything often

If another process is running, try to kill it, and try aplay again.
Comment 6 Lars Müller 2008-11-21 16:10:17 UTC
Created attachment 254418 [details]
"getfacl --tab -R /dev/snd" output
Comment 7 Lars Müller 2008-11-21 16:12:39 UTC
The user "lmuelle" is a member of the audio group.
Comment 8 Lars Müller 2008-11-21 16:18:02 UTC
Fuser doesn't report any process accessing any of the files in /dev/snd/

I've checked alsamixer and each setting - beside the one of mic which was at 0 - everything is at level 81.

kmix isn't running nor have I used it (by intention).
Comment 9 Takashi Iwai 2008-11-21 16:20:23 UTC
And what is the problem now, exactly?
Comment 10 Lars Müller 2008-11-21 16:29:48 UTC
As soon as I reboot or resume from suspend the sound doesn't work any more.

As I workaround I call "alsaconf" each time = after each reboot or resume to get the sound working.

With "work" I mean I can't play sound - for example with aplay - as I had been able before the reboot or resume action.
Comment 11 Takashi Iwai 2008-11-21 16:30:41 UTC
What do you mean "I can't play sound"?  You get an application error or don't get the sound output from any output jack?
Comment 12 Lars Müller 2008-11-21 16:39:41 UTC
I don't get the sound output when I try to play /usr/share/sounds/alsa/test.wav for example _but_ I also don't get any error.

No error from the application nor from the kernel (/var/log/messages, dmesg).

The aplay command as mentioned in comment #3 doesn't return and stays endless in state "SL+".

Sound output works as soon as I call alsaconf again.  But only till the next reboot or suspend/ resume.
Comment 13 Takashi Iwai 2008-11-21 16:45:45 UTC
Weird.  Usually when the operation is blocked due to the hardware misconfiguration, e.g. DMA isn't started, the driver will give you warnings after a certain time, 10 seconds or so.

OK, we should make the things simple.  Reboot with runlevel 3 to avoid KDE.
Login as root on linux console, and check "aplay -vv somefile.wav".
Does it work?  If yes, do suspend, resume and check aplay again.

Also, run /usr/sbin/alsa-info.sh with --no-upload option, and attach the generated file.
Comment 14 Lars Müller 2008-11-21 17:02:52 UTC
Created attachment 254430 [details]
alsa-info output in the working state
Comment 15 Lars Müller 2008-11-21 17:03:28 UTC
Created attachment 254431 [details]
alsa-info output in the non working state after resume
Comment 16 Lars Müller 2008-11-21 17:03:38 UTC
Created attachment 254432 [details]
alsa-info output in the non working state after resume
Comment 17 Lars Müller 2008-11-21 17:04:47 UTC
Comment on attachment 254431 [details]
alsa-info output in the non working state after resume

duplicated alsa-info output.
Comment 18 Lars Müller 2008-11-21 17:09:04 UTC
I've performed the test in run level 3 and got the same results.

I'm able to play sound (aplay /usr/share/sounds/alsa/test.wav
) as root.  I got sound output as expected.

Then I called "powersave -U" to suspend to disk.

After the resume - I stayed in run level 3 - I had not been able to get the same sound output from the same shell and with the same command line.
Comment 19 Takashi Iwai 2008-11-22 10:11:22 UTC
OK, then it's the problem of the driver.  The PM isn't supported on this board indeed.  It's a missing feature in the upstream drivers.

But, don't expect that it'll be fixed for 11.1.  Adding PM in the driver level isn't too trivial to be fixed in a day.

I could close this as UPSTREAM, but as now try to keep open until you can try alsa-driver-kmp on OBS multimedia:audio:KMP repo.
Comment 20 Takashi Iwai 2008-11-24 13:13:19 UTC
A preliminary patch is ready for testing.  It's found in sound-unstable git tree topic/ca0106-resume branch.
    git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-unstable-2.6.git

For building from a tarball, try the latest unstable snapshot from
    ftp://ftp.kernel.org/pub/linux/kernel/people/tiwai/snapshot/alsa-driver-unstable-snapshot.tar.gz

For installation, do the following:
- install the kernel-source.rpm matching to your running kernel
- run configure
    % ./configure --with-debug=full --enable-dynamic-minors
- run make
    % make
- install modules as root
    # make install-modules
- restart ALSA
    # rcalsasound restart

Then try the procedure in comment#13.
Comment 21 Takashi Iwai 2008-11-24 13:14:16 UTC
Oops, the tarball contains a build error.  Fixing now...
Comment 22 Takashi Iwai 2008-11-24 13:21:33 UTC
Fixed.
Comment 23 Takashi Iwai 2008-11-26 15:53:51 UTC
Any news?

You can try the latest KOTD instead of building ALSA drivers manually, too.
Comment 24 Takashi Iwai 2008-12-02 17:03:51 UTC
Ping.
Comment 25 Takashi Iwai 2008-12-15 16:07:45 UTC
*** Bug 457988 has been marked as a duplicate of this bug. ***
Comment 26 Lars Müller 2008-12-15 20:00:44 UTC
Installed and tested with 2.6.27.8-HEAD_20081211152932_1d101639-default as available from http://ftp.suse.com/pub/projects/kernel/kotd/SL111_BRANCH/ and ran into the same issue.

I'm only able to hear random noise after login to KDE.
Comment 27 Takashi Iwai 2008-12-15 23:46:24 UTC
Good that we can finally go forward, at least for a couple of days.

(BTW, you'd better to use HEAD branch of KOTD at this stage...  But, it doesn't matter now since ca0106-pm patch should be in SL111_BRANCH, too.)

Now, please build the latest ALSA driver and install manually.  This will reduce the time of patch testing a lot.  This time, you don't need the unstable but the normal snapshot version:
    ftp://ftp.kernel.org/pub/linux/kernel/people/tiwai/snapshot/alsa-driver-snapshot.tar.gz

Install kernel-source.rpm, get the tarball above, extract it, run the below:
    % ./configure --with-debug=full --enable-dynamic-minors
    % make
then as root
    # make install-modules
and reboot.  Confirm that the sound driver is loaded and working as before, then check /proc/asound/version whether it's version 1.0.18a.

After confirming this, I'll prepare a test patch tomorrow.
Comment 28 Takashi Iwai 2008-12-16 00:50:32 UTC
Oh, forgot to ask one more thing...

If the latest driver doesn't work, please dump the following files (supposing it's the first card) both before and after suspend (or hibernate) to compare:
- /proc/asound/card0/ca0106_*
- /proc/asound/card0/iec958
- /proc/asound/card0/codec97#*/*

[Note that the proc files can't be copied by tar (handled as zero-size files).]

Thanks.
Comment 29 Lars Müller 2008-12-16 14:02:36 UTC
I followed the instructions of comment #27.

The sound driver got loaded and /proc/asound/version reports version 1.0.18a.

Sound is working after reboot to run level 3.

After an init 5 and login to KDE I got the same noise as initially reported.

After a "service alsasound restart" I had working sound with KDE too.
Comment 30 Takashi Iwai 2008-12-16 14:24:30 UTC
Does the problem occur after a fresh *reboot*, not resume?

If the sound gets broken even just going to runlevel 5, it's possibly the broken mixer setup via kmix.

Run "alsactl -f somefile store" at the first KDE login (where the noise appears) to save the mixer elements.  Also run it at the working state ("rcalsasound restore" or whatever) and attach the both files to compare.

It'd be helpful to gather the proc files in both working and non-working states as in comment#28, too.
Comment 31 Lars Müller 2008-12-16 15:52:36 UTC
This happens even after a fresh reboot.

Requested logs follow soon.
Comment 32 Lars Müller 2008-12-16 15:54:14 UTC
Created attachment 260355 [details]
alsactl output in the working state
Comment 33 Lars Müller 2008-12-16 15:56:04 UTC
Created attachment 260356 [details]
Partial tar ball of /proc/asound/card0 as requested.
Comment 34 Lars Müller 2008-12-16 16:07:24 UTC
Created attachment 260363 [details]
alsactl output in the broken state
Comment 35 Lars Müller 2008-12-16 16:11:06 UTC
Created attachment 260364 [details]
Partial tar ball of /proc/asound/card0 as requested (non working state).

/proc/asound/card0/codec97#*/* isn't available on this system.  Neither in the working, nor the non working state.
Comment 36 Takashi Iwai 2008-12-16 16:16:21 UTC
And, is it the fresh reboot or resume?

codec97#0* might be missing in some boards, so it doesn't matter much.
Comment 37 Takashi Iwai 2008-12-16 16:28:10 UTC
Sorry I overlooked comment #31.

So, the procedure to get a broken state is just do graphical login?  This is damn weird.  This problem is basically independent from the lack of PM support in the earlier kernel.

Now the question is what breaks the sound.  Do you see any difference in "aplay -v foo.wav" output between the first runlevel 3 and the broken state (also the re-working state after rcalsasound restart)?
Comment 38 Lars Müller 2008-12-16 17:14:06 UTC
There is no difference between the output of aplay before the reboot (running X/ KDE) and after a (re)boot into runlevel 3.

Even to load the nvidia module (to support dual head) doesn't change anything.  Aplay works as before.

Even switching to run level to 5 (kdm) doesn't change anything.

But soon after login I get the random noise.

In this state I'm able to play a sound.  And it's even possible to hear the sound between the noise.

The output written by aplay to stderr is identical to previous two cases (KDE without noise and console in run lvel 3).

"service alsasound restart" while still being in KDE "fixes" the noise and everything works as expected.
Comment 39 Takashi Iwai 2008-12-16 20:25:58 UTC
Thanks for checking.

Yes, I've seen that alsactl contents are identical among working and non-working cases (although the registers show a bit difference).  So, it's still quite puzzling how this is triggered.

One thing you can test easily is whether this happens with X or any action of the sound by KDE.  Could you re-login in a failsafe session after "rcalsasound restart", and check whether the noisy output occurs again?  Or, what happens if you login freshly into a failsafe mode instead of KDE?  I'd like to see the influence of X server over other devices...
Comment 40 Lars Müller 2008-12-16 23:54:39 UTC
Sounds works if I use failsafe mode or use fvwm2 as session type.

Sound "fails" while using KDE 3 and 4 (which I used for all previous test cases).

With KDE 4 I hear the described noise.

With KDE 3 I initially hear nothing.  But this is a question of the volume.  As soon as increased it's identical to KDE 4.
Comment 41 Takashi Iwai 2008-12-17 10:42:24 UTC
OK, then some service in KDE (e.g. artsd) triggered this.

Could you try the patch below?  Apply it on alsa-driver*/alsa-kernel directory with patch -p2 option.  This essentially disables 44.1KHz for capture streams.
Comment 42 Takashi Iwai 2008-12-17 10:43:48 UTC
Created attachment 260534 [details]
Disable 44.1kHz capture
Comment 43 Takashi Iwai 2008-12-17 10:44:23 UTC
After applying it, run "make" and "make install-modules".
Comment 44 Takashi Iwai 2008-12-17 11:55:14 UTC
BTW, try the very latest alsa-driver-snapshot tarball, too.  This contains the recent two patches regarding ca0106, especially your mobo, and I'd like to know that it's not breaking.  Thanks.
Comment 45 Lars Müller 2008-12-18 21:08:19 UTC
Very strange.  I'm with and without your patch - provided by comment #42 - no longer able to suspend.

If I unload ALSA (service alsound stop) suspend to disk works.

Might I only have tested the reboot case?  Anyhow.

With the patch of comment #44 ALSA works immediately after KDE started.  No restart of the sound system is required.
Comment 46 Takashi Iwai 2008-12-19 07:54:02 UTC
The suspend/hibernate is another issue, so let's forget that right now.

So if I understand correctly, the previous patch (disable 44.1kHz capture) works for the fresh reboot on KDE, solves the noise output?  And, is it with the latest alsa-driver-snapshot tarball?
Comment 47 Takashi Iwai 2008-12-19 08:12:35 UTC
Also, what do you mean "suspend to disk works"?  Does the hibernation hang, or just the sound doesn't come up again, or you get the DMA error at playback, or what?
Comment 48 Lars Müller 2008-12-19 09:38:36 UTC
I've applied the patch on top of the ALSA sources you suggested to use in comment 27.

To get suspend working I have to stop ALSA first.  Or more correkt I have to ensure the particular kernel module is unloaded before.  Else the hibernation hangs.
Comment 49 Takashi Iwai 2008-12-19 09:56:31 UTC
OK, then something wrong in my suspend patch.

Could you try to disable the pm callbacks in alsa-driver*/alsa-kernel/pci/ca0106/ca0106_main.c, such as,
=====
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 5763174..7114030 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -1811,7 +1811,7 @@ static struct pci_driver driver = {
        .id_table = snd_ca0106_ids,
        .probe = snd_ca0106_probe,
        .remove = __devexit_p(snd_ca0106_remove),
-#ifdef CONFIG_PM
+#if 0 // def CONFIG_PM
        .suspend = snd_ca0106_suspend,
        .resume = snd_ca0106_resume,
#endif
=====

Check whether the hibernation works, at least, not hangs.  Of course, the sound device won't be usable after resume with this change.
Comment 50 Lars Müller 2008-12-19 10:57:09 UTC
Disabled the pm callbacks as suggested in comment #49 and hibernation works.

As expected the sound device isn't usable afterwards.
Comment 51 Takashi Iwai 2008-12-19 11:22:00 UTC
OK, then try to enable only the line ".suspend = snd_ca0106_suspend".  Take back #if 0, and simply comment out ".resume = snd_ca0106_resume" line.

Does the hibernation still work?
Comment 52 Lars Müller 2008-12-19 12:43:39 UTC
Module modified, rebuild, unload and load and hibernation no longer works. I again see the progress and then the system freezes.
Comment 53 Takashi Iwai 2008-12-19 12:53:47 UTC
Thanks.  I found a patch in the resume code.  How about the patch below?
Apply it on alsa-driver*/alsa-kernel with patch -p2 option.
Comment 54 Takashi Iwai 2008-12-19 12:54:27 UTC
Created attachment 261301 [details]
Fix PM register save/restore
Comment 55 Lars Müller 2008-12-19 15:26:52 UTC
Have the pm callbacks being enabled or disabled?

While they are enabled suspend hangs as described. 
Comment 56 Takashi Iwai 2008-12-19 15:34:10 UTC
Yes, enable both.

The question is which call in suspend() causes the hang.  First off, could you disable two calls in alsa-driver*/alsa-kernel/pci/ca0106/ca0106_main.c:snd_ca0106_suspend()?

+++ b/sound/pci/ca0106/ca0106_main.c
@@ -1753,9 +1753,9 @@ static int snd_ca0106_suspend(struct pci_dev *pci, pm_mess
        for (i = 0; i < 4; i++)
                snd_pcm_suspend_all(chip->pcm[i]);
        snd_ac97_suspend(chip->ac97);
-       snd_ca0106_mixer_suspend(chip);
+       // snd_ca0106_mixer_suspend(chip);
 
-       ca0106_stop_chip(chip);
+       // ca0106_stop_chip(chip);
 
        pci_disable_device(pci);
        pci_save_state(pci);
@@ -1782,7 +1782,7 @@ static int snd_ca0106_resume(struct pci_dev *pci)
        ca0106_init_chip(chip, 1);
 
        snd_ac97_resume(chip->ac97);
-       snd_ca0106_mixer_resume(chip);
+       // snd_ca0106_mixer_resume(chip);
        if (chip->details->spi_dac) {
                for (i = 0; i < ARRAY_SIZE(chip->spi_dac_reg); i++)
                        snd_ca0106_spi_write(chip, chip->spi_dac_reg[i]);

BTW, this is against the latest alsa-driver-snapshot.  It already includes the patch in comment#54.
Comment 57 Lars Müller 2008-12-19 16:28:07 UTC
Downloaded the current snapshot (19. Dez 15:01) and applied the three changes of comment #56 to disable the three calls.

A suspend request leads to the described system freeze.
Comment 58 Takashi Iwai 2008-12-19 16:38:39 UTC
Hmm, then try to disable the resume callback first (comment out .resume = snd_ca0106_resume line), then try to disable the further calls, e.g. snd_pcm_suspend_all() and snd_ac97_suspend().

Now there should be only calls of snd_power_change_state(), pci_disable_device(), pci_save_state() and pci_set_power_state().  If the hibernation still hangs up, then it's a deeper problem than the sound driver itself.  If it doesn't hang, then the newly commented stuff is the culprit...
Comment 59 Lars Müller 2008-12-19 18:58:47 UTC
If I disable the following calls s2disk works again.

I tried to activate the function calls in reverse order.  As soon as snd_ac97_suspend() is called again we see the same issue again.

Index: alsa-driver/alsa-kernel/pci/ca0106/ca0106_main.c
===================================================================
--- alsa-driver.orig/alsa-kernel/pci/ca0106/ca0106_main.c
+++ alsa-driver/alsa-kernel/pci/ca0106/ca0106_main.c
@@ -1750,9 +1750,9 @@ static int snd_ca0106_suspend(struct pci
        int i;

        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
-       for (i = 0; i < 4; i++)
-               snd_pcm_suspend_all(chip->pcm[i]);
-       snd_ac97_suspend(chip->ac97);
+       // for (i = 0; i < 4; i++)
+       //      snd_pcm_suspend_all(chip->pcm[i]);
+       // snd_ac97_suspend(chip->ac97);
        // snd_ca0106_mixer_suspend(chip);

        // ca0106_stop_chip(chip);
@@ -1808,7 +1808,7 @@ static struct pci_driver driver = {
        .remove = __devexit_p(snd_ca0106_remove),
 #ifdef CONFIG_PM
        .suspend = snd_ca0106_suspend,
-       .resume = snd_ca0106_resume,
+       // .resume = snd_ca0106_resume,
 #endif
Comment 60 Takashi Iwai 2008-12-20 10:27:10 UTC
Thanks for checking.  I think I found the culprit.

Could you try the very latest alsa-driver-snapshot tarball?  This contains the necessary fixes, and may work as is without patches.
Comment 61 Lars Müller 2008-12-21 20:31:00 UTC
ALSA works after hibernation.  I've tested it with the alsa-driver-snapshot.tar.gz from 20. Dez 23:05.
Comment 62 Takashi Iwai 2008-12-22 10:50:10 UTC
Good to hear.  Both fixes are already in SUSE kernel git tree now.
Comment 63 Swamp Workflow Management 2009-02-26 14:32:14 UTC
Update released for: kernel-debug, kernel-debug-base, kernel-debug-debuginfo, kernel-debug-debugsource, kernel-debug-extra, kernel-default, kernel-default-base, kernel-default-debuginfo, kernel-default-debugsource, kernel-default-extra, kernel-docs, kernel-kdump, kernel-kdump-debuginfo, kernel-kdump-debugsource, kernel-pae, kernel-pae-base, kernel-pae-extra, kernel-ppc64, kernel-ppc64-base, kernel-ppc64-debuginfo, kernel-ppc64-debugsource, kernel-ppc64-extra, kernel-ps3, kernel-ps3-debuginfo, kernel-ps3-debugsource, kernel-source, kernel-source-debuginfo, kernel-syms, kernel-trace, kernel-trace-base, kernel-trace-debuginfo, kernel-trace-debugsource, kernel-trace-extra, kernel-vanilla, kernel-vanilla-debuginfo, kernel-vanilla-debugsource, kernel-xen, kernel-xen-base, kernel-xen-debuginfo, kernel-xen-debugsource, kernel-xen-extra
Products:
openSUSE 11.1 (debug, i586, ppc, x86_64)