From patchwork Fri Oct 29 18:05:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 290872 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9TI5xId000619 for ; Fri, 29 Oct 2010 18:06:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753192Ab0J2SF5 (ORCPT ); Fri, 29 Oct 2010 14:05:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18716 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750948Ab0J2SF4 (ORCPT ); Fri, 29 Oct 2010 14:05:56 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9TI5sfD006227 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 29 Oct 2010 14:05:54 -0400 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9TI5qxt029940; Fri, 29 Oct 2010 14:05:52 -0400 From: Alex Williamson Subject: [RFC PATCH] kvm: KVM_EOI_EVENTFD support for eoi_client To: kvm@vger.kernel.org, avi@redhat.com Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws, alex.williamson@redhat.com, mst@redhat.com, chrisw@redhat.com, ddutile@redhat.com Date: Fri, 29 Oct 2010 12:05:52 -0600 Message-ID: <20101029180511.26801.99926.stgit@s20.home> In-Reply-To: <20101029175434.25281.70647.stgit@s20.home> References: <20101029175434.25281.70647.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 29 Oct 2010 18:06:00 +0000 (UTC) diff --git a/hw/ioapic.c b/hw/ioapic.c index c43be3a..707f2a2 100644 --- a/hw/ioapic.c +++ b/hw/ioapic.c @@ -72,14 +72,66 @@ static QLIST_HEAD(ioapic_eoi_client_list, ioapic_eoi_client) ioapic_eoi_client_list = QLIST_HEAD_INITIALIZER(ioapic_eoi_client_list); +#ifdef KVM_EOI_EVENTFD +static void ioapic_eoi_callback(void *opaque) +{ + ioapic_eoi_client *client = opaque; + + if (!event_notifier_test_and_clear(&client->notifier)) { + return; + } + + client->eoi(client); +} +#endif + int ioapic_register_eoi_client(ioapic_eoi_client *client) { QLIST_INSERT_HEAD(&ioapic_eoi_client_list, client, list); + +#ifdef KVM_EOI_EVENTFD + if (kvm_enabled() && kvm_irqchip_in_kernel()) { + int ret, fd; + + ret = event_notifier_init(&client->notifier, 0); + if (ret) { + fprintf(stderr, "%s notifier init failed %d\n", __FUNCTION__, ret); + return ret; + } + + fd = event_notifier_get_fd(&client->notifier); + qemu_set_fd_handler(fd, ioapic_eoi_callback, NULL, client); + + ret = kvm_eoi_eventfd(client->irq, fd, KVM_EOI_EVENTFD_FLAG_DEASSERT); + if (ret) { + fprintf(stderr, "%s eoi eventfd failed %d\n", __FUNCTION__, ret); + return ret; + } + client->notifier_enabled = true; + } +#endif return 0; } void ioapic_unregister_eoi_client(ioapic_eoi_client *client) { +#ifdef KVM_EOI_EVENTFD + if (kvm_enabled() && kvm_irqchip_in_kernel()) { + int ret, fd; + + fd = event_notifier_get_fd(&client->notifier); + + ret = kvm_eoi_eventfd(client->irq, fd, KVM_EOI_EVENTFD_FLAG_DEASSIGN); + if (ret) { + fprintf(stderr, "%s eoi eventfd failed %d\n", __FUNCTION__, ret); + } + + qemu_set_fd_handler(fd, NULL, NULL, NULL); + + event_notifier_cleanup(&client->notifier); + client->notifier_enabled = false; + } +#endif QLIST_REMOVE(client, list); }