[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v8.1 09/13] vfio: add sec_bus_reset notifier to notify
From: |
Chen Fan |
Subject: |
[Qemu-devel] [RFC v8.1 09/13] vfio: add sec_bus_reset notifier to notify physical bus reset is needed |
Date: |
Wed, 27 May 2015 10:46:30 +0800 |
Signed-off-by: Chen Fan <address@hidden>
---
hw/vfio/pci.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 91ad9ad..a8c5988 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -156,6 +156,7 @@ typedef struct VFIOPCIDevice {
PCIHostDeviceAddress host;
EventNotifier err_notifier;
EventNotifier req_notifier;
+ Notifier sec_bus_reset_notifier;
int (*resetfn)(struct VFIOPCIDevice *);
uint32_t features;
#define VFIO_FEATURE_ENABLE_VGA_BIT 0
@@ -172,6 +173,7 @@ typedef struct VFIOPCIDevice {
bool has_flr;
bool has_pm_reset;
bool has_bus_reset;
+ bool needs_bus_reset;
bool rom_read_failed;
} VFIOPCIDevice;
@@ -3828,6 +3830,17 @@ static Notifier machine_notifier = {
.notify = vfio_pci_machine_done_notify,
};
+static void vfio_pci_host_needs_bus_reset(Notifier *n, void *opaque)
+{
+ VFIOPCIDevice *vdev = container_of(n, VFIOPCIDevice,
sec_bus_reset_notifier);
+ VFIODevice *vbasedev = &vdev->vbasedev;
+
+ if (vdev->has_bus_reset) {
+ vdev->needs_bus_reset = true;
+ vbasedev->needs_reset = true;
+ }
+}
+
static int vfio_initfn(PCIDevice *pdev)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
@@ -3978,6 +3991,9 @@ static int vfio_initfn(PCIDevice *pdev)
vfio_register_req_notifier(vdev);
vfio_setup_resetfn(vdev);
+ vdev->sec_bus_reset_notifier.notify = vfio_pci_host_needs_bus_reset;
+ pci_bus_add_reset_notifier(pdev->bus, &vdev->sec_bus_reset_notifier);
+
return 0;
out_teardown:
@@ -4006,6 +4022,7 @@ static void vfio_exitfn(PCIDevice *pdev)
vfio_unregister_req_notifier(vdev);
vfio_unregister_err_notifier(vdev);
+ pci_bus_remove_reset_notifier(&vdev->sec_bus_reset_notifier);
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
vfio_disable_interrupts(vdev);
if (vdev->intx.mmap_timer) {
--
1.9.3
- [Qemu-devel] [RFC v8.1 01/13] vfio: extract vfio_get_hot_reset_info as a single function, (continued)
- [Qemu-devel] [RFC v8.1 01/13] vfio: extract vfio_get_hot_reset_info as a single function, Chen Fan, 2015/05/26
- [Qemu-devel] [RFC v8.1 04/13] aer: impove pcie_aer_init to support vfio device, Chen Fan, 2015/05/26
- [Qemu-devel] [RFC v8.1 05/13] vfio: add aer support for vfio device, Chen Fan, 2015/05/26
- [Qemu-devel] [RFC v8.1 06/13] vfio: add check host bus reset is support or not, Chen Fan, 2015/05/26
- [Qemu-devel] [RFC v8.1 07/13] vfio: add check for vfio devices which enable aer should support bus reset, Chen Fan, 2015/05/26
- [Qemu-devel] [RFC v8.1 08/13] pci: add bus reset_notifiers callbacks for host bus reset, Chen Fan, 2015/05/26
- [Qemu-devel] [RFC v8.1 09/13] vfio: add sec_bus_reset notifier to notify physical bus reset is needed,
Chen Fan <=
- [Qemu-devel] [RFC v8.1 10/13] vfio: do hot bus reset when do virtual secondary bus reset, Chen Fan, 2015/05/26
- [Qemu-devel] [RFC v8.1 11/13] pcie_aer: expose pcie_aer_msg() interface, Chen Fan, 2015/05/26
- [Qemu-devel] [RFC v8.1 12/13] vfio-pci: pass the aer error to guest, Chen Fan, 2015/05/26
- [Qemu-devel] [RFC v8.1 13/13] vfio: add 'aer' property to expose aercap, Chen Fan, 2015/05/26