From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org, eric.auger@redhat.com, peterx@redhat.com
Subject: [Qemu-devel] [PATCH v3 4/6] vfio/quirks: Add quirk reset callback
Date: Thu, 03 May 2018 15:44:55 -0600 [thread overview]
Message-ID: <20180503214455.2749.78227.stgit@gimli.home> (raw)
In-Reply-To: <20180503213458.2749.28566.stgit@gimli.home>
Quirks can be self modifying, provide a hook to allow them to cleanup
on device reset if desired.
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
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;
next prev parent reply other threads:[~2018-05-03 21:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-03 21:44 [Qemu-devel] [PATCH v3 0/6] vfio/quirks: ioeventfd support Alex Williamson
2018-05-03 21:44 ` [Qemu-devel] [PATCH v3 1/6] scripts/update-linux-headers: Update handling of __aligned_u64 Alex Williamson
2018-05-22 14:04 ` Peter Maydell
2018-05-03 21:44 ` [Qemu-devel] [PATCH v3 2/6] linux-headers: Update to v4.17-rc3 Alex Williamson
2018-05-03 21:44 ` [Qemu-devel] [PATCH v3 3/6] vfio/quirks: Add common quirk alloc helper Alex Williamson
2018-05-03 21:44 ` Alex Williamson [this message]
2018-05-03 21:45 ` [Qemu-devel] [PATCH v3 5/6] vfio/quirks: ioeventfd quirk acceleration Alex Williamson
2018-05-04 2:17 ` Peter Xu
2018-05-04 7:51 ` Auger Eric
2018-05-03 21:45 ` [Qemu-devel] [PATCH v3 6/6] vfio/quirks: Enable ioeventfd quirks to be handled by vfio directly Alex Williamson
2018-05-04 2:17 ` Peter Xu
2018-05-04 7:51 ` Auger Eric
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180503214455.2749.78227.stgit@gimli.home \
--to=alex.williamson@redhat.com \
--cc=eric.auger@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).