From patchwork Thu May 5 19:06:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrill Gorcunov X-Patchwork-Id: 757982 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p45J7jdo017008 for ; Thu, 5 May 2011 19:07:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753007Ab1EETHm (ORCPT ); Thu, 5 May 2011 15:07:42 -0400 Received: from mail-ey0-f174.google.com ([209.85.215.174]:33162 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753312Ab1EETHj (ORCPT ); Thu, 5 May 2011 15:07:39 -0400 Received: by mail-ey0-f174.google.com with SMTP id 24so765578eyx.19 for ; Thu, 05 May 2011 12:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:user-agent:date:from:to:cc:subject :references:content-disposition; bh=nffVL82T267/3HRDyUffw6iZSqoM3mLtKbJZxUVI11c=; b=MmLBX9eio0iXZseDcI6BZm94hT8waljfab+QqSFNJYaMRogWBf2XebSCDgtnHz3FAN H3LulhptSo07DLTNYQPBPuzUAzw1D0BrQmwIUE+JdJ47DsOSVkA+CP4xAfyI46Kqz8Gv +Si9IbRIS31ziK6UlaLsUiQil/FWeMR/WC/ZA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:user-agent:date:from:to:cc:subject:references :content-disposition; b=QHRnKX/yCn/DkVM9VXfET6CRoYo7e+eTD4Z79YU3dfb0SoOOD+RpJ3FlUKURVQEVmE r3NDXhV2FD74nLFgAp9eUINCQ0uk6F3fA5pTIgzg19Y4bftSTU3Ltgnzlt4N3y92p8ZT cpQFkGJwvVwmYKwxQXjFrhQNhSn7ROCYco+9g= Received: by 10.213.110.143 with SMTP id n15mr501001ebp.101.1304622459072; Thu, 05 May 2011 12:07:39 -0700 (PDT) Received: from gorcunov (95-26-151-141.broadband.corbina.ru [95.26.151.141]) by mx.google.com with ESMTPS id e32sm689643eee.5.2011.05.05.12.07.34 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 May 2011 12:07:36 -0700 (PDT) Received: by gorcunov (Postfix, from userid 1000) id D37E39E; Thu, 5 May 2011 23:07:33 +0400 (MSD) Message-Id: <20110505190733.660393774@gmail.com> User-Agent: quilt/0.47-1 Date: Thu, 05 May 2011 23:06:41 +0400 From: Cyrill Gorcunov To: penberg@kernel.org, mingo@elte.hu Cc: asias.hejun@gmail.com, prasadjoshi124@gmail.com, kvm@vger.kernel.org, levinsasha928@gmail.com, Cyrill Gorcunov Subject: [patch 2/2] kvm tools - Cleanup IRQs definitions for virtio pci devices References: <20110505190639.741709609@gmail.com> Content-Disposition: inline; filename=kvm-tools-virtio-pci-irqs 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.6 (demeter2.kernel.org [140.211.167.43]); Thu, 05 May 2011 19:07:45 +0000 (UTC) This also requires to tune up mptable code. Note the srcbusirq need to follow specification convention, so we merge device number and pin into one field inside mptable_set_default_int_src helper. Signed-off-by: Cyrill Gorcunov --- tools/kvm/include/kvm/virtio-pci-dev.h | 16 +++++-- tools/kvm/mptable.c | 67 ++++++++++++++++++++++++--------- 2 files changed, 61 insertions(+), 22 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6.git/tools/kvm/include/kvm/virtio-pci-dev.h ===================================================================== --- linux-2.6.git.orig/tools/kvm/include/kvm/virtio-pci-dev.h +++ linux-2.6.git/tools/kvm/include/kvm/virtio-pci-dev.h @@ -30,11 +30,19 @@ enum { VIRTIO_RNG_PIN = 4, }; +/* + * The IRQ numbers should confirm Linux IRQ numbering + * scheme model, which supposes devices to start IRQs + * from 32 ... 127, but 0x30-0x3f are used for ISA + * interrupts so we choose 0x40 as the origin. + */ +#define VIRTIO_PCI_DEV_FIRST_IRQ 0x40 + enum { - VIRTIO_RNG_IRQ = 11, - VIRTIO_CONSOLE_IRQ = 13, - VIRTIO_NET_IRQ = 14, - VIRTIO_BLK_IRQ = 15, + VIRTIO_RNG_IRQ = VIRTIO_PCI_DEV_FIRST_IRQ + 0, + VIRTIO_CONSOLE_IRQ = VIRTIO_PCI_DEV_FIRST_IRQ + 1, + VIRTIO_NET_IRQ = VIRTIO_PCI_DEV_FIRST_IRQ + 2, + VIRTIO_BLK_IRQ = VIRTIO_PCI_DEV_FIRST_IRQ + 3, }; #endif /* VIRTIO_PCI_DEV_H_ */ Index: linux-2.6.git/tools/kvm/mptable.c ===================================================================== --- linux-2.6.git.orig/tools/kvm/mptable.c +++ linux-2.6.git/tools/kvm/mptable.c @@ -3,6 +3,7 @@ #include "kvm/apic.h" #include "kvm/mptable.h" #include "kvm/util.h" +#include "kvm/virtio-pci-dev.h" #include #include @@ -60,16 +61,17 @@ static unsigned int gen_cpu_flag(unsigne */ #define MPTABLE_MAX_CPUS 255 -static void mptable_add_irq_src(struct mpc_intsrc *mpc_intsrc, - u16 srcbusid, u16 srcbusirq, - u16 dstapic, u16 dstirq) +static void +mptable_set_default_int_src(struct mpc_intsrc *dst, + u8 dev, u8 pin, u16 srcbusid, + u16 dstapic, u16 dstirq) { - *mpc_intsrc = (struct mpc_intsrc) { + *dst = (struct mpc_intsrc) { .type = MP_INTSRC, .irqtype = mp_INT, .irqflag = MP_IRQDIR_DEFAULT, .srcbus = srcbusid, - .srcbusirq = srcbusirq, + .srcbusirq = (dev << 2) | (pin - 1), .dstapic = dstapic, .dstirq = dstirq }; @@ -186,28 +188,57 @@ void mptable_setup(struct kvm *kvm, unsi * * Also note we use PCI irqs here, no for ISA bus yet. */ - mpc_intsrc = last_addr; - /* src irq = virtio console irq pin, dst irq = virtio console irq */ - mptable_add_irq_src(mpc_intsrc, pcibusid, 2, ioapicid, 13); - last_addr = (void *)&mpc_intsrc[1]; + /* + * Virtio console. + */ + mpc_intsrc = last_addr; + mptable_set_default_int_src(mpc_intsrc, + PCI_VIRTIO_CONSOLE_DEVNUM, + VIRTIO_CONSOLE_PIN, + pcibusid, ioapicid, + VIRTIO_CONSOLE_IRQ); + last_addr = (void *)&mpc_intsrc[1]; nentries++; - /* Currently we define 4 possible virtio-blk devices */ + /* + * Virtio block devices. + * + * Currently we define 4 possible virtio-blk devices. + */ for (i = 0; i < 4; i++) { - mpc_intsrc = last_addr; - - /* src irq = virtio blk irq pin, dst irq = virtio blk irq */ - mptable_add_irq_src(mpc_intsrc, pcibusid, 1, ioapicid, 9 + i); - last_addr = (void *)&mpc_intsrc[1]; + mpc_intsrc = last_addr; + mptable_set_default_int_src(mpc_intsrc, + PCI_VIRTIO_BLK_DEVNUM, + VIRTIO_BLK_PIN, + pcibusid, ioapicid, + VIRTIO_BLK_IRQ + i); + last_addr = (void *)&mpc_intsrc[1]; nentries++; } + /* + * Virtio net device. + */ mpc_intsrc = last_addr; + mptable_set_default_int_src(mpc_intsrc, + PCI_VIRTIO_NET_DEVNUM, + VIRTIO_NET_PIN, + pcibusid, ioapicid, + VIRTIO_NET_IRQ); + last_addr = (void *)&mpc_intsrc[1]; + nentries++; - /* src irq = virtio net irq pin, dst irq = virtio net irq */ - mptable_add_irq_src(mpc_intsrc, pcibusid, 3, ioapicid, 14); - last_addr = (void *)&mpc_intsrc[1]; + /* + * Virtio random number generator. + */ + mpc_intsrc = last_addr; + mptable_set_default_int_src(mpc_intsrc, + PCI_VIRTIO_RNG_DEVNUM, + VIRTIO_RNG_PIN, + pcibusid, ioapicid, + VIRTIO_RNG_IRQ); + last_addr = (void *)&mpc_intsrc[1]; nentries++; /*