[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 3/6] vfio/quirks: Add quirk reset callback
From: |
Alex Williamson |
Subject: |
[Qemu-devel] [PULL 3/6] vfio/quirks: Add quirk reset callback |
Date: |
Tue, 05 Jun 2018 14:06:31 -0600 |
User-agent: |
StGit/0.18-102-gdf9f |
Quirks can be self modifying, provide a hook to allow them to cleanup
on device reset if desired.
Reviewed-by: Eric Auger <address@hidden>
Reviewed-by: Peter Xu <address@hidden>
Signed-off-by: Alex Williamson <address@hidden>
---
hw/vfio/pci-quirks.c | 15 +++++++++++++++
hw/vfio/pci.c | 2 ++
hw/vfio/pci.h | 2 ++
3 files changed, 19 insertions(+)
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index cc3a74ed992a..f0947cbf152f 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -1694,6 +1694,21 @@ void vfio_bar_quirk_finalize(VFIOPCIDevice *vdev, int nr)
/*
* Reset quirks
*/
+void vfio_quirk_reset(VFIOPCIDevice *vdev)
+{
+ int i;
+
+ for (i = 0; i < PCI_ROM_SLOT; i++) {
+ VFIOQuirk *quirk;
+ VFIOBAR *bar = &vdev->bars[i];
+
+ QLIST_FOREACH(quirk, &bar->quirks, next) {
+ if (quirk->reset) {
+ quirk->reset(vdev, quirk);
+ }
+ }
+ }
+}
/*
* AMD Radeon PCI config reset, based on Linux:
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 4947fe39a28c..65446fb42845 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2207,6 +2207,8 @@ static void vfio_pci_post_reset(VFIOPCIDevice *vdev)
vdev->vbasedev.name, nr);
}
}
+
+ vfio_quirk_reset(vdev);
}
static bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name)
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 59ab7757a300..594a5bd00593 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -29,6 +29,7 @@ typedef struct VFIOQuirk {
void *data;
int nr_mem;
MemoryRegion *mem;
+ void (*reset)(struct VFIOPCIDevice *vdev, struct VFIOQuirk *quirk);
} VFIOQuirk;
typedef struct VFIOBAR {
@@ -167,6 +168,7 @@ void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr);
void vfio_bar_quirk_finalize(VFIOPCIDevice *vdev, int nr);
void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev);
int vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp);
+void vfio_quirk_reset(VFIOPCIDevice *vdev);
extern const PropertyInfo qdev_prop_nv_gpudirect_clique;
- [Qemu-devel] [PULL 0/6] VFIO updates 2018-06-05, Alex Williamson, 2018/06/05
- [Qemu-devel] [PULL 1/6] vfio: remove DPRINTF() definition from vfio-common.h, Alex Williamson, 2018/06/05
- [Qemu-devel] [PULL 2/6] vfio/quirks: Add common quirk alloc helper, Alex Williamson, 2018/06/05
- [Qemu-devel] [PULL 3/6] vfio/quirks: Add quirk reset callback,
Alex Williamson <=
- [Qemu-devel] [PULL 4/6] vfio/quirks: ioeventfd quirk acceleration, Alex Williamson, 2018/06/05
- [Qemu-devel] [PULL 5/6] vfio/quirks: Enable ioeventfd quirks to be handled by vfio directly, Alex Williamson, 2018/06/05
- [Qemu-devel] [PULL 6/6] vfio/pci: Default display option to "off", Alex Williamson, 2018/06/05
- Re: [Qemu-devel] [PULL 0/6] VFIO updates 2018-06-05, no-reply, 2018/06/06
- Re: [Qemu-devel] [PULL 0/6] VFIO updates 2018-06-05, Peter Maydell, 2018/06/07