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