From patchwork Thu May 26 10:30:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 820372 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 p4QAUu2x008898 for ; Thu, 26 May 2011 10:30:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757436Ab1EZKap (ORCPT ); Thu, 26 May 2011 06:30:45 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:60477 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757209Ab1EZKao (ORCPT ); Thu, 26 May 2011 06:30:44 -0400 Received: by mail-ww0-f44.google.com with SMTP id 36so599461wwa.1 for ; Thu, 26 May 2011 03:30:43 -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=CN25LJYNobTiEoOs8YH1ysmyDRMW0/lvrzEXGjRWfZg=; b=W/qKI9jPOBYi+YiSES3D64++3cTlHPYHBuscJlCgyE3tBU0u3WOT0cDlQa8Eggf9TT oc8We+1IVD2G7M8P0dhkIBuJ6oeFIAb1gP3pENoAvO0ERcvahqQHFjaizwao5eC0DORz U9cO65TJVXQZ3iZojnNjrbawNjPfreyZZ/mKs= 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=s+Ur8ru+rCaTyFroN1ZccHyNQefiZEZ+NfRIhsu6ug0Ir/vG+mf8DDEOVJbn2BY6dC jq2FMltD6rpy/aY3lp4rQQA/fAmxbYLqwxf4YkLba6XuuY7iCG0TaUQzCAw3Z79h6COd wfluKSJyIjFo3fHrU65uLKkSwN7VWAJ476Dag= Received: by 10.227.98.9 with SMTP id o9mr677046wbn.25.1306405843471; Thu, 26 May 2011 03:30:43 -0700 (PDT) Received: from localhost.localdomain ([109.66.201.145]) by mx.google.com with ESMTPS id et5sm365858wbb.33.2011.05.26.03.30.42 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 May 2011 03:30:43 -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 v3 6/8] kvm tools: Use dynamic IO port allocation in 9p driver Date: Thu, 26 May 2011 13:30:09 +0300 Message-Id: <1306405811-4482-6-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 In-Reply-To: <1306405811-4482-1-git-send-email-levinsasha928@gmail.com> References: <1306405811-4482-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 10:30:56 +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 84eb65a..310f75d 100644 --- a/tools/kvm/include/kvm/ioport.h +++ b/tools/kvm/include/kvm/ioport.h @@ -12,8 +12,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 c441089..38a997d 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 ioport *ioport, struct kvm *kvm, u16 port 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 ioport *ioport, struct kvm *kvm, u16 por 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, NULL); + 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, NULL); }