applications can't interact with pulseaudio daemon for ~5 minutes after boot

From: Vivian Samuel
Date: Sun Aug 29 2021 - 23:44:58 EST


On each boot, applications that use pulseaudio(pavucontrol, pacmd,
pactl, YouTube on browser) aren't able to connect with the pulseaudio
daemon. After 5 minutes, journalctl reports an error from the kernel
about the realtek sound card and after that rtkit-daemon outputs
something(I guess it's related to starting pulseaudio as my user) and
then applications start working normally, below is the error message
from journalctl along with the followup messages. The first two lines
show the red coloured error message.


Aug 22 12:44:44 arch kernel: snd_hda_codec_realtek ehdaudio0D0: Unable
to sync register 0x2b8000. -5
Aug 22 12:44:48 arch kernel: snd_hda_codec_realtek ehdaudio0D0: Unable
to sync register 0x2b8000. -5
Aug 22 12:45:01 arch rtkit-daemon[462]: Supervising 2 threads of 1
processes of 1 users.
Aug 22 12:45:01 arch rtkit-daemon[462]: Successfully made thread 2017
of process 451 owned by '1000' RT at priority 9.
Aug 22 12:45:01 arch rtkit-daemon[462]: Supervising 3 threads of 1
processes of 1 users.
Aug 22 12:45:01 arch rtkit-daemon[462]: Supervising 3 threads of 1
processes of 1 users.
Aug 22 12:45:01 arch rtkit-daemon[462]: Successfully made thread 2018
of process 451 owned by '1000' RT at priority 9.
Aug 22 12:45:01 arch rtkit-daemon[462]: Supervising 4 threads of 1
processes of 1 users.
Aug 22 12:45:01 arch rtkit-daemon[462]: Supervising 4 threads of 1
processes of 1 users.
Aug 22 12:45:01 arch rtkit-daemon[462]: Successfully made thread 2019
of process 451 owned by '1000' RT at priority 9.
Aug 22 12:45:01 arch rtkit-daemon[462]: Supervising 5 threads of 1
processes of 1 users.


This also causes long delays in shutdown/reboot, it takes about 5
minutes to poweroff, there aren't any error messages reported while it
is powering off. This delay only happens if I shutdown/reboot soon
after I powered on my laptop(say less than 15 minutes of uptime).
Shutdown/reboot times are normal if uptime was long.

I don't know the exact kernel version where this issue started because
I was trying to check for solutions online regarding pulseaudio for
about a month(I thought it was the problem initially). The oldest
kernel that I know that has this issue is version 5.12.14.arch1-1,
which was the latest version as of July 7 2021. The issue started
roughly about a month ago from this version.

I emailed a bug report to the kernel maintainer of realtek sound
cards(oder_chiou@xxxxxxxxxxx) on July 7 2021 but haven't gotten a
reply till now(August 23 2021) so I'm sending another one here. As of
August 23 2021, the latest kernel on Arch Linux's repos is version
5.13.12.arch1-1 and it still has this issue. The latest LTS kernel on
arch's repos is version 5.10.60-1, and it doesn't have this issue so
I've been using the LTS kernel for the past few months.

Though I can't point to the exact kernel version where the issue
started, I've noticed one difference between kernel versions with this
issue(>=5.12.14.arch1-1) and the most recent LTS kernel version that
doesn't have this issue(5.10.60-1-lts). The difference is the kernel
module and driver used by the audio controller,

On kernel versions with the issue(>=5.12.14.arch1-1):

$ lspci -k | grep -A3 'audio controller'
00:1f.3 Multimedia audio controller: Intel Corporation Comet Lake PCH-LP cAVS
Subsystem: Xiaomi Device 1901
Kernel driver in use: sof-audio-pci-intel-cnl
Kernel modules: snd_hda_intel, snd_soc_skl, snd_sof_pci_intel_cnl

On the most recent LTS kernel where the issue is not present(5.10.60-1-lts):

$ lspci -k | grep -A3 'audio controller'
00:1f.3 Multimedia audio controller: Intel Corporation Comet Lake PCH-LP cAVS
Subsystem: Xiaomi Device 1901
Kernel driver in use: sof-audio-pci
Kernel modules: snd_hda_intel, snd_soc_skl, snd_sof_pci

The kernel versions with the issue uses sof-audio-pci-intel-cnl driver
and snd_sof_pci_intel_cnl module while the LTS kernel uses
sof-audio-pci driver and snd_sof_pci module. Note that
>=5.12.14.arch1-1 doesn't indicate that 5.12.14.arch1-1 is where the
issue started, its the oldest kernel version that I know that has this
issue.

Output of /proc/version on the oldest known kernel with the issue:
Linux version 5.12.14-arch1-1 (linux@archlinux) (gcc (GCC) 11.1.0, GNU
ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Thu, 01 Jul 2021 07:26:06
+0000

Errors reported by applications that use pulseaudio:

$ pactl list cards
Connection failure: Connection refused
pa_context_connect() failed: Connection refused

$ sudo alsactl init
alsa-lib main.c:761:(execute_sequence) unable to execute cset
'name='Speaker Playback Volume' 60%'
alsa-lib main.c:2366:(set_boot_user) Unable to execute boot sequence
Found hardware: "sof-hda-dsp" "Realtek ALC256"
"HDA:8086280b,80860101,00100000 HDA:10ec0256,1d721901,00100002
cfg-dmics:2" "" ""
Hardware is initialized using a generic method
/usr/share/alsa/init/default:119: value write error: Input/output error

$ pulseaudio --check
-- returns exit code 0 with no stdout/stderr

Playing a Youtube video : player keeps loading and says "If playback
doesn't begin shortly, try restarting your device" after some time

I have attached the following(I've attached logs and command outputs
from the latest version with the issue(5.13.12-arch1-1), but it is
pretty much the same as the output from 5.12.14.arch1-1):

Excerpts from journalctl taking only the messages that had
'sof-audio-pci' or 'snd_hda_codec_realtek' or other related terms. One
excerpt is from the LTS kernel 5.12.14.arch1-1 without the issue(no
error messages there) and the other from the latest version as of
August 23 2021(5.13.12-arch1-1).

lspci -vvv output

ver_linux output

output of pactl list cards (sound card information)

Keywords: kernel, sof-audio-pci-intel-cnl,
snd_sof_audio_pci_intel_cnl, audio, snd_hda_codec_realtek

Attachment: journalctl_excerpt_5.10.60-1-lts
Description: Binary data

Attachment: journalctl_excerpt_5.13.12-arch1-1
Description: Binary data

Attachment: lspci_5.13.12-arch1-1
Description: Binary data

Attachment: lspci_5.10.60-1-lts
Description: Binary data

Attachment: pactl_list_cards
Description: Binary data

Attachment: ver_linux_5.10.60-1-lts
Description: Binary data

Attachment: ver_linux_5.13.12-arch1-1
Description: Binary data