Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Kernel & Hardware
  • Search

[SOLVED] Auto loading vfio-pci

Kernel not recognizing your hardware? Problems with power management or PCMCIA? What hardware is compatible with Gentoo? See here. (Only for kernels supported by Gentoo.)
Post Reply
Advanced search
5 posts • Page 1 of 1
Author
Message
Kresp
Tux's lil' helper
Tux's lil' helper
Posts: 77
Joined: Mon Oct 17, 2016 3:34 am

[SOLVED] Auto loading vfio-pci

  • Quote

Post by Kresp » Tue Aug 15, 2017 11:08 am

I use vfio-pci to passthrough my GPU to VM.
However, the module does not load automatically on boot.

Code: Select all

$ cat /etc/modprobe.d/vfio-pci.conf
options vfio-pci ids=1002:67df,1002:aaf0
Every time I turn my machine on, I have to manually do:

Code: Select all

modprobe vfio-pci
chown root:kvm /dev/vfio
chmod g+X /dev/vfio
Latter two commands I need to run qemu without sudo.
I already have this udev rule:

Code: Select all

SUBSYSTEM=="vfio", OWNER="root", GROUP="kvm"
But I can not find a way to automatically set proper permissions for parent directory.
My user is member of kvm group.

So, I have to problems: how do I force vfio-pci to auto load on boot, and where do I change attrs for /dev/vfio?
Last edited by Kresp on Sat Aug 26, 2017 3:01 am, edited 2 times in total.
Top
Myu
Apprentice
Apprentice
User avatar
Posts: 164
Joined: Wed Oct 22, 2014 7:28 am
Location: Belgium

  • Quote

Post by Myu » Tue Aug 15, 2017 11:17 am

Hello,

About to automatic loading, I use openRC so I cannot really tell about systemd, that being said :

Add in /etc/conf.d/modules :

Code: Select all

modules="vfio vfio-pci vfio_iommu_type1 vfio_virqfd"
Then make sure that the modules service is started at boot time

Code: Select all

rc-config list | grep modules
rc-config add modules
On my end I didn't had to fidlle with /dev/vfio perms :

drwxr-xr-x 2 root root 80 Aug 15 11:39 vfio
Gentoo stable with bits of ~amd64 // Xfce 4.13 + Compiz Reloaded.
Top
Kresp
Tux's lil' helper
Tux's lil' helper
Posts: 77
Joined: Mon Oct 17, 2016 3:34 am

  • Quote

Post by Kresp » Wed Aug 16, 2017 1:09 pm

Adding vfio-pci helped, but only if snd_hda_intel is blacklisted.
Myu wrote:

Code: Select all

modules="vfio-pci"
Otherwise it grabs RX 480's HDMI audio and system locks after trying to insert vfio-pci module.

How do I load snd_hda_intel only for specific device?

On my system it works with GTX 960 HDMI audio, RX 480 HDMI audio and onboard ALC1220 codec.
I'd like to whitelist it for only ALC1220.



Also, /dev/vfio is 660 by default, so I still ned to chmod+chown after boot.
Top
Myu
Apprentice
Apprentice
User avatar
Posts: 164
Joined: Wed Oct 22, 2014 7:28 am
Location: Belgium

  • Quote

Post by Myu » Thu Aug 17, 2017 5:51 am

Good question, I'm not sure I know an answer about loading the module for a specific device, most likely it can be done

From my experience, I've found that building snd_hda_intel in-kernel made things so much smoother to get audio at boot time on the host then be able to get audio when starting the VM.

I usually pass through my onboard audio chipset to the VM i.e

Before (at boot time)

Dwarf linux # lspci -nnk | grep --context=3 1e20
[...]
00:1b.0 Audio device [0403]: Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller [8086:1e20] (rev 04)
Subsystem: ASRock Incorporation 7 Series/C216 Chipset Family High Definition Audio Controller [1849:8892]
Kernel driver in use: snd_hda_intel
[...]

After (when starting up the VM)

Dwarf linux # lspci -nnk | grep --context=3 1e20
[...]
00:1b.0 Audio device [0403]: Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller [8086:1e20] (rev 04)
Subsystem: ASRock Incorporation 7 Series/C216 Chipset Family High Definition Audio Controller [1849:8892]
Kernel driver in use: vfio-pci
[...]

If you're not against a small kernel rebuilt, I think this might be interesting to try out :)

Hope this helps !
Gentoo stable with bits of ~amd64 // Xfce 4.13 + Compiz Reloaded.
Top
Kresp
Tux's lil' helper
Tux's lil' helper
Posts: 77
Joined: Mon Oct 17, 2016 3:34 am

  • Quote

Post by Kresp » Sat Aug 26, 2017 3:00 am

man modprobe.d ponted to install keyword, which was exactly what I needed to fix module loading order.
I removed snd_hda_intel from blacklist, and left this:

Code: Select all

options vfio-pci ids=1002:67df,1002:aaf0
install vfio-pci /sbin/modprobe -r snd_hda_intel; /sbin/modprobe --ignore-install vfio-pci ids=1002:67df,1002:aaf0; /sbin/modprobe snd_hda_intel
--ignore-install is necessary, or else it recurses.

It's possible to replace modprobe -r with with /bin/echo deviceId to device/driver/unbind, but this ID changes whenever you swap or remove PCI-E devices, so I decided it's safer to remove module altogether, and bind it only after vfio-pci is done.
Top
Post Reply

5 posts • Page 1 of 1

Return to “Kernel & Hardware”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic