[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [v11 12/15] vfio: do hot bus reset when do virtual secondar
From: |
Chen Fan |
Subject: |
[Qemu-devel] [v11 12/15] vfio: do hot bus reset when do virtual secondary bus reset |
Date: |
Wed, 24 Jun 2015 17:46:05 +0800 |
when do virtual secondary bus reset, the vfio device under
this bus need to do host bus reset to reset the device.
so add this case.
Signed-off-by: Chen Fan <address@hidden>
---
hw/vfio/pci.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index aeb489e..9181c15 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -4158,6 +4158,27 @@ static void vfio_exitfn(PCIDevice *pdev)
vfio_unregister_bars(vdev);
}
+static int vfio_pci_is_single_function(VFIOPCIDevice *vdev)
+{
+ struct vfio_pci_hot_reset_info *info = NULL;
+ int ret;
+
+ ret = vfio_get_hot_reset_info(vdev, &info);
+ if (ret) {
+ goto out;
+ }
+
+ if (info->count > 1) {
+ ret = 0;
+ goto out;
+ }
+
+ ret = 1;
+out:
+ g_free(info);
+ return ret;
+}
+
static void vfio_pci_reset(DeviceState *dev)
{
PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, dev);
@@ -4165,6 +4186,16 @@ static void vfio_pci_reset(DeviceState *dev)
trace_vfio_pci_reset(vdev->vbasedev.name);
+ if (vdev->needs_bus_reset) {
+ vdev->needs_bus_reset = false;
+ /* Avoid duplicate bus reset */
+ if (vdev->vbasedev.needs_reset) {
+ vfio_pci_hot_reset(vdev,
+ vfio_pci_is_single_function(vdev) ? true : false);
+ }
+ return;
+ }
+
vfio_pci_pre_reset(vdev);
if (vdev->resetfn && !vdev->resetfn(vdev)) {
--
1.9.3
- [Qemu-devel] [v11 04/15] vfio: make the 4 bytes aligned for capability size, (continued)
- [Qemu-devel] [v11 04/15] vfio: make the 4 bytes aligned for capability size, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 01/15] vfio: extract vfio_get_hot_reset_info as a single function, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 03/15] pcie: modify the capability size assert, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 02/15] vfio: squeeze out vfio_pci_do_hot_reset for support bus reset, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 05/15] vfio: add pcie extanded capability support, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 06/15] aer: impove pcie_aer_init to support vfio device, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 09/15] pci: add bus reset_notifiers callbacks for host bus reset, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 10/15] vfio: add sec_bus_reset notifier to notify physical bus reset is needed, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 11/15] vfio: modify vfio_pci_hot_reset to support bus reset, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 08/15] vfio: add check host bus reset is support or not, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 12/15] vfio: do hot bus reset when do virtual secondary bus reset,
Chen Fan <=
- [Qemu-devel] [v11 13/15] pcie_aer: expose pcie_aer_msg() interface, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 07/15] vfio: add aer support for vfio device, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 14/15] vfio-pci: pass the aer error to guest, Chen Fan, 2015/06/24
- [Qemu-devel] [v11 15/15] vfio: add 'aer' property to expose aercap, Chen Fan, 2015/06/24
- Re: [Qemu-devel] [v11 00/15] vfio-pci: pass the aer error to guest, Chen Fan, 2015/06/30