Linux Host, Windows Guest, GPU passthrough reinitialization fix

now this is a bit old … but it just popped up for me on google search and I wanted to give the OP some love for the original post and to suggest an easier approach.

For those who can’t be bothered to download the driver development kit … you can get the same effect as devcon using the pnputil command (built into ALL versions of win10 … and earlier … I think … definitely used it on Win 7 and Win 10 at any rate). This does all you need. First you need to get the id of the device you want to shut down and start up … e.g. for my graphics card I’m passing through to win 10 (I don’t pass through the audio card).

C:\WINDOWS\system32>pnputil /enum-devices /class Display
Microsoft PnP Utility

Instance ID: PCI\VEN_1002&DEV_66AF&SUBSYS_081E1002&REV_C1\4&23f93f77&0&00E0
Device Description: AMD Radeon VII
Class Name: Display
Class GUID: {4d36e968-e325-11ce-bfc1-08002be10318}
Manufacturer Name: Advanced Micro Devices, Inc.
Status: Started
Driver Name: oem1.inf

You can then pass the instance ID to pnputil /enable-device or pnputil /disable-device.

Thus my startup script is:

pnputil /enum-devices /class Display
pnputil /enable-device "PCI\VEN_1002&DEV_66AF&SUBSYS_081E1002&REV_C1\4&23f93f77&0&00E0

And my shutdown script is:

pnputil /enum-devices /class Display
pnputil /disable-device "PCI\VEN_1002&DEV_66AF&SUBSYS_081E1002&REV_C1\4&23f93f77&0&00E0

I keep the enum-devices command in the script in case somethng changes and they need updating … so I can rememebr how. I have Win Pro so use the GPEdit.msc startup/shudown scripts but you can probably find something in the task scheduler if you don’t.

New here … so if people think I should post this as a new thread instead of pinging a super old one … let me know and I will.

The pnputil command is a must have for all Win10 users as it lets you delete the old and unused drivers cluttering up your drive. After you un-install a driver … Win10 loves to auto install these old uninstalled drivers onto your devices when your trying to update to a newer version. It’s always good to purge those previous versions (pnptuile -e to find them and pnputil -d to delete them).

It’s better than rolling back your VM. Though … frankly … I’ve no idea how your supposed to be able to cope with windows 10 if you can’t do that.

Switch on … BSOD or crash from failed auto-update … roll back Windows 10 to a week ago … Peace on earth.

Now back to ma Jonesin!

Good to have another solution, but all of this is pretty much not necessary anymore, because FLR bug has been worked out with dkms for older stuff. And on new rx 6800 it has been fixed at last.

It seems there is another bug happening with at least the 7800XT - the host locks up completely and eventually hard resets once you shutdown the VM. After the reset, the GPU is not available anymore. See this bug report : hxxps://gitlab.freedesktop.org/drm/amd/-/issues/2955 (can’t post links, replace the xx with tt).

If someone stumbles over this: Disabling the devices before shutdown (and then enabling them again on startup) as described somewhat fixes the issue, a good enough workaround until there is a fix.

Thanks to OP for documenting this years ago :slight_smile: