From patchwork Thu May 26 06:42:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 819722 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 p4Q6h0e6032679 for ; Thu, 26 May 2011 06:43:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755327Ab1EZGm5 (ORCPT ); Thu, 26 May 2011 02:42:57 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:35568 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755070Ab1EZGmy (ORCPT ); Thu, 26 May 2011 02:42:54 -0400 Received: by mail-ww0-f44.google.com with SMTP id 36so405206wwa.1 for ; Wed, 25 May 2011 23:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=p3zeDrdJ1izlwyRMGw1/7ZSqEiiAKXUzmxhwQYsSZ/Q=; b=RSSrYBCL8wS1DxhF2GvIhdmgvjWEsiS1Hb6hYGfBasV+FkQ4G6keAXBJ2YjcVFY468 bgVGAIfVp1asY54XH7Msdr3rgpNN0YG3V15m+bJ2XXSDiJmQk33C4L3emmWfDqSKQuvt VgUovR4Nj62qH0n5ww4Dd4eJvgCcMyjeMeDgo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=S5uVq+oN5YWPOrdMCbkSmJG2/ljLJXTxrAo9pOpABMWh9oHaps/lEhXzkSyTiKPtfX JFbIH5hndeRlt4pcbfJetPT0wQU+saVKwfb8eLKOPMtlCE3PU1WlXrw6gde/i5PGqAnV D3FR0NvkZEYN6etpxjzTbmxEsZV/30pv0mYOU= Received: by 10.227.164.79 with SMTP id d15mr444741wby.62.1306392173933; Wed, 25 May 2011 23:42:53 -0700 (PDT) Received: from localhost.localdomain ([109.66.201.145]) by mx.google.com with ESMTPS id d19sm243507wbh.8.2011.05.25.23.42.52 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2011 23:42:53 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: john@jfloren.net, kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, Sasha Levin Subject: [PATCH v2 6/8] kvm tools: Use dynamic IO port allocation in 9p driver Date: Thu, 26 May 2011 09:42:13 +0300 Message-Id: <1306392135-16993-6-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 In-Reply-To: <1306392135-16993-1-git-send-email-levinsasha928@gmail.com> References: <1306392135-16993-1-git-send-email-levinsasha928@gmail.com> 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 (demeter1.kernel.org [140.211.167.41]); Thu, 26 May 2011 06:43:01 +0000 (UTC) Signed-off-by: Sasha Levin --- tools/kvm/include/kvm/ioport.h | 2 -- tools/kvm/virtio/9p.c | 12 +++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/kvm/include/kvm/ioport.h b/tools/kvm/include/kvm/ioport.h index 5dee9d2..a6bcc6a 100644 --- a/tools/kvm/include/kvm/ioport.h +++ b/tools/kvm/include/kvm/ioport.h @@ -10,8 +10,6 @@ #define IOPORT_START 0x6200 #define IOPORT_SIZE 0x400 -#define IOPORT_VIRTIO_P9 0xb200 /* Virtio 9P device */ -#define IOPORT_VIRTIO_P9_SIZE 256 #define IOPORT_VIRTIO_CONSOLE 0xd200 /* Virtio console device */ #define IOPORT_VIRTIO_CONSOLE_SIZE 256 #define IOPORT_VIRTIO_NET 0xe200 /* Virtio network device */ diff --git a/tools/kvm/virtio/9p.c b/tools/kvm/virtio/9p.c index e307592..af21463 100644 --- a/tools/kvm/virtio/9p.c +++ b/tools/kvm/virtio/9p.c @@ -50,7 +50,6 @@ static struct pci_device_header virtio_p9_pci_device = { .class = 0x010000, .subsys_vendor_id = PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET, .subsys_id = VIRTIO_ID_9P, - .bar[0] = IOPORT_VIRTIO_P9 | PCI_BASE_ADDRESS_SPACE_IO, }; struct p9_dev { @@ -59,6 +58,7 @@ struct p9_dev { u16 config_vector; u32 features; struct virtio_9p_config *config; + u16 base_addr; /* virtio queue */ u16 queue_selector; @@ -96,7 +96,7 @@ static bool virtio_p9_pci_io_in(struct kvm *kvm, u16 port, void *data, int size, unsigned long offset; bool ret = true; - offset = port - IOPORT_VIRTIO_P9; + offset = port - p9dev.base_addr; switch (offset) { case VIRTIO_PCI_HOST_FEATURES: @@ -584,7 +584,7 @@ static bool virtio_p9_pci_io_out(struct kvm *kvm, u16 port, void *data, int size unsigned long offset; bool ret = true; - offset = port - IOPORT_VIRTIO_P9; + offset = port - p9dev.base_addr; switch (offset) { case VIRTIO_MSI_QUEUE_VECTOR: @@ -636,6 +636,7 @@ void virtio_9p__init(struct kvm *kvm, const char *root) { u8 pin, line, dev; u32 i, root_len; + u16 p9_base_addr; p9dev.config = calloc(1, sizeof(*p9dev.config) + sizeof(VIRTIO_P9_TAG)); if (p9dev.config == NULL) @@ -662,7 +663,8 @@ void virtio_9p__init(struct kvm *kvm, const char *root) virtio_p9_pci_device.irq_pin = pin; virtio_p9_pci_device.irq_line = line; + p9_base_addr = ioport__register(IOPORT_EMPTY, &virtio_p9_io_ops, IOPORT_SIZE); + virtio_p9_pci_device.bar[0] = p9_base_addr | PCI_BASE_ADDRESS_SPACE_IO; + p9dev.base_addr = p9_base_addr; pci__register(&virtio_p9_pci_device, dev); - - ioport__register(IOPORT_VIRTIO_P9, &virtio_p9_io_ops, IOPORT_VIRTIO_P9_SIZE); }