From patchwork Wed May 25 14:23:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 816372 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 p4PEOdJZ000869 for ; Wed, 25 May 2011 14:24:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932483Ab1EYOYf (ORCPT ); Wed, 25 May 2011 10:24:35 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:45482 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932975Ab1EYOYd (ORCPT ); Wed, 25 May 2011 10:24:33 -0400 Received: by mail-wy0-f174.google.com with SMTP id 21so5812629wya.19 for ; Wed, 25 May 2011 07:24:33 -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=wcEfzhwnXh+jS/bFh4KfxfORjmP9jbSGerrJSu/OILI=; b=VuWIfND2RZom46lzV4ekZBAIJWJUNrA8RVgVt4t4HIxE8swKQJ/2Y40/0uBec5zOkI +vqGuxNUVjLNxW1PNpTzxuYldex8Li8MIDJ5tdF2Wnj4bp2vKzoaVUexyZtbYV1P7s+e rTfpes+VOER34TzTW6k+yGm9gfpKuf5WJ0CqQ= 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=fy7Qf/aZ34DPeOQtuyU3onMDKO4em//RzGEMr4f91kAcS3pzIB7dDCVk27MheM0p4H iN7zUgA9jzAWHNv5Jq7SER2VsPbFYZgSL0LB9TyBdgpS0piF+CC29phI8iVFLvDvTt4j PM64s0p7ZzRlQFKEMW0t58EkzpZ6rNK0Nqf4w= Received: by 10.227.128.141 with SMTP id k13mr4808487wbs.81.1306333473208; Wed, 25 May 2011 07:24:33 -0700 (PDT) Received: from localhost.localdomain (bzq-109-66-201-145.red.bezeqint.net [109.66.201.145]) by mx.google.com with ESMTPS id m21sm404829wbh.25.2011.05.25.07.24.31 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2011 07:24:32 -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 7/9] kvm tools: Use dynamic IO port allocation in virtio-console driver Date: Wed, 25 May 2011 17:23:45 +0300 Message-Id: <1306333427-26186-7-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 In-Reply-To: <1306333427-26186-1-git-send-email-levinsasha928@gmail.com> References: <1306333427-26186-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 (demeter2.kernel.org [140.211.167.43]); Wed, 25 May 2011 14:24:39 +0000 (UTC) Signed-off-by: Sasha Levin --- tools/kvm/virtio/console.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/kvm/virtio/console.c b/tools/kvm/virtio/console.c index affff0b..eeb5dc9 100644 --- a/tools/kvm/virtio/console.c +++ b/tools/kvm/virtio/console.c @@ -36,7 +36,6 @@ static struct pci_device_header virtio_console_pci_device = { .class = 0x078000, .subsys_vendor_id = PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET, .subsys_id = VIRTIO_ID_CONSOLE, - .bar[0] = IOPORT_VIRTIO_CONSOLE | PCI_BASE_ADDRESS_SPACE_IO, }; struct con_dev { @@ -50,6 +49,7 @@ struct con_dev { u8 status; u8 isr; u16 queue_selector; + u16 base_addr; void *jobs[VIRTIO_CONSOLE_NUM_QUEUES]; }; @@ -113,7 +113,7 @@ static bool virtio_console_pci_io_device_specific_in(void *data, unsigned long o static bool virtio_console_pci_io_in(struct kvm *kvm, u16 port, void *data, int size, u32 count) { - unsigned long offset = port - IOPORT_VIRTIO_CONSOLE; + unsigned long offset = port - cdev.base_addr; bool ret = true; mutex_lock(&cdev.mutex); @@ -181,7 +181,7 @@ static void virtio_console_handle_callback(struct kvm *kvm, void *param) static bool virtio_console_pci_io_out(struct kvm *kvm, u16 port, void *data, int size, u32 count) { - unsigned long offset = port - IOPORT_VIRTIO_CONSOLE; + unsigned long offset = port - cdev.base_addr; bool ret = true; mutex_lock(&cdev.mutex); @@ -243,12 +243,16 @@ static struct ioport_operations virtio_console_io_ops = { void virtio_console__init(struct kvm *kvm) { u8 dev, line, pin; + u16 console_base_addr; if (irq__register_device(VIRTIO_ID_CONSOLE, &dev, &pin, &line) < 0) return; virtio_console_pci_device.irq_pin = pin; virtio_console_pci_device.irq_line = line; + console_base_addr = ioport__find_free_range(); + virtio_console_pci_device.bar[0] = console_base_addr | PCI_BASE_ADDRESS_SPACE_IO; + cdev.base_addr = console_base_addr; pci__register(&virtio_console_pci_device, dev); - ioport__register(IOPORT_VIRTIO_CONSOLE, &virtio_console_io_ops, IOPORT_VIRTIO_CONSOLE_SIZE); + ioport__register(console_base_addr, &virtio_console_io_ops, IOPORT_SIZE); }