From fa6b851993e66fabc6ee5bc567238e47eda36980 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 26 May 2011 13:30:09 +0300 Subject: [PATCH] kvm tools: Use dynamic IO port allocation in 9p driver Signed-off-by: Sasha Levin Signed-off-by: Pekka Enberg --- 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 84eb65af29f5..310f75d31f78 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 c4410891d46d..38a997db7984 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); } -- 2.39.5