Prevent Radeon driver from attaching to specific PCI devices?

I had had some pci_stub-related lines in my rc.local but this was apparently too late in the boot process to help, running after radeon started fiddling with things.

I fixed things by moving the pci_stub kernel module stuff to the initramfs:

  1. lspci -nn | grep Cayman to find the vendor:device numbers (at the very end of the line) for the 6950 and its HDMI port:

    02:00.0 VGA compatible controller [0300]: Advanced Micro Devices [AMD] nee ATI Cayman PRO [Radeon HD 6950] [1002:6719]
    02:00.1 Audio device [0403]: Advanced Micro Devices [AMD] nee ATI Cayman/Antilles HDMI Audio [Radeon HD 6900 Series] [1002:aa80]
    
  2. Pop open /etc/initramfs-tools/modules and add a new line:

    pci_stub ids=1002:6719,1002:aa80
    
  3. Rebuild the initramfs:

    sudo update-initramfs -u
    
  4. Reboot and observe pci_stub beating out radeon:

    dmesg | egrep "pci-stub|radeon"
    
    pci-stub: add 1002:6719 sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
    pci-stub 0000:02:00.0: claimed by stub
    pci-stub: add 1002:AA80 sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
    pci-stub 0000:02:00.1: claimed by stub
    [drm] radeon kernel modesetting enabled.
    radeon 0000:01:00.0: setting latency timer to 64
    radeon 0000:01:00.0: VRAM: 1024M 0x0000000000000000 - 0x000000003FFFFFFF (1024M used)
    radeon 0000:01:00.0: GTT: 512M 0x0000000040000000 - 0x000000005FFFFFFF
    
  5. Enjoy bluescreen-free VGA passthrough!


Using genpfault answer as reference, I created another answer, I think is more simple.

The first step is the same as above:

Then I created a file called /lib/modprobe.d/pci-stub.conf, whith the args I found:

options pci-stub ids=1002:9715,1002:970f

Then I created a file called /lib/modprobe.d/drm.conf, with softdep:

softdep drm pre: pci-stub

This way, when the boot process tries to load drm, first loads pci-stub, which reserves the hardware of one video card, and prevents drm to attach to some device.

Later you can remove the reservation in rc.local, modprobe -r pci-stub.

Optionally you can load another module modprobe another-module for that card.