[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/33] virtio-pci: change & document virtio pci bar
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 19/33] virtio-pci: change & document virtio pci bar layout. |
Date: |
Thu, 4 Jun 2015 12:34:28 +0200 |
This patch adds variables for the pci bars (to get rid of the magic
numbers in the code) and moves the modern virtio bar to region 4 so
regions 2+3 are kept free. virtio-vga wants use them.
Signed-off-by: Gerd Hoffmann <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/virtio/virtio-pci.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index c86a61d..0f3eb34 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -919,8 +919,6 @@ static void virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy,
PCIDevice *dev = &proxy->pci_dev;
int offset;
- cap->bar = 2;
-
offset = pci_add_capability(dev, PCI_CAP_ID_VNDR, 0, cap->cap_len);
assert(offset > 0);
@@ -1196,6 +1194,22 @@ static void virtio_pci_device_plugged(DeviceState *d,
Error **errp)
uint32_t size;
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
+ /*
+ * virtio pci bar layout
+ *
+ * region 0 -- virtio legacy io bar
+ * region 1 -- msi-x bar
+ * region 2+3 -- not used by virtio-pci
+ * region 4+5 -- virtio modern memory (64bit) bar
+ *
+ * Regions 2+3 can be used by VirtIOPCIProxy subclasses.
+ * virtio-vga places the vga framebuffer there.
+ *
+ */
+ uint32_t legacy_io_bar = 0;
+ uint32_t msix_bar = 1;
+ uint32_t modern_mem_bar = 4;
+
config = proxy->pci_dev.config;
if (proxy->class_code) {
pci_config_set_class(config, proxy->class_code);
@@ -1221,24 +1235,28 @@ static void virtio_pci_device_plugged(DeviceState *d,
Error **errp)
struct virtio_pci_cap common = {
.cfg_type = VIRTIO_PCI_CAP_COMMON_CFG,
.cap_len = sizeof common,
+ .bar = modern_mem_bar,
.offset = cpu_to_le32(0x0),
.length = cpu_to_le32(0x1000),
};
struct virtio_pci_cap isr = {
.cfg_type = VIRTIO_PCI_CAP_ISR_CFG,
.cap_len = sizeof isr,
+ .bar = modern_mem_bar,
.offset = cpu_to_le32(0x1000),
.length = cpu_to_le32(0x1000),
};
struct virtio_pci_cap device = {
.cfg_type = VIRTIO_PCI_CAP_DEVICE_CFG,
.cap_len = sizeof device,
+ .bar = modern_mem_bar,
.offset = cpu_to_le32(0x2000),
.length = cpu_to_le32(0x1000),
};
struct virtio_pci_notify_cap notify = {
.cap.cfg_type = VIRTIO_PCI_CAP_NOTIFY_CFG,
.cap.cap_len = sizeof notify,
+ .cap.bar = modern_mem_bar,
.cap.offset = cpu_to_le32(0x3000),
.cap.length = cpu_to_le32(QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
VIRTIO_QUEUE_MAX),
@@ -1318,12 +1336,13 @@ static void virtio_pci_device_plugged(DeviceState *d,
Error **errp)
QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
VIRTIO_QUEUE_MAX);
memory_region_add_subregion(&proxy->modern_bar, 0x3000,
&proxy->notify);
- pci_register_bar(&proxy->pci_dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY,
+ pci_register_bar(&proxy->pci_dev, modern_mem_bar,
+ PCI_BASE_ADDRESS_SPACE_MEMORY,
&proxy->modern_bar);
}
if (proxy->nvectors &&
- msix_init_exclusive_bar(&proxy->pci_dev, proxy->nvectors, 1)) {
+ msix_init_exclusive_bar(&proxy->pci_dev, proxy->nvectors, msix_bar)) {
error_report("unable to init msix vectors to %" PRIu32,
proxy->nvectors);
proxy->nvectors = 0;
@@ -1342,8 +1361,8 @@ static void virtio_pci_device_plugged(DeviceState *d,
Error **errp)
&virtio_pci_config_ops,
proxy, "virtio-pci", size);
- pci_register_bar(&proxy->pci_dev, 0, PCI_BASE_ADDRESS_SPACE_IO,
- &proxy->bar);
+ pci_register_bar(&proxy->pci_dev, legacy_io_bar,
+ PCI_BASE_ADDRESS_SPACE_IO, &proxy->bar);
}
if (!kvm_has_many_ioeventfds()) {
--
1.8.3.1
- [Qemu-devel] [PATCH 02/33] virtio: endianness checks for virtio 1.0 devices, (continued)
- [Qemu-devel] [PATCH 02/33] virtio: endianness checks for virtio 1.0 devices, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 17/33] virtio-pci: add flags to enable/disable legacy/modern, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 08/33] virtio-net: support longer header, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 15/33] virtio: add modern config accessors, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 14/33] virtio: generation counter support, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 21/33] virtio-pci: correctly set host notifiers for modern bar, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 16/33] virtio-pci: switch to modern accessors for 1.0, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 11/33] vhost: 64 bit features, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 22/33] virtio_balloon: header update, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 19/33] virtio-pci: change & document virtio pci bar layout.,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 29/33] virtio-pci: drop identical virtio_pci_cap, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 26/33] virtio-pci: add virtio_pci_modern_region_map(), Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 06/33] virtio: allow to fail setting status, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 23/33] virtio-balloon: switch to virtio_add_feature, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 20/33] virtio-pci: make modern bar 64bit + prefetchable, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 27/33] virtio-pci: move virtio_pci_add_mem_cap call to virtio_pci_modern_region_map, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 12/33] linux-headers: add virtio_pci, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 13/33] virtio-pci: initial virtio 1.0 support, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 18/33] virtio-pci: make QEMU_VIRTIO_PCI_QUEUE_MEM_MULT smaller, Gerd Hoffmann, 2015/06/04
- [Qemu-devel] [PATCH 28/33] virtio-pci: move cap type to VirtIOPCIRegion, Gerd Hoffmann, 2015/06/04