From: "Michael S. Tsirkin" <mst@redhat.com>
To: kvm@vger.kernel.org
Subject: [PATCH 20/20] virtio-pci: irqfd support
Date: Thu, 4 Feb 2010 17:29:19 +0200 [thread overview]
Message-ID: <20100204152919.GU8461@redhat.com> (raw)
In-Reply-To: <cover.1265297173.git.mst@redhat.com>
Use irqfd when supported by kernel.
This uses msix mask notifiers: when vector is masked, we poll it from
userspace. When it is unmasked, we poll it from kernel.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio-pci.c | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 02859a7..f3ed939 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -406,6 +406,27 @@ static void virtio_pci_guest_notifier_read(void *opaque)
}
}
+static int virtio_pci_mask_notifier(PCIDevice *dev, unsigned vector,
+ void *opaque, int masked)
+{
+ VirtQueue *vq = opaque;
+ EventNotifier *notifier = virtio_queue_guest_notifier(vq);
+ int r = kvm_set_irqfd(dev->msix_irq_entries[vector].gsi,
+ event_notifier_get_fd(notifier),
+ !masked);
+ if (r < 0) {
+ return (r == -ENOSYS) ? 0 : r;
+ }
+ if (masked) {
+ qemu_set_fd_handler(event_notifier_get_fd(notifier),
+ virtio_pci_guest_notifier_read, NULL, vq);
+ } else {
+ qemu_set_fd_handler(event_notifier_get_fd(notifier),
+ NULL, NULL, vq);
+ }
+ return 0;
+}
+
static int virtio_pci_guest_notifier(void *opaque, int n, bool assign)
{
VirtIOPCIProxy *proxy = opaque;
@@ -414,11 +435,15 @@ static int virtio_pci_guest_notifier(void *opaque, int n, bool assign)
if (assign) {
int r = event_notifier_init(notifier, 0);
- if (r < 0)
- return r;
+ if (r < 0)
+ return r;
qemu_set_fd_handler(event_notifier_get_fd(notifier),
virtio_pci_guest_notifier_read, NULL, vq);
+ msix_set_mask_notifier(&proxy->pci_dev,
+ virtio_queue_vector(proxy->vdev, n), vq);
} else {
+ msix_set_mask_notifier(&proxy->pci_dev,
+ virtio_queue_vector(proxy->vdev, n), NULL);
qemu_set_fd_handler(event_notifier_get_fd(notifier),
NULL, NULL, vq);
event_notifier_cleanup(notifier);
@@ -503,6 +528,8 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
proxy->pci_dev.config_write = virtio_write_config;
+ proxy->pci_dev.msix_mask_notifier = virtio_pci_mask_notifier;
+
size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev) + vdev->config_len;
if (size & (size-1))
size = 1 << qemu_fls(size);
--
1.6.6.144.g5c3af
prev parent reply other threads:[~2010-02-04 15:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1265297173.git.mst@redhat.com>
2010-02-04 15:27 ` [PATCH 01/20] exec: memory notifiers Michael S. Tsirkin
2010-02-04 15:27 ` [PATCH 02/20] kvm: move kvm_set_phys_mem around Michael S. Tsirkin
2010-02-04 15:27 ` [PATCH 03/20] kvm: move kvm to use memory notifiers Michael S. Tsirkin
2010-02-04 15:27 ` [PATCH 04/20] qemu-kvm: fixup after merging " Michael S. Tsirkin
2010-02-04 15:27 ` [PATCH 05/20] kvm: add API to set ioeventfd Michael S. Tsirkin
2010-02-04 15:27 ` [PATCH 06/20] notifier: event notifier implementation Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 07/20] virtio: add notifier support Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 08/20] virtio: add APIs for queue fields Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 09/20] virtio: add status change callback Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 10/20] virtio: move typedef to qemu-common Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 11/20] virtio-pci: fill in notifier support Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 12/20] tap: add interface to get device fd Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 13/20] vhost: vhost net support Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 14/20] tap: add vhost/vhostfd options Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 15/20] tap: add API to retrieve vhost net header Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 16/20] virtio-net: vhost net support Michael S. Tsirkin
2010-02-04 15:29 ` [PATCH 17/20] qemu-kvm: add vhost.h header Michael S. Tsirkin
2010-02-04 15:29 ` [PATCH 18/20] kvm: irqfd support Michael S. Tsirkin
2010-02-04 15:29 ` [PATCH 19/20] msix: add mask/unmask notifiers Michael S. Tsirkin
2010-02-04 15:29 ` Michael S. Tsirkin [this message]
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=20100204152919.GU8461@redhat.com \
--to=mst@redhat.com \
--cc=kvm@vger.kernel.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