qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RfC PATCH] virtio-pci: place msix regions in modern vi


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] [RfC PATCH] virtio-pci: place msix regions in modern virtio bar
Date: Fri, 23 Jan 2015 15:33:41 +0200

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 <address@hidden>

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, &notify.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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]