From patchwork Mon Jun 23 14:54:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvise Rigo X-Patchwork-Id: 362964 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5C26C14001A for ; Tue, 24 Jun 2014 00:55:08 +1000 (EST) Received: from localhost ([::1]:53978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz5eE-0000sE-3q for incoming@patchwork.ozlabs.org; Mon, 23 Jun 2014 10:55:06 -0400 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) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U9pgDnmMhU0PpDkbRNvMQkad3412414ak/kKXRjVD20=; b=I2hLl3pUurPpELz8ysAgq0Zu1ru/DXRxWA5QKwz/qgw9cWEsjy/TDhoAT3WBH8DrZx 5PtbQ4TmB1AdsDg2LKXgA/fSYoN45WptGBSK2Wesj3ZS4rv0Li+pfW/QKSiHHYpySDhF vVr/vuiRla3wcXC777gVYQErkaT73HOdKu9pMZFVzGqcDnU3q352jcd/mrguiaWzENsO 4GZwG1FRm5L7ElGwf0YkrNW4m3CT8IjwW7KE7RGDrl3/5vaWDryzmYNQvz0pKwiz9274 0f/28Pfq05pApouEZvNWxvyGb1DyZk+6p2kHg5EQOCDtYfhjX+L1uAXu+e+Aho6zMRi3 3+jA== X-Gm-Message-State: ALoCoQmfttYs4wLQnUz3h/Yh+MdhTZVVVbfwOP2Z8FKUxMxF1G0Xbdtp4Ls+XDzwvg10TcALWuzH X-Received: by 10.194.243.104 with SMTP id wx8mr27841570wjc.32.1403535259459; Mon, 23 Jun 2014 07:54:19 -0700 (PDT) Received: from localhost.localdomain (AGrenoble-651-1-433-141.w90-52.abo.wanadoo.fr. [90.52.177.141]) by mx.google.com with ESMTPSA id di7sm17576989wjb.34.2014.06.23.07.54.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jun 2014 07:54:18 -0700 (PDT) From: Alvise Rigo To: qemu-devel@nongnu.org, a.motakis@virtualopensystems.com, eric.auger@st.com Date: Mon, 23 Jun 2014 16:54:05 +0200 Message-Id: <1403535245-30041-5-git-send-email-a.rigo@virtualopensystems.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1403535245-30041-1-git-send-email-a.rigo@virtualopensystems.com> References: <1403535245-30041-1-git-send-email-a.rigo@virtualopensystems.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.45 Cc: Alex Williamson , tech@virtualopensystems.com, Alvise Rigo Subject: [Qemu-devel] [RFC PATCH v3 4/4] Let VFIO handle the unmasking of interrupts at EOI X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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); } } }