[SOLVED] PCI passthrough onboard sound

diversity

Active Member
Feb 19, 2020
245
15
38
54
LS,

I am trying to passthrough onboard audio
lspci -v
34:00.4 Audio device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse HD Audio Controller
Subsystem: ASRock Incorporation Starship/Matisse HD Audio Controller
Flags: fast devsel, IRQ 11
Memory at df500000 (32-bit, non-prefetchable) [disabled] [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 <?>
Capabilities: [150] Advanced Error Reporting
Capabilities: [2a0] Access Control Services
Capabilities: [370] Transaction Processing Hints
Kernel driver in use: vfio-pci
Kernel modules: snd_hda_intel

CPU: AMD Ryzen 9 3950x
Mobo: ASrock x570 Creator (Latest bios 2.10, SR-IOV, IOMMU, ACS, PCIe ARI enabled in settings)
Memory: 4 x Kingston KSM26ED8/16ME (ECC)" (64 GB total)

I have gone through the steps on:
https://pve.proxmox.com/wiki/Pci_passthrough#PCI_EXPRESS_PASSTHROUGH
and
https://pve.proxmox.com/wiki/PCI(e)_Passthrough (perhaps these pages could be merged?)

root@pve:~# find /sys/kernel/iommu_groups/ -type l
/sys/kernel/iommu_groups/45/devices/0000:34:00.4
There is only 1 device in group 45

GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on"

added all modules. blacklist snd_hda_intel in
/etc/modprobe.d/blacklist.conf
(so not sure why it is still listed above in kernel modules)

reboot

root@pve:~# dmesg | grep -e DMAR -e IOMMU -e AMD-Vi
[ 0.635056] pci 0000:00:00.2: AMD-Vi: IOMMU performance counters supported
[ 0.644218] pci 0000:00:00.2: AMD-Vi: Found IOMMU cap 0x40
[ 0.644218] pci 0000:00:00.2: AMD-Vi: Extended features (0x58f77ef22294ade):
[ 0.644220] AMD-Vi: Interrupt remapping enabled
[ 0.644220] AMD-Vi: Virtual APIC enabled
[ 0.644220] AMD-Vi: X2APIC enabled
[ 0.644300] AMD-Vi: Lazy IO/TLB flushing enabled
[ 0.645447] perf/amd_iommu: Detected AMD IOMMU #0 (2 banks, 4 counters/bank).

starting VM fails with the following line in syslog
pve kernel: vfio-pci 0000:34:00.4: not ready 16383ms after FLR; waiting

And then some time later the system reboots. and freezes at Loading initial ramdisk finally continues.

Now lspc -v no longer lists 34:00.4 and a hard reboot is the only way to get it listed again.

VM config:
agent: 1
balloon: 0
bios: ovmf
bootdisk: ide0
cores: 16
efidisk0: local-lvm:vm-101-disk-1,size=128K
hostpci0: 34:00.4,pcie=1,rombar=0
ide0: local-lvm:vm-101-disk-0,size=32G
ide2: local:iso/VBX4B-NW47T-TWXK8-9M4VG-KTRBD.ISO,media=cdrom
machine: q35
memory: 32768
name: win2k19
net0: e1000=EE:60:FD:D6:F7:B1,bridge=vmbr0,firewall=1
numa: 0
ostype: win10
scsihw: virtio-scsi-pci
smbios1: uuid=950732ad-a153-491d-8dc1-f875daf9b702
sockets: 1
vmgenid: af47eb69-6bc6-48ea-8582-6ea382d10b40

Can anyone please help out getting audio to passthrough?

Kind regards
 
updating did not help

root@pve:~# pveversion
pve-manager/6.1-7/13e58d5e (running kernel: 5.3.18-2-pve)

the fail is still the same:
pve kernel: vfio-pci 0000:34:00.4: not ready xxxx ms after FLR; waiting
 
Just a heads up. I have send back this setup in the mean time so can no longer try new things.
If at all possible can someone please take a dry stab it this? I might just buy this setup again if it sounds prommosing
 
Hi,

i got the same problem as you and as i could fix it, i just registered here to answer you :)

All credit goes to this guy on reddit (there also explained why this happening) - is justed adopted the patch and the compiled the proxmox kernel.

I first tried it with kernel 5.3 but i didn't work for me. So i used the latest proxmox 5.4 Kernel.

How to Install:

- Download the custom Kernel (all .deb files) which i compiled and install it -> reboot -> profit.
- Download the patch (0008-amd-no-flr.patch) and compile the kernel by yourself. I used this Guide to compile the proxmox kernel. Just copy the patch to
Code:
/usr/src/pve-kernel/patches/kernel/
and compile the kernel.

Hope it helps.

- seji
 
  • Like
Reactions: ChrisDB
thanks so much for this information. I am not sure though I dare to go the custom compilation route.
 
@seji once again thanks for your contribution. I am going in with your .deb files and have already downloaded them.

can you please share a total noob guide for how to actually 'install' those .deb files? I found some guides that assume some prior knowledge that I don't have yet.
 
Hi,

thats an easy Task. Assuming you downloaded all *.deb file in a single Folder (eg. home).

Bash:
cd
dpkg -i *.deb
reboot

Done :)
 
thanks for the info @seji

however this results in no more netowrking and a boot time that takes ages.
a start job is running for udev wait for complete device initialization
a start job is running for helper to synchronize boot up for ifupdown

originally all went smooth with:
root@pve:~# pveversion
pve-manager/6.2-4/9824574a (running kernel: 5.4.34-1-pve)

It seems your deb files were a patch to an older kernel and mixing the 2 don't play nice

would you have any suggestions left?
 
@seji, or anyone?

perhaps there is a guide for the uninitiated on how to patch the kernel? all i find are guides that assume prior knowledge
 
Hi,
I had the same issue and I have recently compiled the kernel with the patch and all worked for me, reboot went well and I am able to passthrough the PCI audio.
These are the steps I followed to compile the kernel (based on 5.4.34-1)

Bash:
cd /usr/src
git clone git://git.proxmox.com/git/pve-kernel.git

Copy the patch file to the patches folder (I took the one from seji above). I had to modify the patch slightly for the compilation to succeed, I changed all quirk_intel_no_flr into quirk_no_flr
Bash:
cp 0008-amd-no-flr.patch /usr/src/pve-kernel/patches/kernel
Modify 2 files before the compilation
Bash:
nano /usr/src/pve-kernel/debian/scripts/find-firmware.pl
Comment line 11 starting with die "strange directory name:...
Bash:
nano /usr/src/pve-kernel/Makefile
Append at the end of line 14 -noamdflr, it should look like this: EXTRAVERSION=-${KREL}-pve-noamdflr
Bash:
cd /usr/src/pve-kernel
make 2>&1 | tee build.log
Wait a while. If no errors, you should have a list of .deb files in /usr/src/pve-kernel. Install them all with dpkg -i *.deb and reboot.
If any errors, have a look at file build.log to see what could have go wrong. In my case, I saw the patch had to be updated thus why I say above to change the patch but I did not have any other problems.

Hope this helps
 
wow thank you sooo much for holding my hand.

Please allow some time in order for me to try it. I will for sure to get back to this.
 
finally I found the inner strength to try and then :(
kernel
root@pve:/usr/src/pve-kernel/patches# ls
kernel
root@pve:/usr/src/pve-kernel/patches# cd kernal
-bash: cd: kernal: No such file or directory
root@pve:/usr/src/pve-kernel/patches# cd kernel
root@pve:/usr/src/pve-kernel/patches/kernel# ls
0001-Make-mkcompile_h-accept-an-alternate-timestamp-strin.patch 0005-Revert-KVM-VMX-enable-nested-virtualization-by-defau.patch
0002-bridge-keep-MAC-of-first-assigned-port.patch 0006-Revert-scsi-lpfc-Fix-broken-Credit-Recovery-after-dr.patch
0003-pci-Enable-overrides-for-missing-ACS-capabilities-4..patch 0007-net-core-downgrade-unregister_netdevice-refcount-lea.patch
0004-kvm-disable-default-dynamic-halt-polling-growth.patch
root@pve:/usr/src/pve-kernel/patches/kernel# cp 0008-amd-no-flr.patch /usr/src/pve-kernel/patches/kernel
cp: cannot stat '0008-amd-no-flr.patch': No such file or directory
root@pve:/usr/src/pve-kernel/patches/kernel# cd ..
root@pve:/usr/src/pve-kernel/patches# ls
kernel
root@pve:/usr/src/pve-kernel/patches# cd ..
root@pve:/usr/src/pve-kernel# ls
abi-blacklist abi-prev-5.4.65-1-pve debian fwlist-previous Makefile patches README submodules
root@pve:/usr/src/pve-kernel# cd ..
root@pve:/usr/src# ls
pve-kernel
root@pve:/usr/src# git clone git://git.proxmox.com/git/pve-kernel.git
fatal: destination path 'pve-kernel' already exists and is not an empty directory.
root@pve:/usr/src# sudo git clone git://git.proxmox.com/git/pve-kernel.git
-bash: sudo: command not found
root@pve:/usr/src# /sbin/sudo/ git clone git://git.proxmox.com/git/pve-kernel.git
-bash: /sbin/sudo/: No such file or directory
root@pve:/usr/src# cp 0008-amd-no-flr.patch /usr/src/pve-kernel/patches/kernel
cp: cannot stat '0008-amd-no-flr.patch': No such file or directory
root@pve:/usr/src#
 
Hi,
finally I found the inner strength to try and then :(
kernel
root@pve:/usr/src/pve-kernel/patches# ls
kernel
root@pve:/usr/src/pve-kernel/patches# cd kernal
-bash: cd: kernal: No such file or directory
root@pve:/usr/src/pve-kernel/patches# cd kernel
root@pve:/usr/src/pve-kernel/patches/kernel# ls
0001-Make-mkcompile_h-accept-an-alternate-timestamp-strin.patch 0005-Revert-KVM-VMX-enable-nested-virtualization-by-defau.patch
0002-bridge-keep-MAC-of-first-assigned-port.patch 0006-Revert-scsi-lpfc-Fix-broken-Credit-Recovery-after-dr.patch
0003-pci-Enable-overrides-for-missing-ACS-capabilities-4..patch 0007-net-core-downgrade-unregister_netdevice-refcount-lea.patch
0004-kvm-disable-default-dynamic-halt-polling-growth.patch
root@pve:/usr/src/pve-kernel/patches/kernel# cp 0008-amd-no-flr.patch /usr/src/pve-kernel/patches/kernel
cp: cannot stat '0008-amd-no-flr.patch': No such file or directory
root@pve:/usr/src/pve-kernel/patches/kernel# cd ..
root@pve:/usr/src/pve-kernel/patches# ls
kernel
root@pve:/usr/src/pve-kernel/patches# cd ..
root@pve:/usr/src/pve-kernel# ls
abi-blacklist abi-prev-5.4.65-1-pve debian fwlist-previous Makefile patches README submodules
root@pve:/usr/src/pve-kernel# cd ..
root@pve:/usr/src# ls
pve-kernel
root@pve:/usr/src# git clone git://git.proxmox.com/git/pve-kernel.git
fatal: destination path 'pve-kernel' already exists and is not an empty directory.
root@pve:/usr/src# sudo git clone git://git.proxmox.com/git/pve-kernel.git
-bash: sudo: command not found
root@pve:/usr/src# /sbin/sudo/ git clone git://git.proxmox.com/git/pve-kernel.git
-bash: /sbin/sudo/: No such file or directory
root@pve:/usr/src# cp 0008-amd-no-flr.patch /usr/src/pve-kernel/patches/kernel
cp: cannot stat '0008-amd-no-flr.patch': No such file or directory
root@pve:/usr/src#
I see 3 or 4 errors that you are getting:

Bash:
root@pve:/usr/src/pve-kernel/patches/kernel# cp 0008-amd-no-flr.patch /usr/src/pve-kernel/patches/kernel
cp: cannot stat '0008-amd-no-flr.patch': No such file or directory

This happens because file '0008-amd-no-flr.patch' (your patch file) cannot be found in this folder. Where did you download the patch file? In which folder?

Bash:
root@pve:/usr/src# git clone git://git.proxmox.com/git/pve-kernel.git
fatal: destination path 'pve-kernel' already exists and is not an empty directory.

This is because pve-kernel folder already exists, which means that you had already downloaded the kernel source code. Easiest is to remove the folder and download from scratch so you get a clean new folder. Do this:

Bash:
cd /usr/src
rm -rf pve-kernel
git clone git://git.proxmox.com/git/pve-kernel.git

This should work before you compile and copy the patch file

Bash:
sudo git clone git://git.proxmox.com/git/pve-kernel.git
-bash: sudo: command not found

You do not really need to do this as the issue is the one I mentioned just above. However, sudo is not necessary when you are connected to proxmox shell as you are already root.

Next steps for you is remove the pve-kernel folder and do the git command again (the 3 lines above when I mention "Do this"). Then copy the patch file from wherever you have downloaded it and copy it to the folder that contains the patches (the first cp command).
This should work.

Hope this helps. Let me know if anything unclear.
 
I am getting closer, I just got confused, and have the patch file on my system.
can you please paste me what you ended up with after the changes you mention?
I can double check manufacuter and device id's later.
This is what I have now in /usr/src/pve-kernel/patches/kernel/0008-amd-no-flr.patch:

--- a/drivers/pci/quirks.c 2020-03-24 18:57:27.026481021 +0100
+++ b/drivers/pci/quirks.c 2020-03-24 18:58:39.754065062 +0100
@@ -5040,6 +5040,13 @@
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1502, quirk_intel_no_flr);
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1503, quirk_intel_no_flr);

+// USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Matisse USB 3.0 Host Controller [1022:149c]
+DECLARE_PCI_FIXUP_EARLY(0x1022, 0x149c, quirk_intel_no_flr);
+// Audio device [0403]: Advanced Micro Devices, Inc. [AMD] Starship/Matisse HD Audio Controller [1022:1487]
+DECLARE_PCI_FIXUP_EARLY(0x1022, 0x1487, quirk_intel_no_flr);
+// Encryption controller [1080]: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Cryptographic Coprocessor PSPCPP [1022:1486]
+DECLARE_PCI_FIXUP_EARLY(0x1022, 0x1486, quirk_intel_no_flr);
+
static void quirk_intel_th_rtit_bar(struct pci_dev *dev)
{
struct resource *r = &dev->resource[4];
 
Glad I found this thread. I'm also trying to get audio passthru working.
Asrock X470, AMD 3700X.
Want the audio output to be controlled by a VM a la mopidy.

@koivum Thanks for the instructions. Also helped one lurker out.

Managed to follow, up to this error in compile:
```
dh: unable to load addon sphinxdoc: Can't locate Debian/Debhelper/Sequence/sphinxdoc.pm in @INC (you may need to install the Debian::Debhelper::Sequence::sphinxdoc module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.28.1 /usr/local/share/perl/5.28.1 /usr/lib/x86_64-linux-gnu/perl5/5.28 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.28 /usr/share/perl/5.28 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at (eval 14) line 1.

```
Never used make before, so this is new to me too.

What to do with sphinxdoc?

Thanks
 
@qwerty0033 can you please paste me the contents of your 0008 patch file?
Hi @diversity,
This is the content of my patch file:

--- a/drivers/pci/quirks.c 2020-03-24 18:57:27.026481021 +0100
+++ b/drivers/pci/quirks.c 2020-03-24 18:58:39.754065062 +0100
@@ -5040,6 +5040,13 @@
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1502, quirk_no_flr);
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1503, quirk_no_flr);

+// USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Matisse USB 3.0 Host Controller [1022:149c]
+DECLARE_PCI_FIXUP_EARLY(0x1022, 0x149c, quirk_no_flr);
+// Audio device [0403]: Advanced Micro Devices, Inc. [AMD] Starship/Matisse HD Audio Controller [1022:1487]
+DECLARE_PCI_FIXUP_EARLY(0x1022, 0x1487, quirk_no_flr);
+// Encryption controller [1080]: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Cryptographic Coprocessor PSPCPP [1022:1486]
+DECLARE_PCI_FIXUP_EARLY(0x1022, 0x1486, quirk_no_flr);
+
static void quirk_intel_th_rtit_bar(struct pci_dev *dev)
{
struct resource *r = &dev->resource[4];


Hope this works for you
Thanks
 
Glad I found this thread. I'm also trying to get audio passthru working.
Asrock X470, AMD 3700X.
Want the audio output to be controlled by a VM a la mopidy.

@koivum Thanks for the instructions. Also helped one lurker out.

Managed to follow, up to this error in compile:
```
dh: unable to load addon sphinxdoc: Can't locate Debian/Debhelper/Sequence/sphinxdoc.pm in @INC (you may need to install the Debian::Debhelper::Sequence::sphinxdoc module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.28.1 /usr/local/share/perl/5.28.1 /usr/lib/x86_64-linux-gnu/perl5/5.28 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.28 /usr/share/perl/5.28 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at (eval 14) line 1.

```
Never used make before, so this is new to me too.

What to do with sphinxdoc?

Thanks
Hi @qwerty0033,
I think you are missing a package in your system. Can you check you have package sphinx-common installed? if not, please run apt install sphinx-common and try the make command again. It should work after this.
Hope this helps.
Thanks
 
Hi @diversity,
This is the content of my patch file:

--- a/drivers/pci/quirks.c 2020-03-24 18:57:27.026481021 +0100
+++ b/drivers/pci/quirks.c 2020-03-24 18:58:39.754065062 +0100
@@ -5040,6 +5040,13 @@
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1502, quirk_no_flr);
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1503, quirk_no_flr);

+// USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Matisse USB 3.0 Host Controller [1022:149c]
+DECLARE_PCI_FIXUP_EARLY(0x1022, 0x149c, quirk_no_flr);
+// Audio device [0403]: Advanced Micro Devices, Inc. [AMD] Starship/Matisse HD Audio Controller [1022:1487]
+DECLARE_PCI_FIXUP_EARLY(0x1022, 0x1487, quirk_no_flr);
+// Encryption controller [1080]: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Cryptographic Coprocessor PSPCPP [1022:1486]
+DECLARE_PCI_FIXUP_EARLY(0x1022, 0x1486, quirk_no_flr);
+
static void quirk_intel_th_rtit_bar(struct pci_dev *dev)
{
struct resource *r = &dev->resource[4];


Hope this works for you
Thanks
Thanks a lot:
Almost there now. One error while compiling when using your patch file contents:

applying patch '../../patches/kernel/0008-amd-no-flr.patch'
patching file drivers/pci/quirks.c
patch: **** malformed patch at line 4: DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1502, quirk_no_flr);
 
Hi @diversity,
I think the copy/paste of the patch file did not work very well as I did not use the proper format. Try copying this patch content instead:

Code:
--- a/drivers/pci/quirks.c    2020-03-24 18:57:27.026481021 +0100
+++ b/drivers/pci/quirks.c    2020-03-24 18:58:39.754065062 +0100
@@ -5040,6 +5040,13 @@
 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1502, quirk_no_flr);
 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1503, quirk_no_flr);
 
+// USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Matisse USB 3.0 Host Controller [1022:149c]
+DECLARE_PCI_FIXUP_EARLY(0x1022, 0x149c, quirk_no_flr);
+// Audio device [0403]: Advanced Micro Devices, Inc. [AMD] Starship/Matisse HD Audio Controller [1022:1487]
+DECLARE_PCI_FIXUP_EARLY(0x1022, 0x1487, quirk_no_flr);
+// Encryption controller [1080]: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Cryptographic Coprocessor PSPCPP [1022:1486]
+DECLARE_PCI_FIXUP_EARLY(0x1022, 0x1486, quirk_no_flr);
+
 static void quirk_intel_th_rtit_bar(struct pci_dev *dev)
 {
     struct resource *r = &dev->resource[4];

Hope this works better.
Thanks
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!