qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
	Alex Williamson <alex.williamson@redhat.com>
Subject: Re: [Qemu-devel] [PATCH qemu v7 3/4] vfio-pci: Allow mmap of MSIX BAR
Date: Tue, 13 Feb 2018 16:39:00 +1100	[thread overview]
Message-ID: <20180213053900.GM11634@umbus.fritz.box> (raw)
In-Reply-To: <20180209075503.16996-4-aik@ozlabs.ru>

[-- Attachment #1: Type: text/plain, Size: 3832 bytes --]

On Fri, Feb 09, 2018 at 06:55:02PM +1100, Alexey Kardashevskiy wrote:
> At the moment we unconditionally avoid mapping MSIX data of a BAR and
> emulate MSIX table in QEMU. However it is 1) not always necessary as
> a platform may prodive a paravirt interface for MSIX configuration;
> 2) can affect the speed of MMIO access by emulating them in QEMU when
> frequently accessed registers share same system page with MSIX data,
> this is particularly a problem for systems with the page size bigger
> than 4KB.
> 
> A new capability - VFIO_REGION_INFO_CAP_MSIX_MAPPABLE - has been added
> to the kernel [1] which tells the userspace that mapping of the MSIX data
> is possible now. This makes use of it so from now on QEMU tries mapping
> the entire BAR as a whole and emulate MSIX on top of that.
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a32295c612c57990d17fb0f41e7134394b2f35f6
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
> Changes:
> v7:
> * test iova/llsize against pgmask in vfio_listener_region_add/del
> * s/vfio_is_cap_present/vfio_has_region_cap/
> * added comments here and there
> * s/vdev->msix->table_bar/region-nr/
> ---
>  include/hw/vfio/vfio-common.h |  1 +
>  hw/vfio/common.c              | 15 +++++++++++++++
>  hw/vfio/pci.c                 |  9 +++++++++
>  3 files changed, 25 insertions(+)
> 
> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
> index f3a2ac9..42dd2b0 100644
> --- a/include/hw/vfio/vfio-common.h
> +++ b/include/hw/vfio/vfio-common.h
> @@ -171,6 +171,7 @@ int vfio_get_region_info(VFIODevice *vbasedev, int index,
>                           struct vfio_region_info **info);
>  int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type,
>                               uint32_t subtype, struct vfio_region_info **info);
> +bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_type);
>  #endif
>  extern const MemoryListener vfio_prereg_listener;
>  
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 736f271..b99ae77 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -1464,6 +1464,21 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type,
>      return -ENODEV;
>  }
>  
> +bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_type)
> +{
> +    struct vfio_region_info *info = NULL;
> +    bool ret = false;
> +
> +    if (!vfio_get_region_info(vbasedev, region, &info)) {
> +        if (vfio_get_region_info_cap(info, cap_type)) {
> +            ret = true;
> +        }
> +        g_free(info);
> +    }
> +
> +    return ret;
> +}
> +
>  /*
>   * Interfaces for IBM EEH (Enhanced Error Handling)
>   */
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 879510c..ae9098d 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -1294,6 +1294,15 @@ static void vfio_pci_fixup_msix_region(VFIOPCIDevice *vdev)
>      VFIORegion *region = &vdev->bars[vdev->msix->table_bar].region;
>  
>      /*
> +     * If the host driver allows mapping of a MSIX data, we are going to
> +     * do map the entire BAR and emulate MSIX table on top of that.
> +     */
> +    if (vfio_has_region_cap(&vdev->vbasedev, region->nr,
> +                            VFIO_REGION_INFO_CAP_MSIX_MAPPABLE)) {
> +        return;
> +    }
> +
> +    /*
>       * We expect to find a single mmap covering the whole BAR, anything else
>       * means it's either unsupported or already setup.
>       */

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-02-13  5:41 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09  7:54 [Qemu-devel] [PATCH qemu v7 0/4] vfio-pci: Allow mmap of MSIX BAR Alexey Kardashevskiy
2018-02-09  7:55 ` [Qemu-devel] [PATCH qemu v7 1/4] linux-headers: update to f1517df8701c Alexey Kardashevskiy
2018-02-10  7:34   ` David Gibson
2018-02-09  7:55 ` [Qemu-devel] [PATCH qemu v7 2/4] vfio/pci: Relax DMA map errors for MMIO regions Alexey Kardashevskiy
2018-02-12  5:19   ` David Gibson
2018-02-12  7:05     ` Alexey Kardashevskiy
2018-02-12 16:06       ` Alex Williamson
2018-02-13  1:15         ` Alexey Kardashevskiy
2018-02-13  5:36           ` David Gibson
2018-02-13  5:41             ` David Gibson
2018-02-13  8:20               ` Alexey Kardashevskiy
2018-02-14  1:33                 ` David Gibson
2018-02-14  8:09                   ` Alexey Kardashevskiy
2018-02-14 15:55                     ` Alex Williamson
2018-02-16  5:28                       ` David Gibson
2018-02-19  2:46                         ` Alexey Kardashevskiy
2018-02-26  8:36                           ` Alexey Kardashevskiy
2018-03-07  2:17                             ` Alexey Kardashevskiy
2018-03-13  4:53                               ` Alexey Kardashevskiy
2018-03-13 16:56                                 ` Alex Williamson
2018-03-13 17:13                                   ` Auger Eric
2018-03-13 19:17                                     ` Eric Blake
2018-03-14  2:40                                   ` Alexey Kardashevskiy
2018-03-15  2:36                                     ` Alex Williamson
2018-03-19 20:49   ` Auger Eric
2018-03-21 15:29     ` Alex Williamson
2018-03-22  7:45       ` Alexey Kardashevskiy
2018-03-22  7:48         ` Auger Eric
2018-02-09  7:55 ` [Qemu-devel] [PATCH qemu v7 3/4] vfio-pci: Allow mmap of MSIX BAR Alexey Kardashevskiy
2018-02-13  5:39   ` David Gibson [this message]
2018-02-09  7:55 ` [Qemu-devel] [PATCH qemu v7 4/4] ppc/spapr, vfio: Turn off MSIX emulation for VFIO devices Alexey Kardashevskiy
2018-02-13  5:43   ` David Gibson
2018-02-09  8:04 ` [Qemu-devel] [PATCH qemu v7 0/4] vfio-pci: Allow mmap of MSIX BAR no-reply
2018-02-09  8:05 ` no-reply

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=20180213053900.GM11634@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=aik@ozlabs.ru \
    --cc=alex.williamson@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).