[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 07/10] vfio: add check aer functionality for hotp
From: |
Cao jin |
Subject: |
[Qemu-devel] [PATCH v4 07/10] vfio: add check aer functionality for hotplug device |
Date: |
Mon, 21 Mar 2016 18:08:43 +0800 |
From: Chen Fan <address@hidden>
because we make the vfio functions are combined
in the same way as on the host for aer, so we can
do the aer check when the function 0 was hotplugged.
Signed-off-by: Chen Fan <address@hidden>
---
hw/vfio/pci.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index dce3b6d..9902c87 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2030,6 +2030,35 @@ out:
return;
}
+static void vfio_bus_check_aer_functions(PCIDevice *pdev, Error **errp)
+{
+ VFIOPCIDevice *vdev;
+ PCIDevice *dev;
+ Error *local_err = NULL;
+ int devfn;
+
+ for (devfn = 0; devfn < 8; devfn++) {
+ dev = pci_find_device(pdev->bus, pci_bus_num(pdev->bus),
+ PCI_DEVFN(PCI_SLOT(pdev->devfn), devfn));
+ if (!dev) {
+ continue;
+ }
+ if (!object_dynamic_cast(OBJECT(dev), "vfio-pci")) {
+ continue;
+ }
+ vdev = DO_UPCAST(VFIOPCIDevice, pdev, dev);
+ if (vdev->features & VFIO_FEATURE_ENABLE_AER) {
+ vfio_check_hot_bus_reset(vdev, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+ }
+ }
+
+ return;
+}
+
static void vfio_aer_check_host_bus_reset(Error **errp)
{
VFIOGroup *group;
@@ -2982,6 +3011,22 @@ static int vfio_initfn(PCIDevice *pdev)
}
}
+ /*
+ * If this function is func 0, indicate the closure of the slot.
+ * we get the chance to check aer-enabled devices whether support
+ * hot bus reset.
+ */
+ if (DEVICE(pdev)->hotplugged &&
+ pdev == pci_get_function_0(pdev)) {
+ Error *local_err = NULL;
+
+ vfio_bus_check_aer_functions(pdev, &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ goto out_teardown;
+ }
+ }
+
vfio_register_err_notifier(vdev);
vfio_register_req_notifier(vdev);
vfio_setup_resetfn_quirk(vdev);
--
1.9.3
[Qemu-devel] [PATCH v4 10/10] vfio: add 'aer' property to expose aercap, Cao jin, 2016/03/21
[Qemu-devel] [PATCH v4 09/10] vfio-pci: pass the aer error to guest, Cao jin, 2016/03/21
[Qemu-devel] [PATCH v4 07/10] vfio: add check aer functionality for hotplug device,
Cao jin <=