From patchwork Thu Sep 24 20:08:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 54130 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id 14DB322B1E for ; Thu, 24 Sep 2015 20:08:59 +0000 (UTC) Received: by laff1 with SMTP id f1sf27885585laf.2 for ; Thu, 24 Sep 2015 13:08:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=mfols4NbB3AbuXGp5/y6lr2jjLcId7Zh5z2yd2yYCzE=; b=LdeK11qkW+pB9SSF1CKesRR3TEIlVtuwXUNEYbUG7NbZsgDcR7M+M85lNsj5FXhmSL LWbQOHEMCfSCuCvvPr7n6fvLXs6Mslp52skHffoC+RLTNaiMZ+EJGrPF68hlhGbGW4a0 IQNYi/c97EU2CJNuypgn/Qlb9tSDpXR66ft7sHjpH93YQQuC/hpTkKKK3RWl+ZId02wd JSwr7uUiCIgLB+SyZ41GX88TlSiYR0XKYIGOGu+d4M7BlkYCUaI5sw+DjrFP6kER7Ue5 LM2VqCMP2rGJaabLjX2PV8DuoOsSeRMjGYgYvWMJ1WVONDspiLrrBpXOUsMrgS1X82Jp P+3A== X-Gm-Message-State: ALoCoQmcEFWywpXvYimnhMwYPT5QBWrX3mgxSmfoqcY9iJweOQktReNdIY51W6mHLQhZepYoA0e5 X-Received: by 10.112.54.197 with SMTP id l5mr239550lbp.21.1443125338039; Thu, 24 Sep 2015 13:08:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.19.36 with SMTP id j36ls194154lfi.50.gmail; Thu, 24 Sep 2015 13:08:57 -0700 (PDT) X-Received: by 10.152.22.102 with SMTP id c6mr472367laf.16.1443125337906; Thu, 24 Sep 2015 13:08:57 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id 29si1385lfq.18.2015.09.24.13.08.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Sep 2015 13:08:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by lacdq2 with SMTP id dq2so21208279lac.1 for ; Thu, 24 Sep 2015 13:08:57 -0700 (PDT) X-Received: by 10.152.26.41 with SMTP id i9mr467606lag.36.1443125337761; Thu, 24 Sep 2015 13:08:57 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.59.35 with SMTP id w3csp533369lbq; Thu, 24 Sep 2015 13:08:57 -0700 (PDT) X-Received: by 10.180.96.166 with SMTP id dt6mr2496855wib.38.1443125334511; Thu, 24 Sep 2015 13:08:54 -0700 (PDT) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com. [209.85.212.172]) by mx.google.com with ESMTPS id u5si18754841wja.52.2015.09.24.13.08.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Sep 2015 13:08:54 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.172 as permitted sender) client-ip=209.85.212.172; Received: by wicgb1 with SMTP id gb1so265459154wic.1 for ; Thu, 24 Sep 2015 13:08:54 -0700 (PDT) X-Received: by 10.180.107.1 with SMTP id gy1mr12852378wib.56.1443125334271; Thu, 24 Sep 2015 13:08:54 -0700 (PDT) Received: from midway01-04-00.lavalab ([81.128.185.50]) by smtp.gmail.com with ESMTPSA id p4sm6978890wia.15.2015.09.24.13.08.52 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Sep 2015 13:08:53 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, qemu-devel@nongnu.org, alex.williamson@redhat.com Cc: patches@linaro.org, christoffer.dall@linaro.org Subject: [PATCH v2 3/3] hw/vfio/platform: do not set resamplefd for edge-sensitive IRQS Date: Thu, 24 Sep 2015 21:08:39 +0100 Message-Id: <1443125319-16691-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1443125319-16691-1-git-send-email-eric.auger@linaro.org> References: <1443125319-16691-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- v1 -> v2: - introduce vfio_irq_is_automasked helper function. in case of edge-sensitive IRQ, do not allocate/initialize unmask EventNotifier nor call vfio_set_resample_eventfd --- 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 25c53e0..8f7829e 100644 --- a/trace-events +++ b/trace-events @@ -1621,7 +1621,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