From patchwork Thu May 10 21:02:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 158397 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 8632CB7070 for ; Fri, 11 May 2012 07:04:29 +1000 (EST) Received: from localhost ([::1]:50349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSaXD-0002HY-C6 for incoming@patchwork.ozlabs.org; Thu, 10 May 2012 17:04:27 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSaWD-0000A1-5Q for qemu-devel@nongnu.org; Thu, 10 May 2012 17:03:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SSaWB-0006TN-58 for qemu-devel@nongnu.org; Thu, 10 May 2012 17:03:24 -0400 Received: from thoth.sbs.de ([192.35.17.2]:17222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSaWA-0006St-Rd for qemu-devel@nongnu.org; Thu, 10 May 2012 17:03:23 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.13.6/8.13.6) with ESMTP id q4AL3KC3027887; Thu, 10 May 2012 23:03:20 +0200 Received: from mchn199C.mchp.siemens.de ([139.22.46.144]) by mail1.siemens.de (8.13.6/8.13.6) with SMTP id q4AL31bC028153; Thu, 10 May 2012 23:03:19 +0200 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Thu, 10 May 2012 18:02:56 -0300 Message-Id: <609893bc15a234f0d39d535f4fa5f9ec3e294750.1336683774.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.2 Cc: qemu-devel , kvm@vger.kernel.org, "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH v3 7/8] kvm: Add support for direct MSI injections 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 If the kernel supports KVM_SIGNAL_MSI, we can avoid the route-based MSI injection mechanism. Signed-off-by: Jan Kiszka --- kvm-all.c | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index e7ed510..4e8c8f7 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -96,6 +96,7 @@ struct KVMState uint32_t *used_gsi_bitmap; unsigned int gsi_count; QTAILQ_HEAD(msi_hashtab, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE]; + bool direct_msi; #endif }; @@ -898,8 +899,10 @@ static void kvm_init_irq_routing(KVMState *s) s->irq_routes = g_malloc0(sizeof(*s->irq_routes)); s->nr_allocated_irq_routes = 0; - for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) { - QTAILQ_INIT(&s->msi_hashtab[i]); + if (!s->direct_msi) { + for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) { + QTAILQ_INIT(&s->msi_hashtab[i]); + } } kvm_arch_init_irq_routing(s); @@ -1005,7 +1008,7 @@ again: return bit - 1 + i * 32; } - if (retry) { + if (!s->direct_msi && retry) { retry = false; kvm_flush_dynamic_msi_routes(s); goto again; @@ -1031,8 +1034,19 @@ static KVMMSIRoute *kvm_lookup_msi_route(KVMState *s, MSIMessage msg) int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg) { + struct kvm_msi msi; KVMMSIRoute *route; + if (s->direct_msi) { + msi.address_lo = (uint32_t)msg.address; + msi.address_hi = msg.address >> 32; + msi.data = msg.data; + msi.flags = 0; + memset(msi.pad, 0, sizeof(msi.pad)); + + return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi); + } + route = kvm_lookup_msi_route(s, msg); if (!route) { int gsi, ret; @@ -1209,6 +1223,8 @@ int kvm_init(void) s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2); #endif + s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0); + ret = kvm_arch_init(s); if (ret < 0) { goto err;