From patchwork Wed Oct 7 15:43:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 54596 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id CA35822FF8 for ; Wed, 7 Oct 2015 15:46:24 +0000 (UTC) Received: by lbwr8 with SMTP id r8sf9137577lbw.0 for ; Wed, 07 Oct 2015 08:46:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=BZh/Jb7hG7PvBMyPCkHz7ohASPYekcD3Z4wHDHNopvY=; b=JQRuu3JlNUjyi8vn2TVx8OwuHmLPU1FyzxdI03d4v5F3dSCj2OQddhGTnS3IQ+byYj RGcqCFf0Ad0iO8p2wbuzGBgZDlZcMZMMyzAFrna5Fu+r+kgHfJ3PTFgER9OVNdGvE5d6 MwUmbfquTu7wnPVD/PB0Ve8PNw2myJxNjKtdSEUuWAUKazuGpJ3cXqKt/uDlsi1XoG2H p3XHO7JWFvungnp+FSR3P3Rz6jUv9oTaYBfP7RmtqkSzJ0+xAE4pgpRkkbTFeuxA/1Vf 1HlUOEeEkEUwx/gX5Ssmq3F/W7xRRwOZLOs2nKhpU0xPkFYZbH/k4hz09Ka+oRxLguH0 KDeQ== X-Gm-Message-State: ALoCoQnVe0Vhb5lVTRXLXrH/5Ac+Ea010TxXIe959vfST2betNYbIjmA3xHyawxE5uLLL1stwKM5 X-Received: by 10.112.138.4 with SMTP id qm4mr395077lbb.6.1444232783826; Wed, 07 Oct 2015 08:46:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.166.82 with SMTP id p79ls85905lfe.99.gmail; Wed, 07 Oct 2015 08:46:23 -0700 (PDT) X-Received: by 10.25.43.80 with SMTP id r77mr543611lfr.120.1444232783646; Wed, 07 Oct 2015 08:46:23 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id i191si25666875lfg.167.2015.10.07.08.46.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Oct 2015 08:46:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbcao8 with SMTP id ao8so16580125lbc.3 for ; Wed, 07 Oct 2015 08:46:23 -0700 (PDT) X-Received: by 10.25.150.199 with SMTP id y190mr647200lfd.35.1444232783535; Wed, 07 Oct 2015 08:46:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp59891lbq; Wed, 7 Oct 2015 08:46:22 -0700 (PDT) X-Received: by 10.140.152.85 with SMTP id 82mr2585969qhy.8.1444232782466; Wed, 07 Oct 2015 08:46:22 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s85si9163240qkl.78.2015.10.07.08.46.22 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 07 Oct 2015 08:46:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:58305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zjqv8-00042z-0Z for patch@linaro.org; Wed, 07 Oct 2015 11:46:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zjqs3-0000Wp-Tt for qemu-devel@nongnu.org; Wed, 07 Oct 2015 11:43:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zjqs2-0006M0-Qh for qemu-devel@nongnu.org; Wed, 07 Oct 2015 11:43:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35556) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zjqs2-0006Lk-Ie for qemu-devel@nongnu.org; Wed, 07 Oct 2015 11:43:10 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 438E2344F7A; Wed, 7 Oct 2015 15:43:10 +0000 (UTC) Received: from gimli.home (ovpn-113-42.phx2.redhat.com [10.3.113.42]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t97Fh9hC022326; Wed, 7 Oct 2015 11:43:09 -0400 From: Alex Williamson To: qemu-devel@nongnu.org Date: Wed, 07 Oct 2015 09:43:09 -0600 Message-ID: <20151007154309.22135.97820.stgit@gimli.home> In-Reply-To: <20151007153840.22135.78451.stgit@gimli.home> References: <20151007153840.22135.78451.stgit@gimli.home> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Eric Auger Subject: [Qemu-devel] [PULL 3/9] hw/vfio/platform: do not set resamplefd for edge-sensitive IRQS 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.williamson@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Eric Auger In irqfd mode, current code attempts to set a resamplefd whatever the type of the IRQ. For an edge-sensitive IRQ this attempt fails and as a consequence, the whole irqfd setup fails and we fall back to the slow mode. This patch bypasses the resamplefd setting for non level-sentive IRQs. Signed-off-by: Eric Auger Signed-off-by: Alex Williamson --- hw/vfio/platform.c | 42 +++++++++++++++++++++++++++--------------- trace-events | 4 +++- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index cab1517..5c1156c 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -32,6 +32,11 @@ * Functions used whatever the injection method */ +static inline bool vfio_irq_is_automasked(VFIOINTp *intp) +{ + return intp->flags & VFIO_IRQ_INFO_AUTOMASKED; +} + /** * vfio_init_intp - allocate, initialize the IRQ struct pointer * and add it into the list of IRQs @@ -65,15 +70,17 @@ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev, error_report("vfio: Error: trigger event_notifier_init failed "); return NULL; } - /* Get an eventfd for resample/unmask */ - intp->unmask = g_malloc0(sizeof(EventNotifier)); - ret = event_notifier_init(intp->unmask, 0); - if (ret) { - g_free(intp->interrupt); - g_free(intp->unmask); - g_free(intp); - error_report("vfio: Error: resamplefd event_notifier_init failed"); - return NULL; + if (vfio_irq_is_automasked(intp)) { + /* Get an eventfd for resample/unmask */ + intp->unmask = g_malloc0(sizeof(EventNotifier)); + ret = event_notifier_init(intp->unmask, 0); + if (ret) { + g_free(intp->interrupt); + g_free(intp->unmask); + g_free(intp); + error_report("vfio: Error: resamplefd event_notifier_init failed"); + return NULL; + } } QLIST_INSERT_HEAD(&vdev->intp_list, intp, next); @@ -294,7 +301,7 @@ static void vfio_platform_eoi(VFIODevice *vbasedev) /* deassert the virtual IRQ */ qemu_set_irq(intp->qemuirq, 0); - if (intp->flags & VFIO_IRQ_INFO_AUTOMASKED) { + if (vfio_irq_is_automasked(intp)) { /* unmasks the physical level-sensitive IRQ */ vfio_unmask_single_irqindex(vbasedev, intp->pin); } @@ -409,15 +416,20 @@ static void vfio_start_irqfd_injection(SysBusDevice *sbdev, qemu_irq irq) if (vfio_set_trigger_eventfd(intp, NULL) < 0) { goto fail_vfio; } - if (vfio_set_resample_eventfd(intp) < 0) { - goto fail_vfio; + if (vfio_irq_is_automasked(intp)) { + if (vfio_set_resample_eventfd(intp) < 0) { + goto fail_vfio; + } + trace_vfio_platform_start_level_irqfd_injection(intp->pin, + event_notifier_get_fd(intp->interrupt), + event_notifier_get_fd(intp->unmask)); + } else { + trace_vfio_platform_start_edge_irqfd_injection(intp->pin, + event_notifier_get_fd(intp->interrupt)); } intp->kvm_accel = true; - trace_vfio_platform_start_irqfd_injection(intp->pin, - event_notifier_get_fd(intp->interrupt), - event_notifier_get_fd(intp->unmask)); return; fail_vfio: kvm_irqchip_remove_irqfd_notifier(kvm_state, intp->interrupt, irq); diff --git a/trace-events b/trace-events index 36db793..6790292 100644 --- a/trace-events +++ b/trace-events @@ -1624,7 +1624,9 @@ vfio_platform_intp_interrupt(int pin, int fd) "Inject IRQ #%d (fd = %d)" vfio_platform_intp_inject_pending_lockheld(int pin, int fd) "Inject pending IRQ #%d (fd = %d)" vfio_platform_populate_interrupts(int pin, int count, int flags) "- IRQ index %d: count %d, flags=0x%x" vfio_intp_interrupt_set_pending(int index) "irq %d is set PENDING" -vfio_platform_start_irqfd_injection(int index, int fd, int resamplefd) "IRQ index=%d, fd = %d, resamplefd = %d" +vfio_platform_start_level_irqfd_injection(int index, int fd, int resamplefd) "IRQ index=%d, fd = %d, resamplefd = %d" +vfio_platform_start_edge_irqfd_injection(int index, int fd) "IRQ index=%d, fd = %d" + #hw/acpi/memory_hotplug.c mhp_acpi_invalid_slot_selected(uint32_t slot) "0x%"PRIx32