Blame SOURCES/kvm-s390x-pci-Unplug-remaining-requested-devices-on-pcih.patch

b38b0f
From ed71d0c46408c9fdf4df93ddc4d0610f0b039696 Mon Sep 17 00:00:00 2001
b38b0f
From: Cornelia Huck <cohuck@redhat.com>
b38b0f
Date: Wed, 17 Apr 2019 13:57:39 +0100
b38b0f
Subject: [PATCH 22/24] s390x/pci: Unplug remaining requested devices on
b38b0f
 pcihost reset
b38b0f
b38b0f
RH-Author: Cornelia Huck <cohuck@redhat.com>
b38b0f
Message-id: <20190417135741.25297-23-cohuck@redhat.com>
b38b0f
Patchwork-id: 85805
b38b0f
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v2 22/24] s390x/pci: Unplug remaining requested devices on pcihost reset
b38b0f
Bugzilla: 1699070
b38b0f
RH-Acked-by: David Hildenbrand <david@redhat.com>
b38b0f
RH-Acked-by: Thomas Huth <thuth@redhat.com>
b38b0f
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
b38b0f
b38b0f
From: David Hildenbrand <david@redhat.com>
b38b0f
b38b0f
When resetting the guest we should unplug and remove all devices that
b38b0f
are still pending.
b38b0f
b38b0f
With this patch, the requested device will be unplugged on reboot
b38b0f
(S390_RESET_EXTERNAL and S390_RESET_REIPL, which reset the pcihost bridge
b38b0f
via qemu_devices_reset()).
b38b0f
b38b0f
This approach is similar to what's done for acpi PCI hotplug in
b38b0f
acpi_pcihp_reset() -> acpi_pcihp_update() ->
b38b0f
acpi_pcihp_update_hotplug_bus() -> acpi_pcihp_eject_slot().
b38b0f
b38b0f
s390_pci_generate_plug_event()'s will still be generated, I guess this
b38b0f
is not an issue. The same thing would happen right now when unplugging
b38b0f
a device just before starting the guest.
b38b0f
b38b0f
Signed-off-by: David Hildenbrand <david@redhat.com>
b38b0f
Message-Id: <20190130155733.32742-7-david@redhat.com>
b38b0f
Reviewed-by: Collin Walling <walling@linux.ibm.com>
b38b0f
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
b38b0f
(cherry picked from commit 2313a88fe68cb970532ba1641ffc35c848daae86)
b38b0f
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
b38b0f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
b38b0f
---
b38b0f
 hw/s390x/s390-pci-bus.c | 15 +++++++++++++++
b38b0f
 1 file changed, 15 insertions(+)
b38b0f
b38b0f
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
b38b0f
index 1ba7873..383b3e7 100644
b38b0f
--- a/hw/s390x/s390-pci-bus.c
b38b0f
+++ b/hw/s390x/s390-pci-bus.c
b38b0f
@@ -1097,6 +1097,21 @@ static void s390_pcihost_reset(DeviceState *dev)
b38b0f
 {
b38b0f
     S390pciState *s = S390_PCI_HOST_BRIDGE(dev);
b38b0f
     PCIBus *bus = s->parent_obj.bus;
b38b0f
+    S390PCIBusDevice *pbdev, *next;
b38b0f
+
b38b0f
+    /* Process all pending unplug requests */
b38b0f
+    QTAILQ_FOREACH_SAFE(pbdev, &s->zpci_devs, link, next) {
b38b0f
+        if (pbdev->unplug_requested) {
b38b0f
+            if (pbdev->summary_ind) {
b38b0f
+                pci_dereg_irqs(pbdev);
b38b0f
+            }
b38b0f
+            if (pbdev->iommu->enabled) {
b38b0f
+                pci_dereg_ioat(pbdev->iommu);
b38b0f
+            }
b38b0f
+            pbdev->state = ZPCI_FS_STANDBY;
b38b0f
+            s390_pci_perform_unplug(pbdev);
b38b0f
+        }
b38b0f
+    }
b38b0f
 
b38b0f
     /*
b38b0f
      * When resetting a PCI bridge, the assigned numbers are set to 0. So
b38b0f
-- 
b38b0f
1.8.3.1
b38b0f