From patchwork Thu May 17 13:32:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 159905 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2523FB6FB9 for ; Thu, 17 May 2012 23:34:19 +1000 (EST) Received: from localhost ([::1]:50271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV0qO-0003Qh-W8 for incoming@patchwork.ozlabs.org; Thu, 17 May 2012 09:34:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV0pM-0001OE-B2 for qemu-devel@nongnu.org; Thu, 17 May 2012 09:33:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SV0pG-0004Zu-MO for qemu-devel@nongnu.org; Thu, 17 May 2012 09:33:11 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:49770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV0pG-0004ZT-Dv for qemu-devel@nongnu.org; Thu, 17 May 2012 09:33:06 -0400 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate02.web.de (Postfix) with ESMTP id 2151C1C4B8FCF for ; Thu, 17 May 2012 15:33:05 +0200 (CEST) Received: from localhost.localdomain ([187.105.13.240]) by smtp.web.de (mrweb001) with ESMTPA (Nemesis) id 0M7blv-1S8VjM1cwx-00xKlx; Thu, 17 May 2012 15:33:05 +0200 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Thu, 17 May 2012 10:32:35 -0300 Message-Id: X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-Provags-ID: V02:K0:zae5Olaa5LgeM5v+QXgfQVJABKoGsR+7uHHKL/JFOTZ Xq8O6kBfYvk9Nipyb+bQU+vSLIeklN+FJ8u+GHcMe0JIUq12cS untMHzjgzW78T3Xkx3BxQn0mM0nvaa/tymTYOvBU7Zy1ddTRvW rEFKxmAa8FeWbeIH3fOR4UEz7JeidRvzMqUZ8avIzm41Al66v+ xZClKVJMwJhO5F6AWtSpQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.227 Cc: qemu-devel , kvm@vger.kernel.org, "Michael S. Tsirkin" Subject: [Qemu-devel] [RFC][PATCH v2 07/11] kvm: Make kvm_irqchip_commit_routes an internal service 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 From: Jan Kiszka Automatically commit route changes after kvm_add_routing_entry and kvm_irqchip_release_virq. There is no performance relevant use case for which collecting multiple route changes is beneficial. This makes kvm_irqchip_commit_routes an internal service which assert()s that the corresponding IOCTL will always succeed. Signed-off-by: Jan Kiszka --- hw/pc_piix.c | 6 +----- kvm-all.c | 26 ++++++++++++++------------ kvm.h | 1 - 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/hw/pc_piix.c b/hw/pc_piix.c index c17f906..044dfcb 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -56,7 +56,7 @@ static void kvm_piix3_setup_irq_routing(bool pci_enabled) { #ifdef CONFIG_KVM KVMState *s = kvm_state; - int ret, i; + int i; if (kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) { for (i = 0; i < 8; ++i) { @@ -77,10 +77,6 @@ static void kvm_piix3_setup_irq_routing(bool pci_enabled) } } } - ret = kvm_irqchip_commit_routes(s); - if (ret < 0) { - hw_error("KVM IRQ routing setup failed"); - } } #endif /* CONFIG_KVM */ } diff --git a/kvm-all.c b/kvm-all.c index ca6cec6..e96f092 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -908,6 +908,15 @@ static void kvm_init_irq_routing(KVMState *s) kvm_arch_init_irq_routing(s); } +static void kvm_irqchip_commit_routes(KVMState *s) +{ + int ret; + + s->irq_routes->flags = 0; + ret = kvm_vm_ioctl(s, KVM_SET_GSI_ROUTING, s->irq_routes); + assert(ret == 0); +} + static void kvm_add_routing_entry(KVMState *s, struct kvm_irq_routing_entry *entry) { @@ -933,6 +942,8 @@ static void kvm_add_routing_entry(KVMState *s, new->u = entry->u; set_gsi(s, entry->gsi); + + kvm_irqchip_commit_routes(s); } void kvm_irqchip_add_irq_route(KVMState *s, int irq, int irqchip, int pin) @@ -949,12 +960,6 @@ void kvm_irqchip_add_irq_route(KVMState *s, int irq, int irqchip, int pin) kvm_add_routing_entry(s, &e); } -int kvm_irqchip_commit_routes(KVMState *s) -{ - s->irq_routes->flags = 0; - return kvm_vm_ioctl(s, KVM_SET_GSI_ROUTING, s->irq_routes); -} - void kvm_irqchip_release_virq(KVMState *s, int virq) { struct kvm_irq_routing_entry *e; @@ -968,6 +973,8 @@ void kvm_irqchip_release_virq(KVMState *s, int virq) } } clear_gsi(s, virq); + + kvm_irqchip_commit_routes(s); } static unsigned int kvm_hash_msi(uint32_t data) @@ -1049,7 +1056,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg) route = kvm_lookup_msi_route(s, msg); if (!route) { - int virq, ret; + int virq; virq = kvm_irqchip_get_virq(s); if (virq < 0) { @@ -1068,11 +1075,6 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg) QTAILQ_INSERT_TAIL(&s->msi_hashtab[kvm_hash_msi(msg.data)], route, entry); - - ret = kvm_irqchip_commit_routes(s); - if (ret < 0) { - return ret; - } } assert(route->kroute.type == KVM_IRQ_ROUTING_MSI); diff --git a/kvm.h b/kvm.h index 1779e73..f0d0c53 100644 --- a/kvm.h +++ b/kvm.h @@ -135,7 +135,6 @@ int kvm_irqchip_set_irq(KVMState *s, int irq, int level); int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg); void kvm_irqchip_add_irq_route(KVMState *s, int gsi, int irqchip, int pin); -int kvm_irqchip_commit_routes(KVMState *s); void kvm_put_apic_state(DeviceState *d, struct kvm_lapic_state *kapic); void kvm_get_apic_state(DeviceState *d, struct kvm_lapic_state *kapic);