You are not logged in.

#1 2016-06-28 06:00:32

Sara
Member
From: USA
Registered: 2009-07-09
Posts: 219
Website

[SOLVED] Choppy hdmi audio in kvm with pci passthrough

I have successfully passed through my GTX 1080 graphics card and its audio device, and installed the latest drivers with GeForce Experience in the Windows guest. I have an Asus MX239H monitor, and clicking on the volume icon shows it's using NVIDIA High Definition Audio. The only audio I get however is choppy and stutters terribly, which slows down games when they open. Otherwise, the VM is fairly zippy and everything seems to be working fine, except for the sound. Using either the built-in monitor speakers or the headphone plug on the back of the monitor yields the same result, choppy audio.

I attempted to install Razer's virtual audio device per this comment, but that did not resolve my issue (I think also because that solution is limited to Steam streaming). I have already enabled Message Signaled Interrupts via a Windows registry edit per this post. lspci shows it is successfully enabled when I have the VM open:

# lspci -v -s 2:00.0
02:00.0 VGA compatible controller: NVIDIA Corporation Device 1b80 (rev a1) (prog-if 00 [VGA controller])
	Subsystem: NVIDIA Corporation Device 119e
	Flags: bus master, fast devsel, latency 0, IRQ 331
	Memory at db000000 (32-bit, non-prefetchable) [size=16M]
	Memory at a0000000 (64-bit, prefetchable) [size=256M]
	Memory at b0000000 (64-bit, prefetchable) [size=32M]
	I/O ports at d000 [size=128]
	Expansion ROM at dc000000 [disabled] [size=512K]
	Capabilities: [60] Power Management version 3
	Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+
	Capabilities: [78] Express Legacy Endpoint, MSI 00
	Capabilities: [100] Virtual Channel
	Capabilities: [250] Latency Tolerance Reporting
	Capabilities: [128] Power Budgeting <?>
	Capabilities: [420] Advanced Error Reporting
	Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
	Capabilities: [900] #19
	Kernel driver in use: vfio-pci
	Kernel modules: nouveau, nvidia_drm, nvidia

I'm not really sure what else I can do. I am using pulseaudio on the host, though I am not passing it through; I have no sound devices being passed in my libvirt config. I have read that the latest GTX 1080 does not support analog audio, but surely it should still be compatible with in-built PC speakers over HDMI?

Here is my full XML file I'm using with virt-manager, if that might be of help:

<domain type='kvm' id='1'>
  <name>W10</name>
  <uuid>50ad0aea-18cd-4f7f-98fd-85caaaab607b</uuid>
  <memory unit='KiB'>16488448</memory>
  <currentMemory unit='KiB'>16488448</currentMemory>
  <vcpu placement='static' current='2'>3</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.6'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/ovmf/x64/ovmf_x64.bin</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/W10_VARS.fd</nvram>
    <bootmenu enable='no'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <kvm>
      <hidden state='on'/>
    </kvm>
    <vmport state='off'/>
  </features>
  <cpu mode='host-passthrough'/>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/sbin/qemu-system-x86_64</emulator>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source dev='/dev/sdc1'/>
      <backingStore/>
      <target dev='sda' bus='scsi'/>
      <boot order='1'/>
      <alias name='scsi0-0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <backingStore/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <alias name='ide0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <backingStore/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <alias name='usb'/>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <alias name='usb'/>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <alias name='usb'/>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/>
    </controller>
    <controller type='scsi' index='0' model='virtio-scsi'>
      <alias name='scsi0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </controller>
    <interface type='network'>
      <mac address='52:54:00:c3:23:d3'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/0'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/0'>
      <source path='/dev/pts/0'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <input type='mouse' bus='ps2'>
      <alias name='input0'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input1'/>
    </input>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
      </source>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x02' slot='0x00' function='0x1'/>
      </source>
      <alias name='hostdev1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </hostdev>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='none' model='none'/>
  <seclabel type='dynamic' model='dac' relabel='yes'>
    <label>+99:+78</label>
    <imagelabel>+99:+78</imagelabel>
  </seclabel>
</domain>

I'm traveling for the next month so unfortunately I won't be able to run more tests on my machine, but I opened this topic hoping someone could offer me a pointer I could follow through on when I return. Been scratching my head at this for well over a day now. Thanks in advance. smile

Edit: So it turns out I had made the keys but not changed the 0 to a 1 when I added the DWORD on the NVIDIA sound card, and I replicated the steps on the graphics card proper for good measure. But it didn't work until the sound card was enabled so I think that was the thing. So glad the solution was so simple! Really looking forward to gaming via my VM now. big_smile

Last edited by Sara (2016-08-04 16:40:33)


Registed Linux User 483618

Offline

#2 2016-06-28 20:23:49

Jodaco
Member
Registered: 2014-07-30
Posts: 5

Re: [SOLVED] Choppy hdmi audio in kvm with pci passthrough

I had the same problem and followed Alex's blog post here: http://vfio.blogspot.com/2014/09/vfio-i … ndows.html

Offline

#3 2016-06-29 01:09:01

Sara
Member
From: USA
Registered: 2009-07-09
Posts: 219
Website

Re: [SOLVED] Choppy hdmi audio in kvm with pci passthrough

Jodaco wrote:

I had the same problem and followed Alex's blog post here: http://vfio.blogspot.com/2014/09/vfio-i … ndows.html

That's the same guide I followed to enable MSI on my card. However, I verified it was enabled through Linux, not Windows, so it might be worth double-checking in Windows. (Enabled via the Windows regedit, so it only appears to be enabled whilst the VM is running.) Good to know this sufficed for you; I hope that's it, for otherwise I'm clueless. XD


Registed Linux User 483618

Offline

Board footer

Powered by FluxBB