pavolelsig / passthrough_helper_manjaro

67 stars 18 forks source link

Disable Passthrough #8

Open blazini36 opened 3 years ago

blazini36 commented 3 years ago

I realize this is similar to #6 , but using dual identical GPUs this is the only method I've found to work well. I've tried to just remove the grub lines and turn off iommu in bios to hand the GPU back to linux but that's not enough. It'd be nice to not have to make too many alterations and mess up the working passthrough setup

Is there some simple way of disabling the passthrough over a reboot or can a script be created to do so without deleting everything like uninstall.sh does? There are a few tasks in Linux that can leverage that 2nd GPU when I'm not passing it through.

pavolelsig commented 3 years ago

You could just remove iommu=on from grub even at boot time. Or have two grub entries, one with iommu=on and one without.

blazini36 commented 3 years ago

As mentioned above, that doesn't actually work. The 2nd card will use the vfio-pci driver rather than the GPU driver. I removed all new grub options, update-grub, reboot:

$ lspci -nnk 
0e:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] [10de:1b06] (rev a1)
    Subsystem: Micro-Star International Co., Ltd. [MSI] Device [1462:3604]
    Kernel driver in use: nvidia
    Kernel modules: nouveau, nvidia_drm, nvidia
0e:00.1 Audio device [0403]: NVIDIA Corporation GP102 HDMI Audio Controller [10de:10ef] (rev a1)
    Subsystem: Micro-Star International Co., Ltd. [MSI] Device [1462:3604]
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel
0f:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] [10de:1b06] (rev a1)
    Subsystem: Micro-Star International Co., Ltd. [MSI] Device [1462:3604]
    Kernel driver in use: vfio-pci
    Kernel modules: nouveau, nvidia_drm, nvidia
0f:00.1 Audio device [0403]: NVIDIA Corporation GP102 HDMI Audio Controller [10de:10ef] (rev a1)
    Subsystem: Micro-Star International Co., Ltd. [MSI] Device [1462:3604]
    Kernel driver in use: vfio-pci
    Kernel modules: snd_hda_intel
pavolelsig commented 3 years ago

I assumed this would have worked. Instead of using this script you could try to bind the GPU by adding vfio-pci.ids=whatever in grub. Just remove the mention of vfio-pci-override from the files item in mkinitcpio.conf and regenerate initramfs. That way you could just remove the pci-id from grub whenever needed.

blazini36 commented 3 years ago

The kernel parameter that you enter in grub as "vfio-pci ids=" is the vendor:model pair. As you see above I cannot use that since both cards are identical and have the same pair ID.

From the Arch wiki https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF#Binding_vfio-pci_via_device_ID

Note:

    You cannot specify which device to isolate using vendor-device ID pairs if the host GPU and the guest GPU share the same pair (i.e : if both are the same model). If this is your case, read #Using identical guest and host GPUs instead.

The options are to "passthrouh all but the boot GPU" with the same vfio-pci-override.sh script packaged in this repo, or specify a GPU by it's device ID: DEVS="0000:0f:00.0 0000:0f:00.1"

.....In this case. The ladder Iatter I've tried for initial GPU passthrough and haven't gotten to work, I probably missed something else but the only thing I've gotten to work is this manjaro_help.sh script. Either way a vfio-pci-override.sh script would have to exist in my case.

Khyretos commented 3 years ago

Hey,

i have a similair issue. i have

and i passed through my 1060 successfully but i dont always want to pass my 1060, i only want it to pass when i start the vm, i watched the video several times but i cannot make it return controll to the host.

how can i achieve this? what i want is:

but both cases are with the 1060, the 1050 is there just to have the monitors working. how can i achieve this

0a:00.0 VGA compatible controller: NVIDIA Corporation GP107 [GeForce GTX 1050] (rev a1)
        Subsystem: Micro-Star International Co., Ltd. [MSI] Device 8c97
        Kernel driver in use: nvidia
        Kernel modules: nouveau, nvidia_drm, nvidia
0a:00.1 Audio device: NVIDIA Corporation GP107GL High Definition Audio Controller (rev a1)
        Subsystem: Micro-Star International Co., Ltd. [MSI] Device 8c97
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel
0b:00.0 VGA compatible controller: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] (rev a1)
        Subsystem: Gigabyte Technology Co., Ltd Device 3775
        Kernel driver in use: vfio-pci
        Kernel modules: nouveau, nvidia_drm, nvidia
0b:00.1 Audio device: NVIDIA Corporation GP106 High Definition Audio Controller (rev a1)
        Subsystem: Gigabyte Technology Co., Ltd Device 3775
        Kernel driver in use: vfio-pci
        Kernel modules: snd_hda_intel

as you can see the 1060 has the 'vfio-pci' tag so passing it through to the vm is no problem but i cannot use it in my linux system anymore

image

blazini36 commented 3 years ago

Having a simple means of reverting the passthrough would definitely be welcome. I use 2 1080TI's and I give 1 to VFIO to get some video rendering stuff done in Windows and it works very well, but there are a few things in Linux that can use both GPUs. It's kind of a shame I can't get that GPU back without undoing the whole thing.

Khyretos commented 3 years ago

Having a simple means of reverting the passthrough would definitely be welcome. I use 2 1080TI's and I give 1 to VFIO to get some video rendering stuff done in Windows and it works very well, but there are a few things in Linux that can use both GPUs. It's kind of a shame I can't get that GPU back without undoing the whole thing.

There are several ways I have found after asking this question, in your case it could be interesting to check this: https://github.com/DualCoder/vgpu_unlock

And through command lines you can disable it by using this:

echo INSERT_PCI_ADDRESS_HERE > /sys/bus/pci/devices/INSERT_PCI_ADDRESS_HERE/driver/unbind
echo INSERT_PCI_ADDRESS_HERE > /sys/bus/pci/drivers/INSERT_DESIRED_DRIVER_HERE/bind

And then restarting x but I have not tested it yet since I'm still distro hopping and looking for the one that suits my needs

But if either of these work I'll automate it for myself