qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alvise Rigo <a.rigo@virtualopensystems.com>
To: qemu-devel@nongnu.org, a.motakis@virtualopensystems.com,
	eric.auger@st.com
Cc: Alex Williamson <alex.williamson@redhat.com>,
	tech@virtualopensystems.com,
	Alvise Rigo <a.rigo@virtualopensystems.com>
Subject: [Qemu-devel] [RFC PATCH v3 4/4] Let VFIO handle the unmasking of interrupts at EOI
Date: Mon, 23 Jun 2014 16:54:05 +0200	[thread overview]
Message-ID: <1403535245-30041-5-git-send-email-a.rigo@virtualopensystems.com> (raw)
In-Reply-To: <1403535245-30041-1-git-send-email-a.rigo@virtualopensystems.com>

Now that VFIO can unmask the interrupt autonomously through an eventfd
file descriptor, get rid of the resampler_handler.

TODO: move this code and PCI one to common.c
Signed-off-by: Alvise Rigo <a.rigo@virtualopensystems.com>
---
 hw/vfio/platform.c | 38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index 65dcf0e..4fbdcdf 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -440,20 +440,13 @@ static void vfio_disable_intp(VFIOINTp *intp)
 
 /* IRQFD */
 
-static void resampler_handler(void *opaque)
-{
-    VFIOINTp *intp = (VFIOINTp *)opaque;
-    DPRINTF("%s index %d virtual ID = %d fd = %d\n",
-            __func__,
-            intp->pin, intp->virtualID,
-            event_notifier_get_fd(&intp->unmask));
-    vfio_unmask_irqindex(&intp->vdev->vdev, intp->pin);
-}
-
-
-static void vfio_enable_intp_kvm(VFIOINTp *intp)
+static void vfio_enable_intp_kvm(VFIOPlatformDevice *vdev, VFIOINTp *intp)
 {
 #ifdef CONFIG_KVM
+    int argsz, ret;
+    struct vfio_irq_set *irq_set;
+    uint32_t *efd;
+
     struct kvm_irqfd irqfd = {
         .fd = event_notifier_get_fd(&intp->interrupt),
         .gsi = intp->virtualID,
@@ -476,10 +469,27 @@ static void vfio_enable_intp_kvm(VFIOINTp *intp)
         goto fail;
     }
 
+    argsz = sizeof(*irq_set) + sizeof(*efd);
+
+    irq_set = g_malloc0(argsz);
+    irq_set->argsz = argsz;
+    irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_UNMASK;
+    irq_set->index = intp->pin;
+    irq_set->start = 0;
+    irq_set->count = 1;
+
     /* KVM triggers it, VFIO listens for it */
     irqfd.resamplefd = event_notifier_get_fd(&intp->unmask);
-    qemu_set_fd_handler(irqfd.resamplefd, resampler_handler, NULL, intp);
+    efd = (uint32_t *)&irq_set->data;
+
+    *efd = irqfd.resamplefd;
 
+    ret = ioctl(vdev->vdev.fd, VFIO_DEVICE_SET_IRQS, irq_set);
+    g_free(irq_set);
+    if (ret) {
+        error_report("vfio: Error: Failed to setup interrupt unmask fd: %m");
+        goto fail_irqfd;
+    }
 
     if (kvm_vm_ioctl(kvm_state, KVM_IRQFD, &irqfd)) {
         error_report("vfio: Error: Failed to setup resample irqfd: %m");
@@ -508,7 +518,7 @@ void vfio_setup_irqfd(SysBusDevice *s, int index, int virq)
     QLIST_FOREACH(intp, &vdev->intp_list, next) {
         if (intp->pin == index) {
             intp->virtualID = virq;
-            vfio_enable_intp_kvm(intp);
+            vfio_enable_intp_kvm(vdev, intp);
         }
     }
 }
-- 
1.9.1

      parent reply	other threads:[~2014-06-23 14:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23 14:54 [Qemu-devel] [RFC PATCH v3 0/4] AMBA platform device passthrough Alvise Rigo
2014-06-23 14:54 ` [Qemu-devel] [RFC PATCH v3 1/4] Add AMBA devices support to VFIO Alvise Rigo
2014-06-23 14:54 ` [Qemu-devel] [RFC PATCH v3 2/4] vfio: Add irqfd support in platform device Alvise Rigo
2014-06-23 14:54 ` [Qemu-devel] [RFC PATCH v3 3/4] Force eventfd as notifying mechanism for VFIO Alvise Rigo
2014-06-23 14:54 ` Alvise Rigo [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=1403535245-30041-5-git-send-email-a.rigo@virtualopensystems.com \
    --to=a.rigo@virtualopensystems.com \
    --cc=a.motakis@virtualopensystems.com \
    --cc=alex.williamson@redhat.com \
    --cc=eric.auger@st.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tech@virtualopensystems.com \
    /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).