Blame SOURCES/0025-usb-xhci-Fix-PCI-capability-order.patch

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