[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [patch v3 6/9] vfio: add check aer functionality for hotplu
From: |
Cao jin |
Subject: |
[Qemu-devel] [patch v3 6/9] vfio: add check aer functionality for hotplug device |
Date: |
Tue, 15 Mar 2016 09:35:46 +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 | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 9670271..223c0ee 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2029,6 +2029,40 @@ out:
return;
}
+static void vfio_bus_check_aer_functions(PCIDevice *pdev, Error **errp)
+{
+ PCIBus *bus = pdev->bus;
+ VFIOPCIDevice *vdev;
+ PCIDevice *dev;
+ Error *local_err = NULL;
+ int devfn;
+
+ for (devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
+ dev = bus->devices[devfn];
+ if (!dev) {
+ continue;
+ }
+
+ if (pci_get_function_0(dev) != pdev) {
+ return;
+ }
+
+ 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;
@@ -2962,6 +2996,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 v3 0/9] vfio-pci: pass the aer error to guest, part2, Cao jin, 2016/03/14
- [Qemu-devel] [patch v3 1/9] vfio: extract vfio_get_hot_reset_info as a single function, Cao jin, 2016/03/14
- [Qemu-devel] [patch v3 2/9] vfio: squeeze out vfio_pci_do_hot_reset for support bus reset, Cao jin, 2016/03/14
- [Qemu-devel] [patch v3 4/9] vfio: add aer support for vfio device, Cao jin, 2016/03/14
- [Qemu-devel] [patch v3 3/9] vfio: add pcie extended capability support, Cao jin, 2016/03/14
- [Qemu-devel] [patch v3 5/9] vfio: add check host bus reset is support or not, Cao jin, 2016/03/14
- [Qemu-devel] [patch v3 6/9] vfio: add check aer functionality for hotplug device,
Cao jin <=
- [Qemu-devel] [patch v3 7/9] vfio: vote the function 0 to do host bus reset when aer occurred, Cao jin, 2016/03/14
- [Qemu-devel] [patch v3 8/9] vfio-pci: pass the aer error to guest, Cao jin, 2016/03/14
- [Qemu-devel] [patch v3 9/9] vfio: add 'aer' property to expose aercap, Cao jin, 2016/03/14