76daa3
From aad727a5ecde1ad4935eb8427604d4df5a1f1f35 Mon Sep 17 00:00:00 2001
76daa3
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
76daa3
Date: Fri, 5 May 2017 19:06:14 +0200
76daa3
Subject: [PATCH 2/7] usb-xhci: Fix PCI capability order
76daa3
76daa3
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
76daa3
Message-id: <20170505190614.15987-2-dgilbert@redhat.com>
76daa3
Patchwork-id: 75038
76daa3
O-Subject: [RHEL-7.4 qemu-kvm-rhev PATCH 1/1] usb-xhci: Fix PCI capability order
76daa3
Bugzilla: 1447874
76daa3
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
76daa3
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
76daa3
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
76daa3
RH-Acked-by: Juan Quintela <quintela@redhat.com>
76daa3
76daa3
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
76daa3
76daa3
bz: https://bugzilla.redhat.com/show_bug.cgi?id=1447874
76daa3
brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=13141090
76daa3
upstream: No, see below
76daa3
76daa3
Upstream commit 1108b2f8a9 in 2.7.0 changed the order
76daa3
of the PCI capability chain in the XHCI pci device in the case
76daa3
where the device has the PCIe endpoint capability (i.e. only
76daa3
older machine types, pc-i440fx-2.0 upstream, pc-i440fx-rhel7.0.0
76daa3
apparently for us).
76daa3
76daa3
Changing the order breaks migration compatibility; fixing this
76daa3
upstream would mean breaking the same case going from 2.7.0->current
76daa3
that currently works 2.7.0->2.9.0 - so upstream it's a choice
76daa3
of two breakages.
76daa3
76daa3
Since we never released 2.7.0/2.8.0 we can fix this downstream.
76daa3
76daa3
This reverts the order so that we create the capabilities in the
76daa3
order:
76daa3
   PCIe
76daa3
   MSI
76daa3
   MSI-X
76daa3
76daa3
The symptom is:
76daa3
qemu-kvm: get_pci_config_device: Bad config data: i=0x71 read: a0 device: 0 cmask: ff wmask: 0 w1cmask:0
76daa3
qemu-kvm: Failed to load PCIDevice:config
76daa3
qemu-kvm: Failed to load xhci:parent_obj
76daa3
qemu-kvm: error while loading state for instance 0x0 of device '0000:00:0d.0/xhci'
76daa3
qemu-kvm: load of migration failed: Invalid argument
76daa3
76daa3
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
76daa3
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
76daa3
---
76daa3
 hw/usb/hcd-xhci.c | 12 ++++++------
76daa3
 1 file changed, 6 insertions(+), 6 deletions(-)
76daa3
76daa3
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
76daa3
index c38594c..1555aa4 100644
76daa3
--- a/hw/usb/hcd-xhci.c
76daa3
+++ b/hw/usb/hcd-xhci.c
76daa3
@@ -3575,6 +3575,12 @@ static void usb_xhci_realize(struct PCIDevice *dev, Error **errp)
76daa3
         xhci->max_pstreams_mask = 0;
76daa3
     }
76daa3
 
76daa3
+    if (pci_bus_is_express(dev->bus) ||
76daa3
+        xhci_get_flag(xhci, XHCI_FLAG_FORCE_PCIE_ENDCAP)) {
76daa3
+        ret = pcie_endpoint_cap_init(dev, 0xa0);
76daa3
+        assert(ret >= 0);
76daa3
+    }
76daa3
+
76daa3
     if (xhci->msi != ON_OFF_AUTO_OFF) {
76daa3
         ret = msi_init(dev, 0x70, xhci->numintrs, true, false, &err;;
76daa3
         /* Any error other than -ENOTSUP(board's MSI support is broken)
76daa3
@@ -3623,12 +3629,6 @@ static void usb_xhci_realize(struct PCIDevice *dev, Error **errp)
76daa3
                      PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64,
76daa3
                      &xhci->mem);
76daa3
 
76daa3
-    if (pci_bus_is_express(dev->bus) ||
76daa3
-        xhci_get_flag(xhci, XHCI_FLAG_FORCE_PCIE_ENDCAP)) {
76daa3
-        ret = pcie_endpoint_cap_init(dev, 0xa0);
76daa3
-        assert(ret >= 0);
76daa3
-    }
76daa3
-
76daa3
     if (xhci->msix != ON_OFF_AUTO_OFF) {
76daa3
         /* TODO check for errors, and should fail when msix=on */
76daa3
         msix_init(dev, xhci->numintrs,
76daa3
-- 
76daa3
1.8.3.1
76daa3