Received: from eggs.gnu.org ([2001:4830:134:3::10]:59753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEDaH-0002GS-R1 for qemu-devel@nongnu.org; Thu, 22 Jan 2015 03:57:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEDa9-0007lZ-S2 for qemu-devel@nongnu.org; Thu, 22 Jan 2015 03:57:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEDa9-0007lM-KD for qemu-devel@nongnu.org; Thu, 22 Jan 2015 03:57:41 -0500 From: Gerd Hoffmann Date: Thu, 22 Jan 2015 09:57:34 +0100 Message-Id: <1421917056-6560-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1421917056-6560-1-git-send-email-kraxel@redhat.com> References: <1421917056-6560-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 2/3] virtio-pci: use bar0 for non-transitional devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Anthony Liguori , mst@redhat.com --- hw/virtio/virtio-pci.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 407063c..ca325fb 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -966,8 +966,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); @@ -1236,6 +1234,7 @@ static void virtio_pci_device_plugged(DeviceState *d) VirtioBusState *bus = &proxy->bus; bool legacy = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_LEGACY); bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN); + int modern_mem_bar; uint8_t *config; uint32_t size; @@ -1249,6 +1248,7 @@ static void virtio_pci_device_plugged(DeviceState *d) pci_set_word(config + PCI_SUBSYSTEM_VENDOR_ID, pci_get_word(config + PCI_VENDOR_ID)); pci_set_word(config + PCI_SUBSYSTEM_ID, virtio_bus_get_vdev_id(bus)); + modern_mem_bar = 2; } else { /* pure virtio-1.0 */ pci_set_word(config + PCI_VENDOR_ID, @@ -1256,6 +1256,7 @@ static void virtio_pci_device_plugged(DeviceState *d) pci_set_word(config + PCI_DEVICE_ID, 0x1040 + virtio_bus_get_vdev_id(bus)); pci_config_set_revision(config, 1); + modern_mem_bar = 0; } config[PCI_INTERRUPT_PIN] = 1; @@ -1264,24 +1265,28 @@ static void virtio_pci_device_plugged(DeviceState *d) 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_PCI_QUEUE_MAX), @@ -1360,7 +1365,8 @@ static void virtio_pci_device_plugged(DeviceState *d) QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_PCI_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); } -- 1.8.3.1