From patchwork Tue Mar 13 10:35:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 146381 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 43B69B6EF3 for ; Tue, 13 Mar 2012 21:36:04 +1100 (EST) Received: from localhost ([::1]:34537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7P5D-0006Ri-J2 for incoming@patchwork.ozlabs.org; Tue, 13 Mar 2012 06:35:59 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7P56-0006R5-1N for qemu-devel@nongnu.org; Tue, 13 Mar 2012 06:35:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7P4z-000352-RW for qemu-devel@nongnu.org; Tue, 13 Mar 2012 06:35:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7P4z-00034y-Jb for qemu-devel@nongnu.org; Tue, 13 Mar 2012 06:35:45 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2DAZg5i007631 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 13 Mar 2012 06:35:42 -0400 Received: from dhcp-8-167.nay.redhat.com (dhcp-8-167.nay.redhat.com [10.66.8.167]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2DAZev4019670; Tue, 13 Mar 2012 06:35:40 -0400 To: aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, kvm@vger.kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org, avi@redhat.com From: Amos Kong Date: Tue, 13 Mar 2012 18:35:39 +0800 Message-ID: <20120313103539.8714.53454.stgit@dhcp-8-167.nay.redhat.com> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/2] return available ioeventfds count in kvm_has_many_ioeventfds() 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 Older kernels have a 6 device limit on the KVM io bus. This patch makes kvm_has_many_ioeventfds() return available ioeventfd count. ioeventfd will be disabled if there is no 7 available ioeventfds. Signed-off-by: Amos Kong --- hw/virtio-pci.c | 2 +- kvm-all.c | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index a0fb7c1..d63f303 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -678,7 +678,7 @@ void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev) pci_register_bar(&proxy->pci_dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &proxy->bar); - if (!kvm_has_many_ioeventfds()) { + if (kvm_has_many_ioeventfds() != 7) { proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD; } diff --git a/kvm-all.c b/kvm-all.c index 3c6b4f0..d12694b 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -78,7 +78,6 @@ struct KVMState int pit_in_kernel; int pit_state2; int xsave, xcrs; - int many_ioeventfds; int irqchip_inject_ioctl; #ifdef KVM_CAP_IRQ_ROUTING struct kvm_irq_routing *irq_routes; @@ -510,8 +509,8 @@ static int kvm_check_many_ioeventfds(void) } } - /* Decide whether many devices are supported or not */ - ret = i == ARRAY_SIZE(ioeventfds); + /* If i equals to 7, many devices are supported */ + ret = i; while (i-- > 0) { kvm_set_ioeventfd_pio_word(ioeventfds[i], 0, i, false); @@ -1078,8 +1077,6 @@ int kvm_init(void) kvm_state = s; memory_listener_register(&kvm_memory_listener, NULL); - s->many_ioeventfds = kvm_check_many_ioeventfds(); - cpu_interrupt_handler = kvm_handle_interrupt; return 0; @@ -1407,7 +1404,7 @@ int kvm_has_many_ioeventfds(void) if (!kvm_enabled()) { return 0; } - return kvm_state->many_ioeventfds; + return kvm_check_many_ioeventfds(); } int kvm_has_gsi_routing(void)