All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org, Anthony Liguori <aliguori@amazon.com>
Subject: Re: [Qemu-devel] [RfC PATCH] virtio-pci: place msix regions in modern virtio bar
Date: Fri, 23 Jan 2015 15:33:41 +0200	[thread overview]
Message-ID: <20150123133341.GD4579@redhat.com> (raw)
In-Reply-To: <1422016183-15968-1-git-send-email-kraxel@redhat.com>

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 <kraxel@redhat.com>

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	other threads:[~2015-01-23 13:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 12:29 [Qemu-devel] [RfC PATCH] virtio-pci: place msix regions in modern virtio bar Gerd Hoffmann
2015-01-23 13:33 ` Michael S. Tsirkin [this message]
2015-01-23 13:53   ` Gerd Hoffmann
2015-01-23 13:58     ` Michael S. Tsirkin
2015-01-23 14:48       ` Gerd Hoffmann
2015-01-23 15:12         ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150123133341.GD4579@redhat.com \
    --to=mst@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.