Reassigning PCI audio device leads to sound problems

I’m playing with the sys-audio stuff.

I ran the salt formula, and ended up with a sys-audio qube. I was glad to find that after setting default audio vm to it, newly started qubes are using it, sending audio streams to it.

But I cannot play music in newly started qubes. The music player’s progress bar remained at the starting point. I also noticed dragging the volumn slider or click at some buttons in pavucontrol in sys-audio “refreshed” the sound buffer (seemingly), making the progress bar advance a little, and now the speaker was playing the same note again and again. Re-do this (dragging and clicking) updated the note being played. If I clicked quick enough, I could tell that the song is being played, though hard to enjoy.

To solve the problem, I reinstalled pulseaudio, but it didn’t work. I tried with another qube, assigning the audio device to it, and playing music inside the qube. The exact same behaviour. Different templates didn’t make a difference.

When I assign a usb headphone to sys-audio, it works flawlessly. When my soundcard was in dom0, it alse worked flawlessly. So the problem must be a PCI problem.

My system: Qubes R4.1
My chip: AMD Ryzen 5600u.
My soundcard: Realtek ALC257.
Any help is appreciated.

… moved into 4.1 category

1 Like

Yes, sounds like it. Do you see any errors in the kernel log in sys-audio (check dmesg command there)?

Especially look for things related to interrupts, INT, MSI, MSI-X. Compare also sudo lspci -v of that device in dom0 and in sys-audio.

1 Like

Thanks, marmarek. Here are my findings.

First, I’d like to point out that dmesg in dom0 and in sys-audio with audio device attached have the following apparent difference:
In dom0:

[    5.678019] snd_hda_codec_realtek hdaudioC1D0: autoconfig for ALC257: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:speaker
[    5.678020] snd_hda_codec_realtek hdaudioC1D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[    5.678022] snd_hda_codec_realtek hdaudioC1D0:    hp_outs=1 (0x21/0x0/0x0/0x0/0x0)
[    5.678023] snd_hda_codec_realtek hdaudioC1D0:    mono: mono_out=0x0
[    5.678023] snd_hda_codec_realtek hdaudioC1D0:    inputs:
[    5.678024] snd_hda_codec_realtek hdaudioC1D0:      Mic=0x19
[    5.678024] snd_hda_codec_realtek hdaudioC1D0:      Internal Mic=0x12
[    5.725769] input: PC Speaker as /devices/platform/pcspkr/input/input17

But the above messages didn’t show up in sys-audio. Module snd_hda_codec_realtek has been installed in sys-audio.

Secondly, pulseaudio control panel in dom0 shows that my audio card is named “Family 17h (Models 10h-1fh) HD Audio Controller”, but in sys-audio it is named “Built-in Analog Stereo”. However, alsamixer shows that it has successfully identified its model “ALC257”.

Also, pulseaudio doesn’t autostart in sys-audio. But I think this is a trivial thing and fixes easily.

Other results are nothing special.

lspci -v in sys-audio:

00:06.0 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 10h-1fh) HD Audio Controller
	Subsystem: Lenovo Device 382c
	Physical Slot: 6
	Flags: bus master, fast devsel, latency 0, IRQ 69
        Memory at f2010000 (32-bit, non-prefetchable) [size=32K]
 	Capabilities: <access denied>
 	Kernel driver in use: snd_hda_intel
 	Kernel modules: snd_hda_intel
 
00:07.0 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Renoir Radeon High Definition Audio Controller
 	Subsystem: Lenovo Device 381b
 	Physical Slot: 7
 	Flags: bus master, fast devsel, latency 0, IRQ 70
 	Memory at f2018000 (32-bit, non-prefetchable) [size=16K]
 	Capabilities: <access denied>
 	Kernel driver in use: snd_hda_intel
 	Kernel modules: snd_hda_intel

lspci -v in dom0:

05:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Renoir Radeon High Definition Audio Controller
	Subsystem: Lenovo Device 381b
	Flags: bus master, fast devsel, latency 0, IRQ 39
	Memory at d04c8000 (32-bit, non-prefetchable) [size=16K]
	Capabilities: <access denied>
	Kernel driver in use: pciback
	Kernel modules: snd_hda_intel
05:00.6 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 10h-1fh) HD Audio Controller
	Subsystem: Lenovo Device 382c
	Flags: bus master, fast devsel, latency 0, IRQ 36
	Memory at d04c0000 (32-bit, non-prefetchable) [size=32K]
	Capabilities: <access denied>
	Kernel driver in use: pciback
	Kernel modules: snd_hda_intel

Almost the same.

dmesg | grep MSI in sys audio:
[ 0.367757] acpi PNP0A03:00: _OSC: OS supports [ExtendedConfig ASPM ClockPM Segments MSI EDR HPX-Type3]
The same in dom0.

dmesg | grep INT in sys audio:

[    0.011927] ACPI: DSDT 0x00000000FC001040 0092A3 (v02 Xen    HVM      00000000 INTL 20190509)
[    0.011937] ACPI: SSDT 0x00000000FC00A5D0 000031 (v02 Xen    HVM      00000000 INTL 20190509)
[    0.011938] ACPI: SSDT 0x00000000FC00A610 000031 (v02 Xen    HVM      00000000 INTL 20190509)
[    0.016797] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.016799] ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 low level)
[    0.016799] ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 low level)
[    0.016800] ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq 11 low level)

in dom0:

[    0.464470] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.464474] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 low level)

Nothing special.

dmesg | grep interrupt in sys audio:
[ 0.362651] ACPI: Using IOAPIC for interrupt routing
in dom0:

[    0.655022] ACPI: EC: interrupt blocked
[    0.655186] ACPI: Using IOAPIC for interrupt routing
[    0.698781] ACPI: EC: interrupt unblocked

Another wired thing is that this device is using “intel” kernel module. I don’t know why, but it works fine in dom0.

I was asking about sudo lspci -v specifically to have this field filled.

Sorry LOL :stuck_out_tongue:
dom0:

05:00.6 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 10h-1fh) HD Audio Controller
	Subsystem: Lenovo Device 382c
	Flags: bus master, fast devsel, latency 0, IRQ 117
	Memory at d04c0000 (32-bit, non-prefetchable) [size=32K]
	Capabilities: [48] Vendor Specific Information: Len=08 <?>
	Capabilities: [50] Power Management version 3
	Capabilities: [64] Express Endpoint, MSI 00
	Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
	Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel

05:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Device 1637
	Subsystem: Lenovo Device 381b
	Flags: bus master, fast devsel, latency 0, IRQ 116
	Memory at d04c8000 (32-bit, non-prefetchable) [size=16K]
	Capabilities: [48] Vendor Specific Information: Len=08 <?>
	Capabilities: [50] Power Management version 3
	Capabilities: [64] Express Legacy Endpoint, MSI 00
	Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
	Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel

sys-audio

00:06.0 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Renoir Radeon High Definition Audio Controller
	Subsystem: Lenovo Device 381b
	Physical Slot: 6
	Flags: bus master, fast devsel, latency 0, IRQ 69
	Memory at f2018000 (32-bit, non-prefetchable) [size=16K]
	Capabilities: [48] Vendor Specific Information: Len=08 <?>
	Capabilities: [50] Power Management version 3
	Capabilities: [64] Express Legacy Endpoint, MSI 00
	Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel

00:07.0 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 10h-1fh) HD Audio Controller
	Subsystem: Lenovo Device 382c
	Physical Slot: 7
	Flags: bus master, fast devsel, latency 0, IRQ 70
	Memory at f2010000 (32-bit, non-prefetchable) [size=32K]
	Capabilities: [48] Vendor Specific Information: Len=08 <?>
	Capabilities: [50] Power Management version 3
	Capabilities: [64] Express Endpoint, MSI 00
	Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel

When I add xen-pciback.hide= to grub.cfg to hide audio device in dom0, the problem still exists. But now it refreshes the buffer every 1.5 second. I don’t know why.