Bug 215466 - Realtek ALC285, snd_hda_intel: no sound from speakers and headphones
Summary: Realtek ALC285, snd_hda_intel: no sound from speakers and headphones
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: Jaroslav Kysela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-08 21:45 UTC by Alexander Sergeyev
Modified: 2022-01-12 21:11 UTC (History)
0 users

See Also:
Kernel Version: 5.16.0
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Alexander Sergeyev 2022-01-08 21:45:29 UTC
Hello,

I use Gentoo Linux distribution and build own kernel for HP laptop (Elitebook 855 G8 with AMD 5850U). The problem started when I got no sound from speakers (and headphones) when using the built kernel and things got complicated.

1) No sound for Gentoo build, kernel 5.15.12 (no modules, all compiled-in).
2) Sound is always fine so far when booting live Ubuntu 21.10, Ubuntu kernel 5.13.0-19.
3) No sound when using kernel sources from Ubuntu to build kernel for Gentoo (no modules, all compiled-in). (***)
4) No sound when using kernel sources from Ubuntu in Gentoo (with modules, manually modprobe'd from lsmod from Ubuntu).

In both systems alsamixer shows two "HD-Audio Generic" cards:
1) Chip: ATI R6xx HDMI
2) Chip: Realtek ALC285

The offending card is the second one. It's working under Ubuntu, tested with stopped pulseaudio using aplay with an appropriate ALSA_CARD env. I'm testing identically with aplay on both systems with no sound servers running.

Results of alsa-info on Ubuntu: https://alsa-project.org/db/?f=3947d6ce871cb16b3085fce515a81c82506595ea
For Gentoo: http://alsa-project.org/db/?f=2cde5633ba4789f280883552e23aaf0498857b9a

I've found differences in output of "alsactl --debug init", so synced alsa-lib/alsa-utils/alsa-ucm-conf/alsa-topology-conf versions (to be 1.2.4) and copied /usr/share/alsa content from Ubuntu, since there were differences. Still no sound.

(***) At some point I had a clean boot of Ubuntu 5.13.0-19 kernel in Gentoo and sound was working. Also, "Capture" toggle was reflected in the keyboard LED, which haven't happend before in Gentoo runs. After a subsequent reboot with no changes at all -- no sound again. So, I suspect there are some issues with order of initialization or timings/races, which for some reason fine on Ubuntu (because of delays caused by module loading, specific order of module loading or something else, I'm not sure).

The problem is that the working sound situation described above is really rare and I cannot iterate to try things.

Is there any ways I could use to debug the problem further?
Comment 1 Alexander Sergeyev 2022-01-09 11:49:26 UTC
I've written scripts for a reboot loop while testing speakers using an external usb microphone on each try. 51th reboot did the job, speakers are working (on this particular bootup).

The only explanation I have is some race conditions in devices initialization, which I have no idea how to debug further.
Comment 2 Alexander Sergeyev 2022-01-09 12:06:46 UTC
> 51th reboot did the job, speakers are working (on this particular bootup).

Forgot to clarify -- it's about Gentoo build with kernel v5.15.12 (case 1 in the initial description).
Comment 3 Alexander Sergeyev 2022-01-09 15:13:05 UTC
Re-tested with https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tag/?h=v5.15.13

The result is the same -- generally sound does not work, but rarely works. This time on 6th bootup.
Comment 4 Alexander Sergeyev 2022-01-10 18:39:56 UTC
I've found dynamic debug machinery. With added dyndbg="file sound/* +p" in cmdline, good (working speakers) bootups can be distinguished from bad ones by presence of additional lines: 

snd_hda_codec_realtek hdaudioC1D0: hda_codec_setup_stream: NID=0x3, stream=0x5, channel=0, format=0x31
snd_hda_codec_realtek hdaudioC1D0: hda_codec_setup_stream: NID=0x2, stream=0x5, channel=0, format=0x31
snd_hda_codec_realtek hdaudioC1D0: hda_codec_cleanup_stream: NID=0x3
snd_hda_codec_realtek hdaudioC1D0: hda_codec_cleanup_stream: NID=0x2
snd_hda_codec_realtek hdaudioC1D0: hda_codec_setup_stream: NID=0x3, stream=0x5, channel=0, format=0x31
snd_hda_codec_realtek hdaudioC1D0: hda_codec_setup_stream: NID=0x2, stream=0x5, channel=0, format=0x31
snd_hda_codec_realtek hdaudioC1D0: hda_codec_cleanup_stream: NID=0x3
snd_hda_codec_realtek hdaudioC1D0: hda_codec_cleanup_stream: NID=0x2
snd_hda_codec_realtek hdaudioC1D0: hda_codec_setup_stream: NID=0x3, stream=0x5, channel=0, format=0x31
snd_hda_codec_realtek hdaudioC1D0: hda_codec_setup_stream: NID=0x2, stream=0x5, channel=0, format=0x31
snd_hda_codec_realtek hdaudioC1D0: hda_codec_cleanup_stream: NID=0x3
snd_hda_codec_realtek hdaudioC1D0: hda_codec_cleanup_stream: NID=0x2

These records correlate with sound playback on speakers.
Comment 5 Alexander Sergeyev 2022-01-11 18:10:02 UTC
I've done additional boot rounds in the background. There were 16 working-speakers bootups across 709 attempts. The previous statement was not correct -- hda_codec_setup_stream/hda_codec_cleanup_stream messages can appear on bootups with no working sound. But all good bootups had these messages.

These 709 tests were done on recently released kernel v5.16.0.
Comment 6 Alexander Sergeyev 2022-01-12 21:11:34 UTC
Continuing in https://lkml.org/lkml/2022/1/11/950

Note You need to log in before you can comment on or make changes to this bug.