|
|
ae23c9 |
From 2bbc164594e03b4ab2b436433c7757990801ef49 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Cornelia Huck <cohuck@redhat.com>
|
|
|
ae23c9 |
Date: Wed, 17 Apr 2019 13:57:32 +0100
|
|
|
ae23c9 |
Subject: [PATCH 15/24] s390x/pci: Move some hotplug checks to the pre_plug
|
|
|
ae23c9 |
handler
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Cornelia Huck <cohuck@redhat.com>
|
|
|
ae23c9 |
Message-id: <20190417135741.25297-16-cohuck@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 85797
|
|
|
ae23c9 |
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v2 15/24] s390x/pci: Move some hotplug checks to the pre_plug handler
|
|
|
ae23c9 |
Bugzilla: 1699070
|
|
|
ae23c9 |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
From: David Hildenbrand <david@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Let's move most of the checks to the new pre_plug handler. As a PCI
|
|
|
ae23c9 |
bridge is just a PCI device, we can simplify the code.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Notes: We cannot yet move the MSIX check or device ID creation +
|
|
|
ae23c9 |
zPCI device creation to the pre_plug handler as both parts are not
|
|
|
ae23c9 |
fixed before actual device realization (and therefore after pre_plug and
|
|
|
ae23c9 |
before plug). Once that part is factored out, we can move these parts to
|
|
|
ae23c9 |
the pre_plug handler, too and therefore remove all possible errors from
|
|
|
ae23c9 |
the plug handler.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Reviewed-by: Collin Walling <walling@linux.ibm.com>
|
|
|
ae23c9 |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
|
ae23c9 |
Message-Id: <20190114103110.10909-3-david@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 6069bcdeaceebb91f43bc4762e3f63eee48cd390)
|
|
|
ae23c9 |
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
hw/s390x/s390-pci-bus.c | 41 +++++++++++++++++++++++++----------------
|
|
|
ae23c9 |
1 file changed, 25 insertions(+), 16 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
|
|
|
ae23c9 |
index f1b3334..e3f576a 100644
|
|
|
ae23c9 |
--- a/hw/s390x/s390-pci-bus.c
|
|
|
ae23c9 |
+++ b/hw/s390x/s390-pci-bus.c
|
|
|
ae23c9 |
@@ -822,11 +822,31 @@ static bool s390_pci_alloc_idx(S390pciState *s, S390PCIBusDevice *pbdev)
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
pbdev->idx = idx;
|
|
|
ae23c9 |
- s->next_idx = (idx + 1) & FH_MASK_INDEX;
|
|
|
ae23c9 |
-
|
|
|
ae23c9 |
return true;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+static void s390_pcihost_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
ae23c9 |
+ Error **errp)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ S390pciState *s = S390_PCI_HOST_BRIDGE(hotplug_dev);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
|
|
|
ae23c9 |
+ PCIDevice *pdev = PCI_DEVICE(dev);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
|
|
|
ae23c9 |
+ error_setg(errp, "multifunction not supported in s390");
|
|
|
ae23c9 |
+ return;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) {
|
|
|
ae23c9 |
+ S390PCIBusDevice *pbdev = S390_PCI_DEVICE(dev);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ if (!s390_pci_alloc_idx(s, pbdev)) {
|
|
|
ae23c9 |
+ error_setg(errp, "no slot for plugging zpci device");
|
|
|
ae23c9 |
+ return;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
ae23c9 |
Error **errp)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
@@ -839,11 +859,6 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
ae23c9 |
PCIBridge *pb = PCI_BRIDGE(dev);
|
|
|
ae23c9 |
PCIDevice *pdev = PCI_DEVICE(dev);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
|
|
|
ae23c9 |
- error_setg(errp, "multifunction not supported in s390");
|
|
|
ae23c9 |
- return;
|
|
|
ae23c9 |
- }
|
|
|
ae23c9 |
-
|
|
|
ae23c9 |
pci_bridge_map_irq(pb, dev->id, s390_pci_map_irq);
|
|
|
ae23c9 |
pci_setup_iommu(&pb->sec_bus, s390_pci_dma_iommu, s);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -863,11 +878,6 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
ae23c9 |
} else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
|
|
|
ae23c9 |
pdev = PCI_DEVICE(dev);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
|
|
|
ae23c9 |
- error_setg(errp, "multifunction not supported in s390");
|
|
|
ae23c9 |
- return;
|
|
|
ae23c9 |
- }
|
|
|
ae23c9 |
-
|
|
|
ae23c9 |
if (!dev->id) {
|
|
|
ae23c9 |
/* In the case the PCI device does not define an id */
|
|
|
ae23c9 |
/* we generate one based on the PCI address */
|
|
|
ae23c9 |
@@ -909,10 +919,8 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
ae23c9 |
} else if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) {
|
|
|
ae23c9 |
pbdev = S390_PCI_DEVICE(dev);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- if (!s390_pci_alloc_idx(s, pbdev)) {
|
|
|
ae23c9 |
- error_setg(errp, "no slot for plugging zpci device");
|
|
|
ae23c9 |
- return;
|
|
|
ae23c9 |
- }
|
|
|
ae23c9 |
+ /* the allocated idx is actually getting used */
|
|
|
ae23c9 |
+ s->next_idx = (pbdev->idx + 1) & FH_MASK_INDEX;
|
|
|
ae23c9 |
pbdev->fh = pbdev->idx;
|
|
|
ae23c9 |
QTAILQ_INSERT_TAIL(&s->zpci_devs, pbdev, link);
|
|
|
ae23c9 |
g_hash_table_insert(s->zpci_table, &pbdev->idx, pbdev);
|
|
|
ae23c9 |
@@ -1052,6 +1060,7 @@ static void s390_pcihost_class_init(ObjectClass *klass, void *data)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
dc->reset = s390_pcihost_reset;
|
|
|
ae23c9 |
dc->realize = s390_pcihost_realize;
|
|
|
ae23c9 |
+ hc->pre_plug = s390_pcihost_pre_plug;
|
|
|
ae23c9 |
hc->plug = s390_pcihost_plug;
|
|
|
ae23c9 |
hc->unplug = s390_pcihost_unplug;
|
|
|
ae23c9 |
msi_nonbroken = true;
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|