[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/10] vfio: introduce last reset sequence id
From: |
Cao jin |
Subject: |
[Qemu-devel] [PATCH 08/10] vfio: introduce last reset sequence id |
Date: |
Wed, 17 Feb 2016 18:43:52 +0800 |
From: Chen Fan <address@hidden>
avoid multi-reset host bus, we introduce sequence id to specify which
bus is resetting. and if one of the dependent devices has done a reset.
the others should skip.
Signed-off-by: Chen Fan <address@hidden>
---
hw/vfio/pci.c | 14 ++++++++++++++
hw/vfio/pci.h | 3 +++
2 files changed, 17 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index b900f70..5b885e7 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1951,6 +1951,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;
@@ -2283,6 +2285,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 = vdev->pdev.bus->reset_seqid;
ret = vfio_get_hot_reset_info(vdev, &info);
if (ret) {
@@ -2344,6 +2347,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;
}
@@ -3040,6 +3044,16 @@ static void vfio_pci_reset(DeviceState *dev)
trace_vfio_pci_reset(vdev->vbasedev.name);
+ /* if need to do a hot reset */
+ if (pdev->bus->bus_in_reset) {
+ if (vdev->last_bus_reset_seqid == pdev->bus->reset_seqid) {
+ 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 bf9e93c..684931d 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -144,6 +144,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 00/10] vfio-pci: pass the aer error to guest, part2, Cao jin, 2016/02/17
- [Qemu-devel] [PATCH 01/10] vfio: extract vfio_get_hot_reset_info as a single function, Cao jin, 2016/02/17
- [Qemu-devel] [PATCH 02/10] vfio: squeeze out vfio_pci_do_hot_reset for support bus reset, Cao jin, 2016/02/17
- [Qemu-devel] [PATCH 03/10] vfio: add pcie extended capability support, Cao jin, 2016/02/17
- [Qemu-devel] [PATCH 04/10] vfio: add aer support for vfio device, Cao jin, 2016/02/17
- [Qemu-devel] [PATCH 05/10] vfio: add check host bus reset is support or not, Cao jin, 2016/02/17
- [Qemu-devel] [PATCH 06/10] add check reset mechanism when hotplug vfio device, Cao jin, 2016/02/17
- [Qemu-devel] [PATCH 08/10] vfio: introduce last reset sequence id,
Cao jin <=
- [Qemu-devel] [PATCH 07/10] pci: introduce pci bus pre reset, Cao jin, 2016/02/17
- [Qemu-devel] [PATCH 09/10] vfio-pci: pass the aer error to guest, Cao jin, 2016/02/17