Received: from eggs.gnu.org ([2001:4830:134:3::10]:52060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz5dc-0008Kp-QF for qemu-devel@nongnu.org; Mon, 23 Jun 2014 10:54:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wz5dV-00047r-82 for qemu-devel@nongnu.org; Mon, 23 Jun 2014 10:54:28 -0400 Received: from mail-wg0-f45.google.com ([74.125.82.45]:61269) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz5dV-00047i-1x for qemu-devel@nongnu.org; Mon, 23 Jun 2014 10:54:21 -0400 Received: by mail-wg0-f45.google.com with SMTP id l18so6432978wgh.28 for ; Mon, 23 Jun 2014 07:54:19 -0700 (PDT) From: Alvise Rigo Date: Mon, 23 Jun 2014 16:54:05 +0200 Message-Id: <1403535245-30041-5-git-send-email-a.rigo@virtualopensystems.com> In-Reply-To: <1403535245-30041-1-git-send-email-a.rigo@virtualopensystems.com> References: <1403535245-30041-1-git-send-email-a.rigo@virtualopensystems.com> Subject: [Qemu-devel] [RFC PATCH v3 4/4] Let VFIO handle the unmasking of interrupts at EOI List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, a.motakis@virtualopensystems.com, eric.auger@st.com Cc: Alex Williamson , tech@virtualopensystems.com, Alvise Rigo 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 --- 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