|
Justin M. Forbes |
502ffe |
From 2ed38f61f1054e188838bae9244fc1c327f8cda4 Mon Sep 17 00:00:00 2001
|
|
Justin M. Forbes |
502ffe |
From: Marcelo Tosatti <mtosatti@redhat.com>
|
|
Justin M. Forbes |
502ffe |
Date: Mon, 18 Oct 2010 16:17:00 -0200
|
|
Justin M. Forbes |
502ffe |
Subject: [PATCH 42/42] vhost-net patches for qemu-0.13.0 tarball
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
Justin,
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
Attached are the patches to fix vhost-net on the 0.13.0 tarball.
|
|
Justin M. Forbes |
502ffe |
Untested.
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
commit f76cfc6f0882f227101f21d5a5b80804710b88cb
|
|
Justin M. Forbes |
502ffe |
Author: Michael S. Tsirkin <mst@redhat.com>
|
|
Justin M. Forbes |
502ffe |
Date: Wed Oct 6 07:22:00 2010 +0200
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
vhost: fix up irqfd support
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
vhost irqfd support: case where many vqs are
|
|
Justin M. Forbes |
502ffe |
mapped to a single msix vector is currently broken.
|
|
Justin M. Forbes |
502ffe |
Fix it up.
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
Includes this patch from qemu.git:
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
virtio: change set guest notifier to per-device
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
When using irqfd with vhost-net to inject interrupts,
|
|
Justin M. Forbes |
502ffe |
a single evenfd might inject multiple interrupts.
|
|
Justin M. Forbes |
502ffe |
Implementing this is much easier with a single
|
|
Justin M. Forbes |
502ffe |
per-device callback to set guest notifiers.
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Justin M. Forbes |
502ffe |
---
|
|
Justin M. Forbes |
502ffe |
hw/msix.c | 82 +++++++++++++++++++++++++++++++-----------------------
|
|
Justin M. Forbes |
502ffe |
hw/msix.h | 4 +-
|
|
Justin M. Forbes |
502ffe |
hw/pci.h | 3 +-
|
|
Justin M. Forbes |
502ffe |
hw/virtio-pci.c | 56 +++++++++++++++++++++++++++++++------
|
|
Justin M. Forbes |
502ffe |
4 files changed, 97 insertions(+), 48 deletions(-)
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
diff --git a/hw/msix.c b/hw/msix.c
|
|
Justin M. Forbes |
502ffe |
index 3dd0456..c0c6b50 100644
|
|
Justin M. Forbes |
502ffe |
--- a/hw/msix.c
|
|
Justin M. Forbes |
502ffe |
+++ b/hw/msix.c
|
|
Justin M. Forbes |
502ffe |
@@ -300,10 +300,8 @@ static void msix_mmio_writel(void *opaque, target_phys_addr_t addr,
|
|
Justin M. Forbes |
502ffe |
if (kvm_enabled() && kvm_irqchip_in_kernel()) {
|
|
Justin M. Forbes |
502ffe |
kvm_msix_update(dev, vector, was_masked, msix_is_masked(dev, vector));
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
- if (was_masked != msix_is_masked(dev, vector) &&
|
|
Justin M. Forbes |
502ffe |
- dev->msix_mask_notifier && dev->msix_mask_notifier_opaque[vector]) {
|
|
Justin M. Forbes |
502ffe |
+ if (was_masked != msix_is_masked(dev, vector) && dev->msix_mask_notifier) {
|
|
Justin M. Forbes |
502ffe |
int r = dev->msix_mask_notifier(dev, vector,
|
|
Justin M. Forbes |
502ffe |
- dev->msix_mask_notifier_opaque[vector],
|
|
Justin M. Forbes |
502ffe |
msix_is_masked(dev, vector));
|
|
Justin M. Forbes |
502ffe |
assert(r >= 0);
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
@@ -351,9 +349,8 @@ static void msix_mask_all(struct PCIDevice *dev, unsigned nentries)
|
|
Justin M. Forbes |
502ffe |
int was_masked = msix_is_masked(dev, vector);
|
|
Justin M. Forbes |
502ffe |
dev->msix_table_page[offset] |= MSIX_VECTOR_MASK;
|
|
Justin M. Forbes |
502ffe |
if (was_masked != msix_is_masked(dev, vector) &&
|
|
Justin M. Forbes |
502ffe |
- dev->msix_mask_notifier && dev->msix_mask_notifier_opaque[vector]) {
|
|
Justin M. Forbes |
502ffe |
+ dev->msix_mask_notifier) {
|
|
Justin M. Forbes |
502ffe |
r = dev->msix_mask_notifier(dev, vector,
|
|
Justin M. Forbes |
502ffe |
- dev->msix_mask_notifier_opaque[vector],
|
|
Justin M. Forbes |
502ffe |
msix_is_masked(dev, vector));
|
|
Justin M. Forbes |
502ffe |
assert(r >= 0);
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
@@ -379,8 +376,6 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries,
|
|
Justin M. Forbes |
502ffe |
sizeof *dev->msix_irq_entries);
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
#endif
|
|
Justin M. Forbes |
502ffe |
- dev->msix_mask_notifier_opaque =
|
|
Justin M. Forbes |
502ffe |
- qemu_mallocz(nentries * sizeof *dev->msix_mask_notifier_opaque);
|
|
Justin M. Forbes |
502ffe |
dev->msix_mask_notifier = NULL;
|
|
Justin M. Forbes |
502ffe |
dev->msix_entry_used = qemu_mallocz(MSIX_MAX_ENTRIES *
|
|
Justin M. Forbes |
502ffe |
sizeof *dev->msix_entry_used);
|
|
Justin M. Forbes |
502ffe |
@@ -444,8 +439,6 @@ int msix_uninit(PCIDevice *dev)
|
|
Justin M. Forbes |
502ffe |
dev->msix_entry_used = NULL;
|
|
Justin M. Forbes |
502ffe |
qemu_free(dev->msix_irq_entries);
|
|
Justin M. Forbes |
502ffe |
dev->msix_irq_entries = NULL;
|
|
Justin M. Forbes |
502ffe |
- qemu_free(dev->msix_mask_notifier_opaque);
|
|
Justin M. Forbes |
502ffe |
- dev->msix_mask_notifier_opaque = NULL;
|
|
Justin M. Forbes |
502ffe |
dev->cap_present &= ~QEMU_PCI_CAP_MSIX;
|
|
Justin M. Forbes |
502ffe |
return 0;
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
@@ -590,46 +583,65 @@ void msix_unuse_all_vectors(PCIDevice *dev)
|
|
Justin M. Forbes |
502ffe |
msix_free_irq_entries(dev);
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
-int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque)
|
|
Justin M. Forbes |
502ffe |
+/* Invoke the notifier if vector entry is used and unmasked. */
|
|
Justin M. Forbes |
502ffe |
+static int msix_notify_if_unmasked(PCIDevice *dev, unsigned vector, int masked)
|
|
Justin M. Forbes |
502ffe |
{
|
|
Justin M. Forbes |
502ffe |
- int r = 0;
|
|
Justin M. Forbes |
502ffe |
- if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
|
|
Justin M. Forbes |
502ffe |
+ assert(dev->msix_mask_notifier);
|
|
Justin M. Forbes |
502ffe |
+ if (!dev->msix_entry_used[vector] || msix_is_masked(dev, vector)) {
|
|
Justin M. Forbes |
502ffe |
return 0;
|
|
Justin M. Forbes |
502ffe |
+ }
|
|
Justin M. Forbes |
502ffe |
+ return dev->msix_mask_notifier(dev, vector, masked);
|
|
Justin M. Forbes |
502ffe |
+}
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
- assert(dev->msix_mask_notifier);
|
|
Justin M. Forbes |
502ffe |
- assert(opaque);
|
|
Justin M. Forbes |
502ffe |
- assert(!dev->msix_mask_notifier_opaque[vector]);
|
|
Justin M. Forbes |
502ffe |
+static int msix_set_mask_notifier_for_vector(PCIDevice *dev, unsigned vector)
|
|
Justin M. Forbes |
502ffe |
+{
|
|
Justin M. Forbes |
502ffe |
+ /* Notifier has been set. Invoke it on unmasked vectors. */
|
|
Justin M. Forbes |
502ffe |
+ return msix_notify_if_unmasked(dev, vector, 0);
|
|
Justin M. Forbes |
502ffe |
+}
|
|
Justin M. Forbes |
502ffe |
+
|
|
Justin M. Forbes |
502ffe |
+static int msix_unset_mask_notifier_for_vector(PCIDevice *dev, unsigned vector)
|
|
Justin M. Forbes |
502ffe |
+{
|
|
Justin M. Forbes |
502ffe |
+ /* Notifier will be unset. Invoke it to mask unmasked entries. */
|
|
Justin M. Forbes |
502ffe |
+ return msix_notify_if_unmasked(dev, vector, 1);
|
|
Justin M. Forbes |
502ffe |
+}
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
- /* Unmask the new notifier unless vector is masked. */
|
|
Justin M. Forbes |
502ffe |
- if (!msix_is_masked(dev, vector)) {
|
|
Justin M. Forbes |
502ffe |
- r = dev->msix_mask_notifier(dev, vector, opaque, false);
|
|
Justin M. Forbes |
502ffe |
+int msix_set_mask_notifier(PCIDevice *dev, msix_mask_notifier_func f)
|
|
Justin M. Forbes |
502ffe |
+{
|
|
Justin M. Forbes |
502ffe |
+ int r, n;
|
|
Justin M. Forbes |
502ffe |
+ assert(!dev->msix_mask_notifier);
|
|
Justin M. Forbes |
502ffe |
+ dev->msix_mask_notifier = f;
|
|
Justin M. Forbes |
502ffe |
+ for (n = 0; n < dev->msix_entries_nr; ++n) {
|
|
Justin M. Forbes |
502ffe |
+ r = msix_set_mask_notifier_for_vector(dev, n);
|
|
Justin M. Forbes |
502ffe |
if (r < 0) {
|
|
Justin M. Forbes |
502ffe |
- return r;
|
|
Justin M. Forbes |
502ffe |
+ goto undo;
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
- dev->msix_mask_notifier_opaque[vector] = opaque;
|
|
Justin M. Forbes |
502ffe |
+ return 0;
|
|
Justin M. Forbes |
502ffe |
+
|
|
Justin M. Forbes |
502ffe |
+undo:
|
|
Justin M. Forbes |
502ffe |
+ while (--n >= 0) {
|
|
Justin M. Forbes |
502ffe |
+ msix_unset_mask_notifier_for_vector(dev, n);
|
|
Justin M. Forbes |
502ffe |
+ }
|
|
Justin M. Forbes |
502ffe |
+ dev->msix_mask_notifier = NULL;
|
|
Justin M. Forbes |
502ffe |
return r;
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
-int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector)
|
|
Justin M. Forbes |
502ffe |
+int msix_unset_mask_notifier(PCIDevice *dev)
|
|
Justin M. Forbes |
502ffe |
{
|
|
Justin M. Forbes |
502ffe |
- int r = 0;
|
|
Justin M. Forbes |
502ffe |
- void *opaque;
|
|
Justin M. Forbes |
502ffe |
- if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
|
|
Justin M. Forbes |
502ffe |
- return 0;
|
|
Justin M. Forbes |
502ffe |
-
|
|
Justin M. Forbes |
502ffe |
- opaque = dev->msix_mask_notifier_opaque[vector];
|
|
Justin M. Forbes |
502ffe |
-
|
|
Justin M. Forbes |
502ffe |
+ int r, n;
|
|
Justin M. Forbes |
502ffe |
assert(dev->msix_mask_notifier);
|
|
Justin M. Forbes |
502ffe |
- assert(opaque);
|
|
Justin M. Forbes |
502ffe |
-
|
|
Justin M. Forbes |
502ffe |
- /* Mask the old notifier unless it is already masked. */
|
|
Justin M. Forbes |
502ffe |
- if (!msix_is_masked(dev, vector)) {
|
|
Justin M. Forbes |
502ffe |
- r = dev->msix_mask_notifier(dev, vector, opaque, true);
|
|
Justin M. Forbes |
502ffe |
+ for (n = 0; n < dev->msix_entries_nr; ++n) {
|
|
Justin M. Forbes |
502ffe |
+ r = msix_unset_mask_notifier_for_vector(dev, n);
|
|
Justin M. Forbes |
502ffe |
if (r < 0) {
|
|
Justin M. Forbes |
502ffe |
- return r;
|
|
Justin M. Forbes |
502ffe |
+ goto undo;
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
- dev->msix_mask_notifier_opaque[vector] = NULL;
|
|
Justin M. Forbes |
502ffe |
+ dev->msix_mask_notifier = NULL;
|
|
Justin M. Forbes |
502ffe |
+ return 0;
|
|
Justin M. Forbes |
502ffe |
+
|
|
Justin M. Forbes |
502ffe |
+undo:
|
|
Justin M. Forbes |
502ffe |
+ while (--n >= 0) {
|
|
Justin M. Forbes |
502ffe |
+ msix_set_mask_notifier_for_vector(dev, n);
|
|
Justin M. Forbes |
502ffe |
+ }
|
|
Justin M. Forbes |
502ffe |
return r;
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
diff --git a/hw/msix.h b/hw/msix.h
|
|
Justin M. Forbes |
502ffe |
index 6b21ffb..5a81df5 100644
|
|
Justin M. Forbes |
502ffe |
--- a/hw/msix.h
|
|
Justin M. Forbes |
502ffe |
+++ b/hw/msix.h
|
|
Justin M. Forbes |
502ffe |
@@ -33,6 +33,6 @@ void msix_reset(PCIDevice *dev);
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
extern int msix_supported;
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
-int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque);
|
|
Justin M. Forbes |
502ffe |
-int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector);
|
|
Justin M. Forbes |
502ffe |
+int msix_set_mask_notifier(PCIDevice *dev, msix_mask_notifier_func);
|
|
Justin M. Forbes |
502ffe |
+int msix_unset_mask_notifier(PCIDevice *dev);
|
|
Justin M. Forbes |
502ffe |
#endif
|
|
Justin M. Forbes |
502ffe |
diff --git a/hw/pci.h b/hw/pci.h
|
|
Justin M. Forbes |
502ffe |
index ccb99d0..a40dc14 100644
|
|
Justin M. Forbes |
502ffe |
--- a/hw/pci.h
|
|
Justin M. Forbes |
502ffe |
+++ b/hw/pci.h
|
|
Justin M. Forbes |
502ffe |
@@ -131,7 +131,7 @@ enum {
|
|
Justin M. Forbes |
502ffe |
#define PCI_CAPABILITY_CONFIG_MSIX_LENGTH 0x10
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
typedef int (*msix_mask_notifier_func)(PCIDevice *, unsigned vector,
|
|
Justin M. Forbes |
502ffe |
- void *opaque, int masked);
|
|
Justin M. Forbes |
502ffe |
+ int masked);
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
struct PCIDevice {
|
|
Justin M. Forbes |
502ffe |
DeviceState qdev;
|
|
Justin M. Forbes |
502ffe |
@@ -198,7 +198,6 @@ struct PCIDevice {
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
struct kvm_irq_routing_entry *msix_irq_entries;
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
- void **msix_mask_notifier_opaque;
|
|
Justin M. Forbes |
502ffe |
msix_mask_notifier_func msix_mask_notifier;
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
/* Device capability configuration space */
|
|
Justin M. Forbes |
502ffe |
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
|
|
Justin M. Forbes |
502ffe |
index 83b7871..72bc80e 100644
|
|
Justin M. Forbes |
502ffe |
--- a/hw/virtio-pci.c
|
|
Justin M. Forbes |
502ffe |
+++ b/hw/virtio-pci.c
|
|
Justin M. Forbes |
502ffe |
@@ -427,11 +427,10 @@ static void virtio_pci_guest_notifier_read(void *opaque)
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
-static int virtio_pci_mask_notifier(PCIDevice *dev, unsigned vector,
|
|
Justin M. Forbes |
502ffe |
- void *opaque, int masked)
|
|
Justin M. Forbes |
502ffe |
+static int virtio_pci_mask_vq(PCIDevice *dev, unsigned vector,
|
|
Justin M. Forbes |
502ffe |
+ VirtQueue *vq, int masked)
|
|
Justin M. Forbes |
502ffe |
{
|
|
Justin M. Forbes |
502ffe |
#ifdef CONFIG_KVM
|
|
Justin M. Forbes |
502ffe |
- VirtQueue *vq = opaque;
|
|
Justin M. Forbes |
502ffe |
EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
|
|
Justin M. Forbes |
502ffe |
int r = kvm_set_irqfd(dev->msix_irq_entries[vector].gsi,
|
|
Justin M. Forbes |
502ffe |
event_notifier_get_fd(notifier),
|
|
Justin M. Forbes |
502ffe |
@@ -452,6 +451,34 @@ static int virtio_pci_mask_notifier(PCIDevice *dev, unsigned vector,
|
|
Justin M. Forbes |
502ffe |
#endif
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
+static int virtio_pci_mask_notifier(PCIDevice *dev, unsigned vector,
|
|
Justin M. Forbes |
502ffe |
+ int masked)
|
|
Justin M. Forbes |
502ffe |
+{
|
|
Justin M. Forbes |
502ffe |
+ VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev);
|
|
Justin M. Forbes |
502ffe |
+ VirtIODevice *vdev = proxy->vdev;
|
|
Justin M. Forbes |
502ffe |
+ int r, n;
|
|
Justin M. Forbes |
502ffe |
+
|
|
Justin M. Forbes |
502ffe |
+ for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
|
|
Justin M. Forbes |
502ffe |
+ if (!virtio_queue_get_num(vdev, n)) {
|
|
Justin M. Forbes |
502ffe |
+ break;
|
|
Justin M. Forbes |
502ffe |
+ }
|
|
Justin M. Forbes |
502ffe |
+ if (virtio_queue_vector(vdev, n) != vector) {
|
|
Justin M. Forbes |
502ffe |
+ continue;
|
|
Justin M. Forbes |
502ffe |
+ }
|
|
Justin M. Forbes |
502ffe |
+ r = virtio_pci_mask_vq(dev, vector, virtio_get_queue(vdev, n), masked);
|
|
Justin M. Forbes |
502ffe |
+ if (r < 0) {
|
|
Justin M. Forbes |
502ffe |
+ goto undo;
|
|
Justin M. Forbes |
502ffe |
+ }
|
|
Justin M. Forbes |
502ffe |
+ }
|
|
Justin M. Forbes |
502ffe |
+ return 0;
|
|
Justin M. Forbes |
502ffe |
+undo:
|
|
Justin M. Forbes |
502ffe |
+ while (--n >= 0) {
|
|
Justin M. Forbes |
502ffe |
+ virtio_pci_mask_vq(dev, vector, virtio_get_queue(vdev, n), !masked);
|
|
Justin M. Forbes |
502ffe |
+ }
|
|
Justin M. Forbes |
502ffe |
+ return r;
|
|
Justin M. Forbes |
502ffe |
+}
|
|
Justin M. Forbes |
502ffe |
+
|
|
Justin M. Forbes |
502ffe |
+
|
|
Justin M. Forbes |
502ffe |
static int virtio_pci_set_guest_notifier(void *opaque, int n, bool assign)
|
|
Justin M. Forbes |
502ffe |
{
|
|
Justin M. Forbes |
502ffe |
VirtIOPCIProxy *proxy = opaque;
|
|
Justin M. Forbes |
502ffe |
@@ -465,11 +492,7 @@ static int virtio_pci_set_guest_notifier(void *opaque, int n, bool assign)
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
qemu_set_fd_handler(event_notifier_get_fd(notifier),
|
|
Justin M. Forbes |
502ffe |
virtio_pci_guest_notifier_read, NULL, vq);
|
|
Justin M. Forbes |
502ffe |
- msix_set_mask_notifier(&proxy->pci_dev,
|
|
Justin M. Forbes |
502ffe |
- virtio_queue_vector(proxy->vdev, n), vq);
|
|
Justin M. Forbes |
502ffe |
} else {
|
|
Justin M. Forbes |
502ffe |
- msix_unset_mask_notifier(&proxy->pci_dev,
|
|
Justin M. Forbes |
502ffe |
- virtio_queue_vector(proxy->vdev, n));
|
|
Justin M. Forbes |
502ffe |
qemu_set_fd_handler(event_notifier_get_fd(notifier),
|
|
Justin M. Forbes |
502ffe |
NULL, NULL, NULL);
|
|
Justin M. Forbes |
502ffe |
/* Test and clear notifier before closing it,
|
|
Justin M. Forbes |
502ffe |
@@ -487,6 +510,13 @@ static int virtio_pci_set_guest_notifiers(void *opaque, bool assign)
|
|
Justin M. Forbes |
502ffe |
VirtIODevice *vdev = proxy->vdev;
|
|
Justin M. Forbes |
502ffe |
int r, n;
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
+ /* Must unset mask notifier while guest notifier
|
|
Justin M. Forbes |
502ffe |
+ * is still assigned */
|
|
Justin M. Forbes |
502ffe |
+ if (!assign) {
|
|
Justin M. Forbes |
502ffe |
+ r = msix_unset_mask_notifier(&proxy->pci_dev);
|
|
Justin M. Forbes |
502ffe |
+ assert(r >= 0);
|
|
Justin M. Forbes |
502ffe |
+ }
|
|
Justin M. Forbes |
502ffe |
+
|
|
Justin M. Forbes |
502ffe |
for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
|
|
Justin M. Forbes |
502ffe |
if (!virtio_queue_get_num(vdev, n)) {
|
|
Justin M. Forbes |
502ffe |
break;
|
|
Justin M. Forbes |
502ffe |
@@ -498,6 +528,16 @@ static int virtio_pci_set_guest_notifiers(void *opaque, bool assign)
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
}
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
+ /* Must set mask notifier after guest notifier
|
|
Justin M. Forbes |
502ffe |
+ * has been assigned */
|
|
Justin M. Forbes |
502ffe |
+ if (assign) {
|
|
Justin M. Forbes |
502ffe |
+ r = msix_set_mask_notifier(&proxy->pci_dev,
|
|
Justin M. Forbes |
502ffe |
+ virtio_pci_mask_notifier);
|
|
Justin M. Forbes |
502ffe |
+ if (r < 0) {
|
|
Justin M. Forbes |
502ffe |
+ goto assign_error;
|
|
Justin M. Forbes |
502ffe |
+ }
|
|
Justin M. Forbes |
502ffe |
+ }
|
|
Justin M. Forbes |
502ffe |
+
|
|
Justin M. Forbes |
502ffe |
return 0;
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
assign_error:
|
|
Justin M. Forbes |
502ffe |
@@ -583,8 +623,6 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
proxy->pci_dev.config_write = virtio_write_config;
|
|
Justin M. Forbes |
502ffe |
|
|
Justin M. Forbes |
502ffe |
- proxy->pci_dev.msix_mask_notifier = virtio_pci_mask_notifier;
|
|
Justin M. Forbes |
502ffe |
-
|
|
Justin M. Forbes |
502ffe |
size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev) + vdev->config_len;
|
|
Justin M. Forbes |
502ffe |
if (size & (size-1))
|
|
Justin M. Forbes |
502ffe |
size = 1 << qemu_fls(size);
|
|
Justin M. Forbes |
502ffe |
--
|
|
Justin M. Forbes |
502ffe |
1.7.2.3
|
|
Justin M. Forbes |
502ffe |
|