[SOLVED] Single GPU passthrough: Failed to mmap xxxx:xx:xx.x BAR 3. Performance may be slow

Hi,

so I am trying to do the single GPU passthrough with help from this article.

I manged to boot into Windows 10 by detaching/attaching the host GPU with qemu hooks, but I am getting the well known code 43 error. After investigating the problem, i stumbled upon following error:

2021-01-31T16:58:37.050671Z qemu-system-x86_64: -device vfio-pci,host=0000:2d:00.0,id=hostdev0,bus=pci.3,addr=0x0,rombar=1,romfile=/var/lib/libvirt/vbios/VM-Palit-GTX1060.rom: Failed to mmap 0000:2d:00.0 BAR 3. Performance may be slow.

Loading of the custom ROM seem to be working or I would get black screen. I did add a workaround to avoid the code 43, from here, but I think it won’t work as long as I have the “Failed to mmap” error.

Here is a part the qemu XML that concerns the GPU:

   <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x2d' slot='0x00' function='0x0'/>
      </source>
      <rom bar='on' file='/var/lib/libvirt/vbios/VM-Palit-GTX1060.rom'/>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x2d' slot='0x00' function='0x1'/>
      </source>
      <rom bar='on'/>
      <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
    </hostdev>

I am also getting a similar error in dmesg:

[So Jän 31 18:35:14 2021] [drm] [nvidia-drm] [GPU ID 0x00002d00] Unloading driver
[So Jän 31 18:35:14 2021] nvidia-modeset: Unloading
[So Jän 31 18:35:14 2021] nvidia-uvm: Unloaded the UVM driver.
[So Jän 31 18:35:14 2021] nvidia-nvlink: Unregistered the Nvlink Core, major device number 241
[So Jän 31 18:35:15 2021] VFIO - User Level meta-driver version: 0.3
[So Jän 31 18:35:15 2021] vfio-pci 0000:2d:00.0: vgaarb: changed VGA decodes: olddecodes=none,decodes=io+mem:owns=io+mem
[So Jän 31 18:35:15 2021] audit: type=2502 audit(1612114516.075:2191): pid=75520 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='virt=kvm vm="win10-work" uuid=c9f8e364-91c7-4911-b343-1c69ad4ec4ed vm-ctx=+65534:+992 img-ctx=+65534:+992 model=dac exe="/usr/bin/libvirtd" hostname=? addr=? terminal=? res=success'
[So Jän 31 18:35:15 2021] virbr0: port 2(vnet0) entered blocking state
[So Jän 31 18:35:15 2021] virbr0: port 2(vnet0) entered disabled state
[So Jän 31 18:35:15 2021] device vnet0 entered promiscuous mode
[So Jän 31 18:35:15 2021] audit: type=1700 audit(1612114516.085:2192): dev=vnet0 prom=256 old_prom=0 auid=4294967295 uid=0 gid=0 ses=4294967295
[So Jän 31 18:35:15 2021] virbr0: port 2(vnet0) entered blocking state
[So Jän 31 18:35:15 2021] virbr0: port 2(vnet0) entered listening state
[So Jän 31 18:35:15 2021] audit: type=2501 audit(1612114516.085:2193): pid=75520 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='virt=kvm resrc=net reason=open vm="win10-work" uuid=c9f8e364-91c7-4911-b343-1c69ad4ec4ed net=52:54:00:36:8e:80 path="/dev/net/tun" rdev=0A:C8 exe="/usr/bin/libvirtd" hostname=? addr=? terminal=? res=success'
[So Jän 31 18:35:15 2021] audit: type=1130 audit(1612114516.105:2194): pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
[So Jän 31 18:35:15 2021] audit: type=2501 audit(1612114516.125:2195): pid=75520 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='virt=kvm resrc=cgroup reason=deny vm="win10-work" uuid=c9f8e364-91c7-4911-b343-1c69ad4ec4ed cgroup="/sys/fs/cgroup/devices/machine.slice/machine-qemu\x2d2\x2dwin10\x2dwork.scope/" class=all exe="/usr/bin/libvirtd" hostname=? addr=? terminal=? res=success'
[So Jän 31 18:35:17 2021] virbr0: port 2(vnet0) entered learning state
[So Jän 31 18:35:17 2021] vfio-pci 0000:2d:00.0: vfio_ecap_init: hiding ecap [email protected]
[So Jän 31 18:35:17 2021] vfio-pci 0000:2d:00.0: BAR 3: can't reserve [mem 0xe0000000-0xe1ffffff 64bit pref]
[So Jän 31 18:35:17 2021] vfio-pci 0000:2d:00.0: No more image in the PCI ROM

Any tips on how to get rid of this error?

Solved the problem, the card was not detaching properly.

Hey !
Just wanted to know how you were able to solve your problem precisely ? How you managed to properly detach your card ?