Patchwork VFIO VGA test branches

login
register
mail settings
Submitter Knut Omang
Date May 13, 2013, 8:55 p.m.
Message ID <1368478534.14279.201.camel@ori.omang.mine.nu>
Download mbox | patch
Permalink /patch/243537/
State New
Headers show

Comments

Knut Omang - May 13, 2013, 8:55 p.m.
Hi all,

Perfect timing from my perspective, thanks Alex!

I spent the better part of the weekend testing your branches on a new system 
I just put together for this purpose, results below..

On Fri, 2013-05-03 at 16:56 -0600, Alex Williamson wrote:
...
> git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> git://github.com/awilliam/qemu-vfio.git vfio-vga-reset

System setup: 

- Fedora 18 on
- Gigabyte Z77X-UD5H motherboard
- Intel Core i7 3770 (Ivy bridge w/integrated graphics)
- 2 discrete graphics cards:

lspci | egrep 'VGA|Audio'
00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Caicos [Radeon HD 6450]
01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Caicos HDMI Audio [Radeon HD 6400 Series]
02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Cape Verde PRO [Radeon HD 7700 Series]
02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]

Short summary:

- Once I got past a few time consuming obstacles explained below
   - the graphics part of the graphics/hdmi audio passthrough seems to work perfect
     on both discrete graphics cards 
     (though so far only one at at time and with some minor issues, see below)
   - no success with the hdmi audio yet (ideas for further investigation appreciated!)

- Contrary to deniv@lavabit.com I had no success with using pci-assign for VGA
  with a standard fedora 18 kernel and fairly recent qemu, nor with your branches, 

Details:

- I started off with the required kernel parameter 'intel_iommu=on' + necessary parameters for disabling radeon
   (radeon.modeset=0 rd.driver.blacklist=radeon) using the integrated graphics as primary display
   - this caused the system to freeze (with color artifacts on the console)

- In my naivity and because of the "i" in ifgx I tried both with 
  'intel_iommu=ifgx_off' and then 'intel_iommu=on,igfx_off' 
  and a full set of combinations of vfio, cards, kernels and pci-assign before I suspected 
  that iommu support was turned off for **all** graphics cards with igfx_off

- The solution was to have integrated graphics turned off in the BIOS, and 'intel_iommu=on':

- iommu groups:

ls -l /sys/bus/pci/devices/0000:01:00.0/iommu_group/devices
total 0
lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.0 -> ../../../../devices/pci0000:00/0000:00:01.0
lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.1 -> ../../../../devices/pci0000:00/0000:00:01.1
lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.0 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.0
lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.1 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.1
lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.0 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.0
lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.1 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.1

- eg. both the VGA/HDMI Audio pairs + the two root ports they are plugged into are in the same group:

# lspci -n
...
01:00.0 0300: 1002:683f
01:00.1 0403: 1002:aab0
02:00.0 0300: 1002:6779
02:00.1 0403: 1002:aa98
...

modprobe vfio_pci
echo 0000:01:00.1 > /sys/bus/pci/devices/0000\:01\:00.1/driver/unbind
echo 0000:02:00.1 > /sys/bus/pci/devices/0000\:02\:00.1/driver/unbind
echo 1002 683f > /sys/bus/pci/drivers/vfio-pci/new_id
echo 1002 aab0 > /sys/bus/pci/drivers/vfio-pci/new_id
echo 1002 6779 > /sys/bus/pci/drivers/vfio-pci/new_id
echo 1002 aa98 > /sys/bus/pci/drivers/vfio-pci/new_id

# lsusb 
...
Bus 001 Device 008: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
Bus 001 Device 004: ID 046d:c05b Logitech, Inc. M-U0004 810-001317 [B110 Optical USB Mouse]
...

- I also applied your suggested patch to the quirk function in VFIO (see below)

- Here is a (trimmed for readability) command line I successfully used to boot from the Windows 7 install DVD, 
  notice the cd and disk device descriptions and the bus parameter - I struggled a while with that 
  until I came across a comment by Gerd Hoffmann here: https://bugzilla.redhat.com/show_bug.cgi?id=922670 (Thanks, Gerd!)


qemu-kvm -M q35 \
  -nodefconfig -readconfig $SRC/qemu/docs/q35-chipset.cfg \
  -device vfio-pci,host=2:00.0,x-vga=on,multifunction=on,bus=ich9-pcie-port-1,addr=0.0 \
  -device vfio-pci,host=2:00.1,bus=ich9-pcie-port-1,addr=0.1 \
  -L $SRC/seabios/out/ -L $SRC/qemu/pc-bios \
  -vga none -nographic -cpu host -rtc base=localtime -k no -m 8192 -smp 2 \
  -drive file=/dev/sr0,index=2,media=cdrom,id=cd \
  -drive file=ivm03.img,index=0,media=disk,id=ivm03 \
  -device ide-drive,drive=ivm03,bus=ide.0 \
  -device ide-cd,drive=cd,bus=ide.1 \
  -net nic,vlan=0,model=virtio -net tap,vlan=0 \
  -enable-kvm \
  -device usb-host,hostbus=1,hostaddr=8 \
  -device usb-host,hostbus=1,hostaddr=4

- Both the graphics card seems to have a rom but only the HD6450 let itself to "scraping". 
Anyway, supplying it to vfio did not seem to make any difference.

find /sys -name rom
/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/rom
/sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/rom
...

Some observations and remaining unresolved issues:

- VFIO patch:
  Initially (while still running with igfx_off) I observed exactly the same behaviour as deniv@lavabit.com
  reported a while ago: With vfio_pci debug enabled, vfio_pci ended up spinning with repeated calls to
  vfio_ati_3c3_quirk_read and repeated logs: 
    vfio: vfio_vga_read(0x3c3, 1) = 0x0
  I patched up accordingly with 




  This of course did not help much until I actually got the iommu 
  enabled for the radeons (similar "repeated patters" as deniv reported)
  but what I have observed after I got it working is that if 
  I disable the patch above, things are not that well: the Fedora VM 
  comes up with VGA and the Fedora boot screen, then goes blank when 
  switching to X.

- The fact that the iommu group now extends across all my available graphics 
  devices now makes it difficult to  get the radeon (or catalyst) driver use to 
  the other card since the vfio_pci driver needs to hold it.
  Not a complete showstopper since the vesa driver comes up with 1024x768..
  Might it be a good idea to have an override option (exception list or similar?) 
  to allow the vfio_pci to be less restrictive about owning the whole group 
   - allow functionality over security in such case? This of course is further complicated
  by the need for graphics drivers to be disabled/enabled already at the kernel prompt..

- There seems to be a bug in the (version F8) UEFI BIOS on the motherboard, 
  The BIOS offers (undocumented) a full range of selections of which PCIe 
  (or PCIe 1x) graphics card to use as primary, but any other selection 
  than the first PCIe 16x slot has no effect and the motherboard reverts 
  to the first slot, so to be able to test both cards, I had to put the card under test
  into the second (8x) PCIe slot. I am waiting for feedback from Gigabyte on possible 
  fixes for this in newer BIOSes.

- The ultimate goal is to try to consolidate some older Windows desktops as "seats" 
  on the new system, using the discrete graphics with HDMI/Displayport audio. 
  With the HD7700 moved to the second PCIe slot I tested both Windows and 
  Linux guests to try to get some sound through the HDMI audio device. 
  Windows complains that no usable device is available. On Linux (Fedora 18, KDE desktop), 
  the system settings -> multimedia dialogue never opens up which seems to indicate that 
  PulseAudio has problems communicating with the passed through device (?), 
  any hints/pointers here appreciated. From the vfio log it seems at least
  config space is accessed ok.

- There also seems to be issues with radeon and intel_iommu=on - if I try 
  to enable modesetting and normal X support for the radeon cards, X fails to start.

- It would be nice if the integrated graphics could be used as the host primary display - 
  I would be happy if someone has any hints as to if/how the ifgx_off option 
  could be extended/modified to only affect iommu operation on selected device(s),
  if at all possible..

Thanks,

Knut Omang
Alex Williamson - May 13, 2013, 10:23 p.m.
On Mon, 2013-05-13 at 22:55 +0200, Knut Omang wrote:
> Hi all,
> 
> Perfect timing from my perspective, thanks Alex!
> 
> I spent the better part of the weekend testing your branches on a new system 
> I just put together for this purpose, results below..
> 
> On Fri, 2013-05-03 at 16:56 -0600, Alex Williamson wrote:
> ...
> > git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> > git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> 
> System setup: 
> 
> - Fedora 18 on
> - Gigabyte Z77X-UD5H motherboard
> - Intel Core i7 3770 (Ivy bridge w/integrated graphics)
> - 2 discrete graphics cards:
> 
> lspci | egrep 'VGA|Audio'
> 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
> 00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
> 01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Caicos [Radeon HD 6450]
> 01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Caicos HDMI Audio [Radeon HD 6400 Series]
> 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Cape Verde PRO [Radeon HD 7700 Series]
> 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> 
> Short summary:
> 
> - Once I got past a few time consuming obstacles explained below
>    - the graphics part of the graphics/hdmi audio passthrough seems to work perfect
>      on both discrete graphics cards 
>      (though so far only one at at time and with some minor issues, see below)
>    - no success with the hdmi audio yet (ideas for further investigation appreciated!)

I've had hdmi audio working with an HD7850, but only in Windows (7) and
it was using legacy interrupts for some reason instead of MSI.  I wonder
if Liux guests might work with snd_hda_intel.enable_msi=0.  I'm not sure
what's wrong with MSI, but it seems to be new with the PCI bus reset
support.

> - Contrary to deniv@lavabit.com I had no success with using pci-assign for VGA
>   with a standard fedora 18 kernel and fairly recent qemu, nor with your branches, 
> 
> Details:
> 
> - I started off with the required kernel parameter 'intel_iommu=on' + necessary parameters for disabling radeon
>    (radeon.modeset=0 rd.driver.blacklist=radeon) using the integrated graphics as primary display
>    - this caused the system to freeze (with color artifacts on the console)
> 
> - In my naivity and because of the "i" in ifgx I tried both with 
>   'intel_iommu=ifgx_off' and then 'intel_iommu=on,igfx_off' 
>   and a full set of combinations of vfio, cards, kernels and pci-assign before I suspected 
>   that iommu support was turned off for **all** graphics cards with igfx_off

I'm not sure why this is, looks like the code only tries to turn it off
when only graphics is under the remapping device.  We'd probably need to
see the DMAR to know more (/sys/firmware/acpi/tables/DMAR).

> - The solution was to have integrated graphics turned off in the BIOS, and 'intel_iommu=on':
> 
> - iommu groups:
> 
> ls -l /sys/bus/pci/devices/0000:01:00.0/iommu_group/devices
> total 0
> lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.0 -> ../../../../devices/pci0000:00/0000:00:01.0
> lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.1 -> ../../../../devices/pci0000:00/0000:00:01.1
> lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.0 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.0
> lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.1 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.1
> lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.0 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.0
> lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.1 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.1
> 
> - eg. both the VGA/HDMI Audio pairs + the two root ports they are plugged into are in the same group:

Ick.  Intel has been pretty good about advertising ACS support on their
root ports.  I wonder if this is an oversight or if they are actually
not isolated from each other.

> # lspci -n
> ...
> 01:00.0 0300: 1002:683f
> 01:00.1 0403: 1002:aab0
> 02:00.0 0300: 1002:6779
> 02:00.1 0403: 1002:aa98
> ...
> 
> modprobe vfio_pci
> echo 0000:01:00.1 > /sys/bus/pci/devices/0000\:01\:00.1/driver/unbind
> echo 0000:02:00.1 > /sys/bus/pci/devices/0000\:02\:00.1/driver/unbind
> echo 1002 683f > /sys/bus/pci/drivers/vfio-pci/new_id
> echo 1002 aab0 > /sys/bus/pci/drivers/vfio-pci/new_id
> echo 1002 6779 > /sys/bus/pci/drivers/vfio-pci/new_id
> echo 1002 aa98 > /sys/bus/pci/drivers/vfio-pci/new_id
> 
> # lsusb 
> ...
> Bus 001 Device 008: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
> Bus 001 Device 004: ID 046d:c05b Logitech, Inc. M-U0004 810-001317 [B110 Optical USB Mouse]
> ...
> 
> - I also applied your suggested patch to the quirk function in VFIO (see below)
> 
> - Here is a (trimmed for readability) command line I successfully used to boot from the Windows 7 install DVD, 
>   notice the cd and disk device descriptions and the bus parameter - I struggled a while with that 
>   until I came across a comment by Gerd Hoffmann here: https://bugzilla.redhat.com/show_bug.cgi?id=922670 (Thanks, Gerd!)
> 
> 
> qemu-kvm -M q35 \
>   -nodefconfig -readconfig $SRC/qemu/docs/q35-chipset.cfg \
>   -device vfio-pci,host=2:00.0,x-vga=on,multifunction=on,bus=ich9-pcie-port-1,addr=0.0 \
>   -device vfio-pci,host=2:00.1,bus=ich9-pcie-port-1,addr=0.1 \
>   -L $SRC/seabios/out/ -L $SRC/qemu/pc-bios \
>   -vga none -nographic -cpu host -rtc base=localtime -k no -m 8192 -smp 2 \
>   -drive file=/dev/sr0,index=2,media=cdrom,id=cd \
>   -drive file=ivm03.img,index=0,media=disk,id=ivm03 \
>   -device ide-drive,drive=ivm03,bus=ide.0 \
>   -device ide-cd,drive=cd,bus=ide.1 \
>   -net nic,vlan=0,model=virtio -net tap,vlan=0 \
>   -enable-kvm \
>   -device usb-host,hostbus=1,hostaddr=8 \
>   -device usb-host,hostbus=1,hostaddr=4
> 
> - Both the graphics card seemshould really support ACS on s to have a rom but only the HD6450 let itself to "scraping". 

Did you try scraping the HD6450 while the HD7700 was the boot VGA and
vica versa?  The boot VGA ROM is handled in a special way and what you
really get is the shadow copy, which isn't what we want.

> Anyway, supplying it to vfio did not seem to make any difference.
> 
> find /sys -name rom
> /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/rom
> /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/rom
> ...
> 
> Some observations and remaining unresolved issues:
> 
> - VFIO patch:
>   Initially (while still running with igfx_off) I observed exactly the same behaviour as deniv@lavabit.com
>   reported a while ago: With vfio_pci debug enabled, vfio_pci ended up spinning with repeated calls to
>   vfio_ati_3c3_quirk_read and repeated logs: 
>     vfio: vfio_vga_read(0x3c3, 1) = 0x0
>   I patched up accordingly with 
> 
> 
> diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
> index da0e5f9..a361d06 100644
> --- a/hw/misc/vfio.c
> +++ b/hw/misc/vfio.c
> @@ -1291,7 +1291,7 @@ static uint64_t vfio_ati_3c3_quirk_read(void *opaque,
>      uint64_t data = vfio_vga_read(&vdev->vga.region[QEMU_PCI_VGA_IO_HI],
>                                    addr + quirk->data.base_offset, size);
>  
> -    if (data == quirk->data.address_match) {
> +    if (1 || data == quirk->data.address_match) {
>          data = vfio_pci_read_config(&vdev->pdev, quirk->data.address_val, size);
>          DPRINTF("%s(0x3c3, 1) = 0x%"PRIx64"\n", __func__, data);
>      }
> 
> 
>   This of course did not help much until I actually got the iommu 
>   enabled for the radeons (similar "repeated patters" as deniv reported)
>   but what I have observed after I got it working is that if 
>   I disable the patch above, things are not that well: the Fedora VM 
>   comes up with VGA and the Fedora boot screen, then goes blank when 
>   switching to X.

Hmm, I think we'd probably have better luck making that unconditional
until we have reason to do otherwise.

> - The fact that the iommu group now extends across all my available graphics 
>   devices now makes it difficult to  get the radeon (or catalyst) driver use to 
>   the other card since the vfio_pci driver needs to hold it.
>   Not a complete showstopper since the vesa driver comes up with 1024x768..
>   Might it be a good idea to have an override option (exception list or similar?) 
>   to allow the vfio_pci to be less restrictive about owning the whole group 
>    - allow functionality over security in such case? This of course is further complicated
>   by the need for graphics drivers to be disabled/enabled already at the kernel prompt..

We have a quirk in the kernel that enables us to witelist devices, but
yes, there is no flexibility in this w/o modifying the code and
rebuilding.  (see drivers/pci/quirks.c:pci_dev_acs_enabled and follow
the example above w/ pci_dev_dma_source - function can just return 1)

> - There seems to be a bug in the (version F8) UEFI BIOS on the motherboard, 
>   The BIOS offers (undocumented) a full range of selections of which PCIe 
>   (or PCIe 1x) graphics card to use as primary, but any other selection 
>   than the first PCIe 16x slot has no effect and the motherboard reverts 
>   to the first slot, so to be able to test both cards, I had to put the card under test
>   into the second (8x) PCIe slot. I am waiting for feedback from Gigabyte on possible 
>   fixes for this in newer BIOSes.
> 
> - The ultimate goal is to try to consolidate some older Windows desktops as "seats" 
>   on the new system, using the discrete graphics with HDMI/Displayport audio. 
>   With the HD7700 moved to the second PCIe slot I tested both Windows and 
>   Linux guests to try to get some sound through the HDMI audio device. 
>   Windows complains that no usable device is available. On Linux (Fedora 18, KDE desktop), 
>   the system settings -> multimedia dialogue never opens up which seems to indicate that 
>   PulseAudio has problems communicating with the passed through device (?), 
>   any hints/pointers here appreciated. From the vfio log it seems at least
>   config space is accessed ok.
> 
> - There also seems to be issues with radeon and intel_iommu=on - if I try 
>   to enable modesetting and normal X support for the radeon cards, X fails to start.
> 
> - It would be nice if the integrated graphics could be used as the host primary display - 
>   I would be happy if someone has any hints as to if/how the ifgx_off option 
>   could be extended/modified to only affect iommu operation on selected device(s),
>   if at all possible..

Let's see what we can discover from your DMAR.  Also send along sudo
lspci -vvv.  Thanks,

Alex
Knut Omang - May 14, 2013, 6:42 a.m.
On Mon, 2013-05-13 at 16:23 -0600, Alex Williamson wrote:
> On Mon, 2013-05-13 at 22:55 +0200, Knut Omang wrote:
> > Hi all,
> > 
> > Perfect timing from my perspective, thanks Alex!
> > 
> > I spent the better part of the weekend testing your branches on a new system 
> > I just put together for this purpose, results below..
> > 
> > On Fri, 2013-05-03 at 16:56 -0600, Alex Williamson wrote:
> > ...
> > > git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> > > git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> > 
> > System setup: 
> > 
> > - Fedora 18 on
> > - Gigabyte Z77X-UD5H motherboard
> > - Intel Core i7 3770 (Ivy bridge w/integrated graphics)
> > - 2 discrete graphics cards:
> > 
> > lspci | egrep 'VGA|Audio'
> > 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
> > 00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
> > 01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Caicos [Radeon HD 6450]
> > 01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Caicos HDMI Audio [Radeon HD 6400 Series]
> > 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Cape Verde PRO [Radeon HD 7700 Series]
> > 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> > 
> > Short summary:
> > 
> > - Once I got past a few time consuming obstacles explained below
> >    - the graphics part of the graphics/hdmi audio passthrough seems to work perfect
> >      on both discrete graphics cards 
> >      (though so far only one at at time and with some minor issues, see below)
> >    - no success with the hdmi audio yet (ideas for further investigation appreciated!)
> 
> I've had hdmi audio working with an HD7850, but only in Windows (7) and
> it was using legacy interrupts for some reason instead of MSI.  I wonder
> if Liux guests might work with snd_hda_intel.enable_msi=0.  I'm not sure
> what's wrong with MSI, but it seems to be new with the PCI bus reset
> support.

I tried 

modprobe -r snd_hda_intel
modprobe snd_hda_intel enable_msi=0

- did not seem to have any effect on Linux.
Here is the guest's lspci -vvv entry for the audio after the above:

01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
        Subsystem: PC Partner Limited Device aab0
        Physical Slot: 0
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0, Cache Line Size: 64 bytes
        Interrupt: pin B routed to IRQ 17
        Region 0: Memory at fea60000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [48] Vendor Specific Information: Len=08 <?>
        Capabilities: [50] Power Management version 3
                Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [58] Express (v2) Legacy Endpoint, MSI 00
                DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <4us, L1 unlimited
                        ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
                DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
                        RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+
                        MaxPayload 128 bytes, MaxReadReq 512 bytes
                DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend-
                LnkCap: Port #1, Speed 8GT/s, Width x16, ASPM L0s L1, Latency L0 <64ns, L1 <1us
                        ClockPM- Surprise- LLActRep- BwNot-
                LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
                        ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
                LnkSta: Speed 8GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
                DevCap2: Completion Timeout: Not Supported, TimeoutDis-, LTR-, OBFF Not Supported
                DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
                LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-, EqualizationPhase1-
                         EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
        Capabilities: [a0] MSI: Enable- Count=1/1 Maskable- 64bit+
                Address: 00000000fee00000  Data: 4072
        Capabilities: [100 v1] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
        Capabilities: [150 v2] Advanced Error Reporting
                UESta:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UEMsk:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
                CESta:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
                CEMsk:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
                AERCap: First Error Pointer: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
        Kernel driver in use: snd_hda_intel

> > - Contrary to deniv@lavabit.com I had no success with using pci-assign for VGA
> >   with a standard fedora 18 kernel and fairly recent qemu, nor with your branches, 
> > 
> > Details:
> > 
> > - I started off with the required kernel parameter 'intel_iommu=on' + necessary parameters for disabling radeon
> >    (radeon.modeset=0 rd.driver.blacklist=radeon) using the integrated graphics as primary display
> >    - this caused the system to freeze (with color artifacts on the console)
> > 
> > - In my naivity and because of the "i" in ifgx I tried both with 
> >   'intel_iommu=ifgx_off' and then 'intel_iommu=on,igfx_off' 
> >   and a full set of combinations of vfio, cards, kernels and pci-assign before I suspected 
> >   that iommu support was turned off for **all** graphics cards with igfx_off
> 
> I'm not sure why this is, looks like the code only tries to turn it off
> when only graphics is under the remapping device.  We'd probably need to
> see the DMAR to know more (/sys/firmware/acpi/tables/DMAR).

Attaching both a decoded one and the raw dump.

> > - The solution was to have integrated graphics turned off in the BIOS, and 'intel_iommu=on':
> > 
> > - iommu groups:
> > 
> > ls -l /sys/bus/pci/devices/0000:01:00.0/iommu_group/devices
> > total 0
> > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.0 -> ../../../../devices/pci0000:00/0000:00:01.0
> > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.1 -> ../../../../devices/pci0000:00/0000:00:01.1
> > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.0 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.0
> > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.1 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.1
> > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.0 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.0
> > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.1 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.1
> > 
> > - eg. both the VGA/HDMI Audio pairs + the two root ports they are plugged into are in the same group:
> 
> Ick.  Intel has been pretty good about advertising ACS support on their
> root ports.  I wonder if this is an oversight or if they are actually
> not isolated from each other.

Sad state I'm afraid - one of the reasons I went for Intel this time - I
have usually chosen AMD in the past but had a bad experience with an FM1
board with no IOMMU support.. 

No ACS on any of the root ports (or anything else..) - see attachment.. 

I wish there were lspci -vvv's out there for all hardware - quite a
gamble to buy motherboards if one wish to utilize it for something more
than a plain Windows install..

> > # lspci -n
> > ...
> > 01:00.0 0300: 1002:683f
> > 01:00.1 0403: 1002:aab0
> > 02:00.0 0300: 1002:6779
> > 02:00.1 0403: 1002:aa98
> > ...
> > 
> > modprobe vfio_pci
> > echo 0000:01:00.1 > /sys/bus/pci/devices/0000\:01\:00.1/driver/unbind
> > echo 0000:02:00.1 > /sys/bus/pci/devices/0000\:02\:00.1/driver/unbind
> > echo 1002 683f > /sys/bus/pci/drivers/vfio-pci/new_id
> > echo 1002 aab0 > /sys/bus/pci/drivers/vfio-pci/new_id
> > echo 1002 6779 > /sys/bus/pci/drivers/vfio-pci/new_id
> > echo 1002 aa98 > /sys/bus/pci/drivers/vfio-pci/new_id
> > 
> > # lsusb 
> > ...
> > Bus 001 Device 008: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
> > Bus 001 Device 004: ID 046d:c05b Logitech, Inc. M-U0004 810-001317 [B110 Optical USB Mouse]
> > ...
> > 
> > - I also applied your suggested patch to the quirk function in VFIO (see below)
> > 
> > - Here is a (trimmed for readability) command line I successfully used to boot from the Windows 7 install DVD, 
> >   notice the cd and disk device descriptions and the bus parameter - I struggled a while with that 
> >   until I came across a comment by Gerd Hoffmann here: https://bugzilla.redhat.com/show_bug.cgi?id=922670 (Thanks, Gerd!)
> > 
> > 
> > qemu-kvm -M q35 \
> >   -nodefconfig -readconfig $SRC/qemu/docs/q35-chipset.cfg \
> >   -device vfio-pci,host=2:00.0,x-vga=on,multifunction=on,bus=ich9-pcie-port-1,addr=0.0 \
> >   -device vfio-pci,host=2:00.1,bus=ich9-pcie-port-1,addr=0.1 \
> >   -L $SRC/seabios/out/ -L $SRC/qemu/pc-bios \
> >   -vga none -nographic -cpu host -rtc base=localtime -k no -m 8192 -smp 2 \
> >   -drive file=/dev/sr0,index=2,media=cdrom,id=cd \
> >   -drive file=ivm03.img,index=0,media=disk,id=ivm03 \
> >   -device ide-drive,drive=ivm03,bus=ide.0 \
> >   -device ide-cd,drive=cd,bus=ide.1 \
> >   -net nic,vlan=0,model=virtio -net tap,vlan=0 \
> >   -enable-kvm \
> >   -device usb-host,hostbus=1,hostaddr=8 \
> >   -device usb-host,hostbus=1,hostaddr=4
> > 
> > - Both the graphics card seemshould really support ACS on s to have a rom but only the HD6450 let itself to "scraping". 
> 
> Did you try scraping the HD6450 while the HD7700 was the boot VGA and
> vica versa?  The boot VGA ROM is handled in a special way and what you
> really get is the shadow copy, which isn't what we want.

I did all the scraping work with the Radeons with my initial setup while
the integrated graphics was the primary display. I tried once more now
to scrape the HD7700 while the HD6450 is the primary VGA and still get
the same result:

# echo 1 > /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/rom
# cat /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/rom > HD7700.rom 
cat: /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/rom: Input/output error

system log reports:
May 14 07:15:54 asu kernel: [   82.344189] pci 0000:02:00.0: Invalid ROM contents

> 
> > Anyway, supplying it to vfio did not seem to make any difference.
> > 
> > find /sys -name rom
> > /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/rom
> > /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/rom
> > ...
> > 
> > Some observations and remaining unresolved issues:
> > 
> > - VFIO patch:
> >   Initially (while still running with igfx_off) I observed exactly the same behaviour as deniv@lavabit.com
> >   reported a while ago: With vfio_pci debug enabled, vfio_pci ended up spinning with repeated calls to
> >   vfio_ati_3c3_quirk_read and repeated logs: 
> >     vfio: vfio_vga_read(0x3c3, 1) = 0x0
> >   I patched up accordingly with 
> > 
> > 
> > diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
> > index da0e5f9..a361d06 100644
> > --- a/hw/misc/vfio.c
> > +++ b/hw/misc/vfio.c
> > @@ -1291,7 +1291,7 @@ static uint64_t vfio_ati_3c3_quirk_read(void *opaque,
> >      uint64_t data = vfio_vga_read(&vdev->vga.region[QEMU_PCI_VGA_IO_HI],
> >                                    addr + quirk->data.base_offset, size);
> >  
> > -    if (data == quirk->data.address_match) {
> > +    if (1 || data == quirk->data.address_match) {
> >          data = vfio_pci_read_config(&vdev->pdev, quirk->data.address_val, size);
> >          DPRINTF("%s(0x3c3, 1) = 0x%"PRIx64"\n", __func__, data);
> >      }
> > 
> > 
> >   This of course did not help much until I actually got the iommu 
> >   enabled for the radeons (similar "repeated patters" as deniv reported)
> >   but what I have observed after I got it working is that if 
> >   I disable the patch above, things are not that well: the Fedora VM 
> >   comes up with VGA and the Fedora boot screen, then goes blank when 
> >   switching to X.
> 
> Hmm, I think we'd probably have better luck making that unconditional
> until we have reason to do otherwise.

I'm starting to wonder whether there's some timing issue or maybe
something with the initial state of the hardware affecting this.
It might be that the blank screen situation is more likely to occur if
debug is enabled - this morning I saw the same behavior even with the
patch enabled - then tried once more and got success. This was right
after a reboot so I tried a "warm" reboot and the same happened again:
First attempt got through the initial VGA phase then blanked, I ^C'ed
the VM then restarted and got all the way to the GUI again..

> > - The fact that the iommu group now extends across all my available graphics 
> >   devices now makes it difficult to  get the radeon (or catalyst) driver use to 
> >   the other card since the vfio_pci driver needs to hold it.
> >   Not a complete showstopper since the vesa driver comes up with 1024x768..
> >   Might it be a good idea to have an override option (exception list or similar?) 
> >   to allow the vfio_pci to be less restrictive about owning the whole group 
> >    - allow functionality over security in such case? This of course is further complicated
> >   by the need for graphics drivers to be disabled/enabled already at the kernel prompt..
> 
> We have a quirk in the kernel that enables us to witelist devices, but
> yes, there is no flexibility in this w/o modifying the code and
> rebuilding.  (see drivers/pci/quirks.c:pci_dev_acs_enabled and follow
> the example above w/ pci_dev_dma_source - function can just return 1)

Thanks, I'll have a look at that,

> > - There seems to be a bug in the (version F8) UEFI BIOS on the motherboard, 
> >   The BIOS offers (undocumented) a full range of selections of which PCIe 
> >   (or PCIe 1x) graphics card to use as primary, but any other selection 
> >   than the first PCIe 16x slot has no effect and the motherboard reverts 
> >   to the first slot, so to be able to test both cards, I had to put the card under test
> >   into the second (8x) PCIe slot. I am waiting for feedback from Gigabyte on possible 
> >   fixes for this in newer BIOSes.
> > 
> > - The ultimate goal is to try to consolidate some older Windows desktops as "seats" 
> >   on the new system, using the discrete graphics with HDMI/Displayport audio. 
> >   With the HD7700 moved to the second PCIe slot I tested both Windows and 
> >   Linux guests to try to get some sound through the HDMI audio device. 
> >   Windows complains that no usable device is available. On Linux (Fedora 18, KDE desktop), 
> >   the system settings -> multimedia dialogue never opens up which seems to indicate that 
> >   PulseAudio has problems communicating with the passed through device (?), 
> >   any hints/pointers here appreciated. From the vfio log it seems at least
> >   config space is accessed ok.
> > 
> > - There also seems to be issues with radeon and intel_iommu=on - if I try 
> >   to enable modesetting and normal X support for the radeon cards, X fails to start.
> > 
> > - It would be nice if the integrated graphics could be used as the host primary display - 
> >   I would be happy if someone has any hints as to if/how the ifgx_off option 
> >   could be extended/modified to only affect iommu operation on selected device(s),
> >   if at all possible..
> 
> Let's see what we can discover from your DMAR.  Also send along sudo
> lspci -vvv.  Thanks,

Attached.

One "interesting feature" I have never seen before on a motherboard is 
that I get "pcilib: sysfs_read_vpd: read failed: Connection timed out"
while doing the lspci -vvv but this appears to come from trying to read
the Vital Product Data capability of the secondary onboard ethernet
[07:00.0 Ethernet controller: Atheros Communications Inc. AR8151 v2.0
Gigabit Ethernet (rev c0)] which should not have any significance here..

Thanks,

Knut
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor DRAM Controller (rev 09)
	Subsystem: Giga-byte Technology Device 5000
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ >SERR- <PERR- INTx-
	Latency: 0
	Capabilities: [e0] Vendor Specific Information: Len=0c <?>

00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port (rev 09) (prog-if 00 [Normal decode])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
	I/O behind bridge: 0000e000-0000efff
	Memory behind bridge: f7e00000-f7efffff
	Prefetchable memory behind bridge: 00000000e0000000-00000000efffffff
	Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
	BridgeCtl: Parity- SERR- NoISA- VGA+ MAbort- >Reset- FastB2B-
		PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
	Capabilities: [88] Subsystem: Giga-byte Technology Device 5000
	Capabilities: [80] Power Management version 3
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
		Address: fee002d8  Data: 0000
	Capabilities: [a0] Express (v2) Root Port (Slot+), MSI 00
		DevCap:	MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
			ExtTag- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
			MaxPayload 256 bytes, MaxReadReq 128 bytes
		DevSta:	CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
		LnkCap:	Port #2, Speed 8GT/s, Width x8, ASPM unknown, Latency L0 <256ns, L1 <8us
			ClockPM- Surprise- LLActRep- BwNot+
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 2.5GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt+ ABWMgmt-
		SltCap:	AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug- Surprise-
			Slot #1, PowerLimit 75.000W; Interlock- NoCompl+
		SltCtl:	Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
			Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
		SltSta:	Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet+ Interlock-
			Changed: MRL- PresDet- LinkState-
		RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna- CRSVisible-
		RootCap: CRSVisible-
		RootSta: PME ReqID 0000, PMEStatus- PMEPending-
		DevCap2: Completion Timeout: Not Supported, TimeoutDis-, LTR-, OBFF Not Supported ARIFwd-
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled ARIFwd-
		LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance De-emphasis: -6dB
		LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
			 EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
	Capabilities: [100 v1] Virtual Channel
		Caps:	LPEVC=0 RefClk=100ns PATEntryBits=1
		Arb:	Fixed- WRR32- WRR64- WRR128-
		Ctrl:	ArbSelect=Fixed
		Status:	InProgress-
		VC0:	Caps:	PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
			Arb:	Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
			Ctrl:	Enable+ ID=0 ArbSelect=Fixed TC/VC=01
			Status:	NegoPending- InProgress-
	Capabilities: [140 v1] Root Complex Link
		Desc:	PortNumber=02 ComponentID=01 EltType=Config
		Link0:	Desc:	TargetPort=00 TargetComponent=01 AssocRCRB- LinkType=MemMapped LinkValid+
			Addr:	00000000fed19000
	Capabilities: [d94 v1] #19
	Kernel driver in use: pcieport

00:01.1 PCI bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port (rev 09) (prog-if 00 [Normal decode])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Bus: primary=00, secondary=02, subordinate=02, sec-latency=0
	I/O behind bridge: 0000d000-0000dfff
	Memory behind bridge: f7d00000-f7dfffff
	Prefetchable memory behind bridge: 00000000d0000000-00000000dfffffff
	Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ <SERR- <PERR-
	BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
		PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
	Capabilities: [88] Subsystem: Giga-byte Technology Device 5000
	Capabilities: [80] Power Management version 3
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
		Address: fee002f8  Data: 0000
	Capabilities: [a0] Express (v2) Root Port (Slot+), MSI 00
		DevCap:	MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
			ExtTag- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
			MaxPayload 128 bytes, MaxReadReq 128 bytes
		DevSta:	CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
		LnkCap:	Port #3, Speed 8GT/s, Width x8, ASPM unknown, Latency L0 <256ns, L1 <8us
			ClockPM- Surprise- LLActRep- BwNot+
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 8GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt+ ABWMgmt+
		SltCap:	AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug- Surprise-
			Slot #2, PowerLimit 75.000W; Interlock- NoCompl+
		SltCtl:	Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
			Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
		SltSta:	Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet+ Interlock-
			Changed: MRL- PresDet- LinkState-
		RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna- CRSVisible-
		RootCap: CRSVisible-
		RootSta: PME ReqID 0000, PMEStatus- PMEPending-
		DevCap2: Completion Timeout: Not Supported, TimeoutDis-, LTR-, OBFF Not Supported ARIFwd-
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled ARIFwd-
		LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance De-emphasis: -6dB
		LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete+, EqualizationPhase1+
			 EqualizationPhase2+, EqualizationPhase3+, LinkEqualizationRequest-
	Capabilities: [100 v1] Virtual Channel
		Caps:	LPEVC=0 RefClk=100ns PATEntryBits=1
		Arb:	Fixed- WRR32- WRR64- WRR128-
		Ctrl:	ArbSelect=Fixed
		Status:	InProgress-
		VC0:	Caps:	PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
			Arb:	Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
			Ctrl:	Enable+ ID=0 ArbSelect=Fixed TC/VC=01
			Status:	NegoPending- InProgress-
	Capabilities: [140 v1] Root Complex Link
		Desc:	PortNumber=03 ComponentID=01 EltType=Config
		Link0:	Desc:	TargetPort=00 TargetComponent=01 AssocRCRB- LinkType=MemMapped LinkValid+
			Addr:	00000000fed19000
	Capabilities: [d94 v1] #19
	Kernel driver in use: pcieport

00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04) (prog-if 30 [XHCI])
	Subsystem: Giga-byte Technology Device 5007
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin A routed to IRQ 46
	Region 0: Memory at f7f20000 (64-bit, non-prefetchable) [size=64K]
	Capabilities: [70] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=375mA PME(D0-,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [80] MSI: Enable+ Count=1/8 Maskable- 64bit+
		Address: 00000000fee00378  Data: 0000
	Kernel driver in use: xhci_hcd

00:16.0 Communication controller: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 (rev 04)
	Subsystem: Giga-byte Technology Device 1c3a
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin A routed to IRQ 47
	Region 0: Memory at f7f3b000 (64-bit, non-prefetchable) [size=16]
	Capabilities: [50] Power Management version 3
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [8c] MSI: Enable+ Count=1/1 Maskable- 64bit+
		Address: 00000000fee00398  Data: 0000
	Kernel driver in use: mei

00:19.0 Ethernet controller: Intel Corporation 82579V Gigabit Network Connection (rev 04)
	Subsystem: Giga-byte Technology Device e000
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin A routed to IRQ 51
	Region 0: Memory at f7f00000 (32-bit, non-prefetchable) [size=128K]
	Region 1: Memory at f7f39000 (32-bit, non-prefetchable) [size=4K]
	Region 2: I/O ports at f040 [size=32]
	Capabilities: [c8] Power Management version 2
		Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=1 PME-
	Capabilities: [d0] MSI: Enable+ Count=1/1 Maskable- 64bit+
		Address: 00000000fee00458  Data: 0000
	Capabilities: [e0] PCI Advanced Features
		AFCap: TP+ FLR+
		AFCtrl: FLR-
		AFStatus: TP-
	Kernel driver in use: e1000e

00:1a.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 (rev 04) (prog-if 20 [EHCI])
	Subsystem: Giga-byte Technology Device 5006
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin A routed to IRQ 16
	Region 0: Memory at f7f38000 (32-bit, non-prefetchable) [size=1K]
	Capabilities: [50] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=375mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [58] Debug port: BAR=1 offset=00a0
	Capabilities: [98] PCI Advanced Features
		AFCap: TP+ FLR+
		AFCtrl: FLR-
		AFStatus: TP-
	Kernel driver in use: ehci-pci

00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
	Subsystem: Giga-byte Technology Device a072
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Interrupt: pin A routed to IRQ 48
	Region 0: Memory at f7f30000 (64-bit, non-prefetchable) [size=16K]
	Capabilities: [50] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
		Address: 00000000fee003d8  Data: 0000
	Capabilities: [70] Express (v1) Root Complex Integrated Endpoint, MSI 00
		DevCap:	MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
			ExtTag- RBE- FLReset+
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
			MaxPayload 128 bytes, MaxReadReq 128 bytes
		DevSta:	CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
		LnkCap:	Port #0, Speed unknown, Width x0, ASPM unknown, Latency L0 <64ns, L1 <1us
			ClockPM- Surprise- LLActRep- BwNot-
		LnkCtl:	ASPM Disabled; Disabled- Retrain- CommClk-
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed unknown, Width x0, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
	Capabilities: [100 v1] Virtual Channel
		Caps:	LPEVC=0 RefClk=100ns PATEntryBits=1
		Arb:	Fixed- WRR32- WRR64- WRR128-
		Ctrl:	ArbSelect=Fixed
		Status:	InProgress-
		VC0:	Caps:	PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
			Arb:	Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
			Ctrl:	Enable+ ID=0 ArbSelect=Fixed TC/VC=01
			Status:	NegoPending- InProgress-
		VC1:	Caps:	PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
			Arb:	Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
			Ctrl:	Enable+ ID=1 ArbSelect=Fixed TC/VC=22
			Status:	NegoPending- InProgress-
	Capabilities: [130 v1] Root Complex Link
		Desc:	PortNumber=0f ComponentID=00 EltType=Config
		Link0:	Desc:	TargetPort=00 TargetComponent=00 AssocRCRB- LinkType=MemMapped LinkValid+
			Addr:	00000000fed1c000
	Kernel driver in use: snd_hda_intel

00:1c.0 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 1 (rev c4) (prog-if 00 [Normal decode])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Bus: primary=00, secondary=03, subordinate=03, sec-latency=0
	I/O behind bridge: 0000f000-00000fff
	Memory behind bridge: fff00000-000fffff
	Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff
	Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ <SERR- <PERR-
	BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
		PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
	Capabilities: [40] Express (v2) Root Port (Slot+), MSI 00
		DevCap:	MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
			ExtTag- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
			MaxPayload 128 bytes, MaxReadReq 128 bytes
		DevSta:	CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
		LnkCap:	Port #1, Speed 5GT/s, Width x1, ASPM unknown, Latency L0 <1us, L1 <4us
			ClockPM- Surprise- LLActRep+ BwNot-
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 2.5GT/s, Width x0, TrErr- Train+ SlotClk+ DLActive- BWMgmt- ABWMgmt-
		SltCap:	AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug- Surprise-
			Slot #0, PowerLimit 10.000W; Interlock- NoCompl+
		SltCtl:	Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
			Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
		SltSta:	Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet- Interlock-
			Changed: MRL- PresDet- LinkState-
		RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna- CRSVisible-
		RootCap: CRSVisible-
		RootSta: PME ReqID 0000, PMEStatus- PMEPending-
		DevCap2: Completion Timeout: Range BC, TimeoutDis+, LTR-, OBFF Not Supported ARIFwd-
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled ARIFwd-
		LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance De-emphasis: -6dB
		LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-, EqualizationPhase1-
			 EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
	Capabilities: [80] MSI: Enable- Count=1/1 Maskable- 64bit-
		Address: 00000000  Data: 0000
	Capabilities: [90] Subsystem: Giga-byte Technology Device 5001
	Capabilities: [a0] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Kernel driver in use: pcieport

00:1c.1 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 (rev c4) (prog-if 00 [Normal decode])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Bus: primary=00, secondary=04, subordinate=04, sec-latency=0
	I/O behind bridge: 0000c000-0000cfff
	Memory behind bridge: f7c00000-f7cfffff
	Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff
	Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
	BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
		PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
	Capabilities: [40] Express (v2) Root Port (Slot+), MSI 00
		DevCap:	MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
			ExtTag- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
			MaxPayload 128 bytes, MaxReadReq 128 bytes
		DevSta:	CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
		LnkCap:	Port #2, Speed 5GT/s, Width x1, ASPM unknown, Latency L0 <512ns, L1 <4us
			ClockPM- Surprise- LLActRep+ BwNot-
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive+ BWMgmt+ ABWMgmt-
		SltCap:	AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug- Surprise-
			Slot #1, PowerLimit 10.000W; Interlock- NoCompl+
		SltCtl:	Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
			Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
		SltSta:	Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet+ Interlock-
			Changed: MRL- PresDet- LinkState-
		RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna- CRSVisible-
		RootCap: CRSVisible-
		RootSta: PME ReqID 0000, PMEStatus- PMEPending-
		DevCap2: Completion Timeout: Range BC, TimeoutDis+, LTR-, OBFF Not Supported ARIFwd-
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled ARIFwd-
		LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance De-emphasis: -6dB
		LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
			 EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
	Capabilities: [80] MSI: Enable- Count=1/1 Maskable- 64bit-
		Address: 00000000  Data: 0000
	Capabilities: [90] Subsystem: Giga-byte Technology Device 5001
	Capabilities: [a0] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Kernel driver in use: pcieport

00:1c.5 PCI bridge: Intel Corporation 82801 PCI Bridge (rev c4) (prog-if 01 [Subtractive decode])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Bus: primary=00, secondary=05, subordinate=06, sec-latency=0
	I/O behind bridge: 0000b000-0000bfff
	Memory behind bridge: f7b00000-f7bfffff
	Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff
	Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ <SERR- <PERR-
	BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
		PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
	Capabilities: [40] Express (v2) Root Port (Slot+), MSI 00
		DevCap:	MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
			ExtTag- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
			MaxPayload 128 bytes, MaxReadReq 128 bytes
		DevSta:	CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
		LnkCap:	Port #6, Speed 5GT/s, Width x1, ASPM unknown, Latency L0 <1us, L1 <4us
			ClockPM- Surprise- LLActRep+ BwNot-
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive+ BWMgmt+ ABWMgmt-
		SltCap:	AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug- Surprise-
			Slot #5, PowerLimit 10.000W; Interlock- NoCompl+
		SltCtl:	Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
			Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
		SltSta:	Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet+ Interlock-
			Changed: MRL- PresDet- LinkState-
		RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna- CRSVisible-
		RootCap: CRSVisible-
		RootSta: PME ReqID 0000, PMEStatus- PMEPending-
		DevCap2: Completion Timeout: Range BC, TimeoutDis+, LTR-, OBFF Not Supported ARIFwd-
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled ARIFwd-
		LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance De-emphasis: -6dB
		LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-, EqualizationPhase1-
			 EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
	Capabilities: [80] MSI: Enable- Count=1/1 Maskable- 64bit-
		Address: 00000000  Data: 0000
	Capabilities: [90] Subsystem: Giga-byte Technology Device 5001
	Capabilities: [a0] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-

00:1c.6 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 7 (rev c4) (prog-if 00 [Normal decode])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Bus: primary=00, secondary=07, subordinate=07, sec-latency=0
	I/O behind bridge: 0000a000-0000afff
	Memory behind bridge: f7a00000-f7afffff
	Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff
	Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
	BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
		PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
	Capabilities: [40] Express (v2) Root Port (Slot+), MSI 00
		DevCap:	MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
			ExtTag- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
			MaxPayload 128 bytes, MaxReadReq 128 bytes
		DevSta:	CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
		LnkCap:	Port #7, Speed 5GT/s, Width x1, ASPM unknown, Latency L0 <512ns, L1 <4us
			ClockPM- Surprise- LLActRep+ BwNot-
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive+ BWMgmt+ ABWMgmt-
		SltCap:	AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug- Surprise-
			Slot #6, PowerLimit 10.000W; Interlock- NoCompl+
		SltCtl:	Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
			Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
		SltSta:	Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet+ Interlock-
			Changed: MRL- PresDet- LinkState-
		RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna- CRSVisible-
		RootCap: CRSVisible-
		RootSta: PME ReqID 0000, PMEStatus- PMEPending-
		DevCap2: Completion Timeout: Range BC, TimeoutDis+, LTR-, OBFF Not Supported ARIFwd-
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled ARIFwd-
		LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance De-emphasis: -6dB
		LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-, EqualizationPhase1-
			 EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
	Capabilities: [80] MSI: Enable- Count=1/1 Maskable- 64bit-
		Address: 00000000  Data: 0000
	Capabilities: [90] Subsystem: Giga-byte Technology Device 5001
	Capabilities: [a0] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Kernel driver in use: pcieport

00:1c.7 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 8 (rev c4) (prog-if 00 [Normal decode])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Bus: primary=00, secondary=08, subordinate=08, sec-latency=0
	I/O behind bridge: 00009000-00009fff
	Memory behind bridge: f7900000-f79fffff
	Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff
	Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
	BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
		PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
	Capabilities: [40] Express (v2) Root Port (Slot+), MSI 00
		DevCap:	MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
			ExtTag- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
			MaxPayload 128 bytes, MaxReadReq 128 bytes
		DevSta:	CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
		LnkCap:	Port #8, Speed 5GT/s, Width x1, ASPM unknown, Latency L0 <512ns, L1 <4us
			ClockPM- Surprise- LLActRep+ BwNot-
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive+ BWMgmt+ ABWMgmt-
		SltCap:	AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug- Surprise-
			Slot #7, PowerLimit 10.000W; Interlock- NoCompl+
		SltCtl:	Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
			Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
		SltSta:	Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet+ Interlock-
			Changed: MRL- PresDet- LinkState-
		RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna- CRSVisible-
		RootCap: CRSVisible-
		RootSta: PME ReqID 0000, PMEStatus- PMEPending-
		DevCap2: Completion Timeout: Range BC, TimeoutDis+, LTR-, OBFF Not Supported ARIFwd-
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled ARIFwd-
		LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance De-emphasis: -6dB
		LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
			 EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
	Capabilities: [80] MSI: Enable- Count=1/1 Maskable- 64bit-
		Address: 00000000  Data: 0000
	Capabilities: [90] Subsystem: Giga-byte Technology Device 5001
	Capabilities: [a0] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Kernel driver in use: pcieport

00:1d.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 (rev 04) (prog-if 20 [EHCI])
	Subsystem: Giga-byte Technology Device 5006
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin A routed to IRQ 23
	Region 0: Memory at f7f37000 (32-bit, non-prefetchable) [size=1K]
	Capabilities: [50] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=375mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [58] Debug port: BAR=1 offset=00a0
	Capabilities: [98] PCI Advanced Features
		AFCap: TP+ FLR+
		AFCtrl: FLR-
		AFStatus: TP-
	Kernel driver in use: ehci-pci

00:1f.0 ISA bridge: Intel Corporation Z77 Express Chipset LPC Controller (rev 04)
	Subsystem: Giga-byte Technology Device 5001
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Capabilities: [e0] Vendor Specific Information: Len=0c <?>
	Kernel driver in use: lpc_ich

00:1f.2 SATA controller: Intel Corporation 7 Series/C210 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04) (prog-if 01 [AHCI 1.0])
	Subsystem: Giga-byte Technology Device b005
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin B routed to IRQ 43
	Region 0: I/O ports at f090 [size=8]
	Region 1: I/O ports at f080 [size=4]
	Region 2: I/O ports at f070 [size=8]
	Region 3: I/O ports at f060 [size=4]
	Region 4: I/O ports at f020 [size=32]
	Region 5: Memory at f7f36000 (32-bit, non-prefetchable) [size=2K]
	Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
		Address: fee00318  Data: 0000
	Capabilities: [70] Power Management version 3
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot+,D3cold-)
		Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [a8] SATA HBA v1.0 BAR4 Offset=00000004
	Capabilities: [b0] PCI Advanced Features
		AFCap: TP+ FLR+
		AFCtrl: FLR-
		AFStatus: TP-
	Kernel driver in use: ahci

00:1f.3 SMBus: Intel Corporation 7 Series/C210 Series Chipset Family SMBus Controller (rev 04)
	Subsystem: Giga-byte Technology Device 5001
	Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Interrupt: pin C routed to IRQ 18
	Region 0: Memory at f7f35000 (64-bit, non-prefetchable) [size=256]
	Region 4: I/O ports at f000 [size=32]

01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Caicos [Radeon HD 6450] (prog-if 00 [VGA controller])
	Subsystem: ASUSTeK Computer Inc. Device 0461
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Interrupt: pin A routed to IRQ 11
	Region 0: Memory at e0000000 (64-bit, prefetchable) [size=256M]
	Region 2: Memory at f7e20000 (64-bit, non-prefetchable) [size=128K]
	Region 4: I/O ports at e000 [size=256]
	Expansion ROM at f7e00000 [disabled] [size=128K]
	Capabilities: [50] Power Management version 3
		Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [58] Express (v2) Legacy Endpoint, MSI 00
		DevCap:	MaxPayload 256 bytes, PhantFunc 0, Latency L0s <4us, L1 unlimited
			ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+
			MaxPayload 256 bytes, MaxReadReq 512 bytes
		DevSta:	CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend-
		LnkCap:	Port #0, Speed 2.5GT/s, Width x16, ASPM L0s L1, Latency L0 <64ns, L1 <1us
			ClockPM- Surprise- LLActRep- BwNot-
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 2.5GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
		DevCap2: Completion Timeout: Not Supported, TimeoutDis-, LTR-, OBFF Not Supported
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
		LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance De-emphasis: -6dB
		LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
			 EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
	Capabilities: [a0] MSI: Enable- Count=1/1 Maskable- 64bit+
		Address: 0000000000000000  Data: 0000
	Capabilities: [100 v1] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
	Capabilities: [150 v1] Advanced Error Reporting
		UESta:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UEMsk:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UESvrt:	DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
		CESta:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
		CEMsk:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
		AERCap:	First Error Pointer: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
	Kernel driver in use: vfio-pci

01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Caicos HDMI Audio [Radeon HD 6400 Series]
	Subsystem: ASUSTeK Computer Inc. Device aa98
	Control: I/O- Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Interrupt: pin B routed to IRQ 17
	Region 0: Memory at f7e40000 (64-bit, non-prefetchable) [size=16K]
	Capabilities: [50] Power Management version 3
		Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [58] Express (v2) Legacy Endpoint, MSI 00
		DevCap:	MaxPayload 256 bytes, PhantFunc 0, Latency L0s <4us, L1 unlimited
			ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+
			MaxPayload 256 bytes, MaxReadReq 512 bytes
		DevSta:	CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend-
		LnkCap:	Port #0, Speed 2.5GT/s, Width x16, ASPM L0s L1, Latency L0 <64ns, L1 <1us
			ClockPM- Surprise- LLActRep- BwNot-
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 2.5GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
		DevCap2: Completion Timeout: Not Supported, TimeoutDis-, LTR-, OBFF Not Supported
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
		LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
			 EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
	Capabilities: [a0] MSI: Enable- Count=1/1 Maskable- 64bit+
		Address: 00000000fee003f8  Data: 0000
	Capabilities: [100 v1] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
	Capabilities: [150 v1] Advanced Error Reporting
		UESta:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UEMsk:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UESvrt:	DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
		CESta:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
		CEMsk:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
		AERCap:	First Error Pointer: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
	Kernel driver in use: vfio-pci

02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Cape Verde PRO [Radeon HD 7700 Series] (prog-if 00 [VGA controller])
	Subsystem: PC Partner Limited Device e213
	Control: I/O- Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Interrupt: pin A routed to IRQ 10
	Region 0: Memory at d0000000 (64-bit, prefetchable) [disabled] [size=256M]
	Region 2: Memory at f7d00000 (64-bit, non-prefetchable) [disabled] [size=256K]
	Region 4: I/O ports at d000 [disabled] [size=256]
	Expansion ROM at f7d40000 [disabled by cmd] [size=128K]
	Capabilities: [48] Vendor Specific Information: Len=08 <?>
	Capabilities: [50] Power Management version 3
		Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA PME(D0-,D1+,D2+,D3hot+,D3cold-)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [58] Express (v2) Legacy Endpoint, MSI 00
		DevCap:	MaxPayload 256 bytes, PhantFunc 0, Latency L0s <4us, L1 unlimited
			ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+
			MaxPayload 128 bytes, MaxReadReq 512 bytes
		DevSta:	CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend-
		LnkCap:	Port #1, Speed 8GT/s, Width x16, ASPM L0s L1, Latency L0 <64ns, L1 <1us
			ClockPM- Surprise- LLActRep- BwNot-
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 8GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
		DevCap2: Completion Timeout: Not Supported, TimeoutDis-, LTR-, OBFF Not Supported
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
		LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance De-emphasis: -6dB
		LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete+, EqualizationPhase1+
			 EqualizationPhase2+, EqualizationPhase3+, LinkEqualizationRequest-
	Capabilities: [a0] MSI: Enable- Count=1/1 Maskable- 64bit+
		Address: 0000000000000000  Data: 0000
	Capabilities: [100 v1] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
	Capabilities: [150 v2] Advanced Error Reporting
		UESta:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UEMsk:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UESvrt:	DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
		CESta:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
		CEMsk:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
		AERCap:	First Error Pointer: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
	Capabilities: [270 v1] #19
	Kernel driver in use: vfio-pci

02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
	Subsystem: PC Partner Limited Device aab0
	Control: I/O- Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Interrupt: pin B routed to IRQ 18
	Region 0: Memory at f7d60000 (64-bit, non-prefetchable) [size=16K]
	Capabilities: [48] Vendor Specific Information: Len=08 <?>
	Capabilities: [50] Power Management version 3
		Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [58] Express (v2) Legacy Endpoint, MSI 00
		DevCap:	MaxPayload 256 bytes, PhantFunc 0, Latency L0s <4us, L1 unlimited
			ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+
			MaxPayload 128 bytes, MaxReadReq 512 bytes
		DevSta:	CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend-
		LnkCap:	Port #1, Speed 8GT/s, Width x16, ASPM L0s L1, Latency L0 <64ns, L1 <1us
			ClockPM- Surprise- LLActRep- BwNot-
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 8GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
		DevCap2: Completion Timeout: Not Supported, TimeoutDis-, LTR-, OBFF Not Supported
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
		LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-, EqualizationPhase1-
			 EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
	Capabilities: [a0] MSI: Enable- Count=1/1 Maskable- 64bit+
		Address: 00000000fee00418  Data: 0000
	Capabilities: [100 v1] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
	Capabilities: [150 v2] Advanced Error Reporting
		UESta:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UEMsk:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UESvrt:	DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
		CESta:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
		CEMsk:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
		AERCap:	First Error Pointer: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
	Kernel driver in use: vfio-pci

04:00.0 SATA controller: Marvell Technology Group Ltd. 88SE9172 SATA 6Gb/s Controller (rev 11) (prog-if 01 [AHCI 1.0])
	Subsystem: Giga-byte Technology Device b000
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Interrupt: pin A routed to IRQ 44
	Region 0: I/O ports at c040 [size=8]
	Region 1: I/O ports at c030 [size=4]
	Region 2: I/O ports at c020 [size=8]
	Region 3: I/O ports at c010 [size=4]
	Region 4: I/O ports at c000 [size=16]
	Region 5: Memory at f7c10000 (32-bit, non-prefetchable) [size=512]
	Expansion ROM at f7c00000 [disabled] [size=64K]
	Capabilities: [40] Power Management version 3
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot+,D3cold-)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit-
		Address: fee00338  Data: 0000
	Capabilities: [70] Express (v2) Legacy Endpoint, MSI 00
		DevCap:	MaxPayload 512 bytes, PhantFunc 0, Latency L0s <1us, L1 <8us
			ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
			MaxPayload 128 bytes, MaxReadReq 512 bytes
		DevSta:	CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
		LnkCap:	Port #0, Speed 5GT/s, Width x1, ASPM L0s L1, Latency L0 <512ns, L1 <64us
			ClockPM- Surprise- LLActRep- BwNot-
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
		DevCap2: Completion Timeout: Not Supported, TimeoutDis+, LTR-, OBFF Not Supported
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
		LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance De-emphasis: -6dB
		LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
			 EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
	Capabilities: [100 v1] Advanced Error Reporting
		UESta:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UEMsk:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UESvrt:	DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
		CESta:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
		CEMsk:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
		AERCap:	First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
	Kernel driver in use: ahci

05:00.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev 30) (prog-if 01 [Subtractive decode])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Bus: primary=05, secondary=06, subordinate=06, sec-latency=32
	I/O behind bridge: 0000b000-0000bfff
	Memory behind bridge: f7b00000-f7bfffff
	Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff
	Secondary status: 66MHz+ FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort+ <SERR- <PERR-
	BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
		PriDiscTmr- SecDiscTmr+ DiscTmrStat- DiscTmrSERREn-
	Capabilities: [90] Power Management version 2
		Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=55mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [a0] Subsystem: Giga-byte Technology Device 8892

06:01.0 FireWire (IEEE 1394): VIA Technologies, Inc. VT6306/7/8 [Fire II(M)] IEEE 1394 OHCI Controller (rev c0) (prog-if 10 [OHCI])
	Subsystem: Giga-byte Technology GA-7VT600-1394 Motherboard
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 32 (8000ns max), Cache Line Size: 64 bytes
	Interrupt: pin A routed to IRQ 18
	Region 0: Memory at f7b00000 (32-bit, non-prefetchable) [size=2K]
	Region 1: I/O ports at b000 [size=128]
	Capabilities: [50] Power Management version 2
		Flags: PMEClk- DSI- D1- D2+ AuxCurrent=0mA PME(D0-,D1-,D2+,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Kernel driver in use: firewire_ohci

07:00.0 Ethernet controller: Atheros Communications Inc. AR8151 v2.0 Gigabit Ethernet (rev c0)
	Subsystem: Giga-byte Technology Device e000
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Interrupt: pin A routed to IRQ 52
	Region 0: Memory at f7a00000 (64-bit, non-prefetchable) [size=256K]
	Region 2: I/O ports at a000 [size=128]
	Capabilities: [40] Power Management version 3
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=375mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
		Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [48] MSI: Enable+ Count=1/1 Maskable- 64bit+
		Address: 00000000fee00478  Data: 0000
	Capabilities: [58] Express (v1) Endpoint, MSI 00
		DevCap:	MaxPayload 4096 bytes, PhantFunc 0, Latency L0s unlimited, L1 unlimited
			ExtTag- AttnBtn+ AttnInd+ PwrInd+ RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
			MaxPayload 128 bytes, MaxReadReq 512 bytes
		DevSta:	CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
		LnkCap:	Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency L0 unlimited, L1 unlimited
			ClockPM+ Surprise- LLActRep- BwNot-
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
	Capabilities: [6c] Vital Product Data
		Not readable
	Capabilities: [100 v1] Advanced Error Reporting
		UESta:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UEMsk:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UESvrt:	DLP- SDES+ TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
		CESta:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
		CEMsk:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
		AERCap:	First Error Pointer: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
	Capabilities: [180 v1] Device Serial Number ff-53-8a-79-90-2b-34-ff
	Kernel driver in use: atl1c

08:00.0 SATA controller: Marvell Technology Group Ltd. 88SE9172 SATA 6Gb/s Controller (rev 11) (prog-if 01 [AHCI 1.0])
	Subsystem: Giga-byte Technology Device b000
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Interrupt: pin A routed to IRQ 45
	Region 0: I/O ports at 9040 [size=8]
	Region 1: I/O ports at 9030 [size=4]
	Region 2: I/O ports at 9020 [size=8]
	Region 3: I/O ports at 9010 [size=4]
	Region 4: I/O ports at 9000 [size=16]
	Region 5: Memory at f7910000 (32-bit, non-prefetchable) [size=512]
	Expansion ROM at f7900000 [disabled] [size=64K]
	Capabilities: [40] Power Management version 3
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot+,D3cold-)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit-
		Address: fee00358  Data: 0000
	Capabilities: [70] Express (v2) Legacy Endpoint, MSI 00
		DevCap:	MaxPayload 512 bytes, PhantFunc 0, Latency L0s <1us, L1 <8us
			ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
		DevCtl:	Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
			MaxPayload 128 bytes, MaxReadReq 512 bytes
		DevSta:	CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
		LnkCap:	Port #0, Speed 5GT/s, Width x1, ASPM L0s L1, Latency L0 <512ns, L1 <64us
			ClockPM- Surprise- LLActRep- BwNot-
		LnkCtl:	ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
		DevCap2: Completion Timeout: Not Supported, TimeoutDis+, LTR-, OBFF Not Supported
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
		LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance De-emphasis: -6dB
		LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
			 EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
	Capabilities: [100 v1] Advanced Error Reporting
		UESta:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UEMsk:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UESvrt:	DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
		CESta:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
		CEMsk:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
		AERCap:	First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
	Kernel driver in use: ahci
Knut Omang - May 19, 2013, 3:35 p.m.
On Mon, 2013-05-13 at 16:23 -0600, Alex Williamson wrote:
> On Mon, 2013-05-13 at 22:55 +0200, Knut Omang wrote:
> > Hi all,
> > 
> > Perfect timing from my perspective, thanks Alex!
> > 
> > I spent the better part of the weekend testing your branches on a new system 
> > I just put together for this purpose, results below..
> > 
> > On Fri, 2013-05-03 at 16:56 -0600, Alex Williamson wrote:
> > ...
> > > git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> > > git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> > 
> > System setup: 
> > 
> > - Fedora 18 on
> > - Gigabyte Z77X-UD5H motherboard
> > - Intel Core i7 3770 (Ivy bridge w/integrated graphics)
> > - 2 discrete graphics cards:
> > 
> > lspci | egrep 'VGA|Audio'
> > 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
> > 00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
> > 01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Caicos [Radeon HD 6450]
> > 01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Caicos HDMI Audio [Radeon HD 6400 Series]
> > 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Cape Verde PRO [Radeon HD 7700 Series]
> > 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> > 
> > Short summary:
> > 
> > - Once I got past a few time consuming obstacles explained below
> >    - the graphics part of the graphics/hdmi audio passthrough seems to work perfect
> >      on both discrete graphics cards 
> >      (though so far only one at at time and with some minor issues, see below)
> >    - no success with the hdmi audio yet (ideas for further investigation appreciated!)
> 
> I've had hdmi audio working with an HD7850, but only in Windows (7) and
> it was using legacy interrupts for some reason instead of MSI.  I wonder
> if Liux guests might work with snd_hda_intel.enable_msi=0.  I'm not sure
> what's wrong with MSI, but it seems to be new with the PCI bus reset
> support.

In my first tries, Windows were just using a generic
VGA driver, which still seems to work perfect with reboots and everything 
and in full screen resolution (1920x1200).
However after installing the Catalyst AMD driver stack, upon boot
Windows 7 now consequently get a BSOD from the graphics driver
with the message:

"Attempt to reset the display driver and recover from timeout failed"
- a picture of the BSOD screen attached.

I attach the corresponding vfio log where I added some timing code to
make it easier to see when the BSOD happens (with 2 seconds of silence
in the log before the VM reboots, I believe this is at 09:28:32-34 in
the log.

Similar behaviour both just after reboot/power cycle of the host and
subsequent VM boot attempts.

This is still with the HD7700 as passed through device, but after a
motherboard firmware upgrade (to F14) which did not seem to affect the
observed behaviour on Windows prior to Catalyst install or with Linux
guest, neither did it fix the bug in selecting primary devices as I 
was hoping for.

Let me know if you have ideas for further debugging this,

Thanks,

Knut

> > - Contrary to deniv@lavabit.com I had no success with using pci-assign for VGA
> >   with a standard fedora 18 kernel and fairly recent qemu, nor with your branches, 
> > 
> > Details:
> > 
> > - I started off with the required kernel parameter 'intel_iommu=on' + necessary parameters for disabling radeon
> >    (radeon.modeset=0 rd.driver.blacklist=radeon) using the integrated graphics as primary display
> >    - this caused the system to freeze (with color artifacts on the console)
> > 
> > - In my naivity and because of the "i" in ifgx I tried both with 
> >   'intel_iommu=ifgx_off' and then 'intel_iommu=on,igfx_off' 
> >   and a full set of combinations of vfio, cards, kernels and pci-assign before I suspected 
> >   that iommu support was turned off for **all** graphics cards with igfx_off
> 
> I'm not sure why this is, looks like the code only tries to turn it off
> when only graphics is under the remapping device.  We'd probably need to
> see the DMAR to know more (/sys/firmware/acpi/tables/DMAR).
> 
> > - The solution was to have integrated graphics turned off in the BIOS, and 'intel_iommu=on':
> > 
> > - iommu groups:
> > 
> > ls -l /sys/bus/pci/devices/0000:01:00.0/iommu_group/devices
> > total 0
> > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.0 -> ../../../../devices/pci0000:00/0000:00:01.0
> > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.1 -> ../../../../devices/pci0000:00/0000:00:01.1
> > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.0 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.0
> > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.1 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.1
> > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.0 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.0
> > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.1 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.1
> > 
> > - eg. both the VGA/HDMI Audio pairs + the two root ports they are plugged into are in the same group:
> 
> Ick.  Intel has been pretty good about advertising ACS support on their
> root ports.  I wonder if this is an oversight or if they are actually
> not isolated from each other.
> 
> > # lspci -n
> > ...
> > 01:00.0 0300: 1002:683f
> > 01:00.1 0403: 1002:aab0
> > 02:00.0 0300: 1002:6779
> > 02:00.1 0403: 1002:aa98
> > ...
> > 
> > modprobe vfio_pci
> > echo 0000:01:00.1 > /sys/bus/pci/devices/0000\:01\:00.1/driver/unbind
> > echo 0000:02:00.1 > /sys/bus/pci/devices/0000\:02\:00.1/driver/unbind
> > echo 1002 683f > /sys/bus/pci/drivers/vfio-pci/new_id
> > echo 1002 aab0 > /sys/bus/pci/drivers/vfio-pci/new_id
> > echo 1002 6779 > /sys/bus/pci/drivers/vfio-pci/new_id
> > echo 1002 aa98 > /sys/bus/pci/drivers/vfio-pci/new_id
> > 
> > # lsusb 
> > ...
> > Bus 001 Device 008: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
> > Bus 001 Device 004: ID 046d:c05b Logitech, Inc. M-U0004 810-001317 [B110 Optical USB Mouse]
> > ...
> > 
> > - I also applied your suggested patch to the quirk function in VFIO (see below)
> > 
> > - Here is a (trimmed for readability) command line I successfully used to boot from the Windows 7 install DVD, 
> >   notice the cd and disk device descriptions and the bus parameter - I struggled a while with that 
> >   until I came across a comment by Gerd Hoffmann here: https://bugzilla.redhat.com/show_bug.cgi?id=922670 (Thanks, Gerd!)
> > 
> > 
> > qemu-kvm -M q35 \
> >   -nodefconfig -readconfig $SRC/qemu/docs/q35-chipset.cfg \
> >   -device vfio-pci,host=2:00.0,x-vga=on,multifunction=on,bus=ich9-pcie-port-1,addr=0.0 \
> >   -device vfio-pci,host=2:00.1,bus=ich9-pcie-port-1,addr=0.1 \
> >   -L $SRC/seabios/out/ -L $SRC/qemu/pc-bios \
> >   -vga none -nographic -cpu host -rtc base=localtime -k no -m 8192 -smp 2 \
> >   -drive file=/dev/sr0,index=2,media=cdrom,id=cd \
> >   -drive file=ivm03.img,index=0,media=disk,id=ivm03 \
> >   -device ide-drive,drive=ivm03,bus=ide.0 \
> >   -device ide-cd,drive=cd,bus=ide.1 \
> >   -net nic,vlan=0,model=virtio -net tap,vlan=0 \
> >   -enable-kvm \
> >   -device usb-host,hostbus=1,hostaddr=8 \
> >   -device usb-host,hostbus=1,hostaddr=4
> > 
> > - Both the graphics card seemshould really support ACS on s to have a rom but only the HD6450 let itself to "scraping". 
> 
> Did you try scraping the HD6450 while the HD7700 was the boot VGA and
> vica versa?  The boot VGA ROM is handled in a special way and what you
> really get is the shadow copy, which isn't what we want.
> 
> > Anyway, supplying it to vfio did not seem to make any difference.
> > 
> > find /sys -name rom
> > /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/rom
> > /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/rom
> > ...
> > 
> > Some observations and remaining unresolved issues:
> > 
> > - VFIO patch:
> >   Initially (while still running with igfx_off) I observed exactly the same behaviour as deniv@lavabit.com
> >   reported a while ago: With vfio_pci debug enabled, vfio_pci ended up spinning with repeated calls to
> >   vfio_ati_3c3_quirk_read and repeated logs: 
> >     vfio: vfio_vga_read(0x3c3, 1) = 0x0
> >   I patched up accordingly with 
> > 
> > 
> > diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
> > index da0e5f9..a361d06 100644
> > --- a/hw/misc/vfio.c
> > +++ b/hw/misc/vfio.c
> > @@ -1291,7 +1291,7 @@ static uint64_t vfio_ati_3c3_quirk_read(void *opaque,
> >      uint64_t data = vfio_vga_read(&vdev->vga.region[QEMU_PCI_VGA_IO_HI],
> >                                    addr + quirk->data.base_offset, size);
> >  
> > -    if (data == quirk->data.address_match) {
> > +    if (1 || data == quirk->data.address_match) {
> >          data = vfio_pci_read_config(&vdev->pdev, quirk->data.address_val, size);
> >          DPRINTF("%s(0x3c3, 1) = 0x%"PRIx64"\n", __func__, data);
> >      }
> > 
> > 
> >   This of course did not help much until I actually got the iommu 
> >   enabled for the radeons (similar "repeated patters" as deniv reported)
> >   but what I have observed after I got it working is that if 
> >   I disable the patch above, things are not that well: the Fedora VM 
> >   comes up with VGA and the Fedora boot screen, then goes blank when 
> >   switching to X.
> 
> Hmm, I think we'd probably have better luck making that unconditional
> until we have reason to do otherwise.
> 
> > - The fact that the iommu group now extends across all my available graphics 
> >   devices now makes it difficult to  get the radeon (or catalyst) driver use to 
> >   the other card since the vfio_pci driver needs to hold it.
> >   Not a complete showstopper since the vesa driver comes up with 1024x768..
> >   Might it be a good idea to have an override option (exception list or similar?) 
> >   to allow the vfio_pci to be less restrictive about owning the whole group 
> >    - allow functionality over security in such case? This of course is further complicated
> >   by the need for graphics drivers to be disabled/enabled already at the kernel prompt..
> 
> We have a quirk in the kernel that enables us to witelist devices, but
> yes, there is no flexibility in this w/o modifying the code and
> rebuilding.  (see drivers/pci/quirks.c:pci_dev_acs_enabled and follow
> the example above w/ pci_dev_dma_source - function can just return 1)
> 
> > - There seems to be a bug in the (version F8) UEFI BIOS on the motherboard, 
> >   The BIOS offers (undocumented) a full range of selections of which PCIe 
> >   (or PCIe 1x) graphics card to use as primary, but any other selection 
> >   than the first PCIe 16x slot has no effect and the motherboard reverts 
> >   to the first slot, so to be able to test both cards, I had to put the card under test
> >   into the second (8x) PCIe slot. I am waiting for feedback from Gigabyte on possible 
> >   fixes for this in newer BIOSes.
> > 
> > - The ultimate goal is to try to consolidate some older Windows desktops as "seats" 
> >   on the new system, using the discrete graphics with HDMI/Displayport audio. 
> >   With the HD7700 moved to the second PCIe slot I tested both Windows and 
> >   Linux guests to try to get some sound through the HDMI audio device. 
> >   Windows complains that no usable device is available. On Linux (Fedora 18, KDE desktop), 
> >   the system settings -> multimedia dialogue never opens up which seems to indicate that 
> >   PulseAudio has problems communicating with the passed through device (?), 
> >   any hints/pointers here appreciated. From the vfio log it seems at least
> >   config space is accessed ok.
> > 
> > - There also seems to be issues with radeon and intel_iommu=on - if I try 
> >   to enable modesetting and normal X support for the radeon cards, X fails to start.
> > 
> > - It would be nice if the integrated graphics could be used as the host primary display - 
> >   I would be happy if someone has any hints as to if/how the ifgx_off option 
> >   could be extended/modified to only affect iommu operation on selected device(s),
> >   if at all possible..
> 
> Let's see what we can discover from your DMAR.  Also send along sudo
> lspci -vvv.  Thanks,
> 
> Alex
>
Maik Broemme - May 19, 2013, 7:26 p.m.
Hi Knut,

Knut Omang <knuto@ifi.uio.no> wrote:
> 
> On Mon, 2013-05-13 at 16:23 -0600, Alex Williamson wrote:
> > On Mon, 2013-05-13 at 22:55 +0200, Knut Omang wrote:
> > > Hi all,
> > > 
> > > Perfect timing from my perspective, thanks Alex!
> > > 
> > > I spent the better part of the weekend testing your branches on a new system 
> > > I just put together for this purpose, results below..
> > > 
> > > On Fri, 2013-05-03 at 16:56 -0600, Alex Williamson wrote:
> > > ...
> > > > git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> > > > git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> > > 
> > > System setup: 
> > > 
> > > - Fedora 18 on
> > > - Gigabyte Z77X-UD5H motherboard
> > > - Intel Core i7 3770 (Ivy bridge w/integrated graphics)
> > > - 2 discrete graphics cards:
> > > 
> > > lspci | egrep 'VGA|Audio'
> > > 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
> > > 00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
> > > 01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Caicos [Radeon HD 6450]
> > > 01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Caicos HDMI Audio [Radeon HD 6400 Series]
> > > 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Cape Verde PRO [Radeon HD 7700 Series]
> > > 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> > > 
> > > Short summary:
> > > 
> > > - Once I got past a few time consuming obstacles explained below
> > >    - the graphics part of the graphics/hdmi audio passthrough seems to work perfect
> > >      on both discrete graphics cards 
> > >      (though so far only one at at time and with some minor issues, see below)
> > >    - no success with the hdmi audio yet (ideas for further investigation appreciated!)
> > 
> > I've had hdmi audio working with an HD7850, but only in Windows (7) and
> > it was using legacy interrupts for some reason instead of MSI.  I wonder
> > if Liux guests might work with snd_hda_intel.enable_msi=0.  I'm not sure
> > what's wrong with MSI, but it seems to be new with the PCI bus reset
> > support.
> 
> In my first tries, Windows were just using a generic
> VGA driver, which still seems to work perfect with reboots and everything 
> and in full screen resolution (1920x1200).
> However after installing the Catalyst AMD driver stack, upon boot
> Windows 7 now consequently get a BSOD from the graphics driver
> with the message:
> 
> "Attempt to reset the display driver and recover from timeout failed"
> - a picture of the BSOD screen attached.
> 
> I attach the corresponding vfio log where I added some timing code to
> make it easier to see when the BSOD happens (with 2 seconds of silence
> in the log before the VM reboots, I believe this is at 09:28:32-34 in
> the log.
> 
> Similar behaviour both just after reboot/power cycle of the host and
> subsequent VM boot attempts.
> 
> This is still with the HD7700 as passed through device, but after a
> motherboard firmware upgrade (to F14) which did not seem to affect the
> observed behaviour on Windows prior to Catalyst install or with Linux
> guest, neither did it fix the bug in selecting primary devices as I 
> was hoping for.
> 
> Let me know if you have ideas for further debugging this,
> 

I had a similar problem a couple of days ago and posted it in this list.
I got similar BSOD and tested already the following configurations:

1) machine: q35 / kvm: yes / vga: none   / x-vga: on  = qemu freeze
2) machine: q35 / kvm: no  / vga: none   / x-vga: on  = qemu freeze
   (with errors below)
3) machine: q35 / kvm: yes / vga: none   / x-vga: off = qemu runs with
   100% CPU due to no VGA init (no picture)
4) machine: q35 / kvm: yes / vga: cirrus / x-vga: off = qemu runs with
   BOSD on loading atikmpag.sys
5) machine: pc  / kvm: yes / vga: cirrus / x-vga: off = qemu runs fine

However I've re-run the BSOD case already with the following branches
from Alex:

git://github.com/awilliam/linux-vfio.git vfio-vga-reset
git://github.com/awilliam/qemu-vfio.git vfio-vga-reset

Also with latest seabios and it worked so far. No more BSOD and reboot
of VM was also possible without suspend / resume the host between.

> Thanks,
> 
> Knut
> 
> > > - Contrary to deniv@lavabit.com I had no success with using pci-assign for VGA
> > >   with a standard fedora 18 kernel and fairly recent qemu, nor with your branches, 
> > > 
> > > Details:
> > > 
> > > - I started off with the required kernel parameter 'intel_iommu=on' + necessary parameters for disabling radeon
> > >    (radeon.modeset=0 rd.driver.blacklist=radeon) using the integrated graphics as primary display
> > >    - this caused the system to freeze (with color artifacts on the console)
> > > 
> > > - In my naivity and because of the "i" in ifgx I tried both with 
> > >   'intel_iommu=ifgx_off' and then 'intel_iommu=on,igfx_off' 
> > >   and a full set of combinations of vfio, cards, kernels and pci-assign before I suspected 
> > >   that iommu support was turned off for **all** graphics cards with igfx_off
> > 
> > I'm not sure why this is, looks like the code only tries to turn it off
> > when only graphics is under the remapping device.  We'd probably need to
> > see the DMAR to know more (/sys/firmware/acpi/tables/DMAR).
> > 
> > > - The solution was to have integrated graphics turned off in the BIOS, and 'intel_iommu=on':
> > > 
> > > - iommu groups:
> > > 
> > > ls -l /sys/bus/pci/devices/0000:01:00.0/iommu_group/devices
> > > total 0
> > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.0 -> ../../../../devices/pci0000:00/0000:00:01.0
> > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.1 -> ../../../../devices/pci0000:00/0000:00:01.1
> > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.0 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.0
> > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.1 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.1
> > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.0 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.0
> > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.1 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.1
> > > 
> > > - eg. both the VGA/HDMI Audio pairs + the two root ports they are plugged into are in the same group:
> > 
> > Ick.  Intel has been pretty good about advertising ACS support on their
> > root ports.  I wonder if this is an oversight or if they are actually
> > not isolated from each other.
> > 
> > > # lspci -n
> > > ...
> > > 01:00.0 0300: 1002:683f
> > > 01:00.1 0403: 1002:aab0
> > > 02:00.0 0300: 1002:6779
> > > 02:00.1 0403: 1002:aa98
> > > ...
> > > 
> > > modprobe vfio_pci
> > > echo 0000:01:00.1 > /sys/bus/pci/devices/0000\:01\:00.1/driver/unbind
> > > echo 0000:02:00.1 > /sys/bus/pci/devices/0000\:02\:00.1/driver/unbind
> > > echo 1002 683f > /sys/bus/pci/drivers/vfio-pci/new_id
> > > echo 1002 aab0 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > echo 1002 6779 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > echo 1002 aa98 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > 
> > > # lsusb 
> > > ...
> > > Bus 001 Device 008: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
> > > Bus 001 Device 004: ID 046d:c05b Logitech, Inc. M-U0004 810-001317 [B110 Optical USB Mouse]
> > > ...
> > > 
> > > - I also applied your suggested patch to the quirk function in VFIO (see below)
> > > 
> > > - Here is a (trimmed for readability) command line I successfully used to boot from the Windows 7 install DVD, 
> > >   notice the cd and disk device descriptions and the bus parameter - I struggled a while with that 
> > >   until I came across a comment by Gerd Hoffmann here: https://bugzilla.redhat.com/show_bug.cgi?id=922670 (Thanks, Gerd!)
> > > 
> > > 
> > > qemu-kvm -M q35 \
> > >   -nodefconfig -readconfig $SRC/qemu/docs/q35-chipset.cfg \
> > >   -device vfio-pci,host=2:00.0,x-vga=on,multifunction=on,bus=ich9-pcie-port-1,addr=0.0 \
> > >   -device vfio-pci,host=2:00.1,bus=ich9-pcie-port-1,addr=0.1 \
> > >   -L $SRC/seabios/out/ -L $SRC/qemu/pc-bios \
> > >   -vga none -nographic -cpu host -rtc base=localtime -k no -m 8192 -smp 2 \
> > >   -drive file=/dev/sr0,index=2,media=cdrom,id=cd \
> > >   -drive file=ivm03.img,index=0,media=disk,id=ivm03 \
> > >   -device ide-drive,drive=ivm03,bus=ide.0 \
> > >   -device ide-cd,drive=cd,bus=ide.1 \
> > >   -net nic,vlan=0,model=virtio -net tap,vlan=0 \
> > >   -enable-kvm \
> > >   -device usb-host,hostbus=1,hostaddr=8 \
> > >   -device usb-host,hostbus=1,hostaddr=4
> > > 
> > > - Both the graphics card seemshould really support ACS on s to have a rom but only the HD6450 let itself to "scraping". 
> > 
> > Did you try scraping the HD6450 while the HD7700 was the boot VGA and
> > vica versa?  The boot VGA ROM is handled in a special way and what you
> > really get is the shadow copy, which isn't what we want.
> > 
> > > Anyway, supplying it to vfio did not seem to make any difference.
> > > 
> > > find /sys -name rom
> > > /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/rom
> > > /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/rom
> > > ...
> > > 
> > > Some observations and remaining unresolved issues:
> > > 
> > > - VFIO patch:
> > >   Initially (while still running with igfx_off) I observed exactly the same behaviour as deniv@lavabit.com
> > >   reported a while ago: With vfio_pci debug enabled, vfio_pci ended up spinning with repeated calls to
> > >   vfio_ati_3c3_quirk_read and repeated logs: 
> > >     vfio: vfio_vga_read(0x3c3, 1) = 0x0
> > >   I patched up accordingly with 
> > > 
> > > 
> > > diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
> > > index da0e5f9..a361d06 100644
> > > --- a/hw/misc/vfio.c
> > > +++ b/hw/misc/vfio.c
> > > @@ -1291,7 +1291,7 @@ static uint64_t vfio_ati_3c3_quirk_read(void *opaque,
> > >      uint64_t data = vfio_vga_read(&vdev->vga.region[QEMU_PCI_VGA_IO_HI],
> > >                                    addr + quirk->data.base_offset, size);
> > >  
> > > -    if (data == quirk->data.address_match) {
> > > +    if (1 || data == quirk->data.address_match) {
> > >          data = vfio_pci_read_config(&vdev->pdev, quirk->data.address_val, size);
> > >          DPRINTF("%s(0x3c3, 1) = 0x%"PRIx64"\n", __func__, data);
> > >      }
> > > 
> > > 
> > >   This of course did not help much until I actually got the iommu 
> > >   enabled for the radeons (similar "repeated patters" as deniv reported)
> > >   but what I have observed after I got it working is that if 
> > >   I disable the patch above, things are not that well: the Fedora VM 
> > >   comes up with VGA and the Fedora boot screen, then goes blank when 
> > >   switching to X.
> > 
> > Hmm, I think we'd probably have better luck making that unconditional
> > until we have reason to do otherwise.
> > 
> > > - The fact that the iommu group now extends across all my available graphics 
> > >   devices now makes it difficult to  get the radeon (or catalyst) driver use to 
> > >   the other card since the vfio_pci driver needs to hold it.
> > >   Not a complete showstopper since the vesa driver comes up with 1024x768..
> > >   Might it be a good idea to have an override option (exception list or similar?) 
> > >   to allow the vfio_pci to be less restrictive about owning the whole group 
> > >    - allow functionality over security in such case? This of course is further complicated
> > >   by the need for graphics drivers to be disabled/enabled already at the kernel prompt..
> > 
> > We have a quirk in the kernel that enables us to witelist devices, but
> > yes, there is no flexibility in this w/o modifying the code and
> > rebuilding.  (see drivers/pci/quirks.c:pci_dev_acs_enabled and follow
> > the example above w/ pci_dev_dma_source - function can just return 1)
> > 
> > > - There seems to be a bug in the (version F8) UEFI BIOS on the motherboard, 
> > >   The BIOS offers (undocumented) a full range of selections of which PCIe 
> > >   (or PCIe 1x) graphics card to use as primary, but any other selection 
> > >   than the first PCIe 16x slot has no effect and the motherboard reverts 
> > >   to the first slot, so to be able to test both cards, I had to put the card under test
> > >   into the second (8x) PCIe slot. I am waiting for feedback from Gigabyte on possible 
> > >   fixes for this in newer BIOSes.
> > > 
> > > - The ultimate goal is to try to consolidate some older Windows desktops as "seats" 
> > >   on the new system, using the discrete graphics with HDMI/Displayport audio. 
> > >   With the HD7700 moved to the second PCIe slot I tested both Windows and 
> > >   Linux guests to try to get some sound through the HDMI audio device. 
> > >   Windows complains that no usable device is available. On Linux (Fedora 18, KDE desktop), 
> > >   the system settings -> multimedia dialogue never opens up which seems to indicate that 
> > >   PulseAudio has problems communicating with the passed through device (?), 
> > >   any hints/pointers here appreciated. From the vfio log it seems at least
> > >   config space is accessed ok.
> > > 
> > > - There also seems to be issues with radeon and intel_iommu=on - if I try 
> > >   to enable modesetting and normal X support for the radeon cards, X fails to start.
> > > 
> > > - It would be nice if the integrated graphics could be used as the host primary display - 
> > >   I would be happy if someone has any hints as to if/how the ifgx_off option 
> > >   could be extended/modified to only affect iommu operation on selected device(s),
> > >   if at all possible..
> > 
> > Let's see what we can discover from your DMAR.  Also send along sudo
> > lspci -vvv.  Thanks,
> > 
> > Alex
> > 
> 
> 

--Maik
Alex Williamson - May 20, 2013, 3:17 a.m.
On Sun, 2013-05-19 at 23:26 +0400, Maik Broemme wrote:
> Hi Knut,
> 
> Knut Omang <knuto@ifi.uio.no> wrote:
> > 
> > On Mon, 2013-05-13 at 16:23 -0600, Alex Williamson wrote:
> > > On Mon, 2013-05-13 at 22:55 +0200, Knut Omang wrote:
> > > > Hi all,
> > > > 
> > > > Perfect timing from my perspective, thanks Alex!
> > > > 
> > > > I spent the better part of the weekend testing your branches on a new system 
> > > > I just put together for this purpose, results below..
> > > > 
> > > > On Fri, 2013-05-03 at 16:56 -0600, Alex Williamson wrote:
> > > > ...
> > > > > git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> > > > > git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> > > > 
> > > > System setup: 
> > > > 
> > > > - Fedora 18 on
> > > > - Gigabyte Z77X-UD5H motherboard
> > > > - Intel Core i7 3770 (Ivy bridge w/integrated graphics)
> > > > - 2 discrete graphics cards:
> > > > 
> > > > lspci | egrep 'VGA|Audio'
> > > > 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
> > > > 00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
> > > > 01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Caicos [Radeon HD 6450]
> > > > 01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Caicos HDMI Audio [Radeon HD 6400 Series]
> > > > 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Cape Verde PRO [Radeon HD 7700 Series]
> > > > 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> > > > 
> > > > Short summary:
> > > > 
> > > > - Once I got past a few time consuming obstacles explained below
> > > >    - the graphics part of the graphics/hdmi audio passthrough seems to work perfect
> > > >      on both discrete graphics cards 
> > > >      (though so far only one at at time and with some minor issues, see below)
> > > >    - no success with the hdmi audio yet (ideas for further investigation appreciated!)
> > > 
> > > I've had hdmi audio working with an HD7850, but only in Windows (7) and
> > > it was using legacy interrupts for some reason instead of MSI.  I wonder
> > > if Liux guests might work with snd_hda_intel.enable_msi=0.  I'm not sure
> > > what's wrong with MSI, but it seems to be new with the PCI bus reset
> > > support.
> > 
> > In my first tries, Windows were just using a generic
> > VGA driver, which still seems to work perfect with reboots and everything 
> > and in full screen resolution (1920x1200).
> > However after installing the Catalyst AMD driver stack, upon boot
> > Windows 7 now consequently get a BSOD from the graphics driver
> > with the message:
> > 
> > "Attempt to reset the display driver and recover from timeout failed"
> > - a picture of the BSOD screen attached.
> > 
> > I attach the corresponding vfio log where I added some timing code to
> > make it easier to see when the BSOD happens (with 2 seconds of silence
> > in the log before the VM reboots, I believe this is at 09:28:32-34 in
> > the log.
> > 
> > Similar behaviour both just after reboot/power cycle of the host and
> > subsequent VM boot attempts.
> > 
> > This is still with the HD7700 as passed through device, but after a
> > motherboard firmware upgrade (to F14) which did not seem to affect the
> > observed behaviour on Windows prior to Catalyst install or with Linux
> > guest, neither did it fix the bug in selecting primary devices as I 
> > was hoping for.
> > 
> > Let me know if you have ideas for further debugging this,
> > 
> 
> I had a similar problem a couple of days ago and posted it in this list.
> I got similar BSOD and tested already the following configurations:
> 
> 1) machine: q35 / kvm: yes / vga: none   / x-vga: on  = qemu freeze
> 2) machine: q35 / kvm: no  / vga: none   / x-vga: on  = qemu freeze
>    (with errors below)
> 3) machine: q35 / kvm: yes / vga: none   / x-vga: off = qemu runs with
>    100% CPU due to no VGA init (no picture)
> 4) machine: q35 / kvm: yes / vga: cirrus / x-vga: off = qemu runs with
>    BOSD on loading atikmpag.sys
> 5) machine: pc  / kvm: yes / vga: cirrus / x-vga: off = qemu runs fine
> 
> However I've re-run the BSOD case already with the following branches
> from Alex:
> 
> git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> 
> Also with latest seabios and it worked so far. No more BSOD and reboot
> of VM was also possible without suspend / resume the host between.

Good to hear.  It looks like you have the same motherboard as my AMD
test system.  An HD7850 in that system runs quite reliably with the
branches above although I do occasionally get VGA palette corruption.

Are you still require -vga cirrus or do the -vga none, x-vga=on cases
work now too?  Thanks,

Alex
Alex Williamson - May 20, 2013, 4:15 a.m.
On Sun, 2013-05-19 at 17:35 +0200, Knut Omang wrote:
> On Mon, 2013-05-13 at 16:23 -0600, Alex Williamson wrote:
> > On Mon, 2013-05-13 at 22:55 +0200, Knut Omang wrote:
> > > Hi all,
> > > 
> > > Perfect timing from my perspective, thanks Alex!
> > > 
> > > I spent the better part of the weekend testing your branches on a new system 
> > > I just put together for this purpose, results below..
> > > 
> > > On Fri, 2013-05-03 at 16:56 -0600, Alex Williamson wrote:
> > > ...
> > > > git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> > > > git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> > > 
> > > System setup: 
> > > 
> > > - Fedora 18 on
> > > - Gigabyte Z77X-UD5H motherboard
> > > - Intel Core i7 3770 (Ivy bridge w/integrated graphics)
> > > - 2 discrete graphics cards:
> > > 
> > > lspci | egrep 'VGA|Audio'
> > > 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
> > > 00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
> > > 01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Caicos [Radeon HD 6450]
> > > 01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Caicos HDMI Audio [Radeon HD 6400 Series]
> > > 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Cape Verde PRO [Radeon HD 7700 Series]
> > > 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> > > 
> > > Short summary:
> > > 
> > > - Once I got past a few time consuming obstacles explained below
> > >    - the graphics part of the graphics/hdmi audio passthrough seems to work perfect
> > >      on both discrete graphics cards 
> > >      (though so far only one at at time and with some minor issues, see below)
> > >    - no success with the hdmi audio yet (ideas for further investigation appreciated!)
> > 
> > I've had hdmi audio working with an HD7850, but only in Windows (7) and
> > it was using legacy interrupts for some reason instead of MSI.  I wonder
> > if Liux guests might work with snd_hda_intel.enable_msi=0.  I'm not sure
> > what's wrong with MSI, but it seems to be new with the PCI bus reset
> > support.
> 
> In my first tries, Windows were just using a generic
> VGA driver, which still seems to work perfect with reboots and everything 
> and in full screen resolution (1920x1200).
> However after installing the Catalyst AMD driver stack, upon boot
> Windows 7 now consequently get a BSOD from the graphics driver
> with the message:
> 
> "Attempt to reset the display driver and recover from timeout failed"
> - a picture of the BSOD screen attached.

I've seen that BSOD before, but I don't know how to reproduce it.  It
seems like I haven't seen it with the PCI bus reset code.  I'm running
version 13.1 of the catalyst driver, you?

> I attach the corresponding vfio log where I added some timing code to
> make it easier to see when the BSOD happens (with 2 seconds of silence
> in the log before the VM reboots, I believe this is at 09:28:32-34 in
> the log.

Yep, looks like that's where windows starts the BSOD.

> Similar behaviour both just after reboot/power cycle of the host and
> subsequent VM boot attempts.
> 
> This is still with the HD7700 as passed through device, but after a
> motherboard firmware upgrade (to F14) which did not seem to affect the
> observed behaviour on Windows prior to Catalyst install or with Linux
> guest, neither did it fix the bug in selecting primary devices as I 
> was hoping for.
> 
> Let me know if you have ideas for further debugging this,

I don't have any great ideas since I don't know how to reproduce the
timeout.  Double/triple check that you're using the correct
vfio-vga-reset branches in both qemu and kernel

# grep VFIO_DEVICE_PCI_BUS_RESET qemu.git/hw/misc/vfio.c
# grep VFIO_DEVICE_PCI_BUS_RESET linux.git/drivers/vfio/pci/vfio_pci.c

I didn't see anything telling in your DMAR either.  The system seems to
have just one DRHD that includes everything, so I'm not sure why you saw
any behavior change from igfx_off.  Thanks,

Alex

> > > - Contrary to deniv@lavabit.com I had no success with using pci-assign for VGA
> > >   with a standard fedora 18 kernel and fairly recent qemu, nor with your branches, 
> > > 
> > > Details:
> > > 
> > > - I started off with the required kernel parameter 'intel_iommu=on' + necessary parameters for disabling radeon
> > >    (radeon.modeset=0 rd.driver.blacklist=radeon) using the integrated graphics as primary display
> > >    - this caused the system to freeze (with color artifacts on the console)
> > > 
> > > - In my naivity and because of the "i" in ifgx I tried both with 
> > >   'intel_iommu=ifgx_off' and then 'intel_iommu=on,igfx_off' 
> > >   and a full set of combinations of vfio, cards, kernels and pci-assign before I suspected 
> > >   that iommu support was turned off for **all** graphics cards with igfx_off
> > 
> > I'm not sure why this is, looks like the code only tries to turn it off
> > when only graphics is under the remapping device.  We'd probably need to
> > see the DMAR to know more (/sys/firmware/acpi/tables/DMAR).
> > 
> > > - The solution was to have integrated graphics turned off in the BIOS, and 'intel_iommu=on':
> > > 
> > > - iommu groups:
> > > 
> > > ls -l /sys/bus/pci/devices/0000:01:00.0/iommu_group/devices
> > > total 0
> > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.0 -> ../../../../devices/pci0000:00/0000:00:01.0
> > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.1 -> ../../../../devices/pci0000:00/0000:00:01.1
> > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.0 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.0
> > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.1 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.1
> > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.0 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.0
> > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.1 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.1
> > > 
> > > - eg. both the VGA/HDMI Audio pairs + the two root ports they are plugged into are in the same group:
> > 
> > Ick.  Intel has been pretty good about advertising ACS support on their
> > root ports.  I wonder if this is an oversight or if they are actually
> > not isolated from each other.
> > 
> > > # lspci -n
> > > ...
> > > 01:00.0 0300: 1002:683f
> > > 01:00.1 0403: 1002:aab0
> > > 02:00.0 0300: 1002:6779
> > > 02:00.1 0403: 1002:aa98
> > > ...
> > > 
> > > modprobe vfio_pci
> > > echo 0000:01:00.1 > /sys/bus/pci/devices/0000\:01\:00.1/driver/unbind
> > > echo 0000:02:00.1 > /sys/bus/pci/devices/0000\:02\:00.1/driver/unbind
> > > echo 1002 683f > /sys/bus/pci/drivers/vfio-pci/new_id
> > > echo 1002 aab0 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > echo 1002 6779 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > echo 1002 aa98 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > 
> > > # lsusb 
> > > ...
> > > Bus 001 Device 008: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
> > > Bus 001 Device 004: ID 046d:c05b Logitech, Inc. M-U0004 810-001317 [B110 Optical USB Mouse]
> > > ...
> > > 
> > > - I also applied your suggested patch to the quirk function in VFIO (see below)
> > > 
> > > - Here is a (trimmed for readability) command line I successfully used to boot from the Windows 7 install DVD, 
> > >   notice the cd and disk device descriptions and the bus parameter - I struggled a while with that 
> > >   until I came across a comment by Gerd Hoffmann here: https://bugzilla.redhat.com/show_bug.cgi?id=922670 (Thanks, Gerd!)
> > > 
> > > 
> > > qemu-kvm -M q35 \
> > >   -nodefconfig -readconfig $SRC/qemu/docs/q35-chipset.cfg \
> > >   -device vfio-pci,host=2:00.0,x-vga=on,multifunction=on,bus=ich9-pcie-port-1,addr=0.0 \
> > >   -device vfio-pci,host=2:00.1,bus=ich9-pcie-port-1,addr=0.1 \
> > >   -L $SRC/seabios/out/ -L $SRC/qemu/pc-bios \
> > >   -vga none -nographic -cpu host -rtc base=localtime -k no -m 8192 -smp 2 \
> > >   -drive file=/dev/sr0,index=2,media=cdrom,id=cd \
> > >   -drive file=ivm03.img,index=0,media=disk,id=ivm03 \
> > >   -device ide-drive,drive=ivm03,bus=ide.0 \
> > >   -device ide-cd,drive=cd,bus=ide.1 \
> > >   -net nic,vlan=0,model=virtio -net tap,vlan=0 \
> > >   -enable-kvm \
> > >   -device usb-host,hostbus=1,hostaddr=8 \
> > >   -device usb-host,hostbus=1,hostaddr=4
> > > 
> > > - Both the graphics card seemshould really support ACS on s to have a rom but only the HD6450 let itself to "scraping". 
> > 
> > Did you try scraping the HD6450 while the HD7700 was the boot VGA and
> > vica versa?  The boot VGA ROM is handled in a special way and what you
> > really get is the shadow copy, which isn't what we want.
> > 
> > > Anyway, supplying it to vfio did not seem to make any difference.
> > > 
> > > find /sys -name rom
> > > /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/rom
> > > /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/rom
> > > ...
> > > 
> > > Some observations and remaining unresolved issues:
> > > 
> > > - VFIO patch:
> > >   Initially (while still running with igfx_off) I observed exactly the same behaviour as deniv@lavabit.com
> > >   reported a while ago: With vfio_pci debug enabled, vfio_pci ended up spinning with repeated calls to
> > >   vfio_ati_3c3_quirk_read and repeated logs: 
> > >     vfio: vfio_vga_read(0x3c3, 1) = 0x0
> > >   I patched up accordingly with 
> > > 
> > > 
> > > diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
> > > index da0e5f9..a361d06 100644
> > > --- a/hw/misc/vfio.c
> > > +++ b/hw/misc/vfio.c
> > > @@ -1291,7 +1291,7 @@ static uint64_t vfio_ati_3c3_quirk_read(void *opaque,
> > >      uint64_t data = vfio_vga_read(&vdev->vga.region[QEMU_PCI_VGA_IO_HI],
> > >                                    addr + quirk->data.base_offset, size);
> > >  
> > > -    if (data == quirk->data.address_match) {
> > > +    if (1 || data == quirk->data.address_match) {
> > >          data = vfio_pci_read_config(&vdev->pdev, quirk->data.address_val, size);
> > >          DPRINTF("%s(0x3c3, 1) = 0x%"PRIx64"\n", __func__, data);
> > >      }
> > > 
> > > 
> > >   This of course did not help much until I actually got the iommu 
> > >   enabled for the radeons (similar "repeated patters" as deniv reported)
> > >   but what I have observed after I got it working is that if 
> > >   I disable the patch above, things are not that well: the Fedora VM 
> > >   comes up with VGA and the Fedora boot screen, then goes blank when 
> > >   switching to X.
> > 
> > Hmm, I think we'd probably have better luck making that unconditional
> > until we have reason to do otherwise.
> > 
> > > - The fact that the iommu group now extends across all my available graphics 
> > >   devices now makes it difficult to  get the radeon (or catalyst) driver use to 
> > >   the other card since the vfio_pci driver needs to hold it.
> > >   Not a complete showstopper since the vesa driver comes up with 1024x768..
> > >   Might it be a good idea to have an override option (exception list or similar?) 
> > >   to allow the vfio_pci to be less restrictive about owning the whole group 
> > >    - allow functionality over security in such case? This of course is further complicated
> > >   by the need for graphics drivers to be disabled/enabled already at the kernel prompt..
> > 
> > We have a quirk in the kernel that enables us to witelist devices, but
> > yes, there is no flexibility in this w/o modifying the code and
> > rebuilding.  (see drivers/pci/quirks.c:pci_dev_acs_enabled and follow
> > the example above w/ pci_dev_dma_source - function can just return 1)
> > 
> > > - There seems to be a bug in the (version F8) UEFI BIOS on the motherboard, 
> > >   The BIOS offers (undocumented) a full range of selections of which PCIe 
> > >   (or PCIe 1x) graphics card to use as primary, but any other selection 
> > >   than the first PCIe 16x slot has no effect and the motherboard reverts 
> > >   to the first slot, so to be able to test both cards, I had to put the card under test
> > >   into the second (8x) PCIe slot. I am waiting for feedback from Gigabyte on possible 
> > >   fixes for this in newer BIOSes.
> > > 
> > > - The ultimate goal is to try to consolidate some older Windows desktops as "seats" 
> > >   on the new system, using the discrete graphics with HDMI/Displayport audio. 
> > >   With the HD7700 moved to the second PCIe slot I tested both Windows and 
> > >   Linux guests to try to get some sound through the HDMI audio device. 
> > >   Windows complains that no usable device is available. On Linux (Fedora 18, KDE desktop), 
> > >   the system settings -> multimedia dialogue never opens up which seems to indicate that 
> > >   PulseAudio has problems communicating with the passed through device (?), 
> > >   any hints/pointers here appreciated. From the vfio log it seems at least
> > >   config space is accessed ok.
> > > 
> > > - There also seems to be issues with radeon and intel_iommu=on - if I try 
> > >   to enable modesetting and normal X support for the radeon cards, X fails to start.
> > > 
> > > - It would be nice if the integrated graphics could be used as the host primary display - 
> > >   I would be happy if someone has any hints as to if/how the ifgx_off option 
> > >   could be extended/modified to only affect iommu operation on selected device(s),
> > >   if at all possible..
> > 
> > Let's see what we can discover from your DMAR.  Also send along sudo
> > lspci -vvv.  Thanks,
> > 
> > Alex
> > 
> 
>
Maik Broemme - May 20, 2013, 11:05 a.m.
Hi Alex,

Alex Williamson <alex.williamson@redhat.com> wrote:
> On Sun, 2013-05-19 at 23:26 +0400, Maik Broemme wrote:
> > Hi Knut,
> > 
> > Knut Omang <knuto@ifi.uio.no> wrote:
> > > 
> > > On Mon, 2013-05-13 at 16:23 -0600, Alex Williamson wrote:
> > > > On Mon, 2013-05-13 at 22:55 +0200, Knut Omang wrote:
> > > > > Hi all,
> > > > > 
> > > > > Perfect timing from my perspective, thanks Alex!
> > > > > 
> > > > > I spent the better part of the weekend testing your branches on a new system 
> > > > > I just put together for this purpose, results below..
> > > > > 
> > > > > On Fri, 2013-05-03 at 16:56 -0600, Alex Williamson wrote:
> > > > > ...
> > > > > > git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> > > > > > git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> > > > > 
> > > > > System setup: 
> > > > > 
> > > > > - Fedora 18 on
> > > > > - Gigabyte Z77X-UD5H motherboard
> > > > > - Intel Core i7 3770 (Ivy bridge w/integrated graphics)
> > > > > - 2 discrete graphics cards:
> > > > > 
> > > > > lspci | egrep 'VGA|Audio'
> > > > > 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
> > > > > 00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
> > > > > 01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Caicos [Radeon HD 6450]
> > > > > 01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Caicos HDMI Audio [Radeon HD 6400 Series]
> > > > > 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Cape Verde PRO [Radeon HD 7700 Series]
> > > > > 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> > > > > 
> > > > > Short summary:
> > > > > 
> > > > > - Once I got past a few time consuming obstacles explained below
> > > > >    - the graphics part of the graphics/hdmi audio passthrough seems to work perfect
> > > > >      on both discrete graphics cards 
> > > > >      (though so far only one at at time and with some minor issues, see below)
> > > > >    - no success with the hdmi audio yet (ideas for further investigation appreciated!)
> > > > 
> > > > I've had hdmi audio working with an HD7850, but only in Windows (7) and
> > > > it was using legacy interrupts for some reason instead of MSI.  I wonder
> > > > if Liux guests might work with snd_hda_intel.enable_msi=0.  I'm not sure
> > > > what's wrong with MSI, but it seems to be new with the PCI bus reset
> > > > support.
> > > 
> > > In my first tries, Windows were just using a generic
> > > VGA driver, which still seems to work perfect with reboots and everything 
> > > and in full screen resolution (1920x1200).
> > > However after installing the Catalyst AMD driver stack, upon boot
> > > Windows 7 now consequently get a BSOD from the graphics driver
> > > with the message:
> > > 
> > > "Attempt to reset the display driver and recover from timeout failed"
> > > - a picture of the BSOD screen attached.
> > > 
> > > I attach the corresponding vfio log where I added some timing code to
> > > make it easier to see when the BSOD happens (with 2 seconds of silence
> > > in the log before the VM reboots, I believe this is at 09:28:32-34 in
> > > the log.
> > > 
> > > Similar behaviour both just after reboot/power cycle of the host and
> > > subsequent VM boot attempts.
> > > 
> > > This is still with the HD7700 as passed through device, but after a
> > > motherboard firmware upgrade (to F14) which did not seem to affect the
> > > observed behaviour on Windows prior to Catalyst install or with Linux
> > > guest, neither did it fix the bug in selecting primary devices as I 
> > > was hoping for.
> > > 
> > > Let me know if you have ideas for further debugging this,
> > > 
> > 
> > I had a similar problem a couple of days ago and posted it in this list.
> > I got similar BSOD and tested already the following configurations:
> > 
> > 1) machine: q35 / kvm: yes / vga: none   / x-vga: on  = qemu freeze
> > 2) machine: q35 / kvm: no  / vga: none   / x-vga: on  = qemu freeze
> >    (with errors below)
> > 3) machine: q35 / kvm: yes / vga: none   / x-vga: off = qemu runs with
> >    100% CPU due to no VGA init (no picture)
> > 4) machine: q35 / kvm: yes / vga: cirrus / x-vga: off = qemu runs with
> >    BOSD on loading atikmpag.sys
> > 5) machine: pc  / kvm: yes / vga: cirrus / x-vga: off = qemu runs fine
> > 
> > However I've re-run the BSOD case already with the following branches
> > from Alex:
> > 
> > git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> > git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> > 
> > Also with latest seabios and it worked so far. No more BSOD and reboot
> > of VM was also possible without suspend / resume the host between.
> 
> Good to hear.  It looks like you have the same motherboard as my AMD
> test system.  An HD7850 in that system runs quite reliably with the
> branches above although I do occasionally get VGA palette corruption.
> 

Good to know. I'm using a Radeon HD7870 which works fine now. I have the
same VGA palette corruption occasionally but only until Catalyst driver
is loaded. So it happens sometimes during VGA init if Windows 7 boot
logo is shown with very strange colors and went away if Catalyst driver
is loaded.

> Are you still require -vga cirrus or do the -vga none, x-vga=on cases
> work now too?  Thanks,
> 

No longer required, -vga none with x-vga=on work on your branches fine
now. Not sure if there was something more changed because with original
Fedora 3.9.2 kernel it still doesn't work.

> Alex
> 

--Maik
Knut Omang - May 20, 2013, 9:08 p.m.
On Sun, 2013-05-19 at 23:26 +0400, Maik Broemme wrote:
> Hi Knut,
> 
> Knut Omang <knuto@ifi.uio.no> wrote:
> > 
> > On Mon, 2013-05-13 at 16:23 -0600, Alex Williamson wrote:
> > > On Mon, 2013-05-13 at 22:55 +0200, Knut Omang wrote:
> > > > Hi all,
> > > > 
> > > > Perfect timing from my perspective, thanks Alex!
> > > > 
> > > > I spent the better part of the weekend testing your branches on a new system 
> > > > I just put together for this purpose, results below..
> > > > 
> > > > On Fri, 2013-05-03 at 16:56 -0600, Alex Williamson wrote:
> > > > ...
> > > > > git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> > > > > git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> > > > 
> > > > System setup: 
> > > > 
> > > > - Fedora 18 on
> > > > - Gigabyte Z77X-UD5H motherboard
> > > > - Intel Core i7 3770 (Ivy bridge w/integrated graphics)
> > > > - 2 discrete graphics cards:
> > > > 
> > > > lspci | egrep 'VGA|Audio'
> > > > 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
> > > > 00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
> > > > 01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Caicos [Radeon HD 6450]
> > > > 01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Caicos HDMI Audio [Radeon HD 6400 Series]
> > > > 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Cape Verde PRO [Radeon HD 7700 Series]
> > > > 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> > > > 
> > > > Short summary:
> > > > 
> > > > - Once I got past a few time consuming obstacles explained below
> > > >    - the graphics part of the graphics/hdmi audio passthrough seems to work perfect
> > > >      on both discrete graphics cards 
> > > >      (though so far only one at at time and with some minor issues, see below)
> > > >    - no success with the hdmi audio yet (ideas for further investigation appreciated!)
> > > 
> > > I've had hdmi audio working with an HD7850, but only in Windows (7) and
> > > it was using legacy interrupts for some reason instead of MSI.  I wonder
> > > if Liux guests might work with snd_hda_intel.enable_msi=0.  I'm not sure
> > > what's wrong with MSI, but it seems to be new with the PCI bus reset
> > > support.
> > 
> > In my first tries, Windows were just using a generic
> > VGA driver, which still seems to work perfect with reboots and everything 
> > and in full screen resolution (1920x1200).
> > However after installing the Catalyst AMD driver stack, upon boot
> > Windows 7 now consequently get a BSOD from the graphics driver
> > with the message:
> > 
> > "Attempt to reset the display driver and recover from timeout failed"
> > - a picture of the BSOD screen attached.
> > 
> > I attach the corresponding vfio log where I added some timing code to
> > make it easier to see when the BSOD happens (with 2 seconds of silence
> > in the log before the VM reboots, I believe this is at 09:28:32-34 in
> > the log.
> > 
> > Similar behaviour both just after reboot/power cycle of the host and
> > subsequent VM boot attempts.
> > 
> > This is still with the HD7700 as passed through device, but after a
> > motherboard firmware upgrade (to F14) which did not seem to affect the
> > observed behaviour on Windows prior to Catalyst install or with Linux
> > guest, neither did it fix the bug in selecting primary devices as I 
> > was hoping for.
> > 
> > Let me know if you have ideas for further debugging this,
> > 
> 
> I had a similar problem a couple of days ago and posted it in this list.
> I got similar BSOD and tested already the following configurations:
> 
> 1) machine: q35 / kvm: yes / vga: none   / x-vga: on  = qemu freeze
> 2) machine: q35 / kvm: no  / vga: none   / x-vga: on  = qemu freeze
>    (with errors below)
> 3) machine: q35 / kvm: yes / vga: none   / x-vga: off = qemu runs with
>    100% CPU due to no VGA init (no picture)
> 4) machine: q35 / kvm: yes / vga: cirrus / x-vga: off = qemu runs with
>    BOSD on loading atikmpag.sys
> 5) machine: pc  / kvm: yes / vga: cirrus / x-vga: off = qemu runs fine
> 
> However I've re-run the BSOD case already with the following branches
> from Alex:
> 
> git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> 
> Also with latest seabios and it worked so far. No more BSOD and reboot
> of VM was also possible without suspend / resume the host between.

Hmm, seems you have been more lucky with the choice of chipset/CPU than
me - all my tests are also with these branches but on Intel...

Knut

> > Thanks,
> > 
> > Knut
> > 
> > > > - Contrary to deniv@lavabit.com I had no success with using pci-assign for VGA
> > > >   with a standard fedora 18 kernel and fairly recent qemu, nor with your branches, 
> > > > 
> > > > Details:
> > > > 
> > > > - I started off with the required kernel parameter 'intel_iommu=on' + necessary parameters for disabling radeon
> > > >    (radeon.modeset=0 rd.driver.blacklist=radeon) using the integrated graphics as primary display
> > > >    - this caused the system to freeze (with color artifacts on the console)
> > > > 
> > > > - In my naivity and because of the "i" in ifgx I tried both with 
> > > >   'intel_iommu=ifgx_off' and then 'intel_iommu=on,igfx_off' 
> > > >   and a full set of combinations of vfio, cards, kernels and pci-assign before I suspected 
> > > >   that iommu support was turned off for **all** graphics cards with igfx_off
> > > 
> > > I'm not sure why this is, looks like the code only tries to turn it off
> > > when only graphics is under the remapping device.  We'd probably need to
> > > see the DMAR to know more (/sys/firmware/acpi/tables/DMAR).
> > > 
> > > > - The solution was to have integrated graphics turned off in the BIOS, and 'intel_iommu=on':
> > > > 
> > > > - iommu groups:
> > > > 
> > > > ls -l /sys/bus/pci/devices/0000:01:00.0/iommu_group/devices
> > > > total 0
> > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.0 -> ../../../../devices/pci0000:00/0000:00:01.0
> > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.1 -> ../../../../devices/pci0000:00/0000:00:01.1
> > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.0 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.0
> > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.1 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.1
> > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.0 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.0
> > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.1 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.1
> > > > 
> > > > - eg. both the VGA/HDMI Audio pairs + the two root ports they are plugged into are in the same group:
> > > 
> > > Ick.  Intel has been pretty good about advertising ACS support on their
> > > root ports.  I wonder if this is an oversight or if they are actually
> > > not isolated from each other.
> > > 
> > > > # lspci -n
> > > > ...
> > > > 01:00.0 0300: 1002:683f
> > > > 01:00.1 0403: 1002:aab0
> > > > 02:00.0 0300: 1002:6779
> > > > 02:00.1 0403: 1002:aa98
> > > > ...
> > > > 
> > > > modprobe vfio_pci
> > > > echo 0000:01:00.1 > /sys/bus/pci/devices/0000\:01\:00.1/driver/unbind
> > > > echo 0000:02:00.1 > /sys/bus/pci/devices/0000\:02\:00.1/driver/unbind
> > > > echo 1002 683f > /sys/bus/pci/drivers/vfio-pci/new_id
> > > > echo 1002 aab0 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > > echo 1002 6779 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > > echo 1002 aa98 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > > 
> > > > # lsusb 
> > > > ...
> > > > Bus 001 Device 008: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
> > > > Bus 001 Device 004: ID 046d:c05b Logitech, Inc. M-U0004 810-001317 [B110 Optical USB Mouse]
> > > > ...
> > > > 
> > > > - I also applied your suggested patch to the quirk function in VFIO (see below)
> > > > 
> > > > - Here is a (trimmed for readability) command line I successfully used to boot from the Windows 7 install DVD, 
> > > >   notice the cd and disk device descriptions and the bus parameter - I struggled a while with that 
> > > >   until I came across a comment by Gerd Hoffmann here: https://bugzilla.redhat.com/show_bug.cgi?id=922670 (Thanks, Gerd!)
> > > > 
> > > > 
> > > > qemu-kvm -M q35 \
> > > >   -nodefconfig -readconfig $SRC/qemu/docs/q35-chipset.cfg \
> > > >   -device vfio-pci,host=2:00.0,x-vga=on,multifunction=on,bus=ich9-pcie-port-1,addr=0.0 \
> > > >   -device vfio-pci,host=2:00.1,bus=ich9-pcie-port-1,addr=0.1 \
> > > >   -L $SRC/seabios/out/ -L $SRC/qemu/pc-bios \
> > > >   -vga none -nographic -cpu host -rtc base=localtime -k no -m 8192 -smp 2 \
> > > >   -drive file=/dev/sr0,index=2,media=cdrom,id=cd \
> > > >   -drive file=ivm03.img,index=0,media=disk,id=ivm03 \
> > > >   -device ide-drive,drive=ivm03,bus=ide.0 \
> > > >   -device ide-cd,drive=cd,bus=ide.1 \
> > > >   -net nic,vlan=0,model=virtio -net tap,vlan=0 \
> > > >   -enable-kvm \
> > > >   -device usb-host,hostbus=1,hostaddr=8 \
> > > >   -device usb-host,hostbus=1,hostaddr=4
> > > > 
> > > > - Both the graphics card seemshould really support ACS on s to have a rom but only the HD6450 let itself to "scraping". 
> > > 
> > > Did you try scraping the HD6450 while the HD7700 was the boot VGA and
> > > vica versa?  The boot VGA ROM is handled in a special way and what you
> > > really get is the shadow copy, which isn't what we want.
> > > 
> > > > Anyway, supplying it to vfio did not seem to make any difference.
> > > > 
> > > > find /sys -name rom
> > > > /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/rom
> > > > /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/rom
> > > > ...
> > > > 
> > > > Some observations and remaining unresolved issues:
> > > > 
> > > > - VFIO patch:
> > > >   Initially (while still running with igfx_off) I observed exactly the same behaviour as deniv@lavabit.com
> > > >   reported a while ago: With vfio_pci debug enabled, vfio_pci ended up spinning with repeated calls to
> > > >   vfio_ati_3c3_quirk_read and repeated logs: 
> > > >     vfio: vfio_vga_read(0x3c3, 1) = 0x0
> > > >   I patched up accordingly with 
> > > > 
> > > > 
> > > > diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
> > > > index da0e5f9..a361d06 100644
> > > > --- a/hw/misc/vfio.c
> > > > +++ b/hw/misc/vfio.c
> > > > @@ -1291,7 +1291,7 @@ static uint64_t vfio_ati_3c3_quirk_read(void *opaque,
> > > >      uint64_t data = vfio_vga_read(&vdev->vga.region[QEMU_PCI_VGA_IO_HI],
> > > >                                    addr + quirk->data.base_offset, size);
> > > >  
> > > > -    if (data == quirk->data.address_match) {
> > > > +    if (1 || data == quirk->data.address_match) {
> > > >          data = vfio_pci_read_config(&vdev->pdev, quirk->data.address_val, size);
> > > >          DPRINTF("%s(0x3c3, 1) = 0x%"PRIx64"\n", __func__, data);
> > > >      }
> > > > 
> > > > 
> > > >   This of course did not help much until I actually got the iommu 
> > > >   enabled for the radeons (similar "repeated patters" as deniv reported)
> > > >   but what I have observed after I got it working is that if 
> > > >   I disable the patch above, things are not that well: the Fedora VM 
> > > >   comes up with VGA and the Fedora boot screen, then goes blank when 
> > > >   switching to X.
> > > 
> > > Hmm, I think we'd probably have better luck making that unconditional
> > > until we have reason to do otherwise.
> > > 
> > > > - The fact that the iommu group now extends across all my available graphics 
> > > >   devices now makes it difficult to  get the radeon (or catalyst) driver use to 
> > > >   the other card since the vfio_pci driver needs to hold it.
> > > >   Not a complete showstopper since the vesa driver comes up with 1024x768..
> > > >   Might it be a good idea to have an override option (exception list or similar?) 
> > > >   to allow the vfio_pci to be less restrictive about owning the whole group 
> > > >    - allow functionality over security in such case? This of course is further complicated
> > > >   by the need for graphics drivers to be disabled/enabled already at the kernel prompt..
> > > 
> > > We have a quirk in the kernel that enables us to witelist devices, but
> > > yes, there is no flexibility in this w/o modifying the code and
> > > rebuilding.  (see drivers/pci/quirks.c:pci_dev_acs_enabled and follow
> > > the example above w/ pci_dev_dma_source - function can just return 1)
> > > 
> > > > - There seems to be a bug in the (version F8) UEFI BIOS on the motherboard, 
> > > >   The BIOS offers (undocumented) a full range of selections of which PCIe 
> > > >   (or PCIe 1x) graphics card to use as primary, but any other selection 
> > > >   than the first PCIe 16x slot has no effect and the motherboard reverts 
> > > >   to the first slot, so to be able to test both cards, I had to put the card under test
> > > >   into the second (8x) PCIe slot. I am waiting for feedback from Gigabyte on possible 
> > > >   fixes for this in newer BIOSes.
> > > > 
> > > > - The ultimate goal is to try to consolidate some older Windows desktops as "seats" 
> > > >   on the new system, using the discrete graphics with HDMI/Displayport audio. 
> > > >   With the HD7700 moved to the second PCIe slot I tested both Windows and 
> > > >   Linux guests to try to get some sound through the HDMI audio device. 
> > > >   Windows complains that no usable device is available. On Linux (Fedora 18, KDE desktop), 
> > > >   the system settings -> multimedia dialogue never opens up which seems to indicate that 
> > > >   PulseAudio has problems communicating with the passed through device (?), 
> > > >   any hints/pointers here appreciated. From the vfio log it seems at least
> > > >   config space is accessed ok.
> > > > 
> > > > - There also seems to be issues with radeon and intel_iommu=on - if I try 
> > > >   to enable modesetting and normal X support for the radeon cards, X fails to start.
> > > > 
> > > > - It would be nice if the integrated graphics could be used as the host primary display - 
> > > >   I would be happy if someone has any hints as to if/how the ifgx_off option 
> > > >   could be extended/modified to only affect iommu operation on selected device(s),
> > > >   if at all possible..
> > > 
> > > Let's see what we can discover from your DMAR.  Also send along sudo
> > > lspci -vvv.  Thanks,
> > > 
> > > Alex
> > > 
> > 
> > 
> 
> --Maik
Knut Omang - May 20, 2013, 9:11 p.m.
On Sun, 2013-05-19 at 22:15 -0600, Alex Williamson wrote:
> On Sun, 2013-05-19 at 17:35 +0200, Knut Omang wrote:
> > On Mon, 2013-05-13 at 16:23 -0600, Alex Williamson wrote:
> > > On Mon, 2013-05-13 at 22:55 +0200, Knut Omang wrote:
> > > > Hi all,
> > > > 
> > > > Perfect timing from my perspective, thanks Alex!
> > > > 
> > > > I spent the better part of the weekend testing your branches on a new system 
> > > > I just put together for this purpose, results below..
> > > > 
> > > > On Fri, 2013-05-03 at 16:56 -0600, Alex Williamson wrote:
> > > > ...
> > > > > git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> > > > > git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> > > > 
> > > > System setup: 
> > > > 
> > > > - Fedora 18 on
> > > > - Gigabyte Z77X-UD5H motherboard
> > > > - Intel Core i7 3770 (Ivy bridge w/integrated graphics)
> > > > - 2 discrete graphics cards:
> > > > 
> > > > lspci | egrep 'VGA|Audio'
> > > > 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
> > > > 00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
> > > > 01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Caicos [Radeon HD 6450]
> > > > 01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Caicos HDMI Audio [Radeon HD 6400 Series]
> > > > 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Cape Verde PRO [Radeon HD 7700 Series]
> > > > 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> > > > 
> > > > Short summary:
> > > > 
> > > > - Once I got past a few time consuming obstacles explained below
> > > >    - the graphics part of the graphics/hdmi audio passthrough seems to work perfect
> > > >      on both discrete graphics cards 
> > > >      (though so far only one at at time and with some minor issues, see below)
> > > >    - no success with the hdmi audio yet (ideas for further investigation appreciated!)
> > > 
> > > I've had hdmi audio working with an HD7850, but only in Windows (7) and
> > > it was using legacy interrupts for some reason instead of MSI.  I wonder
> > > if Liux guests might work with snd_hda_intel.enable_msi=0.  I'm not sure
> > > what's wrong with MSI, but it seems to be new with the PCI bus reset
> > > support.
> > 
> > In my first tries, Windows were just using a generic
> > VGA driver, which still seems to work perfect with reboots and everything 
> > and in full screen resolution (1920x1200).
> > However after installing the Catalyst AMD driver stack, upon boot
> > Windows 7 now consequently get a BSOD from the graphics driver
> > with the message:
> > 
> > "Attempt to reset the display driver and recover from timeout failed"
> > - a picture of the BSOD screen attached.
> 
> I've seen that BSOD before, but I don't know how to reproduce it.  It
> seems like I haven't seen it with the PCI bus reset code.  I'm running
> version 13.1 of the catalyst driver, you?

I first tried with the install CD that came with the card - v.13-045
then upgraded to the latest from AMD, catalyst v.13.4 which appears to
be driver v.12.104 - similar behaviour for both. This was with a plain
Windows 7 install from my SP1 DVD. 

With most recommended windows updates and the latest catalyst driver,
the BSOD is gone but instead I see the initial VGA boot screen and the
windows logo, then syncs but no display and then reboot into recovery
mode. (If I try all updates, Windows seems never to be able to recover
from the last reboot)

I have tried without kvm and also with vnc or spice graphics in addition
but in those cases it seems Windows is not able to allocate MMIO
resources for both adapters so I haven't been able to test the catalyst
driver as a secondary windows display.

> > I attach the corresponding vfio log where I added some timing code to
> > make it easier to see when the BSOD happens (with 2 seconds of silence
> > in the log before the VM reboots, I believe this is at 09:28:32-34 in
> > the log.
> 
> Yep, looks like that's where windows starts the BSOD.
> 
> > Similar behaviour both just after reboot/power cycle of the host and
> > subsequent VM boot attempts.
> > 
> > This is still with the HD7700 as passed through device, but after a
> > motherboard firmware upgrade (to F14) which did not seem to affect the
> > observed behaviour on Windows prior to Catalyst install or with Linux
> > guest, neither did it fix the bug in selecting primary devices as I 
> > was hoping for.
> > 
> > Let me know if you have ideas for further debugging this,
> 
> I don't have any great ideas since I don't know how to reproduce the
> timeout.  Double/triple check that you're using the correct
> vfio-vga-reset branches in both qemu and kernel
> 
> # grep VFIO_DEVICE_PCI_BUS_RESET qemu.git/hw/misc/vfio.c
> # grep VFIO_DEVICE_PCI_BUS_RESET linux.git/drivers/vfio/pci/vfio_pci.c

[Matches in both..]
I do believe I have used the right branches all along.

> I didn't see anything telling in your DMAR either.  The system seems to
> have just one DRHD that includes everything, so I'm not sure why you saw
> any behavior change from igfx_off.  Thanks,

After the firmware upgrade, I tried again with the integrated graphics
enabled, this time with more success - I am now able to get a GUI fedora
console on the integrated graphics, but see some colorful artifacts
there during the VGA startup on one of the Radeon cards, which goes away
with a toggle to another console and back.

Seems I have slightly mislead you with the DMAR table - sorry about that
- the table I posted was with the igfx disabled, with the igfx enabled I
see one more hardware unit dedicated to the igfx if I am able to
interpret it right (attached)

Both the HD7700 and the HD6450 behave very similar and both still starts
and displays Windows fine if I disable the Catalyst driver.

Knut

> Alex
> 
> > > > - Contrary to deniv@lavabit.com I had no success with using pci-assign for VGA
> > > >   with a standard fedora 18 kernel and fairly recent qemu, nor with your branches, 
> > > > 
> > > > Details:
> > > > 
> > > > - I started off with the required kernel parameter 'intel_iommu=on' + necessary parameters for disabling radeon
> > > >    (radeon.modeset=0 rd.driver.blacklist=radeon) using the integrated graphics as primary display
> > > >    - this caused the system to freeze (with color artifacts on the console)
> > > > 
> > > > - In my naivity and because of the "i" in ifgx I tried both with 
> > > >   'intel_iommu=ifgx_off' and then 'intel_iommu=on,igfx_off' 
> > > >   and a full set of combinations of vfio, cards, kernels and pci-assign before I suspected 
> > > >   that iommu support was turned off for **all** graphics cards with igfx_off
> > > 
> > > I'm not sure why this is, looks like the code only tries to turn it off
> > > when only graphics is under the remapping device.  We'd probably need to
> > > see the DMAR to know more (/sys/firmware/acpi/tables/DMAR).
> > > 
> > > > - The solution was to have integrated graphics turned off in the BIOS, and 'intel_iommu=on':
> > > > 
> > > > - iommu groups:
> > > > 
> > > > ls -l /sys/bus/pci/devices/0000:01:00.0/iommu_group/devices
> > > > total 0
> > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.0 -> ../../../../devices/pci0000:00/0000:00:01.0
> > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.1 -> ../../../../devices/pci0000:00/0000:00:01.1
> > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.0 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.0
> > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.1 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.1
> > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.0 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.0
> > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.1 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.1
> > > > 
> > > > - eg. both the VGA/HDMI Audio pairs + the two root ports they are plugged into are in the same group:
> > > 
> > > Ick.  Intel has been pretty good about advertising ACS support on their
> > > root ports.  I wonder if this is an oversight or if they are actually
> > > not isolated from each other.
> > > 
> > > > # lspci -n
> > > > ...
> > > > 01:00.0 0300: 1002:683f
> > > > 01:00.1 0403: 1002:aab0
> > > > 02:00.0 0300: 1002:6779
> > > > 02:00.1 0403: 1002:aa98
> > > > ...
> > > > 
> > > > modprobe vfio_pci
> > > > echo 0000:01:00.1 > /sys/bus/pci/devices/0000\:01\:00.1/driver/unbind
> > > > echo 0000:02:00.1 > /sys/bus/pci/devices/0000\:02\:00.1/driver/unbind
> > > > echo 1002 683f > /sys/bus/pci/drivers/vfio-pci/new_id
> > > > echo 1002 aab0 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > > echo 1002 6779 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > > echo 1002 aa98 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > > 
> > > > # lsusb 
> > > > ...
> > > > Bus 001 Device 008: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
> > > > Bus 001 Device 004: ID 046d:c05b Logitech, Inc. M-U0004 810-001317 [B110 Optical USB Mouse]
> > > > ...
> > > > 
> > > > - I also applied your suggested patch to the quirk function in VFIO (see below)
> > > > 
> > > > - Here is a (trimmed for readability) command line I successfully used to boot from the Windows 7 install DVD, 
> > > >   notice the cd and disk device descriptions and the bus parameter - I struggled a while with that 
> > > >   until I came across a comment by Gerd Hoffmann here: https://bugzilla.redhat.com/show_bug.cgi?id=922670 (Thanks, Gerd!)
> > > > 
> > > > 
> > > > qemu-kvm -M q35 \
> > > >   -nodefconfig -readconfig $SRC/qemu/docs/q35-chipset.cfg \
> > > >   -device vfio-pci,host=2:00.0,x-vga=on,multifunction=on,bus=ich9-pcie-port-1,addr=0.0 \
> > > >   -device vfio-pci,host=2:00.1,bus=ich9-pcie-port-1,addr=0.1 \
> > > >   -L $SRC/seabios/out/ -L $SRC/qemu/pc-bios \
> > > >   -vga none -nographic -cpu host -rtc base=localtime -k no -m 8192 -smp 2 \
> > > >   -drive file=/dev/sr0,index=2,media=cdrom,id=cd \
> > > >   -drive file=ivm03.img,index=0,media=disk,id=ivm03 \
> > > >   -device ide-drive,drive=ivm03,bus=ide.0 \
> > > >   -device ide-cd,drive=cd,bus=ide.1 \
> > > >   -net nic,vlan=0,model=virtio -net tap,vlan=0 \
> > > >   -enable-kvm \
> > > >   -device usb-host,hostbus=1,hostaddr=8 \
> > > >   -device usb-host,hostbus=1,hostaddr=4
> > > > 
> > > > - Both the graphics card seemshould really support ACS on s to have a rom but only the HD6450 let itself to "scraping". 
> > > 
> > > Did you try scraping the HD6450 while the HD7700 was the boot VGA and
> > > vica versa?  The boot VGA ROM is handled in a special way and what you
> > > really get is the shadow copy, which isn't what we want.
> > > 
> > > > Anyway, supplying it to vfio did not seem to make any difference.
> > > > 
> > > > find /sys -name rom
> > > > /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/rom
> > > > /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/rom
> > > > ...
> > > > 
> > > > Some observations and remaining unresolved issues:
> > > > 
> > > > - VFIO patch:
> > > >   Initially (while still running with igfx_off) I observed exactly the same behaviour as deniv@lavabit.com
> > > >   reported a while ago: With vfio_pci debug enabled, vfio_pci ended up spinning with repeated calls to
> > > >   vfio_ati_3c3_quirk_read and repeated logs: 
> > > >     vfio: vfio_vga_read(0x3c3, 1) = 0x0
> > > >   I patched up accordingly with 
> > > > 
> > > > 
> > > > diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
> > > > index da0e5f9..a361d06 100644
> > > > --- a/hw/misc/vfio.c
> > > > +++ b/hw/misc/vfio.c
> > > > @@ -1291,7 +1291,7 @@ static uint64_t vfio_ati_3c3_quirk_read(void *opaque,
> > > >      uint64_t data = vfio_vga_read(&vdev->vga.region[QEMU_PCI_VGA_IO_HI],
> > > >                                    addr + quirk->data.base_offset, size);
> > > >  
> > > > -    if (data == quirk->data.address_match) {
> > > > +    if (1 || data == quirk->data.address_match) {
> > > >          data = vfio_pci_read_config(&vdev->pdev, quirk->data.address_val, size);
> > > >          DPRINTF("%s(0x3c3, 1) = 0x%"PRIx64"\n", __func__, data);
> > > >      }
> > > > 
> > > > 
> > > >   This of course did not help much until I actually got the iommu 
> > > >   enabled for the radeons (similar "repeated patters" as deniv reported)
> > > >   but what I have observed after I got it working is that if 
> > > >   I disable the patch above, things are not that well: the Fedora VM 
> > > >   comes up with VGA and the Fedora boot screen, then goes blank when 
> > > >   switching to X.
> > > 
> > > Hmm, I think we'd probably have better luck making that unconditional
> > > until we have reason to do otherwise.
> > > 
> > > > - The fact that the iommu group now extends across all my available graphics 
> > > >   devices now makes it difficult to  get the radeon (or catalyst) driver use to 
> > > >   the other card since the vfio_pci driver needs to hold it.
> > > >   Not a complete showstopper since the vesa driver comes up with 1024x768..
> > > >   Might it be a good idea to have an override option (exception list or similar?) 
> > > >   to allow the vfio_pci to be less restrictive about owning the whole group 
> > > >    - allow functionality over security in such case? This of course is further complicated
> > > >   by the need for graphics drivers to be disabled/enabled already at the kernel prompt..
> > > 
> > > We have a quirk in the kernel that enables us to witelist devices, but
> > > yes, there is no flexibility in this w/o modifying the code and
> > > rebuilding.  (see drivers/pci/quirks.c:pci_dev_acs_enabled and follow
> > > the example above w/ pci_dev_dma_source - function can just return 1)
> > > 
> > > > - There seems to be a bug in the (version F8) UEFI BIOS on the motherboard, 
> > > >   The BIOS offers (undocumented) a full range of selections of which PCIe 
> > > >   (or PCIe 1x) graphics card to use as primary, but any other selection 
> > > >   than the first PCIe 16x slot has no effect and the motherboard reverts 
> > > >   to the first slot, so to be able to test both cards, I had to put the card under test
> > > >   into the second (8x) PCIe slot. I am waiting for feedback from Gigabyte on possible 
> > > >   fixes for this in newer BIOSes.
> > > > 
> > > > - The ultimate goal is to try to consolidate some older Windows desktops as "seats" 
> > > >   on the new system, using the discrete graphics with HDMI/Displayport audio. 
> > > >   With the HD7700 moved to the second PCIe slot I tested both Windows and 
> > > >   Linux guests to try to get some sound through the HDMI audio device. 
> > > >   Windows complains that no usable device is available. On Linux (Fedora 18, KDE desktop), 
> > > >   the system settings -> multimedia dialogue never opens up which seems to indicate that 
> > > >   PulseAudio has problems communicating with the passed through device (?), 
> > > >   any hints/pointers here appreciated. From the vfio log it seems at least
> > > >   config space is accessed ok.
> > > > 
> > > > - There also seems to be issues with radeon and intel_iommu=on - if I try 
> > > >   to enable modesetting and normal X support for the radeon cards, X fails to start.
> > > > 
> > > > - It would be nice if the integrated graphics could be used as the host primary display - 
> > > >   I would be happy if someone has any hints as to if/how the ifgx_off option 
> > > >   could be extended/modified to only affect iommu operation on selected device(s),
> > > >   if at all possible..
> > > 
> > > Let's see what we can discover from your DMAR.  Also send along sudo
> > > lspci -vvv.  Thanks,
> > > 
> > > Alex
> > > 
> > 
> > 
> 
> 
>
Maik Broemme - May 28, 2013, 1:40 a.m.
Hi Alex,

Maik Broemme <mbroemme@parallels.com> wrote:
> Hi Alex,
> 
> Alex Williamson <alex.williamson@redhat.com> wrote:
> > 
> > Good to hear.  It looks like you have the same motherboard as my AMD
> > test system.  An HD7850 in that system runs quite reliably with the
> > branches above although I do occasionally get VGA palette corruption.
> > 
> 
> Good to know. I'm using a Radeon HD7870 which works fine now. I have the
> same VGA palette corruption occasionally but only until Catalyst driver
> is loaded. So it happens sometimes during VGA init if Windows 7 boot
> logo is shown with very strange colors and went away if Catalyst driver
> is loaded.
> 
> > Are you still require -vga cirrus or do the -vga none, x-vga=on cases
> > work now too?  Thanks,
> > 
> 
> No longer required, -vga none with x-vga=on work on your branches fine
> now. Not sure if there was something more changed because with original
> Fedora 3.9.2 kernel it still doesn't work.
> 

Alex, I have a strange issue now with either the 'vfio-vga-reset'
branches or with the stable 3.9.4 kernel. This is my 'lspci' output:

00:14.2 Audio device: Advanced Micro Devices [AMD] nee ATI SBx00 Azalia (Intel HDA) (rev 40)
01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 520] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GF119 HDMI Audio Controller (rev a1)
02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Pitcairn [Radeon HD 7800]
02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]

The '01:00.0' is my primary device used for Linux and '02:00.0' my
secondary for QEMU. Two new different problems:

1) If the 'nvidia.ko' binary driver is loaded for the first card, QEMU
immediately get stuck after startup and hangs with:

1140  futex(0x7f0ad9b21300, FUTEX_WAIT_PRIVATE, 2, NULL

I have the complete strace output if needed. After that I can only
terminate qemu with 'kill -9' and if I start it again the following
Oops occurs:

[  655.684121] ------------[ cut here ]------------
[  655.684134] WARNING: at lib/list_debug.c:29 __list_add+0x77/0xd0()
[  655.684151] Hardware name: GA-990FXA-UD3
[  655.684271] list_add corruption. next->prev should be prev (ffffffff81ca3d98), but was           (null). (next=ffff88041bc3fe08).
[  655.684477] Modules linked in: vhost_net macvtap macvlan tun arc4 md4 nls_utf8 cifs dns_resolver fscache vfio_pci vfio_iommu_type1 vfio bridge stp llc ip6table_filter ip6_tables it87 hwmon_vid snd_hda_codec_hdmi nvidia(POF) acpi_cpufreq mperf kvm_amd snd_hda_codec_realtek kvm crc32_pclmul crc32c_intel ghash_clmulni_intel snd_hda_intel snd_hda_codec microcode edac_core snd_hwdep fam15h_power snd_seq edac_mce_amd snd_seq_device k10temp r8169 sp5100_tco snd_pcm mii i2c_piix4 snd_page_alloc snd_timer i2c_core snd soundcore mxm_wmi firewire_ohci firewire_core crc_itu_t wmi
[  655.685451] Pid: 2097, comm: qemu-system-x86 Tainted: PF          O 3.9.4-200.fc18.x86_64 #1
[  655.685642] Call Trace:
[  655.685738]  [<ffffffff8105f125>] warn_slowpath_common+0x75/0xa0
[  655.685851]  [<ffffffff8105f206>] warn_slowpath_fmt+0x46/0x50
[  655.685955]  [<ffffffff81316ef7>] __list_add+0x77/0xd0
[  655.686058]  [<ffffffff8108392c>] add_wait_queue+0x3c/0x60
[  655.686162]  [<ffffffff813f241d>] vga_get+0xdd/0x190
[  655.686266]  [<ffffffff81093e40>] ? try_to_wake_up+0x2d0/0x2d0
[  655.686373]  [<ffffffffa01ac625>] vfio_pci_vga_rw+0xb5/0x230 [vfio_pci]
[  655.686481]  [<ffffffffa01aa279>] vfio_pci_rw+0x39/0x80 [vfio_pci]
[  655.686587]  [<ffffffffa01aa30c>] vfio_pci_read+0x1c/0x20 [vfio_pci]
[  655.686701]  [<ffffffffa01a40e3>] vfio_device_fops_read+0x23/0x30 [vfio]
[  655.686814]  [<ffffffff811a01b9>] vfs_read+0xa9/0x180
[  655.686915]  [<ffffffff811a05ba>] sys_pread64+0x9a/0xb0
[  655.687018]  [<ffffffff81669f59>] system_call_fastpath+0x16/0x1b
[  655.687123] ---[ end trace a68eabc3660237b1 ]---

This is always reproducible. I know it is the binary driver and maybe
nobody cares but it is widely used. :)

2) If the 'nouveau.ko' driver is loaded it is even more strange. As soon
as I start qemu all my SATA links get a hard reset and kernel freezes.
No SysRQs are working anymore and only reboot helps. If needed I can
look if I can get some dumps from this freeze because it writes nothing
more to the disks.

But it is getting even more strange. I was putting the secondary card
in another PCI slot and then it started to work with nouveau module
loaded and passthrough ATI card to QEMU. But this worked only until I
started X server with nouveau X driver. As soon as X is running and I
started QEMU it hanged again in FUTEX_WAIT_PRIVATE.

3) Without loading 'nvidia.ko' or 'nouveau.ko' modules it works out of
the box with several start/stop cycles. However I have no X in this
case. ;)

Any ideas? :)

> > Alex
> > 
> 
> --Maik
> 

--Maik
Alex Williamson - May 28, 2013, 3:21 a.m.
On Tue, 2013-05-28 at 03:40 +0200, Maik Broemme wrote:
> Hi Alex,
> 
> Maik Broemme <mbroemme@parallels.com> wrote:
> > Hi Alex,
> > 
> > Alex Williamson <alex.williamson@redhat.com> wrote:
> > > 
> > > Good to hear.  It looks like you have the same motherboard as my AMD
> > > test system.  An HD7850 in that system runs quite reliably with the
> > > branches above although I do occasionally get VGA palette corruption.
> > > 
> > 
> > Good to know. I'm using a Radeon HD7870 which works fine now. I have the
> > same VGA palette corruption occasionally but only until Catalyst driver
> > is loaded. So it happens sometimes during VGA init if Windows 7 boot
> > logo is shown with very strange colors and went away if Catalyst driver
> > is loaded.
> > 
> > > Are you still require -vga cirrus or do the -vga none, x-vga=on cases
> > > work now too?  Thanks,
> > > 
> > 
> > No longer required, -vga none with x-vga=on work on your branches fine
> > now. Not sure if there was something more changed because with original
> > Fedora 3.9.2 kernel it still doesn't work.
> > 
> 
> Alex, I have a strange issue now with either the 'vfio-vga-reset'
> branches or with the stable 3.9.4 kernel. This is my 'lspci' output:
> 
> 00:14.2 Audio device: Advanced Micro Devices [AMD] nee ATI SBx00 Azalia (Intel HDA) (rev 40)
> 01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 520] (rev a1)
> 01:00.1 Audio device: NVIDIA Corporation GF119 HDMI Audio Controller (rev a1)
> 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Pitcairn [Radeon HD 7800]
> 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> 
> The '01:00.0' is my primary device used for Linux and '02:00.0' my
> secondary for QEMU. Two new different problems:
> 
> 1) If the 'nvidia.ko' binary driver is loaded for the first card, QEMU
> immediately get stuck after startup and hangs with:
> 
> 1140  futex(0x7f0ad9b21300, FUTEX_WAIT_PRIVATE, 2, NULL
> 
> I have the complete strace output if needed. After that I can only
> terminate qemu with 'kill -9' and if I start it again the following
> Oops occurs:
> 
> [  655.684121] ------------[ cut here ]------------
> [  655.684134] WARNING: at lib/list_debug.c:29 __list_add+0x77/0xd0()
> [  655.684151] Hardware name: GA-990FXA-UD3
> [  655.684271] list_add corruption. next->prev should be prev (ffffffff81ca3d98), but was           (null). (next=ffff88041bc3fe08).
> [  655.684477] Modules linked in: vhost_net macvtap macvlan tun arc4 md4 nls_utf8 cifs dns_resolver fscache vfio_pci vfio_iommu_type1 vfio bridge stp llc ip6table_filter ip6_tables it87 hwmon_vid snd_hda_codec_hdmi nvidia(POF) acpi_cpufreq mperf kvm_amd snd_hda_codec_realtek kvm crc32_pclmul crc32c_intel ghash_clmulni_intel snd_hda_intel snd_hda_codec microcode edac_core snd_hwdep fam15h_power snd_seq edac_mce_amd snd_seq_device k10temp r8169 sp5100_tco snd_pcm mii i2c_piix4 snd_page_alloc snd_timer i2c_core snd soundcore mxm_wmi firewire_ohci firewire_core crc_itu_t wmi
> [  655.685451] Pid: 2097, comm: qemu-system-x86 Tainted: PF          O 3.9.4-200.fc18.x86_64 #1
> [  655.685642] Call Trace:
> [  655.685738]  [<ffffffff8105f125>] warn_slowpath_common+0x75/0xa0
> [  655.685851]  [<ffffffff8105f206>] warn_slowpath_fmt+0x46/0x50
> [  655.685955]  [<ffffffff81316ef7>] __list_add+0x77/0xd0
> [  655.686058]  [<ffffffff8108392c>] add_wait_queue+0x3c/0x60
> [  655.686162]  [<ffffffff813f241d>] vga_get+0xdd/0x190
> [  655.686266]  [<ffffffff81093e40>] ? try_to_wake_up+0x2d0/0x2d0
> [  655.686373]  [<ffffffffa01ac625>] vfio_pci_vga_rw+0xb5/0x230 [vfio_pci]
> [  655.686481]  [<ffffffffa01aa279>] vfio_pci_rw+0x39/0x80 [vfio_pci]
> [  655.686587]  [<ffffffffa01aa30c>] vfio_pci_read+0x1c/0x20 [vfio_pci]
> [  655.686701]  [<ffffffffa01a40e3>] vfio_device_fops_read+0x23/0x30 [vfio]
> [  655.686814]  [<ffffffff811a01b9>] vfs_read+0xa9/0x180
> [  655.686915]  [<ffffffff811a05ba>] sys_pread64+0x9a/0xb0
> [  655.687018]  [<ffffffff81669f59>] system_call_fastpath+0x16/0x1b
> [  655.687123] ---[ end trace a68eabc3660237b1 ]---
> 
> This is always reproducible. I know it is the binary driver and maybe
> nobody cares but it is widely used. :)

Hmm, so perhaps the first attempt called into the vga arbiter to get the
VGA resources and the hang is because it was never able to get them.
VFIO only uses the interruptible vga_get call, so you were able to kill
the process, but maybe the vga arbiter didn't cleanup so well.  There's
not much we can do if nvidia.ko never releases the VGA resources.  The
VGA arbiter could do a better job with list cleanup on interruption, but
it doesn't seem like it would help you run w/ nvidia.ko in the host.

> 2) If the 'nouveau.ko' driver is loaded it is even more strange. As soon
> as I start qemu all my SATA links get a hard reset and kernel freezes.
> No SysRQs are working anymore and only reboot helps. If needed I can
> look if I can get some dumps from this freeze because it writes nothing
> more to the disks.

This was after a host reboot, I hope?  If you're using the
vfio-vga-reset kernel branch then a secondary bus reset happens when the
guest is started.  I have seen cases on my GA-990FXA-UD3 where the bus
doesn't come back from reset (possibly due to queued I/O on the bus).
After reset we attempt to restore device config space which hangs with
the PCI config space access lock held.  This generally results in soft
lockups and a mostly unusable system.  Does this sound similar to what
you're seeing?  This is the main problem preventing me from trying to
push the PCI bus reset patches upstream.

> But it is getting even more strange. I was putting the secondary card
> in another PCI slot and then it started to work with nouveau module
> loaded and passthrough ATI card to QEMU. But this worked only until I
> started X server with nouveau X driver. As soon as X is running and I
> started QEMU it hanged again in FUTEX_WAIT_PRIVATE.
>
> 3) Without loading 'nvidia.ko' or 'nouveau.ko' modules it works out of
> the box with several start/stop cycles. However I have no X in this
> case. ;)
> 
> Any ideas? :)

I'd suspect that the nouveau X driver also isn't releasing the VGA
resources through the VGA arbiter.  That's pretty disappointing.  You
can check from userspace who own VGA via: sudo head /dev/vga_arbiter.
Without VGA arbiter we have no coordination of legacy VGA resources
between various drivers, but not all drivers support it (vgacon) and
those that do apparently don't attempt to be very fair.  We'll need to
look into fixing Xorg on the host if this is actually the problem.
Thanks,

Alex
Knut Omang - May 28, 2013, 5:33 a.m.
On Mon, 2013-05-20 at 23:11 +0200, Knut Omang wrote:
> On Sun, 2013-05-19 at 22:15 -0600, Alex Williamson wrote:
> > On Sun, 2013-05-19 at 17:35 +0200, Knut Omang wrote:
> > > On Mon, 2013-05-13 at 16:23 -0600, Alex Williamson wrote:
> > > > On Mon, 2013-05-13 at 22:55 +0200, Knut Omang wrote:
> > > > > Hi all,
> > > > > 
> > > > > Perfect timing from my perspective, thanks Alex!
> > > > > 
> > > > > I spent the better part of the weekend testing your branches on a new system 
> > > > > I just put together for this purpose, results below..
> > > > > 
> > > > > On Fri, 2013-05-03 at 16:56 -0600, Alex Williamson wrote:
> > > > > ...
> > > > > > git://github.com/awilliam/linux-vfio.git vfio-vga-reset
> > > > > > git://github.com/awilliam/qemu-vfio.git vfio-vga-reset
> > > > > 
> > > > > System setup: 
> > > > > 
> > > > > - Fedora 18 on
> > > > > - Gigabyte Z77X-UD5H motherboard
> > > > > - Intel Core i7 3770 (Ivy bridge w/integrated graphics)
> > > > > - 2 discrete graphics cards:
> > > > > 
> > > > > lspci | egrep 'VGA|Audio'
> > > > > 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
> > > > > 00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
> > > > > 01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Caicos [Radeon HD 6450]
> > > > > 01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Caicos HDMI Audio [Radeon HD 6400 Series]
> > > > > 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Cape Verde PRO [Radeon HD 7700 Series]
> > > > > 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> > > > > 
> > > > > Short summary:
> > > > > 
> > > > > - Once I got past a few time consuming obstacles explained below
> > > > >    - the graphics part of the graphics/hdmi audio passthrough seems to work perfect
> > > > >      on both discrete graphics cards 
> > > > >      (though so far only one at at time and with some minor issues, see below)
> > > > >    - no success with the hdmi audio yet (ideas for further investigation appreciated!)
> > > > 
> > > > I've had hdmi audio working with an HD7850, but only in Windows (7) and
> > > > it was using legacy interrupts for some reason instead of MSI.  I wonder
> > > > if Liux guests might work with snd_hda_intel.enable_msi=0.  I'm not sure
> > > > what's wrong with MSI, but it seems to be new with the PCI bus reset
> > > > support.
> > > 
> > > In my first tries, Windows were just using a generic
> > > VGA driver, which still seems to work perfect with reboots and everything 
> > > and in full screen resolution (1920x1200).
> > > However after installing the Catalyst AMD driver stack, upon boot
> > > Windows 7 now consequently get a BSOD from the graphics driver
> > > with the message:
> > > 
> > > "Attempt to reset the display driver and recover from timeout failed"
> > > - a picture of the BSOD screen attached.
> > 
> > I've seen that BSOD before, but I don't know how to reproduce it.  It
> > seems like I haven't seen it with the PCI bus reset code.  I'm running
> > version 13.1 of the catalyst driver, you?
> 
> I first tried with the install CD that came with the card - v.13-045
> then upgraded to the latest from AMD, catalyst v.13.4 which appears to
> be driver v.12.104 - similar behaviour for both. This was with a plain
> Windows 7 install from my SP1 DVD. 
> 
> With most recommended windows updates and the latest catalyst driver,
> the BSOD is gone but instead I see the initial VGA boot screen and the
> windows logo, then syncs but no display and then reboot into recovery
> mode. (If I try all updates, Windows seems never to be able to recover
> from the last reboot)
> 
> I have tried without kvm and also with vnc or spice graphics in addition
> but in those cases it seems Windows is not able to allocate MMIO
> resources for both adapters so I haven't been able to test the catalyst
> driver as a secondary windows display.
> 
> > > I attach the corresponding vfio log where I added some timing code to
> > > make it easier to see when the BSOD happens (with 2 seconds of silence
> > > in the log before the VM reboots, I believe this is at 09:28:32-34 in
> > > the log.
> > 
> > Yep, looks like that's where windows starts the BSOD.
> > 
> > > Similar behaviour both just after reboot/power cycle of the host and
> > > subsequent VM boot attempts.
> > > 
> > > This is still with the HD7700 as passed through device, but after a
> > > motherboard firmware upgrade (to F14) which did not seem to affect the
> > > observed behaviour on Windows prior to Catalyst install or with Linux
> > > guest, neither did it fix the bug in selecting primary devices as I 
> > > was hoping for.
> > > 
> > > Let me know if you have ideas for further debugging this,
> > 
> > I don't have any great ideas since I don't know how to reproduce the
> > timeout.  Double/triple check that you're using the correct
> > vfio-vga-reset branches in both qemu and kernel
> > 
> > # grep VFIO_DEVICE_PCI_BUS_RESET qemu.git/hw/misc/vfio.c
> > # grep VFIO_DEVICE_PCI_BUS_RESET linux.git/drivers/vfio/pci/vfio_pci.c
> 
> [Matches in both..]
> I do believe I have used the right branches all along.
> 
> > I didn't see anything telling in your DMAR either.  The system seems to
> > have just one DRHD that includes everything, so I'm not sure why you saw
> > any behavior change from igfx_off.  Thanks,
> 
> After the firmware upgrade, I tried again with the integrated graphics
> enabled, this time with more success - I am now able to get a GUI fedora
> console on the integrated graphics, but see some colorful artifacts
> there during the VGA startup on one of the Radeon cards, which goes away
> with a toggle to another console and back.
> 
> Seems I have slightly mislead you with the DMAR table - sorry about that
> - the table I posted was with the igfx disabled, with the igfx enabled I
> see one more hardware unit dedicated to the igfx if I am able to
> interpret it right (attached)

I noticed this warning in the host log - I suppose it is unrelated but
thought I'd mention it just in case there is some side effect I do not
understand here:

[    0.538124] IOMMU: Setting identity map for device 0000:00:1f.0 [0x0 - 0xffffff]
[    0.538619] PCI-DMA: Intel(R) Virtualization Technology for Directed I/O
[    0.538676] ------------[ cut here ]------------
[    0.538681] WARNING: at drivers/pci/search.c:46 pci_find_upstream_pcie_bridge+0x58/0x80()
[    0.538683] Hardware name: To be filled by O.E.M.
[    0.538685] Modules linked in:
[    0.538687] Pid: 1, comm: swapper/0 Not tainted 3.9.0+ #1
[    0.538689] Call Trace:
[    0.538694]  [<ffffffff8105ed2f>] warn_slowpath_common+0x7f/0xc0
[    0.538697]  [<ffffffff8105ed8a>] warn_slowpath_null+0x1a/0x20
[    0.538699]  [<ffffffff8132dc28>] pci_find_upstream_pcie_bridge+0x58/0x80
[    0.538703]  [<ffffffff8152e26b>] intel_iommu_add_device+0x4b/0x1f0
[    0.538706]  [<ffffffff81525b30>] ? bus_set_iommu+0x60/0x60
[    0.538708]  [<ffffffff81525b63>] add_iommu_group+0x33/0x60
[    0.538712]  [<ffffffff813f38fd>] bus_for_each_dev+0x5d/0xa0
[    0.538714]  [<ffffffff81525b1b>] bus_set_iommu+0x4b/0x60
[    0.538718]  [<ffffffff81d47d61>] intel_iommu_init+0xa72/0xb9a
[    0.538722]  [<ffffffff81d0db94>] ? memblock_find_dma_reserve+0x13d/0x13d
[    0.538724]  [<ffffffff81d0dba7>] pci_iommu_init+0x13/0x3e
[    0.538727]  [<ffffffff8100215a>] do_one_initcall+0x12a/0x180
[    0.538730]  [<ffffffff81d0603b>] kernel_init_freeable+0x150/0x1df
[    0.538732]  [<ffffffff81d0588d>] ? do_early_param+0x8c/0x8c
[    0.538736]  [<ffffffff81646580>] ? rest_init+0x80/0x80
[    0.538738]  [<ffffffff8164658e>] kernel_init+0xe/0xf0
[    0.538742]  [<ffffffff8166af6c>] ret_from_fork+0x7c/0xb0
[    0.538744]  [<ffffffff81646580>] ? rest_init+0x80/0x80
[    0.538749] ---[ end trace f4e8b5168095f9c1 ]---


> Both the HD7700 and the HD6450 behave very similar and both still starts
> and displays Windows fine if I disable the Catalyst driver.
> 
> Knut
> 
> > Alex
> > 
> > > > > - Contrary to deniv@lavabit.com I had no success with using pci-assign for VGA
> > > > >   with a standard fedora 18 kernel and fairly recent qemu, nor with your branches, 
> > > > > 
> > > > > Details:
> > > > > 
> > > > > - I started off with the required kernel parameter 'intel_iommu=on' + necessary parameters for disabling radeon
> > > > >    (radeon.modeset=0 rd.driver.blacklist=radeon) using the integrated graphics as primary display
> > > > >    - this caused the system to freeze (with color artifacts on the console)
> > > > > 
> > > > > - In my naivity and because of the "i" in ifgx I tried both with 
> > > > >   'intel_iommu=ifgx_off' and then 'intel_iommu=on,igfx_off' 
> > > > >   and a full set of combinations of vfio, cards, kernels and pci-assign before I suspected 
> > > > >   that iommu support was turned off for **all** graphics cards with igfx_off
> > > > 
> > > > I'm not sure why this is, looks like the code only tries to turn it off
> > > > when only graphics is under the remapping device.  We'd probably need to
> > > > see the DMAR to know more (/sys/firmware/acpi/tables/DMAR).
> > > > 
> > > > > - The solution was to have integrated graphics turned off in the BIOS, and 'intel_iommu=on':
> > > > > 
> > > > > - iommu groups:
> > > > > 
> > > > > ls -l /sys/bus/pci/devices/0000:01:00.0/iommu_group/devices
> > > > > total 0
> > > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.0 -> ../../../../devices/pci0000:00/0000:00:01.0
> > > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:00:01.1 -> ../../../../devices/pci0000:00/0000:00:01.1
> > > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.0 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.0
> > > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:01:00.1 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.1
> > > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.0 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.0
> > > > > lrwxrwxrwx 1 root root 0 May 11 08:55 0000:02:00.1 -> ../../../../devices/pci0000:00/0000:00:01.1/0000:02:00.1
> > > > > 
> > > > > - eg. both the VGA/HDMI Audio pairs + the two root ports they are plugged into are in the same group:
> > > > 
> > > > Ick.  Intel has been pretty good about advertising ACS support on their
> > > > root ports.  I wonder if this is an oversight or if they are actually
> > > > not isolated from each other.
> > > > 
> > > > > # lspci -n
> > > > > ...
> > > > > 01:00.0 0300: 1002:683f
> > > > > 01:00.1 0403: 1002:aab0
> > > > > 02:00.0 0300: 1002:6779
> > > > > 02:00.1 0403: 1002:aa98
> > > > > ...
> > > > > 
> > > > > modprobe vfio_pci
> > > > > echo 0000:01:00.1 > /sys/bus/pci/devices/0000\:01\:00.1/driver/unbind
> > > > > echo 0000:02:00.1 > /sys/bus/pci/devices/0000\:02\:00.1/driver/unbind
> > > > > echo 1002 683f > /sys/bus/pci/drivers/vfio-pci/new_id
> > > > > echo 1002 aab0 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > > > echo 1002 6779 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > > > echo 1002 aa98 > /sys/bus/pci/drivers/vfio-pci/new_id
> > > > > 
> > > > > # lsusb 
> > > > > ...
> > > > > Bus 001 Device 008: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
> > > > > Bus 001 Device 004: ID 046d:c05b Logitech, Inc. M-U0004 810-001317 [B110 Optical USB Mouse]
> > > > > ...
> > > > > 
> > > > > - I also applied your suggested patch to the quirk function in VFIO (see below)
> > > > > 
> > > > > - Here is a (trimmed for readability) command line I successfully used to boot from the Windows 7 install DVD, 
> > > > >   notice the cd and disk device descriptions and the bus parameter - I struggled a while with that 
> > > > >   until I came across a comment by Gerd Hoffmann here: https://bugzilla.redhat.com/show_bug.cgi?id=922670 (Thanks, Gerd!)
> > > > > 
> > > > > 
> > > > > qemu-kvm -M q35 \
> > > > >   -nodefconfig -readconfig $SRC/qemu/docs/q35-chipset.cfg \
> > > > >   -device vfio-pci,host=2:00.0,x-vga=on,multifunction=on,bus=ich9-pcie-port-1,addr=0.0 \
> > > > >   -device vfio-pci,host=2:00.1,bus=ich9-pcie-port-1,addr=0.1 \
> > > > >   -L $SRC/seabios/out/ -L $SRC/qemu/pc-bios \
> > > > >   -vga none -nographic -cpu host -rtc base=localtime -k no -m 8192 -smp 2 \
> > > > >   -drive file=/dev/sr0,index=2,media=cdrom,id=cd \
> > > > >   -drive file=ivm03.img,index=0,media=disk,id=ivm03 \
> > > > >   -device ide-drive,drive=ivm03,bus=ide.0 \
> > > > >   -device ide-cd,drive=cd,bus=ide.1 \
> > > > >   -net nic,vlan=0,model=virtio -net tap,vlan=0 \
> > > > >   -enable-kvm \
> > > > >   -device usb-host,hostbus=1,hostaddr=8 \
> > > > >   -device usb-host,hostbus=1,hostaddr=4
> > > > > 
> > > > > - Both the graphics card seemshould really support ACS on s to have a rom but only the HD6450 let itself to "scraping". 
> > > > 
> > > > Did you try scraping the HD6450 while the HD7700 was the boot VGA and
> > > > vica versa?  The boot VGA ROM is handled in a special way and what you
> > > > really get is the shadow copy, which isn't what we want.
> > > > 
> > > > > Anyway, supplying it to vfio did not seem to make any difference.
> > > > > 
> > > > > find /sys -name rom
> > > > > /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/rom
> > > > > /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/rom
> > > > > ...
> > > > > 
> > > > > Some observations and remaining unresolved issues:
> > > > > 
> > > > > - VFIO patch:
> > > > >   Initially (while still running with igfx_off) I observed exactly the same behaviour as deniv@lavabit.com
> > > > >   reported a while ago: With vfio_pci debug enabled, vfio_pci ended up spinning with repeated calls to
> > > > >   vfio_ati_3c3_quirk_read and repeated logs: 
> > > > >     vfio: vfio_vga_read(0x3c3, 1) = 0x0
> > > > >   I patched up accordingly with 
> > > > > 
> > > > > 
> > > > > diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
> > > > > index da0e5f9..a361d06 100644
> > > > > --- a/hw/misc/vfio.c
> > > > > +++ b/hw/misc/vfio.c
> > > > > @@ -1291,7 +1291,7 @@ static uint64_t vfio_ati_3c3_quirk_read(void *opaque,
> > > > >      uint64_t data = vfio_vga_read(&vdev->vga.region[QEMU_PCI_VGA_IO_HI],
> > > > >                                    addr + quirk->data.base_offset, size);
> > > > >  
> > > > > -    if (data == quirk->data.address_match) {
> > > > > +    if (1 || data == quirk->data.address_match) {
> > > > >          data = vfio_pci_read_config(&vdev->pdev, quirk->data.address_val, size);
> > > > >          DPRINTF("%s(0x3c3, 1) = 0x%"PRIx64"\n", __func__, data);
> > > > >      }
> > > > > 
> > > > > 
> > > > >   This of course did not help much until I actually got the iommu 
> > > > >   enabled for the radeons (similar "repeated patters" as deniv reported)
> > > > >   but what I have observed after I got it working is that if 
> > > > >   I disable the patch above, things are not that well: the Fedora VM 
> > > > >   comes up with VGA and the Fedora boot screen, then goes blank when 
> > > > >   switching to X.
> > > > 
> > > > Hmm, I think we'd probably have better luck making that unconditional
> > > > until we have reason to do otherwise.
> > > > 
> > > > > - The fact that the iommu group now extends across all my available graphics 
> > > > >   devices now makes it difficult to  get the radeon (or catalyst) driver use to 
> > > > >   the other card since the vfio_pci driver needs to hold it.
> > > > >   Not a complete showstopper since the vesa driver comes up with 1024x768..
> > > > >   Might it be a good idea to have an override option (exception list or similar?) 
> > > > >   to allow the vfio_pci to be less restrictive about owning the whole group 
> > > > >    - allow functionality over security in such case? This of course is further complicated
> > > > >   by the need for graphics drivers to be disabled/enabled already at the kernel prompt..
> > > > 
> > > > We have a quirk in the kernel that enables us to witelist devices, but
> > > > yes, there is no flexibility in this w/o modifying the code and
> > > > rebuilding.  (see drivers/pci/quirks.c:pci_dev_acs_enabled and follow
> > > > the example above w/ pci_dev_dma_source - function can just return 1)
> > > > 
> > > > > - There seems to be a bug in the (version F8) UEFI BIOS on the motherboard, 
> > > > >   The BIOS offers (undocumented) a full range of selections of which PCIe 
> > > > >   (or PCIe 1x) graphics card to use as primary, but any other selection 
> > > > >   than the first PCIe 16x slot has no effect and the motherboard reverts 
> > > > >   to the first slot, so to be able to test both cards, I had to put the card under test
> > > > >   into the second (8x) PCIe slot. I am waiting for feedback from Gigabyte on possible 
> > > > >   fixes for this in newer BIOSes.
> > > > > 
> > > > > - The ultimate goal is to try to consolidate some older Windows desktops as "seats" 
> > > > >   on the new system, using the discrete graphics with HDMI/Displayport audio. 
> > > > >   With the HD7700 moved to the second PCIe slot I tested both Windows and 
> > > > >   Linux guests to try to get some sound through the HDMI audio device. 
> > > > >   Windows complains that no usable device is available. On Linux (Fedora 18, KDE desktop), 
> > > > >   the system settings -> multimedia dialogue never opens up which seems to indicate that 
> > > > >   PulseAudio has problems communicating with the passed through device (?), 
> > > > >   any hints/pointers here appreciated. From the vfio log it seems at least
> > > > >   config space is accessed ok.
> > > > > 
> > > > > - There also seems to be issues with radeon and intel_iommu=on - if I try 
> > > > >   to enable modesetting and normal X support for the radeon cards, X fails to start.
> > > > > 
> > > > > - It would be nice if the integrated graphics could be used as the host primary display - 
> > > > >   I would be happy if someone has any hints as to if/how the ifgx_off option 
> > > > >   could be extended/modified to only affect iommu operation on selected device(s),
> > > > >   if at all possible..
> > > > 
> > > > Let's see what we can discover from your DMAR.  Also send along sudo
> > > > lspci -vvv.  Thanks,
> > > > 
> > > > Alex
> > > > 
> > > 
> > > 
> > 
> > 
> > 
>
Alex Williamson - May 28, 2013, 1:53 p.m.
On Tue, 2013-05-28 at 07:33 +0200, Knut Omang wrote:
> 
> I noticed this warning in the host log - I suppose it is unrelated but
> thought I'd mention it just in case there is some side effect I do not
> understand here:
> 
> [    0.538124] IOMMU: Setting identity map for device 0000:00:1f.0 [0x0 - 0xffffff]
> [    0.538619] PCI-DMA: Intel(R) Virtualization Technology for Directed I/O
> [    0.538676] ------------[ cut here ]------------
> [    0.538681] WARNING: at drivers/pci/search.c:46 pci_find_upstream_pcie_bridge+0x58/0x80()
> [    0.538683] Hardware name: To be filled by O.E.M.
> [    0.538685] Modules linked in:
> [    0.538687] Pid: 1, comm: swapper/0 Not tainted 3.9.0+ #1
> [    0.538689] Call Trace:
> [    0.538694]  [<ffffffff8105ed2f>] warn_slowpath_common+0x7f/0xc0
> [    0.538697]  [<ffffffff8105ed8a>] warn_slowpath_null+0x1a/0x20
> [    0.538699]  [<ffffffff8132dc28>] pci_find_upstream_pcie_bridge+0x58/0x80
> [    0.538703]  [<ffffffff8152e26b>] intel_iommu_add_device+0x4b/0x1f0
> [    0.538706]  [<ffffffff81525b30>] ? bus_set_iommu+0x60/0x60
> [    0.538708]  [<ffffffff81525b63>] add_iommu_group+0x33/0x60
> [    0.538712]  [<ffffffff813f38fd>] bus_for_each_dev+0x5d/0xa0
> [    0.538714]  [<ffffffff81525b1b>] bus_set_iommu+0x4b/0x60
> [    0.538718]  [<ffffffff81d47d61>] intel_iommu_init+0xa72/0xb9a
> [    0.538722]  [<ffffffff81d0db94>] ? memblock_find_dma_reserve+0x13d/0x13d
> [    0.538724]  [<ffffffff81d0dba7>] pci_iommu_init+0x13/0x3e
> [    0.538727]  [<ffffffff8100215a>] do_one_initcall+0x12a/0x180
> [    0.538730]  [<ffffffff81d0603b>] kernel_init_freeable+0x150/0x1df
> [    0.538732]  [<ffffffff81d0588d>] ? do_early_param+0x8c/0x8c
> [    0.538736]  [<ffffffff81646580>] ? rest_init+0x80/0x80
> [    0.538738]  [<ffffffff8164658e>] kernel_init+0xe/0xf0
> [    0.538742]  [<ffffffff8166af6c>] ret_from_fork+0x7c/0xb0
> [    0.538744]  [<ffffffff81646580>] ? rest_init+0x80/0x80
> [    0.538749] ---[ end trace f4e8b5168095f9c1 ]---


There's a bug for this:

https://bugzilla.kernel.org/show_bug.cgi?id=44881


Chances are your system includes one of the non-compliant PCIe-to-PCI
bridges that doesn't include a PCIe capability.  So long as you're not
assigning anything behind that bridge, it shouldn't matter, but I think
we'll setup the wrong grouping and use the wrong source ID for devices
behind it.  Thanks,

Alex
Maik Broemme - May 28, 2013, 6:45 p.m.
Hi,

Maik Broemme <mbroemme@parallels.com> wrote:
> Hi Alex,
> 
> Maik Broemme <mbroemme@parallels.com> wrote:
> > Hi Alex,
> > 
> > Alex Williamson <alex.williamson@redhat.com> wrote:
> > > 
> > > Good to hear.  It looks like you have the same motherboard as my AMD
> > > test system.  An HD7850 in that system runs quite reliably with the
> > > branches above although I do occasionally get VGA palette corruption.
> > > 
> > 
> > Good to know. I'm using a Radeon HD7870 which works fine now. I have the
> > same VGA palette corruption occasionally but only until Catalyst driver
> > is loaded. So it happens sometimes during VGA init if Windows 7 boot
> > logo is shown with very strange colors and went away if Catalyst driver
> > is loaded.
> > 
> > > Are you still require -vga cirrus or do the -vga none, x-vga=on cases
> > > work now too?  Thanks,
> > > 
> > 
> > No longer required, -vga none with x-vga=on work on your branches fine
> > now. Not sure if there was something more changed because with original
> > Fedora 3.9.2 kernel it still doesn't work.
> > 
> 
> Alex, I have a strange issue now with either the 'vfio-vga-reset'
> branches or with the stable 3.9.4 kernel. This is my 'lspci' output:
> 
> 00:14.2 Audio device: Advanced Micro Devices [AMD] nee ATI SBx00 Azalia (Intel HDA) (rev 40)
> 01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 520] (rev a1)
> 01:00.1 Audio device: NVIDIA Corporation GF119 HDMI Audio Controller (rev a1)
> 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Pitcairn [Radeon HD 7800]
> 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> 
> The '01:00.0' is my primary device used for Linux and '02:00.0' my
> secondary for QEMU. Two new different problems:
> 
> 1) If the 'nvidia.ko' binary driver is loaded for the first card, QEMU
> immediately get stuck after startup and hangs with:
> 
> 1140  futex(0x7f0ad9b21300, FUTEX_WAIT_PRIVATE, 2, NULL
> 
> I have the complete strace output if needed. After that I can only
> terminate qemu with 'kill -9' and if I start it again the following
> Oops occurs:
> 
> [  655.684121] ------------[ cut here ]------------
> [  655.684134] WARNING: at lib/list_debug.c:29 __list_add+0x77/0xd0()
> [  655.684151] Hardware name: GA-990FXA-UD3
> [  655.684271] list_add corruption. next->prev should be prev (ffffffff81ca3d98), but was           (null). (next=ffff88041bc3fe08).
> [  655.684477] Modules linked in: vhost_net macvtap macvlan tun arc4 md4 nls_utf8 cifs dns_resolver fscache vfio_pci vfio_iommu_type1 vfio bridge stp llc ip6table_filter ip6_tables it87 hwmon_vid snd_hda_codec_hdmi nvidia(POF) acpi_cpufreq mperf kvm_amd snd_hda_codec_realtek kvm crc32_pclmul crc32c_intel ghash_clmulni_intel snd_hda_intel snd_hda_codec microcode edac_core snd_hwdep fam15h_power snd_seq edac_mce_amd snd_seq_device k10temp r8169 sp5100_tco snd_pcm mii i2c_piix4 snd_page_alloc snd_timer i2c_core snd soundcore mxm_wmi firewire_ohci firewire_core crc_itu_t wmi
> [  655.685451] Pid: 2097, comm: qemu-system-x86 Tainted: PF          O 3.9.4-200.fc18.x86_64 #1
> [  655.685642] Call Trace:
> [  655.685738]  [<ffffffff8105f125>] warn_slowpath_common+0x75/0xa0
> [  655.685851]  [<ffffffff8105f206>] warn_slowpath_fmt+0x46/0x50
> [  655.685955]  [<ffffffff81316ef7>] __list_add+0x77/0xd0
> [  655.686058]  [<ffffffff8108392c>] add_wait_queue+0x3c/0x60
> [  655.686162]  [<ffffffff813f241d>] vga_get+0xdd/0x190
> [  655.686266]  [<ffffffff81093e40>] ? try_to_wake_up+0x2d0/0x2d0
> [  655.686373]  [<ffffffffa01ac625>] vfio_pci_vga_rw+0xb5/0x230 [vfio_pci]
> [  655.686481]  [<ffffffffa01aa279>] vfio_pci_rw+0x39/0x80 [vfio_pci]
> [  655.686587]  [<ffffffffa01aa30c>] vfio_pci_read+0x1c/0x20 [vfio_pci]
> [  655.686701]  [<ffffffffa01a40e3>] vfio_device_fops_read+0x23/0x30 [vfio]
> [  655.686814]  [<ffffffff811a01b9>] vfs_read+0xa9/0x180
> [  655.686915]  [<ffffffff811a05ba>] sys_pread64+0x9a/0xb0
> [  655.687018]  [<ffffffff81669f59>] system_call_fastpath+0x16/0x1b
> [  655.687123] ---[ end trace a68eabc3660237b1 ]---
> 
> This is always reproducible. I know it is the binary driver and maybe
> nobody cares but it is widely used. :)

Here is the DEBUG_VFIO output:

vfio: vfio_initfn(0000:04:00.0) group 14
vfio: region_add 0 - afffffff [0x7f8698000000]
vfio: SKIPPING region_add fec00000 - fec00fff
vfio: SKIPPING region_add fed00000 - fed003ff
vfio: SKIPPING region_add fee00000 - feefffff
vfio: region_add fffe0000 - ffffffff [0x7f88aa400000]
vfio: region_add 100000000 - 24fffffff [0x7f8748000000]
vfio: Device 0000:04:00.0 flags: 3, regions: 9, irgs: 4
vfio: Device 0000:04:00.0 region 0:
vfio:   size: 0x10000000, offset: 0x0, flags: 0x7
vfio: Device 0000:04:00.0 region 1:
vfio:   size: 0x0, offset: 0x10000000000, flags: 0x0
vfio: Device 0000:04:00.0 region 2:
vfio:   size: 0x40000, offset: 0x20000000000, flags: 0x7
vfio: Device 0000:04:00.0 region 3:
vfio:   size: 0x0, offset: 0x30000000000, flags: 0x0
vfio: Device 0000:04:00.0 region 4:
vfio:   size: 0x100, offset: 0x40000000000, flags: 0x3
vfio: Device 0000:04:00.0 region 5:
vfio:   size: 0x0, offset: 0x50000000000, flags: 0x0
vfio: Device 0000:04:00.0 ROM:
vfio:   size: 0x20000, offset: 0x60000000000, flags: 0x1
vfio: Device 0000:04:00.0 config:
vfio:   size: 0x1000, offset: 0x70000000000, flags: 0x3
vfio: vfio_load_rom(0000:04:00.0)
vfio: Enabled ATI/AMD BAR2 0x4000 quirk for device 0000:04:00.0
vfio: Enabled ATI/AMD BAR4 window quirk for device 0000:04:00.0
vfio: Enabled ATI/AMD quirk 0x3c3 BAR4 for device 0000:04:00.0
vfio: 0000:04:00.0 PCI MSI CAP @0xa0
vfio: vfio_pci_read_config(0000:04:00.0, @0x3d, len=0x1) 1
vfio: vfio_pci_read_config(0000:04:00.0, @0x3d, len=0x1) 1
vfio: vfio_enable_intx_kvm(0000:04:00.0) KVM INTx accel enabled
vfio: vfio_enable_intx(0000:04:00.0)
vfio: vfio_initfn(0000:04:00.1) group 14
vfio: Device 0000:04:00.1 flags: 3, regions: 9, irgs: 4
vfio: Device 0000:04:00.1 region 0:
vfio:   size: 0x4000, offset: 0x0, flags: 0x7
vfio: Device 0000:04:00.1 region 1:
vfio:   size: 0x0, offset: 0x10000000000, flags: 0x0
vfio: Device 0000:04:00.1 region 2:
vfio:   size: 0x0, offset: 0x20000000000, flags: 0x0
vfio: Device 0000:04:00.1 region 3:
vfio:   size: 0x0, offset: 0x30000000000, flags: 0x0
vfio: Device 0000:04:00.1 region 4:
vfio:   size: 0x0, offset: 0x40000000000, flags: 0x0
vfio: Device 0000:04:00.1 region 5:
vfio:   size: 0x0, offset: 0x50000000000, flags: 0x0
vfio: Device 0000:04:00.1 ROM:
vfio:   size: 0x0, offset: 0x60000000000, flags: 0x0
vfio: Device 0000:04:00.1 config:
vfio:   size: 0x1000, offset: 0x70000000000, flags: 0x3
vfio: 0000:04:00.1 PCI MSI CAP @0xa0
vfio: vfio_pci_read_config(0000:04:00.1, @0x3d, len=0x1) 2
vfio: vfio_pci_read_config(0000:04:00.1, @0x3d, len=0x1) 2
vfio: vfio_enable_intx_kvm(0000:04:00.1) KVM INTx accel enabled
vfio: vfio_enable_intx(0000:04:00.1)
vfio: region_del 0 - afffffff
vfio: region_add 0 - bffff [0x7f8698000000]
vfio: region_add c0000 - dffff [0x7f88aa200000]
vfio: region_add e0000 - fffff [0x7f88aa400000]
vfio: region_add 100000 - afffffff [0x7f8698100000]
vfio: vfio_pci_reset(0000:04:00.0)
vfio: vfio_disable_intx_kvm(0000:04:00.0) KVM INTx accel disabled
vfio: vfio_disable_intx(0000:04:00.0)
vfio: vfio_pci_read_config(0000:04:00.0, @0x54, len=0x2) 0
vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 3
vfio: vfio_pci_write_config(0000:04:00.0, @0x4, 0x0, len=0x2)
vfio: vfio_pci_read_config(0000:04:00.0, @0x3d, len=0x1) 1
vfio: vfio_enable_intx_kvm(0000:04:00.0) KVM INTx accel enabled
vfio: vfio_enable_intx(0000:04:00.0)
vfio: vfio_pci_reset(0000:04:00.1)
vfio: vfio_disable_intx_kvm(0000:04:00.1) KVM INTx accel disabled
vfio: vfio_disable_intx(0000:04:00.1)
vfio: vfio_pci_read_config(0000:04:00.1, @0x54, len=0x2) 0
vfio: vfio_pci_read_config(0000:04:00.1, @0x4, len=0x2) 6
vfio: vfio_pci_write_config(0000:04:00.1, @0x4, 0x0, len=0x2)
vfio: vfio_pci_read_config(0000:04:00.1, @0x3d, len=0x1) 2
vfio: vfio_enable_intx_kvm(0000:04:00.1) KVM INTx accel enabled
vfio: vfio_enable_intx(0000:04:00.1)
vfio: region_del 0 - bffff
vfio: region_del c0000 - dffff
vfio: region_add 0 - c7fff [0x7f8698000000]
vfio: region_add c8000 - dffff [0x7f88aa208000]
vfio: region_del 0 - c7fff
vfio: region_del c8000 - dffff
vfio: region_add 0 - cffff [0x7f8698000000]
vfio: region_add d0000 - dffff [0x7f88aa210000]
vfio: region_del 0 - cffff
vfio: region_del d0000 - dffff
vfio: region_add 0 - d7fff [0x7f8698000000]
vfio: region_add d8000 - dffff [0x7f88aa218000]
vfio: region_del 0 - d7fff
vfio: region_del d8000 - dffff
vfio: region_add 0 - dffff [0x7f8698000000]
vfio: region_del 0 - dffff
vfio: region_del e0000 - fffff
vfio: region_add 0 - e7fff [0x7f8698000000]
vfio: region_add e8000 - fffff [0x7f88aa408000]
vfio: region_del 0 - e7fff
vfio: region_del e8000 - fffff
vfio: region_add 0 - effff [0x7f8698000000]
vfio: region_add f0000 - fffff [0x7f88aa410000]
vfio: region_del 0 - effff
vfio: region_del f0000 - fffff
vfio: region_del 100000 - afffffff
vfio: region_add 0 - afffffff [0x7f8698000000]
vfio: vfio_pci_read_config(0000:04:00.0, @0x0, len=0x2) 1002
vfio: vfio_pci_read_config(0000:04:00.0, @0xa, len=0x2) 300
vfio: vfio_pci_read_config(0000:04:00.0, @0xe, len=0x1) 80
vfio: vfio_pci_read_config(0000:04:00.1, @0x0, len=0x2) 1002
vfio: vfio_pci_read_config(0000:04:00.1, @0xa, len=0x2) 403
vfio: vfio_pci_read_config(0000:04:00.0, @0x0, len=0x2) 1002
vfio: vfio_pci_read_config(0000:04:00.0, @0xa, len=0x2) 300
vfio: vfio_pci_read_config(0000:04:00.0, @0xe, len=0x1) 80
vfio: vfio_pci_read_config(0000:04:00.1, @0x0, len=0x2) 1002
vfio: vfio_pci_read_config(0000:04:00.1, @0xa, len=0x2) 403
vfio: vfio_pci_read_config(0000:04:00.0, @0x0, len=0x2) 1002
vfio: vfio_pci_read_config(0000:04:00.0, @0x0, len=0x4) 68181002
vfio: vfio_pci_read_config(0000:04:00.0, @0x8, len=0x4) 3000000
vfio: vfio_pci_read_config(0000:04:00.0, @0xe, len=0x1) 80
vfio: vfio_pci_read_config(0000:04:00.0, @0xe, len=0x1) 80
vfio: vfio_pci_read_config(0000:04:00.1, @0x0, len=0x2) 1002
vfio: vfio_pci_read_config(0000:04:00.1, @0x0, len=0x4) aab01002
vfio: vfio_pci_read_config(0000:04:00.1, @0x8, len=0x4) 4030000
vfio: vfio_pci_read_config(0000:04:00.1, @0xe, len=0x1) 80
vfio: SKIPPING region_add b0000000 - bfffffff
vfio: vfio_pci_read_config(0000:04:00.0, @0x10, len=0x4) c000000c
vfio: vfio_pci_write_config(0000:04:00.0, @0x10, 0xffffffff, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x10, len=0x4) f000000c
vfio: vfio_pci_write_config(0000:04:00.0, @0x10, 0xc000000c, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x14, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.0, @0x14, 0xffffffff, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x14, len=0x4) ffffffff
vfio: vfio_pci_write_config(0000:04:00.0, @0x14, 0x0, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x18, len=0x4) fde80004
vfio: vfio_pci_write_config(0000:04:00.0, @0x18, 0xffffffff, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x18, len=0x4) fffc0004
vfio: vfio_pci_write_config(0000:04:00.0, @0x18, 0xfde80004, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x1c, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.0, @0x1c, 0xffffffff, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x1c, len=0x4) ffffffff
vfio: vfio_pci_write_config(0000:04:00.0, @0x1c, 0x0, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x20, len=0x4) ce01
vfio: vfio_pci_write_config(0000:04:00.0, @0x20, 0xffffffff, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x20, len=0x4) ffffff01
vfio: vfio_pci_write_config(0000:04:00.0, @0x20, 0xce01, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x24, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.0, @0x24, 0xffffffff, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x24, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.0, @0x24, 0x0, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x30, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfffff800, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x30, len=0x4) fffe0000
vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0x0, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x10, len=0x4) fdefc004
vfio: vfio_pci_write_config(0000:04:00.1, @0x10, 0xffffffff, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x10, len=0x4) ffffc004
vfio: vfio_pci_write_config(0000:04:00.1, @0x10, 0xfdefc004, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x14, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.1, @0x14, 0xffffffff, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x14, len=0x4) ffffffff
vfio: vfio_pci_write_config(0000:04:00.1, @0x14, 0x0, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x18, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.1, @0x18, 0xffffffff, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x18, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.1, @0x18, 0x0, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x1c, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.1, @0x1c, 0xffffffff, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x1c, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.1, @0x1c, 0x0, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x20, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.1, @0x20, 0xffffffff, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x20, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.1, @0x20, 0x0, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x24, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.1, @0x24, 0xffffffff, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x24, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.1, @0x24, 0x0, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x30, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.1, @0x30, 0xfffff800, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.1, @0x30, len=0x4) 0
vfio: vfio_pci_write_config(0000:04:00.1, @0x30, 0x0, len=0x4)
vfio: vfio_pci_write_config(0000:04:00.0, @0x20, 0xc000, len=0x4)
vfio: vfio_pci_write_config(0000:04:00.0, @0x18, 0xfea00000, len=0x4)
vfio: vfio_pci_write_config(0000:04:00.0, @0x1c, 0x0, len=0x4)
vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfea40000, len=0x4)
vfio: vfio_pci_write_config(0000:04:00.1, @0x10, 0xfea60000, len=0x4)
vfio: vfio_pci_write_config(0000:04:00.1, @0x14, 0x0, len=0x4)
vfio: vfio_pci_write_config(0000:04:00.0, @0x10, 0xe0000000, len=0x4)
vfio: vfio_pci_write_config(0000:04:00.0, @0x14, 0x0, len=0x4)
vfio: SKIPPING region_add feb40000 - feb4002f
vfio: SKIPPING region_add feb40800 - feb40807
vfio: SKIPPING region_add feb41000 - feb4101f
vfio: SKIPPING region_add feb41800 - feb41807
vfio: vfio_update_irq(0000:04:00.1) IRQ moved 20 -> 10
vfio: vfio_disable_intx_kvm(0000:04:00.1) KVM INTx accel disabled
vfio: vfio_enable_intx_kvm(0000:04:00.1) KVM INTx accel enabled
vfio: vfio_update_irq(0000:04:00.0) IRQ moved 23 -> 11
vfio: vfio_disable_intx_kvm(0000:04:00.0) KVM INTx accel disabled
vfio: vfio_enable_intx_kvm(0000:04:00.0) KVM INTx accel enabled
vfio: SKIPPING region_add feb42000 - feb42fff
vfio: vfio_pci_read_config(0000:04:00.0, @0x3d, len=0x1) 1
vfio: vfio_pci_write_config(0000:04:00.0, @0x3c, 0xb, len=0x1)
vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 0
vfio: vfio_pci_write_config(0000:04:00.0, @0x4, 0x103, len=0x2)
vfio: region_add e0000000 - efffffff [0x7f8688000000]
vfio: region_add fea00000 - fea03fff [0x7f88aa7b8000]
vfio: SKIPPING region_add fea04000 - fea04fff
vfio: region_add fea05000 - fea3ffff [0x7f88aa7bd000]
vfio: vfio_pci_read_config(0000:04:00.1, @0x3d, len=0x1) 2
vfio: vfio_pci_write_config(0000:04:00.1, @0x3c, 0xa, len=0x1)
vfio: vfio_pci_read_config(0000:04:00.1, @0x4, len=0x2) 0
vfio: vfio_pci_write_config(0000:04:00.1, @0x4, 0x103, len=0x2)
vfio: region_add fea60000 - fea63fff [0x7f88bc710000]
vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 103
vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 103
vfio: vfio_pci_write_config(0000:04:00.0, @0x4, 0x103, len=0x2)
vfio: region_del 0 - afffffff
vfio: region_add 0 - 9ffff [0x7f8698000000]
vfio: SKIPPING region_add a0000 - bffff
vfio: region_add c0000 - afffffff [0x7f86980c0000]
vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 103
vfio: vfio_pci_read_config(0000:04:00.0, @0x30, len=0x4) fea40000
vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfffffffe, len=0x4)
vfio: vfio_pci_read_config(0000:04:00.0, @0x30, len=0x4) fffe0000
vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfea40001, len=0x4)
vfio: region_add fea40000 - fea5ffff [0x7f88a9e00000]
vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfea40000, len=0x4)
vfio: region_del fea40000 - fea5ffff

Here is the strace output from this failure:

1110  ioctl(14, KVM_RUN, 0)             = 0
1110  pread(20,  <unfinished ...>
1099  <... poll resumed> )              = 1 ([{fd=0, revents=POLLIN}])
1099  futex(0x7ff73ca62fa0, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
1109  <... futex resumed> )             = -1 ETIMEDOUT (Connection timed out)
1109  madvise(0x7ff72fe17000, 8368128, MADV_DONTNEED) = 0
1109  _exit(0)                          = ?
1109  +++ exited with 0 +++

From reading the source 'hw/misc/vfio.c' it looks like the following
in 'vfio_vga_read' never finished:

    if (pread(vga->fd, &buf, size, offset) != size) {
        error_report("%s(,0x%"HWADDR_PRIx", %d) failed: %m",
                     __func__, region->offset + addr, size);
        return (uint64_t)-1;
    }

> 
> 2) If the 'nouveau.ko' driver is loaded it is even more strange. As soon
> as I start qemu all my SATA links get a hard reset and kernel freezes.
> No SysRQs are working anymore and only reboot helps. If needed I can
> look if I can get some dumps from this freeze because it writes nothing
> more to the disks.
> 
> But it is getting even more strange. I was putting the secondary card
> in another PCI slot and then it started to work with nouveau module
> loaded and passthrough ATI card to QEMU. But this worked only until I
> started X server with nouveau X driver. As soon as X is running and I
> started QEMU it hanged again in FUTEX_WAIT_PRIVATE.
> 
> 3) Without loading 'nvidia.ko' or 'nouveau.ko' modules it works out of
> the box with several start/stop cycles. However I have no X in this
> case. ;)
> 
> Any ideas? :)
> 
> > > Alex
> > > 
> > 
> > --Maik
> > 
> 
> --Maik
> 

--Maik
Alex Williamson - May 28, 2013, 10:28 p.m.
On Tue, 2013-05-28 at 20:45 +0200, Maik Broemme wrote:
> Hi,
> 
> Maik Broemme <mbroemme@parallels.com> wrote:
> > Hi Alex,
> > 
> > Maik Broemme <mbroemme@parallels.com> wrote:
> > > Hi Alex,
> > > 
> > > Alex Williamson <alex.williamson@redhat.com> wrote:
> > > > 
> > > > Good to hear.  It looks like you have the same motherboard as my AMD
> > > > test system.  An HD7850 in that system runs quite reliably with the
> > > > branches above although I do occasionally get VGA palette corruption.
> > > > 
> > > 
> > > Good to know. I'm using a Radeon HD7870 which works fine now. I have the
> > > same VGA palette corruption occasionally but only until Catalyst driver
> > > is loaded. So it happens sometimes during VGA init if Windows 7 boot
> > > logo is shown with very strange colors and went away if Catalyst driver
> > > is loaded.
> > > 
> > > > Are you still require -vga cirrus or do the -vga none, x-vga=on cases
> > > > work now too?  Thanks,
> > > > 
> > > 
> > > No longer required, -vga none with x-vga=on work on your branches fine
> > > now. Not sure if there was something more changed because with original
> > > Fedora 3.9.2 kernel it still doesn't work.
> > > 
> > 
> > Alex, I have a strange issue now with either the 'vfio-vga-reset'
> > branches or with the stable 3.9.4 kernel. This is my 'lspci' output:
> > 
> > 00:14.2 Audio device: Advanced Micro Devices [AMD] nee ATI SBx00 Azalia (Intel HDA) (rev 40)
> > 01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 520] (rev a1)
> > 01:00.1 Audio device: NVIDIA Corporation GF119 HDMI Audio Controller (rev a1)
> > 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Pitcairn [Radeon HD 7800]
> > 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> > 
> > The '01:00.0' is my primary device used for Linux and '02:00.0' my
> > secondary for QEMU. Two new different problems:
> > 
> > 1) If the 'nvidia.ko' binary driver is loaded for the first card, QEMU
> > immediately get stuck after startup and hangs with:
> > 
> > 1140  futex(0x7f0ad9b21300, FUTEX_WAIT_PRIVATE, 2, NULL
> > 
> > I have the complete strace output if needed. After that I can only
> > terminate qemu with 'kill -9' and if I start it again the following
> > Oops occurs:
> > 
> > [  655.684121] ------------[ cut here ]------------
> > [  655.684134] WARNING: at lib/list_debug.c:29 __list_add+0x77/0xd0()
> > [  655.684151] Hardware name: GA-990FXA-UD3
> > [  655.684271] list_add corruption. next->prev should be prev (ffffffff81ca3d98), but was           (null). (next=ffff88041bc3fe08).
> > [  655.684477] Modules linked in: vhost_net macvtap macvlan tun arc4 md4 nls_utf8 cifs dns_resolver fscache vfio_pci vfio_iommu_type1 vfio bridge stp llc ip6table_filter ip6_tables it87 hwmon_vid snd_hda_codec_hdmi nvidia(POF) acpi_cpufreq mperf kvm_amd snd_hda_codec_realtek kvm crc32_pclmul crc32c_intel ghash_clmulni_intel snd_hda_intel snd_hda_codec microcode edac_core snd_hwdep fam15h_power snd_seq edac_mce_amd snd_seq_device k10temp r8169 sp5100_tco snd_pcm mii i2c_piix4 snd_page_alloc snd_timer i2c_core snd soundcore mxm_wmi firewire_ohci firewire_core crc_itu_t wmi
> > [  655.685451] Pid: 2097, comm: qemu-system-x86 Tainted: PF          O 3.9.4-200.fc18.x86_64 #1
> > [  655.685642] Call Trace:
> > [  655.685738]  [<ffffffff8105f125>] warn_slowpath_common+0x75/0xa0
> > [  655.685851]  [<ffffffff8105f206>] warn_slowpath_fmt+0x46/0x50
> > [  655.685955]  [<ffffffff81316ef7>] __list_add+0x77/0xd0
> > [  655.686058]  [<ffffffff8108392c>] add_wait_queue+0x3c/0x60
> > [  655.686162]  [<ffffffff813f241d>] vga_get+0xdd/0x190
> > [  655.686266]  [<ffffffff81093e40>] ? try_to_wake_up+0x2d0/0x2d0
> > [  655.686373]  [<ffffffffa01ac625>] vfio_pci_vga_rw+0xb5/0x230 [vfio_pci]
> > [  655.686481]  [<ffffffffa01aa279>] vfio_pci_rw+0x39/0x80 [vfio_pci]
> > [  655.686587]  [<ffffffffa01aa30c>] vfio_pci_read+0x1c/0x20 [vfio_pci]
> > [  655.686701]  [<ffffffffa01a40e3>] vfio_device_fops_read+0x23/0x30 [vfio]
> > [  655.686814]  [<ffffffff811a01b9>] vfs_read+0xa9/0x180
> > [  655.686915]  [<ffffffff811a05ba>] sys_pread64+0x9a/0xb0
> > [  655.687018]  [<ffffffff81669f59>] system_call_fastpath+0x16/0x1b
> > [  655.687123] ---[ end trace a68eabc3660237b1 ]---
> > 
> > This is always reproducible. I know it is the binary driver and maybe
> > nobody cares but it is widely used. :)
> 
> Here is the DEBUG_VFIO output:
> 
> vfio: vfio_initfn(0000:04:00.0) group 14
> vfio: region_add 0 - afffffff [0x7f8698000000]
> vfio: SKIPPING region_add fec00000 - fec00fff
> vfio: SKIPPING region_add fed00000 - fed003ff
> vfio: SKIPPING region_add fee00000 - feefffff
> vfio: region_add fffe0000 - ffffffff [0x7f88aa400000]
> vfio: region_add 100000000 - 24fffffff [0x7f8748000000]
> vfio: Device 0000:04:00.0 flags: 3, regions: 9, irgs: 4
> vfio: Device 0000:04:00.0 region 0:
> vfio:   size: 0x10000000, offset: 0x0, flags: 0x7
> vfio: Device 0000:04:00.0 region 1:
> vfio:   size: 0x0, offset: 0x10000000000, flags: 0x0
> vfio: Device 0000:04:00.0 region 2:
> vfio:   size: 0x40000, offset: 0x20000000000, flags: 0x7
> vfio: Device 0000:04:00.0 region 3:
> vfio:   size: 0x0, offset: 0x30000000000, flags: 0x0
> vfio: Device 0000:04:00.0 region 4:
> vfio:   size: 0x100, offset: 0x40000000000, flags: 0x3
> vfio: Device 0000:04:00.0 region 5:
> vfio:   size: 0x0, offset: 0x50000000000, flags: 0x0
> vfio: Device 0000:04:00.0 ROM:
> vfio:   size: 0x20000, offset: 0x60000000000, flags: 0x1
> vfio: Device 0000:04:00.0 config:
> vfio:   size: 0x1000, offset: 0x70000000000, flags: 0x3
> vfio: vfio_load_rom(0000:04:00.0)
> vfio: Enabled ATI/AMD BAR2 0x4000 quirk for device 0000:04:00.0
> vfio: Enabled ATI/AMD BAR4 window quirk for device 0000:04:00.0
> vfio: Enabled ATI/AMD quirk 0x3c3 BAR4 for device 0000:04:00.0
> vfio: 0000:04:00.0 PCI MSI CAP @0xa0
> vfio: vfio_pci_read_config(0000:04:00.0, @0x3d, len=0x1) 1
> vfio: vfio_pci_read_config(0000:04:00.0, @0x3d, len=0x1) 1
> vfio: vfio_enable_intx_kvm(0000:04:00.0) KVM INTx accel enabled
> vfio: vfio_enable_intx(0000:04:00.0)
> vfio: vfio_initfn(0000:04:00.1) group 14
> vfio: Device 0000:04:00.1 flags: 3, regions: 9, irgs: 4
> vfio: Device 0000:04:00.1 region 0:
> vfio:   size: 0x4000, offset: 0x0, flags: 0x7
> vfio: Device 0000:04:00.1 region 1:
> vfio:   size: 0x0, offset: 0x10000000000, flags: 0x0
> vfio: Device 0000:04:00.1 region 2:
> vfio:   size: 0x0, offset: 0x20000000000, flags: 0x0
> vfio: Device 0000:04:00.1 region 3:
> vfio:   size: 0x0, offset: 0x30000000000, flags: 0x0
> vfio: Device 0000:04:00.1 region 4:
> vfio:   size: 0x0, offset: 0x40000000000, flags: 0x0
> vfio: Device 0000:04:00.1 region 5:
> vfio:   size: 0x0, offset: 0x50000000000, flags: 0x0
> vfio: Device 0000:04:00.1 ROM:
> vfio:   size: 0x0, offset: 0x60000000000, flags: 0x0
> vfio: Device 0000:04:00.1 config:
> vfio:   size: 0x1000, offset: 0x70000000000, flags: 0x3
> vfio: 0000:04:00.1 PCI MSI CAP @0xa0
> vfio: vfio_pci_read_config(0000:04:00.1, @0x3d, len=0x1) 2
> vfio: vfio_pci_read_config(0000:04:00.1, @0x3d, len=0x1) 2
> vfio: vfio_enable_intx_kvm(0000:04:00.1) KVM INTx accel enabled
> vfio: vfio_enable_intx(0000:04:00.1)
> vfio: region_del 0 - afffffff
> vfio: region_add 0 - bffff [0x7f8698000000]
> vfio: region_add c0000 - dffff [0x7f88aa200000]
> vfio: region_add e0000 - fffff [0x7f88aa400000]
> vfio: region_add 100000 - afffffff [0x7f8698100000]
> vfio: vfio_pci_reset(0000:04:00.0)
> vfio: vfio_disable_intx_kvm(0000:04:00.0) KVM INTx accel disabled
> vfio: vfio_disable_intx(0000:04:00.0)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x54, len=0x2) 0
> vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 3
> vfio: vfio_pci_write_config(0000:04:00.0, @0x4, 0x0, len=0x2)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x3d, len=0x1) 1
> vfio: vfio_enable_intx_kvm(0000:04:00.0) KVM INTx accel enabled
> vfio: vfio_enable_intx(0000:04:00.0)
> vfio: vfio_pci_reset(0000:04:00.1)
> vfio: vfio_disable_intx_kvm(0000:04:00.1) KVM INTx accel disabled
> vfio: vfio_disable_intx(0000:04:00.1)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x54, len=0x2) 0
> vfio: vfio_pci_read_config(0000:04:00.1, @0x4, len=0x2) 6
> vfio: vfio_pci_write_config(0000:04:00.1, @0x4, 0x0, len=0x2)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x3d, len=0x1) 2
> vfio: vfio_enable_intx_kvm(0000:04:00.1) KVM INTx accel enabled
> vfio: vfio_enable_intx(0000:04:00.1)
> vfio: region_del 0 - bffff
> vfio: region_del c0000 - dffff
> vfio: region_add 0 - c7fff [0x7f8698000000]
> vfio: region_add c8000 - dffff [0x7f88aa208000]
> vfio: region_del 0 - c7fff
> vfio: region_del c8000 - dffff
> vfio: region_add 0 - cffff [0x7f8698000000]
> vfio: region_add d0000 - dffff [0x7f88aa210000]
> vfio: region_del 0 - cffff
> vfio: region_del d0000 - dffff
> vfio: region_add 0 - d7fff [0x7f8698000000]
> vfio: region_add d8000 - dffff [0x7f88aa218000]
> vfio: region_del 0 - d7fff
> vfio: region_del d8000 - dffff
> vfio: region_add 0 - dffff [0x7f8698000000]
> vfio: region_del 0 - dffff
> vfio: region_del e0000 - fffff
> vfio: region_add 0 - e7fff [0x7f8698000000]
> vfio: region_add e8000 - fffff [0x7f88aa408000]
> vfio: region_del 0 - e7fff
> vfio: region_del e8000 - fffff
> vfio: region_add 0 - effff [0x7f8698000000]
> vfio: region_add f0000 - fffff [0x7f88aa410000]
> vfio: region_del 0 - effff
> vfio: region_del f0000 - fffff
> vfio: region_del 100000 - afffffff
> vfio: region_add 0 - afffffff [0x7f8698000000]
> vfio: vfio_pci_read_config(0000:04:00.0, @0x0, len=0x2) 1002
> vfio: vfio_pci_read_config(0000:04:00.0, @0xa, len=0x2) 300
> vfio: vfio_pci_read_config(0000:04:00.0, @0xe, len=0x1) 80
> vfio: vfio_pci_read_config(0000:04:00.1, @0x0, len=0x2) 1002
> vfio: vfio_pci_read_config(0000:04:00.1, @0xa, len=0x2) 403
> vfio: vfio_pci_read_config(0000:04:00.0, @0x0, len=0x2) 1002
> vfio: vfio_pci_read_config(0000:04:00.0, @0xa, len=0x2) 300
> vfio: vfio_pci_read_config(0000:04:00.0, @0xe, len=0x1) 80
> vfio: vfio_pci_read_config(0000:04:00.1, @0x0, len=0x2) 1002
> vfio: vfio_pci_read_config(0000:04:00.1, @0xa, len=0x2) 403
> vfio: vfio_pci_read_config(0000:04:00.0, @0x0, len=0x2) 1002
> vfio: vfio_pci_read_config(0000:04:00.0, @0x0, len=0x4) 68181002
> vfio: vfio_pci_read_config(0000:04:00.0, @0x8, len=0x4) 3000000
> vfio: vfio_pci_read_config(0000:04:00.0, @0xe, len=0x1) 80
> vfio: vfio_pci_read_config(0000:04:00.0, @0xe, len=0x1) 80
> vfio: vfio_pci_read_config(0000:04:00.1, @0x0, len=0x2) 1002
> vfio: vfio_pci_read_config(0000:04:00.1, @0x0, len=0x4) aab01002
> vfio: vfio_pci_read_config(0000:04:00.1, @0x8, len=0x4) 4030000
> vfio: vfio_pci_read_config(0000:04:00.1, @0xe, len=0x1) 80
> vfio: SKIPPING region_add b0000000 - bfffffff
> vfio: vfio_pci_read_config(0000:04:00.0, @0x10, len=0x4) c000000c
> vfio: vfio_pci_write_config(0000:04:00.0, @0x10, 0xffffffff, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x10, len=0x4) f000000c
> vfio: vfio_pci_write_config(0000:04:00.0, @0x10, 0xc000000c, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x14, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.0, @0x14, 0xffffffff, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x14, len=0x4) ffffffff
> vfio: vfio_pci_write_config(0000:04:00.0, @0x14, 0x0, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x18, len=0x4) fde80004
> vfio: vfio_pci_write_config(0000:04:00.0, @0x18, 0xffffffff, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x18, len=0x4) fffc0004
> vfio: vfio_pci_write_config(0000:04:00.0, @0x18, 0xfde80004, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x1c, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.0, @0x1c, 0xffffffff, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x1c, len=0x4) ffffffff
> vfio: vfio_pci_write_config(0000:04:00.0, @0x1c, 0x0, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x20, len=0x4) ce01
> vfio: vfio_pci_write_config(0000:04:00.0, @0x20, 0xffffffff, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x20, len=0x4) ffffff01
> vfio: vfio_pci_write_config(0000:04:00.0, @0x20, 0xce01, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x24, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.0, @0x24, 0xffffffff, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x24, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.0, @0x24, 0x0, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x30, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfffff800, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x30, len=0x4) fffe0000
> vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0x0, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x10, len=0x4) fdefc004
> vfio: vfio_pci_write_config(0000:04:00.1, @0x10, 0xffffffff, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x10, len=0x4) ffffc004
> vfio: vfio_pci_write_config(0000:04:00.1, @0x10, 0xfdefc004, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x14, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.1, @0x14, 0xffffffff, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x14, len=0x4) ffffffff
> vfio: vfio_pci_write_config(0000:04:00.1, @0x14, 0x0, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x18, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.1, @0x18, 0xffffffff, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x18, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.1, @0x18, 0x0, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x1c, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.1, @0x1c, 0xffffffff, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x1c, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.1, @0x1c, 0x0, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x20, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.1, @0x20, 0xffffffff, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x20, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.1, @0x20, 0x0, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x24, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.1, @0x24, 0xffffffff, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x24, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.1, @0x24, 0x0, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x30, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.1, @0x30, 0xfffff800, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x30, len=0x4) 0
> vfio: vfio_pci_write_config(0000:04:00.1, @0x30, 0x0, len=0x4)
> vfio: vfio_pci_write_config(0000:04:00.0, @0x20, 0xc000, len=0x4)
> vfio: vfio_pci_write_config(0000:04:00.0, @0x18, 0xfea00000, len=0x4)
> vfio: vfio_pci_write_config(0000:04:00.0, @0x1c, 0x0, len=0x4)
> vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfea40000, len=0x4)
> vfio: vfio_pci_write_config(0000:04:00.1, @0x10, 0xfea60000, len=0x4)
> vfio: vfio_pci_write_config(0000:04:00.1, @0x14, 0x0, len=0x4)
> vfio: vfio_pci_write_config(0000:04:00.0, @0x10, 0xe0000000, len=0x4)
> vfio: vfio_pci_write_config(0000:04:00.0, @0x14, 0x0, len=0x4)
> vfio: SKIPPING region_add feb40000 - feb4002f
> vfio: SKIPPING region_add feb40800 - feb40807
> vfio: SKIPPING region_add feb41000 - feb4101f
> vfio: SKIPPING region_add feb41800 - feb41807
> vfio: vfio_update_irq(0000:04:00.1) IRQ moved 20 -> 10
> vfio: vfio_disable_intx_kvm(0000:04:00.1) KVM INTx accel disabled
> vfio: vfio_enable_intx_kvm(0000:04:00.1) KVM INTx accel enabled
> vfio: vfio_update_irq(0000:04:00.0) IRQ moved 23 -> 11
> vfio: vfio_disable_intx_kvm(0000:04:00.0) KVM INTx accel disabled
> vfio: vfio_enable_intx_kvm(0000:04:00.0) KVM INTx accel enabled
> vfio: SKIPPING region_add feb42000 - feb42fff
> vfio: vfio_pci_read_config(0000:04:00.0, @0x3d, len=0x1) 1
> vfio: vfio_pci_write_config(0000:04:00.0, @0x3c, 0xb, len=0x1)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 0
> vfio: vfio_pci_write_config(0000:04:00.0, @0x4, 0x103, len=0x2)
> vfio: region_add e0000000 - efffffff [0x7f8688000000]
> vfio: region_add fea00000 - fea03fff [0x7f88aa7b8000]
> vfio: SKIPPING region_add fea04000 - fea04fff
> vfio: region_add fea05000 - fea3ffff [0x7f88aa7bd000]
> vfio: vfio_pci_read_config(0000:04:00.1, @0x3d, len=0x1) 2
> vfio: vfio_pci_write_config(0000:04:00.1, @0x3c, 0xa, len=0x1)
> vfio: vfio_pci_read_config(0000:04:00.1, @0x4, len=0x2) 0
> vfio: vfio_pci_write_config(0000:04:00.1, @0x4, 0x103, len=0x2)
> vfio: region_add fea60000 - fea63fff [0x7f88bc710000]
> vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 103
> vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 103
> vfio: vfio_pci_write_config(0000:04:00.0, @0x4, 0x103, len=0x2)
> vfio: region_del 0 - afffffff
> vfio: region_add 0 - 9ffff [0x7f8698000000]
> vfio: SKIPPING region_add a0000 - bffff
> vfio: region_add c0000 - afffffff [0x7f86980c0000]
> vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 103
> vfio: vfio_pci_read_config(0000:04:00.0, @0x30, len=0x4) fea40000
> vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfffffffe, len=0x4)
> vfio: vfio_pci_read_config(0000:04:00.0, @0x30, len=0x4) fffe0000

Here the option ROM was sized

> vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfea40001, len=0x4)

Then enabled

> vfio: region_add fea40000 - fea5ffff [0x7f88a9e00000]

Adding this memory region

> vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfea40000, len=0x4)
> vfio: region_del fea40000 - fea5ffff

Then disabled, removing the memory region.  Presumably between the
enable and disable the contents were read and copied to 0xc0000, which
is where the VGA BIOS is shadowed.

> Here is the strace output from this failure:
> 
> 1110  ioctl(14, KVM_RUN, 0)             = 0
> 1110  pread(20,  <unfinished ...>
> 1099  <... poll resumed> )              = 1 ([{fd=0, revents=POLLIN}])
> 1099  futex(0x7ff73ca62fa0, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
> 1109  <... futex resumed> )             = -1 ETIMEDOUT (Connection timed out)
> 1109  madvise(0x7ff72fe17000, 8368128, MADV_DONTNEED) = 0
> 1109  _exit(0)                          = ?
> 1109  +++ exited with 0 +++
> 
> From reading the source 'hw/misc/vfio.c' it looks like the following
> in 'vfio_vga_read' never finished:
> 
>     if (pread(vga->fd, &buf, size, offset) != size) {
>         error_report("%s(,0x%"HWADDR_PRIx", %d) failed: %m",
>                      __func__, region->offset + addr, size);
>         return (uint64_t)-1;
>     }

I agree.  Every VGA access requires us to lock the VGA resources on the
device, so if we can't get the lock, we stop making progress.  I took a
look at Xorg last night and it seems like it should be taking and
releasing the VGA arbiter lock in a way that would be compatible with
our use.  That's in the xserver, not the actual display hardware driver,
and it wraps access functions in the arbiter support, so should be
transparent to the drivers.  So for nouveau, it seems like it should
work.  For nvidia, we don't really know, it could be locking the device
from the kernel module.

You could instrument vga_get, vga_tryget, and vga_put to figure out
what's happening.  It might be enough to look at /dev/vga_arbiter at
each step in the sequence to reproduce (sudo head
--lines=1 /dev/vga_arbiter).  Thanks,

Alex

> > 
> > 2) If the 'nouveau.ko' driver is loaded it is even more strange. As soon
> > as I start qemu all my SATA links get a hard reset and kernel freezes.
> > No SysRQs are working anymore and only reboot helps. If needed I can
> > look if I can get some dumps from this freeze because it writes nothing
> > more to the disks.
> > 
> > But it is getting even more strange. I was putting the secondary card
> > in another PCI slot and then it started to work with nouveau module
> > loaded and passthrough ATI card to QEMU. But this worked only until I
> > started X server with nouveau X driver. As soon as X is running and I
> > started QEMU it hanged again in FUTEX_WAIT_PRIVATE.
> > 
> > 3) Without loading 'nvidia.ko' or 'nouveau.ko' modules it works out of
> > the box with several start/stop cycles. However I have no X in this
> > case. ;)
> > 
> > Any ideas? :)
> > 
> > > > Alex
> > > > 
> > > 
> > > --Maik
> > > 
> > 
> > --Maik
> > 
> 
> --Maik
Maik Broemme - May 29, 2013, 3:27 p.m.
Hi,

Alex Williamson <alex.williamson@redhat.com> wrote:
> On Tue, 2013-05-28 at 20:45 +0200, Maik Broemme wrote:
> > Hi,
> > 
> > Maik Broemme <mbroemme@parallels.com> wrote:
> > > Hi Alex,
> > > 
> > > Maik Broemme <mbroemme@parallels.com> wrote:
> > > > Hi Alex,
> > > > 
> > > > Alex Williamson <alex.williamson@redhat.com> wrote:
> > > > > 
> > > > > Good to hear.  It looks like you have the same motherboard as my AMD
> > > > > test system.  An HD7850 in that system runs quite reliably with the
> > > > > branches above although I do occasionally get VGA palette corruption.
> > > > > 
> > > > 
> > > > Good to know. I'm using a Radeon HD7870 which works fine now. I have the
> > > > same VGA palette corruption occasionally but only until Catalyst driver
> > > > is loaded. So it happens sometimes during VGA init if Windows 7 boot
> > > > logo is shown with very strange colors and went away if Catalyst driver
> > > > is loaded.
> > > > 
> > > > > Are you still require -vga cirrus or do the -vga none, x-vga=on cases
> > > > > work now too?  Thanks,
> > > > > 
> > > > 
> > > > No longer required, -vga none with x-vga=on work on your branches fine
> > > > now. Not sure if there was something more changed because with original
> > > > Fedora 3.9.2 kernel it still doesn't work.
> > > > 
> > > 
> > > Alex, I have a strange issue now with either the 'vfio-vga-reset'
> > > branches or with the stable 3.9.4 kernel. This is my 'lspci' output:
> > > 
> > > 00:14.2 Audio device: Advanced Micro Devices [AMD] nee ATI SBx00 Azalia (Intel HDA) (rev 40)
> > > 01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 520] (rev a1)
> > > 01:00.1 Audio device: NVIDIA Corporation GF119 HDMI Audio Controller (rev a1)
> > > 02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Pitcairn [Radeon HD 7800]
> > > 02:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
> > > 
> > > The '01:00.0' is my primary device used for Linux and '02:00.0' my
> > > secondary for QEMU. Two new different problems:
> > > 
> > > 1) If the 'nvidia.ko' binary driver is loaded for the first card, QEMU
> > > immediately get stuck after startup and hangs with:
> > > 
> > > 1140  futex(0x7f0ad9b21300, FUTEX_WAIT_PRIVATE, 2, NULL
> > > 
> > > I have the complete strace output if needed. After that I can only
> > > terminate qemu with 'kill -9' and if I start it again the following
> > > Oops occurs:
> > > 
> > > [  655.684121] ------------[ cut here ]------------
> > > [  655.684134] WARNING: at lib/list_debug.c:29 __list_add+0x77/0xd0()
> > > [  655.684151] Hardware name: GA-990FXA-UD3
> > > [  655.684271] list_add corruption. next->prev should be prev (ffffffff81ca3d98), but was           (null). (next=ffff88041bc3fe08).
> > > [  655.684477] Modules linked in: vhost_net macvtap macvlan tun arc4 md4 nls_utf8 cifs dns_resolver fscache vfio_pci vfio_iommu_type1 vfio bridge stp llc ip6table_filter ip6_tables it87 hwmon_vid snd_hda_codec_hdmi nvidia(POF) acpi_cpufreq mperf kvm_amd snd_hda_codec_realtek kvm crc32_pclmul crc32c_intel ghash_clmulni_intel snd_hda_intel snd_hda_codec microcode edac_core snd_hwdep fam15h_power snd_seq edac_mce_amd snd_seq_device k10temp r8169 sp5100_tco snd_pcm mii i2c_piix4 snd_page_alloc snd_timer i2c_core snd soundcore mxm_wmi firewire_ohci firewire_core crc_itu_t wmi
> > > [  655.685451] Pid: 2097, comm: qemu-system-x86 Tainted: PF          O 3.9.4-200.fc18.x86_64 #1
> > > [  655.685642] Call Trace:
> > > [  655.685738]  [<ffffffff8105f125>] warn_slowpath_common+0x75/0xa0
> > > [  655.685851]  [<ffffffff8105f206>] warn_slowpath_fmt+0x46/0x50
> > > [  655.685955]  [<ffffffff81316ef7>] __list_add+0x77/0xd0
> > > [  655.686058]  [<ffffffff8108392c>] add_wait_queue+0x3c/0x60
> > > [  655.686162]  [<ffffffff813f241d>] vga_get+0xdd/0x190
> > > [  655.686266]  [<ffffffff81093e40>] ? try_to_wake_up+0x2d0/0x2d0
> > > [  655.686373]  [<ffffffffa01ac625>] vfio_pci_vga_rw+0xb5/0x230 [vfio_pci]
> > > [  655.686481]  [<ffffffffa01aa279>] vfio_pci_rw+0x39/0x80 [vfio_pci]
> > > [  655.686587]  [<ffffffffa01aa30c>] vfio_pci_read+0x1c/0x20 [vfio_pci]
> > > [  655.686701]  [<ffffffffa01a40e3>] vfio_device_fops_read+0x23/0x30 [vfio]
> > > [  655.686814]  [<ffffffff811a01b9>] vfs_read+0xa9/0x180
> > > [  655.686915]  [<ffffffff811a05ba>] sys_pread64+0x9a/0xb0
> > > [  655.687018]  [<ffffffff81669f59>] system_call_fastpath+0x16/0x1b
> > > [  655.687123] ---[ end trace a68eabc3660237b1 ]---
> > > 
> > > This is always reproducible. I know it is the binary driver and maybe
> > > nobody cares but it is widely used. :)
> > 
> > Here is the DEBUG_VFIO output:
> > 
> > vfio: vfio_initfn(0000:04:00.0) group 14
> > vfio: region_add 0 - afffffff [0x7f8698000000]
> > vfio: SKIPPING region_add fec00000 - fec00fff
> > vfio: SKIPPING region_add fed00000 - fed003ff
> > vfio: SKIPPING region_add fee00000 - feefffff
> > vfio: region_add fffe0000 - ffffffff [0x7f88aa400000]
> > vfio: region_add 100000000 - 24fffffff [0x7f8748000000]
> > vfio: Device 0000:04:00.0 flags: 3, regions: 9, irgs: 4
> > vfio: Device 0000:04:00.0 region 0:
> > vfio:   size: 0x10000000, offset: 0x0, flags: 0x7
> > vfio: Device 0000:04:00.0 region 1:
> > vfio:   size: 0x0, offset: 0x10000000000, flags: 0x0
> > vfio: Device 0000:04:00.0 region 2:
> > vfio:   size: 0x40000, offset: 0x20000000000, flags: 0x7
> > vfio: Device 0000:04:00.0 region 3:
> > vfio:   size: 0x0, offset: 0x30000000000, flags: 0x0
> > vfio: Device 0000:04:00.0 region 4:
> > vfio:   size: 0x100, offset: 0x40000000000, flags: 0x3
> > vfio: Device 0000:04:00.0 region 5:
> > vfio:   size: 0x0, offset: 0x50000000000, flags: 0x0
> > vfio: Device 0000:04:00.0 ROM:
> > vfio:   size: 0x20000, offset: 0x60000000000, flags: 0x1
> > vfio: Device 0000:04:00.0 config:
> > vfio:   size: 0x1000, offset: 0x70000000000, flags: 0x3
> > vfio: vfio_load_rom(0000:04:00.0)
> > vfio: Enabled ATI/AMD BAR2 0x4000 quirk for device 0000:04:00.0
> > vfio: Enabled ATI/AMD BAR4 window quirk for device 0000:04:00.0
> > vfio: Enabled ATI/AMD quirk 0x3c3 BAR4 for device 0000:04:00.0
> > vfio: 0000:04:00.0 PCI MSI CAP @0xa0
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x3d, len=0x1) 1
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x3d, len=0x1) 1
> > vfio: vfio_enable_intx_kvm(0000:04:00.0) KVM INTx accel enabled
> > vfio: vfio_enable_intx(0000:04:00.0)
> > vfio: vfio_initfn(0000:04:00.1) group 14
> > vfio: Device 0000:04:00.1 flags: 3, regions: 9, irgs: 4
> > vfio: Device 0000:04:00.1 region 0:
> > vfio:   size: 0x4000, offset: 0x0, flags: 0x7
> > vfio: Device 0000:04:00.1 region 1:
> > vfio:   size: 0x0, offset: 0x10000000000, flags: 0x0
> > vfio: Device 0000:04:00.1 region 2:
> > vfio:   size: 0x0, offset: 0x20000000000, flags: 0x0
> > vfio: Device 0000:04:00.1 region 3:
> > vfio:   size: 0x0, offset: 0x30000000000, flags: 0x0
> > vfio: Device 0000:04:00.1 region 4:
> > vfio:   size: 0x0, offset: 0x40000000000, flags: 0x0
> > vfio: Device 0000:04:00.1 region 5:
> > vfio:   size: 0x0, offset: 0x50000000000, flags: 0x0
> > vfio: Device 0000:04:00.1 ROM:
> > vfio:   size: 0x0, offset: 0x60000000000, flags: 0x0
> > vfio: Device 0000:04:00.1 config:
> > vfio:   size: 0x1000, offset: 0x70000000000, flags: 0x3
> > vfio: 0000:04:00.1 PCI MSI CAP @0xa0
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x3d, len=0x1) 2
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x3d, len=0x1) 2
> > vfio: vfio_enable_intx_kvm(0000:04:00.1) KVM INTx accel enabled
> > vfio: vfio_enable_intx(0000:04:00.1)
> > vfio: region_del 0 - afffffff
> > vfio: region_add 0 - bffff [0x7f8698000000]
> > vfio: region_add c0000 - dffff [0x7f88aa200000]
> > vfio: region_add e0000 - fffff [0x7f88aa400000]
> > vfio: region_add 100000 - afffffff [0x7f8698100000]
> > vfio: vfio_pci_reset(0000:04:00.0)
> > vfio: vfio_disable_intx_kvm(0000:04:00.0) KVM INTx accel disabled
> > vfio: vfio_disable_intx(0000:04:00.0)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x54, len=0x2) 0
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 3
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x4, 0x0, len=0x2)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x3d, len=0x1) 1
> > vfio: vfio_enable_intx_kvm(0000:04:00.0) KVM INTx accel enabled
> > vfio: vfio_enable_intx(0000:04:00.0)
> > vfio: vfio_pci_reset(0000:04:00.1)
> > vfio: vfio_disable_intx_kvm(0000:04:00.1) KVM INTx accel disabled
> > vfio: vfio_disable_intx(0000:04:00.1)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x54, len=0x2) 0
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x4, len=0x2) 6
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x4, 0x0, len=0x2)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x3d, len=0x1) 2
> > vfio: vfio_enable_intx_kvm(0000:04:00.1) KVM INTx accel enabled
> > vfio: vfio_enable_intx(0000:04:00.1)
> > vfio: region_del 0 - bffff
> > vfio: region_del c0000 - dffff
> > vfio: region_add 0 - c7fff [0x7f8698000000]
> > vfio: region_add c8000 - dffff [0x7f88aa208000]
> > vfio: region_del 0 - c7fff
> > vfio: region_del c8000 - dffff
> > vfio: region_add 0 - cffff [0x7f8698000000]
> > vfio: region_add d0000 - dffff [0x7f88aa210000]
> > vfio: region_del 0 - cffff
> > vfio: region_del d0000 - dffff
> > vfio: region_add 0 - d7fff [0x7f8698000000]
> > vfio: region_add d8000 - dffff [0x7f88aa218000]
> > vfio: region_del 0 - d7fff
> > vfio: region_del d8000 - dffff
> > vfio: region_add 0 - dffff [0x7f8698000000]
> > vfio: region_del 0 - dffff
> > vfio: region_del e0000 - fffff
> > vfio: region_add 0 - e7fff [0x7f8698000000]
> > vfio: region_add e8000 - fffff [0x7f88aa408000]
> > vfio: region_del 0 - e7fff
> > vfio: region_del e8000 - fffff
> > vfio: region_add 0 - effff [0x7f8698000000]
> > vfio: region_add f0000 - fffff [0x7f88aa410000]
> > vfio: region_del 0 - effff
> > vfio: region_del f0000 - fffff
> > vfio: region_del 100000 - afffffff
> > vfio: region_add 0 - afffffff [0x7f8698000000]
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x0, len=0x2) 1002
> > vfio: vfio_pci_read_config(0000:04:00.0, @0xa, len=0x2) 300
> > vfio: vfio_pci_read_config(0000:04:00.0, @0xe, len=0x1) 80
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x0, len=0x2) 1002
> > vfio: vfio_pci_read_config(0000:04:00.1, @0xa, len=0x2) 403
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x0, len=0x2) 1002
> > vfio: vfio_pci_read_config(0000:04:00.0, @0xa, len=0x2) 300
> > vfio: vfio_pci_read_config(0000:04:00.0, @0xe, len=0x1) 80
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x0, len=0x2) 1002
> > vfio: vfio_pci_read_config(0000:04:00.1, @0xa, len=0x2) 403
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x0, len=0x2) 1002
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x0, len=0x4) 68181002
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x8, len=0x4) 3000000
> > vfio: vfio_pci_read_config(0000:04:00.0, @0xe, len=0x1) 80
> > vfio: vfio_pci_read_config(0000:04:00.0, @0xe, len=0x1) 80
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x0, len=0x2) 1002
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x0, len=0x4) aab01002
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x8, len=0x4) 4030000
> > vfio: vfio_pci_read_config(0000:04:00.1, @0xe, len=0x1) 80
> > vfio: SKIPPING region_add b0000000 - bfffffff
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x10, len=0x4) c000000c
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x10, 0xffffffff, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x10, len=0x4) f000000c
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x10, 0xc000000c, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x14, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x14, 0xffffffff, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x14, len=0x4) ffffffff
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x14, 0x0, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x18, len=0x4) fde80004
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x18, 0xffffffff, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x18, len=0x4) fffc0004
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x18, 0xfde80004, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x1c, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x1c, 0xffffffff, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x1c, len=0x4) ffffffff
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x1c, 0x0, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x20, len=0x4) ce01
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x20, 0xffffffff, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x20, len=0x4) ffffff01
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x20, 0xce01, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x24, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x24, 0xffffffff, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x24, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x24, 0x0, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x30, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfffff800, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x30, len=0x4) fffe0000
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0x0, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x10, len=0x4) fdefc004
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x10, 0xffffffff, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x10, len=0x4) ffffc004
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x10, 0xfdefc004, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x14, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x14, 0xffffffff, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x14, len=0x4) ffffffff
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x14, 0x0, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x18, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x18, 0xffffffff, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x18, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x18, 0x0, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x1c, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x1c, 0xffffffff, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x1c, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x1c, 0x0, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x20, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x20, 0xffffffff, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x20, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x20, 0x0, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x24, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x24, 0xffffffff, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x24, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x24, 0x0, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x30, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x30, 0xfffff800, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x30, len=0x4) 0
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x30, 0x0, len=0x4)
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x20, 0xc000, len=0x4)
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x18, 0xfea00000, len=0x4)
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x1c, 0x0, len=0x4)
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfea40000, len=0x4)
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x10, 0xfea60000, len=0x4)
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x14, 0x0, len=0x4)
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x10, 0xe0000000, len=0x4)
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x14, 0x0, len=0x4)
> > vfio: SKIPPING region_add feb40000 - feb4002f
> > vfio: SKIPPING region_add feb40800 - feb40807
> > vfio: SKIPPING region_add feb41000 - feb4101f
> > vfio: SKIPPING region_add feb41800 - feb41807
> > vfio: vfio_update_irq(0000:04:00.1) IRQ moved 20 -> 10
> > vfio: vfio_disable_intx_kvm(0000:04:00.1) KVM INTx accel disabled
> > vfio: vfio_enable_intx_kvm(0000:04:00.1) KVM INTx accel enabled
> > vfio: vfio_update_irq(0000:04:00.0) IRQ moved 23 -> 11
> > vfio: vfio_disable_intx_kvm(0000:04:00.0) KVM INTx accel disabled
> > vfio: vfio_enable_intx_kvm(0000:04:00.0) KVM INTx accel enabled
> > vfio: SKIPPING region_add feb42000 - feb42fff
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x3d, len=0x1) 1
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x3c, 0xb, len=0x1)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 0
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x4, 0x103, len=0x2)
> > vfio: region_add e0000000 - efffffff [0x7f8688000000]
> > vfio: region_add fea00000 - fea03fff [0x7f88aa7b8000]
> > vfio: SKIPPING region_add fea04000 - fea04fff
> > vfio: region_add fea05000 - fea3ffff [0x7f88aa7bd000]
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x3d, len=0x1) 2
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x3c, 0xa, len=0x1)
> > vfio: vfio_pci_read_config(0000:04:00.1, @0x4, len=0x2) 0
> > vfio: vfio_pci_write_config(0000:04:00.1, @0x4, 0x103, len=0x2)
> > vfio: region_add fea60000 - fea63fff [0x7f88bc710000]
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 103
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 103
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x4, 0x103, len=0x2)
> > vfio: region_del 0 - afffffff
> > vfio: region_add 0 - 9ffff [0x7f8698000000]
> > vfio: SKIPPING region_add a0000 - bffff
> > vfio: region_add c0000 - afffffff [0x7f86980c0000]
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x4, len=0x2) 103
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x30, len=0x4) fea40000
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfffffffe, len=0x4)
> > vfio: vfio_pci_read_config(0000:04:00.0, @0x30, len=0x4) fffe0000
> 
> Here the option ROM was sized
> 
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfea40001, len=0x4)
> 
> Then enabled
> 
> > vfio: region_add fea40000 - fea5ffff [0x7f88a9e00000]
> 
> Adding this memory region
> 
> > vfio: vfio_pci_write_config(0000:04:00.0, @0x30, 0xfea40000, len=0x4)
> > vfio: region_del fea40000 - fea5ffff
> 
> Then disabled, removing the memory region.  Presumably between the
> enable and disable the contents were read and copied to 0xc0000, which
> is where the VGA BIOS is shadowed.
> 
> > Here is the strace output from this failure:
> > 
> > 1110  ioctl(14, KVM_RUN, 0)             = 0
> > 1110  pread(20,  <unfinished ...>
> > 1099  <... poll resumed> )              = 1 ([{fd=0, revents=POLLIN}])
> > 1099  futex(0x7ff73ca62fa0, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
> > 1109  <... futex resumed> )             = -1 ETIMEDOUT (Connection timed out)
> > 1109  madvise(0x7ff72fe17000, 8368128, MADV_DONTNEED) = 0
> > 1109  _exit(0)                          = ?
> > 1109  +++ exited with 0 +++
> > 
> > From reading the source 'hw/misc/vfio.c' it looks like the following
> > in 'vfio_vga_read' never finished:
> > 
> >     if (pread(vga->fd, &buf, size, offset) != size) {
> >         error_report("%s(,0x%"HWADDR_PRIx", %d) failed: %m",
> >                      __func__, region->offset + addr, size);
> >         return (uint64_t)-1;
> >     }
> 
> I agree.  Every VGA access requires us to lock the VGA resources on the
> device, so if we can't get the lock, we stop making progress.  I took a
> look at Xorg last night and it seems like it should be taking and
> releasing the VGA arbiter lock in a way that would be compatible with
> our use.  That's in the xserver, not the actual display hardware driver,
> and it wraps access functions in the arbiter support, so should be
> transparent to the drivers.  So for nouveau, it seems like it should
> work.  For nvidia, we don't really know, it could be locking the device
> from the kernel module.
> 
> You could instrument vga_get, vga_tryget, and vga_put to figure out
> what's happening.  It might be enough to look at /dev/vga_arbiter at
> each step in the sequence to reproduce (sudo head
> --lines=1 /dev/vga_arbiter).  Thanks,
> 

I've played a bit more with it and there are some differences in
behavior with 'nouveau' and 'nvidia' driver. As soon as I load the
binary driver I see the following:

[   18.628676] [drm] Initialized drm 1.1.0 20060810
[   18.668038] nvidia: module license 'NVIDIA' taints kernel.
[   18.668107] Disabling lock debugging due to kernel taint
[   18.676638] vgaarb: device changed decodes: PCI:0000:01:00.0,olddecodes=io+mem,decodes=none:owns=io+mem
[   18.676722] vgaarb: transferring owner from PCI:0000:01:00.0 to PCI:0000:04:00.0
[   18.677007] [drm] Initialized nvidia-drm 0.0.0 20130102 for 0000:01:00.0 on minor 0
[   18.677090] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  319.23  Thu May 16 19:36:02 PDT 2013

root@homer:~# head --lines=1 /dev/vga_arbiter
count:2,PCI:0000:01:00.0,decodes=io+mem,owns=io+mem,locks=none(0:0)
root@homer:~# modprobe nvidia
root@homer:~# head --lines=1 /dev/vga_arbiter
count:1,PCI:0000:01:00.0,decodes=none,owns=none,locks=io+mem(1:1)
root@homer:~# /usr/local/bin/qemu-system-x86_64 \
        -L /usr/local/share/qemu \
        -L /usr/local/share/qemu \
        -M q35 -enable-kvm -cpu host -smp cores=4,threads=1,sockets=1 \
        -m 8192 -rtc base=localtime -k de -nodefaults -vga none \
        -drive file=/home/mbroemme/.kvm/maggie.img,id=drive0,if=none,cache=none,aio=threads \
        -device virtio-blk-pci,drive=drive0,ioeventfd=on \
        -device ioh3420,id=pcie0,multifunction=on \
        -device vfio-pci,host=04:00.0,addr=0.0,bus=pcie0,multifunction=on,x-vga=on \
        -device vfio-pci,host=04:00.1,addr=0.1,bus=pcie0 -monitor stdio -nographic
root@homer:~# head --lines=1 /dev/vga_arbiter
count:1,PCI:0000:01:00.0,decodes=none,owns=none,locks=io+mem(1:1)

It looks like nvidia binary driver locks some resources. :( Whereas
with nouveau driver the VGA arbitration starts first if I start the
VM with VGA passthrough:

[  178.187706] vfio-pci 0000:04:00.0: enabling device (0000 -> 0003)
[  178.209599] vfio_ecap_init: 0000:04:00.0 hiding ecap 0x19@0x270
[  178.209631] vfio_ecap_init: 0000:04:00.0 hiding ecap 0x1b@0x2d0
[  181.198191] vgaarb: device changed decodes: PCI:0000:01:00.0,olddecodes=io+mem,decodes=none:owns=io+mem
[  181.198208] vgaarb: transferring owner from PCI:0000:01:00.0 to PCI:0000:04:00.0

root@homer:~# head --lines=1 /dev/vga_arbiter
count:2,PCI:0000:01:00.0,decodes=io+mem,owns=io+mem,locks=none(0:0)
root@homer:~# /usr/local/bin/qemu-system-x86_64 \
        -L /usr/local/share/qemu \
        -L /usr/local/share/qemu \
        -M q35 -enable-kvm -cpu host -smp cores=4,threads=1,sockets=1 \
        -m 8192 -rtc base=localtime -k de -nodefaults -vga none \
        -drive file=/home/mbroemme/.kvm/maggie.img,id=drive0,if=none,cache=none,aio=threads \
        -device virtio-blk-pci,drive=drive0,ioeventfd=on \
        -device ioh3420,id=pcie0,multifunction=on \
        -device vfio-pci,host=04:00.0,addr=0.0,bus=pcie0,multifunction=on,x-vga=on \
        -device vfio-pci,host=04:00.1,addr=0.1,bus=pcie0 -monitor stdio -nographic
root@homer:~# head --lines=1 /dev/vga_arbiter
count:1,PCI:0000:01:00.0,decodes=none,owns=none,locks=none(0:0)

> Alex
> 
> > > 
> > > 2) If the 'nouveau.ko' driver is loaded it is even more strange. As soon
> > > as I start qemu all my SATA links get a hard reset and kernel freezes.
> > > No SysRQs are working anymore and only reboot helps. If needed I can
> > > look if I can get some dumps from this freeze because it writes nothing
> > > more to the disks.
> > > 
> > > But it is getting even more strange. I was putting the secondary card
> > > in another PCI slot and then it started to work with nouveau module
> > > loaded and passthrough ATI card to QEMU. But this worked only until I
> > > started X server with nouveau X driver. As soon as X is running and I
> > > started QEMU it hanged again in FUTEX_WAIT_PRIVATE.
> > > 
> > > 3) Without loading 'nvidia.ko' or 'nouveau.ko' modules it works out of
> > > the box with several start/stop cycles. However I have no X in this
> > > case. ;)
> > > 
> > > Any ideas? :)
> > > 
> > > > > Alex
> > > > > 
> > > > 
> > > > --Maik
> > > > 
> > > 
> > > --Maik
> > > 
> > 
> > --Maik
> 
> 
> 

Kind regards
Maik

Parallels, Inc.
http://www.parallels.com/

Patch

diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index da0e5f9..a361d06 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -1291,7 +1291,7 @@  static uint64_t vfio_ati_3c3_quirk_read(void *opaque,
     uint64_t data = vfio_vga_read(&vdev->vga.region[QEMU_PCI_VGA_IO_HI],
                                   addr + quirk->data.base_offset, size);
 
-    if (data == quirk->data.address_match) {
+    if (1 || data == quirk->data.address_match) {
         data = vfio_pci_read_config(&vdev->pdev, quirk->data.address_val, size);
         DPRINTF("%s(0x3c3, 1) = 0x%"PRIx64"\n", __func__, data);
     }