Bug 1183869

Summary: No more sound on internal speakers after suspend and wake up of the laptop
Product: [openSUSE] openSUSE Distribution Reporter: Jérémy Friche <jeremy.friche>
Component: SoundAssignee: Takashi Iwai <tiwai>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: jeremy.friche
Version: Leap 15.3   
Target Milestone: ---   
Hardware: x86-64   
OS: All   
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Alsa-info result before suspend (sound working)
Alsa-info result after suspend (sound NOT working)
Alsa-info result before suspend (sound working) - with dump_coef
Alsa-info result after suspend (sound NOT working) - with dump_coef
alsa-info after hda-verb
Fix patch

Description Jérémy Friche 2021-03-22 16:46:43 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
Build Identifier: 

When my laptop goes goes suspend and wake up, there is no more sound coming out the internal speakers. If I plug headphones, they have sound.
I have to reboot to have sound back on internal speakers. Restarting PulseAudio and ALSA doesn't help.

A trick can make sound work without rebooting : 

echo 1 > /sys/bus/pci/devices/0000\:00\:1b.0/remove
echo 1 > /sys/bus/pci/rescan

Reproducible: Always

Steps to Reproduce:
1. Let the laptop going to suspend mode or manually suspend it
2. Wake-up the laptop and log-in
3. -
Actual Results:  
No more sound on internal speaker, but headphones works

Expected Results:  
Sound works on internal speakers

  Host: jf-leap-e1-731 Kernel: 5.3.18-51-default x86_64 bits: 64 
  Desktop: Gnome 3.34.5 Distro: openSUSE Leap 15.3 Beta 
  Device-1: Intel 7 Series/C216 Family High Definition Audio 
  driver: snd_hda_intel 
  Sound Server: ALSA v: k5.3.18-51-default 

jeremy@jf-leap-e1-731:~> aplay -L
    Discard all samples (playback) or generate zero samples (capture)
    Rate Converter Plugin Using Speex Resampler
    PulseAudio Sound Server
    Plugin for channel upmix (4,6,8)
    Default ALSA Output (currently PulseAudio Sound Server)
    HDA Intel PCH, ALC269VB Analog
    Default Audio Device
    HDA Intel PCH, ALC269VB Analog
    Front output / input
    HDA Intel PCH, ALC269VB Analog
    2.1 Surround output to Front and Subwoofer speakers
    HDA Intel PCH, ALC269VB Analog
    4.0 Surround output to Front and Rear speakers
    HDA Intel PCH, ALC269VB Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
    HDA Intel PCH, ALC269VB Analog
    5.0 Surround output to Front, Center and Rear speakers
    HDA Intel PCH, ALC269VB Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
    HDA Intel PCH, ALC269VB Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
    HDA Intel PCH, HDMI 0
    HDMI Audio Output
Comment 1 Takashi Iwai 2021-03-26 09:12:57 UTC
Could you try gathering some detailed information in the following way?

At the working state:

# echo 1 > /sys/module/snd_hda_codec/parameters/dump_coef
# alsa-info.sh --no-upload

Keep the output.  Then do suspend/resume (and confirm that it's broken), and run again
# alsa-info.sh --no-upload

And attach both outputs to Bugzilla.
Comment 2 Jérémy Friche 2021-03-26 10:01:58 UTC
Thank you for your concern.

I'm reinstalling Tumbleweed at this moment.
You can have a look at this forum thread : https://forums.opensuse.org/showthread.php/551762-No-more-sound-after-sleep-mode

This post shows the difference between alsa-info.sh outputs : https://forums.opensuse.org/showthread.php/551762-No-more-sound-after-sleep-mode?p=3015047#post3015047
(Only line 335 changes, from "Converter: stream=1, channel=0" to "Converter: stream=0, channel=0"

I'll do your test again when install finish.

Like said on the forum thread, I tested few other distros and only Debian Buster and Linux Mint Debian Edition (which is based on Debian Buster) don't have the problem: kernel is version 4.x
All kernel 5.x version distros I have tested have the problem.
Comment 3 Jérémy Friche 2021-03-26 13:50:08 UTC
Created attachment 847699 [details]
Alsa-info result before suspend (sound working)
Comment 4 Jérémy Friche 2021-03-26 13:50:49 UTC
Created attachment 847700 [details]
Alsa-info result after suspend (sound NOT working)
Comment 5 Takashi Iwai 2021-03-30 12:21:13 UTC
Could you make sure that you enabled dump_coef parameter as described before taking alsa-info.sh output snapshots?
  echo 1 > /sys/module/snd_hda_codec/parameters/dump_coef
Comment 6 Jérémy Friche 2021-03-30 13:14:24 UTC
Created attachment 847823 [details]
Alsa-info result before suspend (sound working) - with dump_coef
Comment 7 Jérémy Friche 2021-03-30 13:16:05 UTC
Created attachment 847824 [details]
Alsa-info result after suspend (sound NOT working) - with dump_coef
Comment 8 Jérémy Friche 2021-03-30 13:18:29 UTC
Sorry, I had access denied when I tried with sudo the last time. I didn't think to try "sudo su".
Now it seems ok.
Comment 9 Takashi Iwai 2021-03-30 13:24:38 UTC
Thanks.  The diff between them showed the COEF change
-    Coeff 0x0d: 0x6440
+    Coeff 0x0d: 0x0440

Let's check whether simply restoring this cures the problem.
Try to install hda-verb package (if not done yet), and run the commands below as root after the resume (non-working state):

   hda-verb /dev/snd/hwC0D0 0x20 SET_COEF_INDEX 0x0d
   hda-verb /dev/snd/hwC0D0 0x20 SET_PROC_COEF 0x6440
Comment 10 Jérémy Friche 2021-03-30 14:08:11 UTC
localhost:~ # hda-verb /dev/snd/hwC0D0 0x20 SET_COEF_INDEX 0x0d
nid = 0x20, verb = 0x500, param = 0xd
value = 0x0
localhost:~ # hda-verb /dev/snd/hwC0D0 0x20 SET_PROC_COEF 0x6440
nid = 0x20, verb = 0x400, param = 0x6440
value = 0x0

Still no sound after that.
Comment 11 Takashi Iwai 2021-03-30 14:50:58 UTC
Please disable the runtime PM before testing it.
  echo 0 > /sys/module/snd_hda_intel/parameters/power_save

Otherwise the device may be in the runtime suspend and forget what you changed again.

If the problem is still seen, please take alsa-info.sh output after hda-verb tweaks again for comparison.
Comment 12 Jérémy Friche 2021-03-30 16:14:14 UTC
/dev/snd/hwC0D0 disappeared and I have no more sound.
Even Windows says "No audio card plugged" now.

localhost:~ # ll /dev/snd/
total 0
drwxr-xr-x  2 root root       60 Mar 30 17:55 by-path
crw-rw----+ 1 root audio 116,  4 Mar 30 17:55 controlC0
crw-rw----+ 1 root audio 116,  3 Mar 30 17:55 hwC0D3
crw-rw----+ 1 root audio 116,  2 Mar 30 17:56 pcmC0D3p
crw-rw----+ 1 root audio 116,  1 Mar 30 17:55 seq
crw-rw----+ 1 root audio 116, 33 Mar 30 17:55 timer
Comment 13 Jérémy Friche 2021-03-30 16:14:39 UTC
Created attachment 847833 [details]
alsa-info after hda-verb
Comment 14 Takashi Iwai 2021-03-30 16:41:49 UTC
Something went wrong.  Please retry after the cold boot.  (Shut down and power off completely once).
Comment 15 Jérémy Friche 2021-03-30 17:23:19 UTC
OK, after a shutdown and a cold boot, sound is working.

I did
   echo 0 > /sys/module/snd_hda_intel/parameters/power_save

After a suspend, sound don't work.

I did
   hda-verb /dev/snd/hwC0D0 0x20 SET_COEF_INDEX 0x0d
   hda-verb /dev/snd/hwC0D0 0x20 SET_PROC_COEF 0x6440

Sound is working!
Comment 16 Takashi Iwai 2021-04-07 09:58:43 UTC
Good to hear.

Below is the kernel patch that adds the quirk for the missing amp setup.
Let me know if the problem persists even after applying the patch.
Comment 17 Takashi Iwai 2021-04-07 09:59:01 UTC
Created attachment 848038 [details]
Fix patch
Comment 18 Takashi Iwai 2021-04-07 12:38:51 UTC
I'm building a test kernel with the patch. It's being built in OBS home:tiwai:bsc1183869 repo.  Once after the build finishes (usually takes for an hour or so), the test kernel package will be available later at:

Please give it a try later.

Note that it's a build with an unofficial key, hence it won't work with Secure Boot.
Comment 19 Jérémy Friche 2021-04-07 18:52:32 UTC

I'll try to install it (I never patched or installed kernel) and I'll tell you.
Comment 20 Jérémy Friche 2021-04-08 19:08:39 UTC

I installed the new kernel right now (wasn't difficult at all :D) and... I have sound after suspended and waked up my laptop!
Thank you so much!

Will the default leap/tumbleweed kernel be patched too ?
Comment 21 Takashi Iwai 2021-04-12 13:41:43 UTC
Yes, it'll have the backport soon later via stable tree for TW.  And I backported the fix to SLE/Leap kernel, too.