From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEeMu-0007ir-4U for qemu-devel@nongnu.org; Fri, 23 Jan 2015 08:33:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEeMs-0003d7-Uc for qemu-devel@nongnu.org; Fri, 23 Jan 2015 08:33:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEeMs-0003cz-OI for qemu-devel@nongnu.org; Fri, 23 Jan 2015 08:33:46 -0500 Date: Fri, 23 Jan 2015 15:33:41 +0200 From: "Michael S. Tsirkin" Message-ID: <20150123133341.GD4579@redhat.com> References: <1422016183-15968-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1422016183-15968-1-git-send-email-kraxel@redhat.com> Subject: Re: [Qemu-devel] [RfC PATCH] virtio-pci: place msix regions in modern virtio bar List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org, Anthony Liguori On Fri, Jan 23, 2015 at 01:29:43PM +0100, Gerd Hoffmann wrote: > Only for legacy-free virtio devices, to avoid unpleasent > surprises with old drivers. > > mtree snippet: > > 00000000fea00000-00000000fea7ffff (prio 1, RW): virtio-pci > 00000000fea00000-00000000fea00fff (prio 0, RW): virtio-pci-common > 00000000fea01000-00000000fea01fff (prio 0, RW): virtio-pci-isr > 00000000fea02000-00000000fea02fff (prio 0, RW): virtio-pci-device > 00000000fea03000-00000000fea42fff (prio 0, RW): virtio-pci-notify > 00000000fea7e000-00000000fea7e02f (prio 0, RW): msix-table > 00000000fea7f000-00000000fea7f007 (prio 0, RW): msix-pba > > Applies on top of mst's virtio-1.0 branch, plus my three virtio-pci > patches posted to the list yesterday. > > Signed-off-by: Gerd Hoffmann Hmm what's the point here? I wanted to make the modern BAR prefetcheable, so it can be a full 64-bit one, this is impossible with the MSI-X BAR. This requires keeping it separate though. Again, if we start running of BARs we'll consider our options then, these things are easy to change. > --- > hw/virtio/virtio-pci.c | 39 +++++++++++++++++++++++++++------------ > 1 file changed, 27 insertions(+), 12 deletions(-) > > diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c > index ba1405f..934ca7a 100644 > --- a/hw/virtio/virtio-pci.c > +++ b/hw/virtio/virtio-pci.c > @@ -1235,7 +1235,7 @@ static void virtio_pci_device_plugged(DeviceState *d) > bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN); > int modern_mem_bar; > uint8_t *config; > - uint32_t size; > + uint32_t modern_mem_size, legacy_io_size; > > config = proxy->pci_dev.config; > if (proxy->class_code) { > @@ -1339,9 +1339,10 @@ static void virtio_pci_device_plugged(DeviceState *d) > virtio_pci_add_mem_cap(proxy, ¬ify.cap); > > virtio_add_feature(&proxy->host_features, VIRTIO_F_VERSION_1); > + modern_mem_size = 2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * > + VIRTIO_PCI_QUEUE_MAX; > memory_region_init(&proxy->modern_bar, OBJECT(proxy), "virtio-pci", > - 2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * > - VIRTIO_PCI_QUEUE_MAX); > + modern_mem_size); > memory_region_init_io(&proxy->common, OBJECT(proxy), > &common_ops, > proxy, > @@ -1369,25 +1370,39 @@ static void virtio_pci_device_plugged(DeviceState *d) > &proxy->modern_bar); > } > > - if (proxy->nvectors && > - msix_init_exclusive_bar(&proxy->pci_dev, proxy->nvectors, 1)) { > - error_report("unable to init msix vectors to %" PRIu32, > - proxy->nvectors); > - proxy->nvectors = 0; > + if (proxy->nvectors) { > + if (modern && modern_mem_bar == 0) { > + if (msix_init(&proxy->pci_dev, proxy->nvectors, > + &proxy->modern_bar, modern_mem_bar, > + modern_mem_size - 0x2000, > + &proxy->modern_bar, modern_mem_bar, > + modern_mem_size - 0x1000, > + 0x90)) { > + error_report("unable to init msix vectors to %" PRIu32, > + proxy->nvectors); > + proxy->nvectors = 0; > + } > + } else { > + if (msix_init_exclusive_bar(&proxy->pci_dev, proxy->nvectors, 1)) { > + error_report("unable to init msix vectors to %" PRIu32, > + proxy->nvectors); > + proxy->nvectors = 0; > + } > + } > } > > proxy->pci_dev.config_write = virtio_write_config; > > if (legacy) { > - size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev) > + legacy_io_size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev) > + virtio_bus_get_vdev_config_len(bus); > - if (size & (size - 1)) { > - size = 1 << qemu_fls(size); > + if (legacy_io_size & (legacy_io_size - 1)) { > + legacy_io_size = 1 << qemu_fls(legacy_io_size); > } > > memory_region_init_io(&proxy->bar, OBJECT(proxy), > &virtio_pci_config_ops, > - proxy, "virtio-pci", size); > + proxy, "virtio-pci", legacy_io_size); > > pci_register_bar(&proxy->pci_dev, 0, PCI_BASE_ADDRESS_SPACE_IO, > &proxy->bar); > -- > 1.8.3.1