Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Vfio driver override not working
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
genvfio
n00b
n00b


Joined: 31 Oct 2016
Posts: 1

PostPosted: Mon Oct 31, 2016 5:52 pm    Post subject: Vfio driver override not working Reply with quote

Hey,
I'm trying to override the driver of my graphicscard with vfio-pci to passthrough it for my kvm but this sh** is not working very well :(
I have two identical cards so I can't use the vendor ids. For assinging the kernel driver I use the initramfs dracut.
Dracut script:
Code:
#!/bin/bash

# called by dracut
check() {
    require_binaries /bin/bash
}

# called by dracut
depends() {
    return 0
}

# called by dracut
install() {
    inst_simple "/sbin/vfio-pci-override.sh"
    inst_simple "/etc/modprobe.d/vfio.conf"
}


/sbin/vfio-pci-override.sh script:

Code:
#!/bin/sh
 
# 03:00.0 is the pci-bus of my graphics card and 03:00.1 its sound bus
# that I want to use for my virtual machine
DEVS="0000:03:00.0 0000:03:00.1"
 
for DEV in $DEVS; do
    echo "vfio-pci" > /sys/bus/pci/devices/$DEV/driver_override
done
 
modprobe -i vfio-pci


/etc/modprobe.d/vfio.conf script:
Code:
install vfio-pci /sbin/vfio-pci-override.sh


When I run my kernel with the initramfs the graphicscard uses vfio-pci but not the soundcard:
lspci -nnk:
Code:

03:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM204 [GeForce GTX 970] [10de:13c2] (rev a1)
   Subsystem: Gigabyte Technology Co., Ltd GM204 [GeForce GTX 970] [1458:367a]
   Kernel driver in use: vfio-pci
   Kernel modules: nvidia_drm, nvidia
03:00.1 Audio device [0403]: NVIDIA Corporation GM204 High Definition Audio Controller [10de:0fbb] (rev a1)
   Subsystem: Gigabyte Technology Co., Ltd GM204 High Definition Audio Controller [1458:367a]
   Kernel driver in use: snd_hda_intel

But in /sys/bus/pci/devices/0000:03:00.1/driver_override is vfio-pci so I don't know why only the VGA controller is using the vfio-pci.
I hope you have an idea what I could do and how to resolve the problem.
Thanks in advance.
Back to top
View user's profile Send private message
Plumbo
n00b
n00b


Joined: 01 Feb 2008
Posts: 46

PostPosted: Thu Nov 03, 2016 10:54 pm    Post subject: Reply with quote

Hi,

I've never tried this with two identical cards before, but I would imagine that complicates things somewhat.

Do you have the audiodrivers built in-kernel? If so, what happens if you let vfio claim them in-kernel and load the audio as modules?

Also, I've never used the driver_override as you have, but in my QEmu-launchscript I have this to unload alsa-drivers and passthrough the hole card to the guest:

/etc/init.d/alsasound stop
echo "8086 8d20" > /sys/bus/pci/drivers/vfio-pci/new_id
echo "0000:00:1b.0" > /sys/bus/pci/drivers/snd_hda_intel/unbind
echo "0000:00:1b.0" > /sys/bus/pci/drivers/vfio-pci/bind
echo "8086 8d20" > /sys/bus/pci/drivers/vfio-pci/remove_id

This removes snd_hda_intel (which I use in linux), and replaces it with vfio-pci. Maybe you can try the same, and if your second card gets assigned as well you can always do the reverse when exiting the guest. Having both binded to vfio wont matter as long as you're in the guest system.

Hope you figure it out. :D
_________________
/Plumbo
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum