From patchwork Mon Oct 5 20:36:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 54508 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id 24BA022F05 for ; Mon, 5 Oct 2015 20:40:24 +0000 (UTC) Received: by lbos8 with SMTP id s8sf17179191lbo.2 for ; Mon, 05 Oct 2015 13:40: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=Jv1/41gX4W+UcDg1HZRExPGssZTPoiVk83vjxR1iWF4=; b=Uwg+lgfFWj4SEzJg+Vgv1soB8iJRccmp0fKTLTC69c3lzweQqeQl6T/KcWRbIavYXV k8qgptnP7I4Y9PSzqsqwyn02yU8p32NPTnA+9IHo0YxX6Xvpr9UmEKi5Sdx9IK0xixMt juyo7vW+Jjp21JS3/xdMkd5aoS8Y1PwGHW7oA1nJ73MB2WR+vzJeeK2kBPrakCm8KpFI M4qOPnJqWB7OMdR/wXoU0Liyl4BRMlm2TRMnjc0iLPK21X1J+UtmybPfRpGoiKrL7616 AiT05gwPvzlF5nJXd3ELG3UcPEZkFu/VG9UnRqYbv+w1gVgFUfXz2dfzE4SdtSZlTLiD e5xQ== X-Gm-Message-State: ALoCoQlv4TC955wG6BkqH+WwyD5N3p8/E3wq0Lg2uoPWDnJHunndGEn+sqDGi4Og17WBeNm8y7u5 X-Received: by 10.112.181.10 with SMTP id ds10mr4511731lbc.3.1444077623116; Mon, 05 Oct 2015 13:40:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.156.78 with SMTP id f75ls511833lfe.69.gmail; Mon, 05 Oct 2015 13:40:22 -0700 (PDT) X-Received: by 10.112.130.39 with SMTP id ob7mr12856718lbb.66.1444077622809; Mon, 05 Oct 2015 13:40:22 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id sv1si16083058lbb.14.2015.10.05.13.40.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Oct 2015 13:40:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbwr8 with SMTP id r8so64825310lbw.2 for ; Mon, 05 Oct 2015 13:40:22 -0700 (PDT) X-Received: by 10.112.180.230 with SMTP id dr6mr12425585lbc.72.1444077622512; Mon, 05 Oct 2015 13:40:22 -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 w3csp1466087lbq; Mon, 5 Oct 2015 13:40:21 -0700 (PDT) X-Received: by 10.140.87.97 with SMTP id q88mr41740782qgd.86.1444077621047; Mon, 05 Oct 2015 13:40:21 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m7si24799366qge.113.2015.10.05.13.40.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 05 Oct 2015 13:40:21 -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]:47638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjCYW-0000ts-7W for patch@linaro.org; Mon, 05 Oct 2015 16:40:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjCV7-0003qG-RE for qemu-devel@nongnu.org; Mon, 05 Oct 2015 16:36:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjCV4-00009e-JX for qemu-devel@nongnu.org; Mon, 05 Oct 2015 16:36:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjCV4-00009G-Bv for qemu-devel@nongnu.org; Mon, 05 Oct 2015 16:36:46 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 1730C8E3F2; Mon, 5 Oct 2015 20:36:46 +0000 (UTC) Received: from gimli.home (ovpn-113-42.phx2.redhat.com [10.3.113.42]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t95Kaj0D021697; Mon, 5 Oct 2015 16:36:45 -0400 From: Alex Williamson To: qemu-devel@nongnu.org Date: Mon, 05 Oct 2015 14:36:45 -0600 Message-ID: <20151005203637.310.65864.stgit@gimli.home> In-Reply-To: <20151005203357.310.44414.stgit@gimli.home> References: <20151005203357.310.44414.stgit@gimli.home> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 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 02/10] hw/vfio/platform: change interrupt/unmask fields into pointer 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.171 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 unmask EventNotifier might not be initialized in case of edge sensitive irq. Using EventNotifier pointers make life simpler to handle the edge-sensitive irqfd setup. Signed-off-by: Eric Auger Signed-off-by: Alex Williamson --- hw/vfio/platform.c | 35 ++++++++++++++++++++--------------- include/hw/vfio/vfio-platform.h | 4 ++-- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index d864342..cab1517 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -57,15 +57,20 @@ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev, sysbus_init_irq(sbdev, &intp->qemuirq); /* Get an eventfd for trigger */ - ret = event_notifier_init(&intp->interrupt, 0); + intp->interrupt = g_malloc0(sizeof(EventNotifier)); + ret = event_notifier_init(intp->interrupt, 0); if (ret) { + g_free(intp->interrupt); g_free(intp); error_report("vfio: Error: trigger event_notifier_init failed "); return NULL; } /* Get an eventfd for resample/unmask */ - ret = event_notifier_init(&intp->unmask, 0); + 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; @@ -100,7 +105,7 @@ static int vfio_set_trigger_eventfd(VFIOINTp *intp, irq_set->start = 0; irq_set->count = 1; pfd = (int32_t *)&irq_set->data; - *pfd = event_notifier_get_fd(&intp->interrupt); + *pfd = event_notifier_get_fd(intp->interrupt); qemu_set_fd_handler(*pfd, (IOHandler *)handler, NULL, intp); ret = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set); g_free(irq_set); @@ -182,7 +187,7 @@ static void vfio_intp_mmap_enable(void *opaque) static void vfio_intp_inject_pending_lockheld(VFIOINTp *intp) { trace_vfio_platform_intp_inject_pending_lockheld(intp->pin, - event_notifier_get_fd(&intp->interrupt)); + event_notifier_get_fd(intp->interrupt)); intp->state = VFIO_IRQ_ACTIVE; @@ -224,18 +229,18 @@ static void vfio_intp_interrupt(VFIOINTp *intp) trace_vfio_intp_interrupt_set_pending(intp->pin); QSIMPLEQ_INSERT_TAIL(&vdev->pending_intp_queue, intp, pqnext); - ret = event_notifier_test_and_clear(&intp->interrupt); + ret = event_notifier_test_and_clear(intp->interrupt); qemu_mutex_unlock(&vdev->intp_mutex); return; } trace_vfio_platform_intp_interrupt(intp->pin, - event_notifier_get_fd(&intp->interrupt)); + event_notifier_get_fd(intp->interrupt)); - ret = event_notifier_test_and_clear(&intp->interrupt); + ret = event_notifier_test_and_clear(intp->interrupt); if (!ret) { error_report("Error when clearing fd=%d (ret = %d)", - event_notifier_get_fd(&intp->interrupt), ret); + event_notifier_get_fd(intp->interrupt), ret); } intp->state = VFIO_IRQ_ACTIVE; @@ -283,7 +288,7 @@ static void vfio_platform_eoi(VFIODevice *vbasedev) QLIST_FOREACH(intp, &vdev->intp_list, next) { if (intp->state == VFIO_IRQ_ACTIVE) { trace_vfio_platform_eoi(intp->pin, - event_notifier_get_fd(&intp->interrupt)); + event_notifier_get_fd(intp->interrupt)); intp->state = VFIO_IRQ_INACTIVE; /* deassert the virtual IRQ */ @@ -360,7 +365,7 @@ static int vfio_set_resample_eventfd(VFIOINTp *intp) irq_set->start = 0; irq_set->count = 1; pfd = (int32_t *)&irq_set->data; - *pfd = event_notifier_get_fd(&intp->unmask); + *pfd = event_notifier_get_fd(intp->unmask); qemu_set_fd_handler(*pfd, NULL, NULL, NULL); ret = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set); g_free(irq_set); @@ -396,8 +401,8 @@ static void vfio_start_irqfd_injection(SysBusDevice *sbdev, qemu_irq irq) } assert(intp); - if (kvm_irqchip_add_irqfd_notifier(kvm_state, &intp->interrupt, - &intp->unmask, irq) < 0) { + if (kvm_irqchip_add_irqfd_notifier(kvm_state, intp->interrupt, + intp->unmask, irq) < 0) { goto fail_irqfd; } @@ -411,11 +416,11 @@ static void vfio_start_irqfd_injection(SysBusDevice *sbdev, qemu_irq irq) intp->kvm_accel = true; trace_vfio_platform_start_irqfd_injection(intp->pin, - event_notifier_get_fd(&intp->interrupt), - event_notifier_get_fd(&intp->unmask)); + 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); + kvm_irqchip_remove_irqfd_notifier(kvm_state, intp->interrupt, irq); error_report("vfio: failed to start eventfd signaling for IRQ %d: %m", intp->pin); abort(); diff --git a/include/hw/vfio/vfio-platform.h b/include/hw/vfio/vfio-platform.h index c5cf1d7..b468f80 100644 --- a/include/hw/vfio/vfio-platform.h +++ b/include/hw/vfio/vfio-platform.h @@ -34,8 +34,8 @@ enum { typedef struct VFIOINTp { QLIST_ENTRY(VFIOINTp) next; /* entry for IRQ list */ QSIMPLEQ_ENTRY(VFIOINTp) pqnext; /* entry for pending IRQ queue */ - EventNotifier interrupt; /* eventfd triggered on interrupt */ - EventNotifier unmask; /* eventfd for unmask on QEMU bypass */ + EventNotifier *interrupt; /* eventfd triggered on interrupt */ + EventNotifier *unmask; /* eventfd for unmask on QEMU bypass */ qemu_irq qemuirq; struct VFIOPlatformDevice *vdev; /* back pointer to device */ int state; /* inactive, pending, active */