[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v16 11/14] vfio: introduce last reset sequence id
From: |
Cao jin |
Subject: |
[Qemu-devel] [PATCH v16 11/14] vfio: introduce last reset sequence id |
Date: |
Tue, 12 Jan 2016 10:43:12 +0800 |
From: Chen Fan <address@hidden>
avoid multi-reset host bus, we introduce sequence id to secify which
bus is resetting. and if one of the dependent devices has been do reset.
the others should skip.
Signed-off-by: Chen Fan <address@hidden>
---
hw/vfio/pci.c | 15 +++++++++++++++
hw/vfio/pci.h | 3 +++
2 files changed, 18 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index ff25c9b..da4815e 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1914,6 +1914,8 @@ static int vfio_check_host_bus_reset(VFIOPCIDevice *vdev)
/* List all affected devices by bus reset */
devices = &info->devices[0];
+ vdev->single_depend_dev = (info->count == 1);
+
/* Verify that we have all the groups required */
for (i = 0; i < info->count; i++) {
PCIHostDeviceAddress host;
@@ -2249,6 +2251,7 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool
single)
vfio_pci_pre_reset(vdev);
vdev->vbasedev.needs_reset = false;
+ vdev->last_bus_reset_seqid = 0;
ret = vfio_get_hot_reset_info(vdev, &info);
if (ret) {
@@ -2310,6 +2313,7 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool
single)
}
vfio_pci_pre_reset(tmp);
tmp->vbasedev.needs_reset = false;
+ tmp->last_bus_reset_seqid = vdev->pdev.bus->reset_seqid;
multi = true;
break;
}
@@ -3006,6 +3010,17 @@ static void vfio_pci_reset(DeviceState *dev)
trace_vfio_pci_reset(vdev->vbasedev.name);
+ /* if need to do a hot reset */
+ if (pdev->bus->in_reset) {
+ if (vdev->last_bus_reset_seqid == pdev->bus->reset_seqid) {
+ vdev->last_bus_reset_seqid = 0;
+ return;
+ } else if ((vdev->features & VFIO_FEATURE_ENABLE_AER)) {
+ vfio_pci_hot_reset(vdev, vdev->single_depend_dev);
+ return;
+ }
+ }
+
vfio_pci_pre_reset(vdev);
if (vdev->resetfn && !vdev->resetfn(vdev)) {
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index b385f07..728cbb8 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -143,6 +143,9 @@ typedef struct VFIOPCIDevice {
bool no_kvm_msi;
bool no_kvm_msix;
+ bool single_depend_dev;
+ uint32_t last_bus_reset_seqid;
+
NotifierWithReturn hotplug_notifier;
} VFIOPCIDevice;
--
1.9.3
- [Qemu-devel] [PATCH v16 08/14] vfio: add check host bus reset is support or not, (continued)
- [Qemu-devel] [PATCH v16 08/14] vfio: add check host bus reset is support or not, Cao jin, 2016/01/11
- [Qemu-devel] [PATCH v16 10/14] pci: introduce pci bus pre reset, Cao jin, 2016/01/11
- [Qemu-devel] [PATCH v16 09/14] add check reset mechanism when hotplug vfio device, Cao jin, 2016/01/11
- [Qemu-devel] [PATCH v16 12/14] pcie_aer: expose pcie_aer_msg() interface, Cao jin, 2016/01/11
- [Qemu-devel] [PATCH v16 11/14] vfio: introduce last reset sequence id,
Cao jin <=
- [Qemu-devel] [PATCH v16 13/14] vfio-pci: pass the aer error to guest, Cao jin, 2016/01/11
- [Qemu-devel] [PATCH v16 14/14] vfio: add 'aer' property to expose aercap, Cao jin, 2016/01/11
- Re: [Qemu-devel] [PATCH v16 00/14] vfio-pci: pass the aer error to guest, Michael S. Tsirkin, 2016/01/16