util/vfio-helpers: Allow using multiple MSIX IRQs
cover util/vfio-helpers: Allow using multiple MSIX IRQs
This series allow using multiple MSIX IRQs
We currently share a single IRQ between 2 NVMe queues (ADMIN and I/O). This series still uses 1 shared IRQ but prepare for using multiple ones.
The series is organized as:
- Fix device minimum page size (prerequisite: patch 1)
- Check IOMMU minimum page size (patches 3, 4)
- Boring cleanups already reviewed (patches 2, 5-12)
- Introduce helpers to use multiple MSIX (patches 13, 14)
- Switch NVMe block driver to use the multiple MSIX API (15)
- Remove single MSIX helper (16).
Most patches are trivial, except 13 and 14 which are the important VFIO ones.
Please review,
Phil.
Philippe Mathieu-Daudé (16):
block/nvme: Correct minimum device page size util/vfio-helpers: Improve reporting unsupported IOMMU type util/vfio-helpers: Pass minimum page size to qemu_vfio_open_pci() util/vfio-helpers: Report error when IOMMU page size is not supported util/vfio-helpers: Trace PCI I/O config accesses util/vfio-helpers: Trace PCI BAR region info util/vfio-helpers: Trace where BARs are mapped util/vfio-helpers: Improve DMA trace events util/vfio-helpers: Convert vfio_dump_mapping to trace events util/vfio-helpers: Let qemu_vfio_dma_map() propagate Error util/vfio-helpers: Let qemu_vfio_do_mapping() propagate Error util/vfio-helpers: Let qemu_vfio_verify_mappings() use error_report() util/vfio-helpers: Introduce qemu_vfio_pci_msix_init_irqs() util/vfio-helpers: Introduce qemu_vfio_pci_msix_set_irq() block/nvme: Switch to using the MSIX API util/vfio-helpers: Remove now unused qemu_vfio_pci_init_irq()
include/qemu/vfio-helpers.h | 15 ++- block/nvme.c | 33 ++++--- util/vfio-helpers.c | 183 +++++++++++++++++++++++++++--------- util/trace-events | 13 ++- 4 files changed, 182 insertions(+), 62 deletions(-)
Signature · 1 line
2.26.2
PATCH 3/16 util/vfio-helpers: Pass minimum page size to qemu_vfio_open_pci()
The block driver asks for a minimum page size, but it might not match the minimum IOMMU requirement.
In the next commit qemu_vfio_init_pci() will be able to report the minimum IOMMU page size back to the block driver. In preparation, pass the minimum page size as argument to qemu_vfio_open_pci().
--- include/qemu/vfio-helpers.h | 3 ++- block/nvme.c | 5 +++-- util/vfio-helpers.c | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-)
include/qemu/vfio-helpers.h +2 -1
@@ -15,7 +15,8 @@typedef struct QEMUVFIOState QEMUVFIOState ; -QEMUVFIOState *qemu_vfio_open_pci (const char *device,Error **errp); +QEMUVFIOState *qemu_vfio_open_pci (const char *device,size_t *min_page_size, +Error **errp);void qemu_vfio_close (QEMUVFIOState *s);int qemu_vfio_dma_map (QEMUVFIOState *s,void *host,size_t size,bool temporary,uint64_t *iova_list);
block/nvme.c +3 -2
@@ -690,6 +690,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,uint64_t deadline, now;Error *local_err =NULL ;volatile NvmeBar *regs =NULL ; +size_t min_page_size =4096 ;qemu_co_mutex_init (&s->dma_map_lock);qemu_co_queue_init (&s->dma_flush_queue);
@@ -702,7 +703,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,return ret; } - s->vfio =qemu_vfio_open_pci (device, errp); + s->vfio =qemu_vfio_open_pci (device, &min_page_size, errp);if (!s->vfio) { ret = -EINVAL ; goto out;
@@ -724,7 +725,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, goto out; } - s->page_size =MAX (4096 ,1u << (12 +NVME_CAP_MPSMIN (cap))); + s->page_size =MAX (min_page_size,1u << (12 +NVME_CAP_MPSMIN (cap))); s->doorbell_scale = (4 <<NVME_CAP_DSTRD (cap)) /sizeof (uint32_t ); bs->bl.opt_mem_alignment = s->page_size; timeout_ms =MIN (500 *NVME_CAP_TO (cap),30000 );
util/vfio-helpers.c +7 -1
@@ -488,8 +488,14 @@ static void qemu_vfio_open_common(QEMUVFIOState *s)/** * Open a PCI device, e.g. "0000:00:01.0". +* +* @min_page_size: Pointer holding the minimum page size requested +* +* If the IOMMU can not be configured with @min_page_size, the minimum +* page size is stored in @min_page_size and -EINVAL is returned. */ -QEMUVFIOState *qemu_vfio_open_pci (const char *device,Error **errp) +QEMUVFIOState *qemu_vfio_open_pci (const char *device,size_t *min_page_size, +Error **errp) {int r;QEMUVFIOState *s =g_new0 (QEMUVFIOState,1 );
Signature · 1 line
2.26.2
PATCH 1/16 block/nvme: Correct minimum device page size
In reply to Philippe Mathieu-DaudéWhile trying to simplify the code using a macro, we forgot the 12-bit shift... Correct that.
--- block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/nvme.c +1 -1
@@ -724,7 +724,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, goto out; } - s->page_size =MAX (4096 ,1 <<NVME_CAP_MPSMIN (cap)); + s->page_size =MAX (4096 ,1u << (12 +NVME_CAP_MPSMIN (cap))); s->doorbell_scale = (4 <<NVME_CAP_DSTRD (cap)) /sizeof (uint32_t ); bs->bl.opt_mem_alignment = s->page_size; timeout_ms =MIN (500 *NVME_CAP_TO (cap),30000 );
Signature · 1 line
2.26.2
PATCH 2/16 util/vfio-helpers: Improve reporting unsupported IOMMU type
In reply to Philippe Mathieu-DaudéChange the confuse "VFIO IOMMU check failed" error message by the explicit "VFIO IOMMU Type1 is not supported" once.
Example on POWER:
$ qemu-system-ppc64 -drive if=none,id=nvme0,file=nvme://0001:01:00.0/1,format=raw qemu-system-ppc64: -drive if=none,id=nvme0,file=nvme://0001:01:00.0/1,format=raw: VFIO IOMMU Type1 is not supported
--- util/vfio-helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
util/vfio-helpers.c +1 -1
@@ -300,7 +300,7 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, }if (!ioctl (s->container,VFIO_CHECK_EXTENSION ,VFIO_TYPE1_IOMMU )) { -error_setg_errno (errp, errno,"VFIO IOMMU check failed" ); +error_setg_errno (errp, errno,"VFIO IOMMU Type1 is not supported" ); ret = -EINVAL ; goto fail_container; }
Signature · 1 line
2.26.2
PATCH 4/16 util/vfio-helpers: Report error when IOMMU page size is not supported
In reply to Philippe Mathieu-DaudéThis driver uses the host page size to align its memory regions, but this size is not always compatible with the IOMMU. Add a check if the size matches, and bails out providing a hint what is the minimum page size the driver should use.
--- util/vfio-helpers.c | 28 ++++++++++++++++++++++++++-- util/trace-events | 1 + 2 files changed, 27 insertions(+), 2 deletions(-)
util/vfio-helpers.c +26 -2
@@ -11,6 +11,7 @@*/ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include <sys/ioctl.h> #include <linux/vfio.h> #include "qapi/error.h"
@@ -273,7 +274,7 @@ static void collect_usable_iova_ranges(QEMUVFIOState *s, void *buf) }static int qemu_vfio_init_pci (QEMUVFIOState *s,const char *device, -Error **errp) +size_t *requested_page_size,Error **errp) {int ret;int i;
@@ -284,6 +285,8 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device,struct vfio_device_info device_info = { .argsz =sizeof (device_info) };char *group_file =NULL ; +assert (requested_page_size &&is_power_of_2 (*requested_page_size)); + s->usable_iova_ranges =NULL ;/* Create a new container */
@@ -358,6 +361,27 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, ret = -errno; goto fail; } +if (!(iommu_info->flags &VFIO_IOMMU_INFO_PGSIZES )) { +error_setg (errp,"Failed to get IOMMU page size info" ); + ret = -EINVAL ; + goto fail; + } +trace_qemu_vfio_iommu_iova_pgsizes (iommu_info->iova_pgsizes); +if (!(iommu_info->iova_pgsizes & *requested_page_size)) { + g_autofree char *req_page_size_str = size_to_str(*requested_page_size); + g_autofree char *min_page_size_str = NULL; +uint64_t pgsizes_masked; + + pgsizes_masked =MAKE_64BIT_MASK (0 ,ctz64 (*requested_page_size)); + *requested_page_size =1U <<ctz64 (iommu_info->iova_pgsizes + & ~pgsizes_masked); + min_page_size_str =size_to_str (*requested_page_size); +error_setg (errp,"Unsupported IOMMU page size: %s" , req_page_size_str); +error_append_hint (errp,"Minimum IOMMU page size: %s\n" , + min_page_size_str); + ret = -EINVAL ; + goto fail; + }/* * if the kernel does not report usable IOVA regions, choose
@@ -500,7 +524,7 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, size_t *min_page_size,int r;QEMUVFIOState *s =g_new0 (QEMUVFIOState,1 ); - r =qemu_vfio_init_pci (s, device, errp); + r =qemu_vfio_init_pci (s, device, min_page_size, errp);if (r) {g_free (s);return NULL ;
util/trace-events +1 -0
@@ -85,3 +85,4 @@ qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_t iova qemu_vfio_do_mapping(void *s, void *host, size_t size, uint64_t iova) "s %p host %p size 0x%zx iova 0x%"PRIx64 qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d iova %p" qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" +qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitmask: 0x%08"PRIx64
Signature · 1 line
2.26.2
PATCH 11/16 util/vfio-helpers: Let qemu_vfio_do_mapping() propagate Error
In reply to Philippe Mathieu-DaudéPass qemu_vfio_do_mapping() an Error* argument so it can propagate any error to callers. Replace error_report() which only report to the monitor by the more generic error_setg_errno().
--- util/vfio-helpers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
util/vfio-helpers.c +4 -4
@@ -639,7 +639,7 @@ static IOVAMapping *qemu_vfio_add_mapping(QEMUVFIOState *s,/* Do the DMA mapping with VFIO. */ static int qemu_vfio_do_mapping (QEMUVFIOState *s,void *host,size_t size, -uint64_t iova) +uint64_t iova,Error **errp) {struct vfio_iommu_type1_dma_map dma_map = { .argsz =sizeof (dma_map),
@@ -651,7 +651,7 @@ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void *host, size_t size,trace_qemu_vfio_do_mapping (s, host, iova, size);if (ioctl (s->container,VFIO_IOMMU_MAP_DMA , &dma_map)) { -error_report ("VFIO_MAP_DMA failed: %s" ,strerror (errno)); +error_setg_errno (errp, errno,"VFIO_MAP_DMA failed" );return -errno; }return 0 ;
@@ -787,7 +787,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, goto out; }assert (qemu_vfio_verify_mappings (s)); - ret =qemu_vfio_do_mapping (s, host, size, iova0); + ret =qemu_vfio_do_mapping (s, host, size, iova0, errp);if (ret) {qemu_vfio_undo_mapping (s, mapping,NULL ); goto out;
@@ -798,7 +798,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, ret = -ENOMEM ; goto out; } - ret =qemu_vfio_do_mapping (s, host, size, iova0); + ret =qemu_vfio_do_mapping (s, host, size, iova0, errp);if (ret) { goto out; }
Signature · 1 line
2.26.2
PATCH 5/16 util/vfio-helpers: Trace PCI I/O config accesses
In reply to Philippe Mathieu-DaudéWe sometime get kernel panic with some devices on Aarch64 hosts. Alex Williamson suggests it might be broken PCIe root complex. Add trace event to record the latest I/O access before crashing. In case, assert our accesses are aligned.
--- util/vfio-helpers.c | 8 ++++++++ util/trace-events | 2 ++ 2 files changed, 10 insertions(+)
util/vfio-helpers.c +8 -0
@@ -228,6 +228,10 @@ static int qemu_vfio_pci_read_config(QEMUVFIOState *s, void *buf, {int ret; +trace_qemu_vfio_pci_read_config (buf, ofs, size, + s->config_region_info.offset, + s->config_region_info.size); +assert (QEMU_IS_ALIGNED (s->config_region_info.offset + ofs, size));do { ret =pread (s->device, buf, size, s->config_region_info.offset + ofs); }while (ret ==-1 && errno ==EINTR );
@@ -238,6 +242,10 @@ static int qemu_vfio_pci_write_config(QEMUVFIOState *s, void *buf, int size, int {int ret; +trace_qemu_vfio_pci_write_config (buf, ofs, size, + s->config_region_info.offset, + s->config_region_info.size); +assert (QEMU_IS_ALIGNED (s->config_region_info.offset + ofs, size));do { ret =pwrite (s->device, buf, size, s->config_region_info.offset + ofs); }while (ret ==-1 && errno ==EINTR );
util/trace-events +2 -0
@@ -86,3 +86,5 @@ qemu_vfio_do_mapping(void *s, void *host, size_t size, uint64_t iova) "s %p host qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d iova %p" qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitmask: 0x%08"PRIx64 +qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" +qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")"
Signature · 1 line
2.26.2
PATCH 6/16 util/vfio-helpers: Trace PCI BAR region info
In reply to Philippe Mathieu-DaudéFor debug purpose, trace BAR regions info.
--- util/vfio-helpers.c | 8 ++++++++ util/trace-events | 1 + 2 files changed, 9 insertions(+)
util/vfio-helpers.c +8 -0
@@ -137,6 +137,7 @@ static inline void assert_bar_index_valid(QEMUVFIOState *s, int index)static int qemu_vfio_pci_init_bar (QEMUVFIOState *s,int index,Error **errp) { + g_autofree char *barname = NULL;assert_bar_index_valid (s, index); s->bar_region_info[index] = (struct vfio_region_info ) { .index =VFIO_PCI_BAR0_REGION_INDEX + index,
@@ -146,6 +147,10 @@ static int qemu_vfio_pci_init_bar(QEMUVFIOState *s, int index, Error **errp)error_setg_errno (errp, errno,"Failed to get BAR region info" );return -errno; } + barname =g_strdup_printf ("bar[%d]" , index); +trace_qemu_vfio_region_info (barname, s->bar_region_info[index].offset, + s->bar_region_info[index].size, + s->bar_region_info[index].cap_offset);return 0 ; }
@@ -440,6 +445,9 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, ret = -errno; goto fail; } +trace_qemu_vfio_region_info ("config" , s->config_region_info.offset, + s->config_region_info.size, + s->config_region_info.cap_offset);for (i =0 ; i <ARRAY_SIZE (s->bar_region_info); i++) { ret =qemu_vfio_pci_init_bar (s, i, errp);
util/trace-events +1 -0
@@ -88,3 +88,4 @@ qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitmask: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" +qemu_vfio_region_info(const char *desc, uint64_t offset, uint64_t size, uint32_t cap_offset) "region '%s' ofs 0x%"PRIx64" size %"PRId64" cap_ofs %"PRId32
Signature · 1 line
2.26.2
PATCH 13/16 util/vfio-helpers: Introduce qemu_vfio_pci_msix_init_irqs()
In reply to Philippe Mathieu-Daudéqemu_vfio_pci_init_irq() allows us to initialize any type of IRQ, but only one. Introduce qemu_vfio_pci_msix_init_irqs() which is specific to MSIX IRQ type, and allow us to use multiple IRQs (thus passing multiple eventfd notifiers).
All eventfd notifiers are initialized with the special '-1' value meaning "un-assigned".
--- include/qemu/vfio-helpers.h | 6 +++- util/vfio-helpers.c | 65 ++++++++++++++++++++++++++++++++++++- util/trace-events | 1 + 3 files changed, 70 insertions(+), 2 deletions(-)
include/qemu/vfio-helpers.h +5 -1
@@ -1,11 +1,13 @@/* * QEMU VFIO helpers * -* Copyright 2016 - 2018 Red Hat, Inc. +* Copyright 2016 - 2020 Red Hat, Inc. * * Authors: * Fam Zheng <[email protected]> +* Philippe Mathieu-Daudé <[email protected]> * +* SPDX-License-Identifier: GPL-2.0-or-later * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */
@@ -29,5 +31,7 @@ void qemu_vfio_pci_unmap_bar(QEMUVFIOState *s, int index, void *bar, uint64_t offset, uint64_t size);int qemu_vfio_pci_init_irq (QEMUVFIOState *s,EventNotifier *e,int irq_type,Error **errp); +int qemu_vfio_pci_msix_init_irqs (QEMUVFIOState *s, +unsigned *irq_count,Error **errp);#endif
util/vfio-helpers.c +64 -1
81 lines not on this page · raw message
util/trace-events +1 -0
@@ -87,6 +87,7 @@ qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, size_t size) "s %p host qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d &iova %p" qemu_vfio_dma_mapped(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64" size 0x%zx" qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" +qemu_vfio_msix_info_irqs(uint32_t count, unsigned asked) "msix irqs %"PRIu32" (asked: %u)" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitmask: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")"
Signature · 1 line
2.26.2
PATCH 7/16 util/vfio-helpers: Trace where BARs are mapped
In reply to Philippe Mathieu-DaudéFor debugging purpose, trace where a BAR is mapped.
--- util/vfio-helpers.c | 2 ++ util/trace-events | 1 + 2 files changed, 3 insertions(+)
util/vfio-helpers.c +2 -0
@@ -167,6 +167,8 @@ void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index, p =mmap (NULL ,MIN (size, s->bar_region_info[index].size - offset), prot,MAP_SHARED , s->device, s->bar_region_info[index].offset + offset); +trace_qemu_vfio_pci_map_bar (index, s->bar_region_info[index].offset , + size, offset, p);if (p ==MAP_FAILED ) {error_setg_errno (errp, errno,"Failed to map BAR region" ); p =NULL ;
util/trace-events +1 -0
@@ -89,3 +89,4 @@ qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitmask: 0x qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_region_info(const char *desc, uint64_t offset, uint64_t size, uint32_t cap_offset) "region '%s' ofs 0x%"PRIx64" size %"PRId64" cap_ofs %"PRId32 +qemu_vfio_pci_map_bar(int index, uint64_t region_ofs, uint64_t region_size, int ofs, void *host) "map region bar#%d ofs 0x%"PRIx64" size %"PRId64" ofs %d host %p"
Signature · 1 line
2.26.2
PATCH 9/16 util/vfio-helpers: Convert vfio_dump_mapping to trace events
In reply to Philippe Mathieu-DaudéThe QEMU_VFIO_DEBUG definition is only modifiable at build-time. Trace events can be enabled at run-time. As we prefer the latter, convert qemu_vfio_dump_mappings() to use trace events instead of fprintf().
--- util/vfio-helpers.c | 19 ++++--------------- util/trace-events | 1 + 2 files changed, 5 insertions(+), 15 deletions(-)
util/vfio-helpers.c +4 -15
@@ -551,23 +551,12 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, size_t *min_page_size,return s; } -static void qemu_vfio_dump_mapping (IOVAMapping *m) -{ -if (QEMU_VFIO_DEBUG ) { -printf (" vfio mapping %p %" PRIx64" to %" PRIx64"\n" , m->host, - (uint64_t )m->size, (uint64_t )m->iova); - } -} -static void qemu_vfio_dump_mappings (QEMUVFIOState *s) { -int i; - -if (QEMU_VFIO_DEBUG ) { -printf ("vfio mappings\n" ); -for (i =0 ; i < s->nr_mappings; ++i) { -qemu_vfio_dump_mapping (&s->mappings[i]); - } +for (int i =0 ; i < s->nr_mappings; ++i) { +trace_qemu_vfio_dump_mapping (s->mappings[i].host, + s->mappings[i].iova, + s->mappings[i].size); } }
util/trace-events +1 -0
@@ -80,6 +80,7 @@ qemu_mutex_unlock(void *mutex, const char *file, const int line) "released mutex qemu_vfio_dma_reset_temporary(void *s) "s %p" qemu_vfio_ram_block_added(void *s, void *p, size_t size) "s %p host %p size 0x%zx" qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p size 0x%zx" +qemu_vfio_dump_mapping(void *host, uint64_t iova, size_t size) "vfio mapping %p to iova 0x%08" PRIx64 " size 0x%zx" qemu_vfio_find_mapping(void *s, void *p) "s %p host %p" qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_t iova) "s %p host %p size 0x%zx index %d iova 0x%"PRIx64 qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64 " size 0x%zx"
Signature · 1 line
2.26.2
PATCH 16/16 util/vfio-helpers: Remove now unused qemu_vfio_pci_init_irq()
In reply to Philippe Mathieu-DaudéOur only user, the NVMe block driver, switched to the MSIX API. As this function is now unused, remove it.
--- include/qemu/vfio-helpers.h | 2 -- util/vfio-helpers.c | 43 ------------------------------------- 2 files changed, 45 deletions(-)
include/qemu/vfio-helpers.h +0 -2
@@ -29,8 +29,6 @@ void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index, Error **errp);void qemu_vfio_pci_unmap_bar (QEMUVFIOState *s,int index,void *bar,uint64_t offset,uint64_t size); -int qemu_vfio_pci_init_irq (QEMUVFIOState *s,EventNotifier *e, -int irq_type,Error **errp);int qemu_vfio_pci_msix_init_irqs (QEMUVFIOState *s,unsigned *irq_count,Error **errp); int qemu_vfio_pci_msix_set_irq(QEMUVFIOState *s, unsigned irq_index,
util/vfio-helpers.c +0 -43
49 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 8/16 util/vfio-helpers: Improve DMA trace events
In reply to Philippe Mathieu-DaudéFor debugging purpose, trace where DMA regions are mapped.
--- util/vfio-helpers.c | 3 ++- util/trace-events | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)
util/vfio-helpers.c +2 -1
@@ -657,7 +657,7 @@ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void *host, size_t size, .vaddr = (uintptr_t)host, .size = size, }; -trace_qemu_vfio_do_mapping (s, host, size, iova); +trace_qemu_vfio_do_mapping (s, host, iova, size);if (ioctl (s->container,VFIO_IOMMU_MAP_DMA , &dma_map)) {error_report ("VFIO_MAP_DMA failed: %s" ,strerror (errno));
@@ -813,6 +813,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, } } } +trace_qemu_vfio_dma_mapped (s, host, iova0, size);if (iova) { *iova = iova0; }
util/trace-events +3 -2
@@ -82,8 +82,9 @@ qemu_vfio_ram_block_added(void *s, void *p, size_t size) "s %p host %p size 0x%z qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p size 0x%zx" qemu_vfio_find_mapping(void *s, void *p) "s %p host %p" qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_t iova) "s %p host %p size 0x%zx index %d iova 0x%"PRIx64 -qemu_vfio_do_mapping(void *s, void *host, size_t size, uint64_t iova) "s %p host %p size 0x%zx iova 0x%"PRIx64 -qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d iova %p" +qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64 " size 0x%zx" +qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d &iova %p" +qemu_vfio_dma_mapped(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64" size 0x%zx" qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitmask: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")"
Signature · 1 line
2.26.2
PATCH 10/16 util/vfio-helpers: Let qemu_vfio_dma_map() propagate Error
In reply to Philippe Mathieu-DaudéCurrently qemu_vfio_dma_map() displays errors on stderr. When using management interface, this information is simply lost. Pass qemu_vfio_dma_map() an Error* argument so it can propagate the error to callers.
--- include/qemu/vfio-helpers.h | 2 +- block/nvme.c | 14 +++++++------- util/vfio-helpers.c | 12 +++++++----- 3 files changed, 15 insertions(+), 13 deletions(-)
include/qemu/vfio-helpers.h +1 -1
@@ -19,7 +19,7 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, size_t *min_page_size, Error **errp);void qemu_vfio_close (QEMUVFIOState *s);int qemu_vfio_dma_map (QEMUVFIOState *s,void *host,size_t size, -bool temporary,uint64_t *iova_list); +bool temporary,uint64_t *iova_list,Error **errp);int qemu_vfio_dma_reset_temporary (QEMUVFIOState *s);void qemu_vfio_dma_unmap (QEMUVFIOState *s,void *host); void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index,
block/nvme.c +7 -7
@@ -167,9 +167,9 @@ static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,return ; }memset (q->queue,0 , bytes); - r =qemu_vfio_dma_map (s->vfio, q->queue, bytes, false, &q->iova); + r =qemu_vfio_dma_map (s->vfio, q->queue, bytes, false, &q->iova, errp);if (r) { -error_setg (errp,"Cannot map queue" ); +error_prepend (errp,"Cannot map queue: " ); } }
@@ -223,7 +223,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, q->completion_bh =aio_bh_new (aio_context, nvme_process_completion_bh, q); r =qemu_vfio_dma_map (s->vfio, q->prp_list_pages, s->page_size *NVME_NUM_REQS , - false, &prp_list_iova); + false, &prp_list_iova, errp);if (r) { goto fail; }
@@ -514,9 +514,9 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp)error_setg (errp,"Cannot allocate buffer for identify response" ); goto out; } - r =qemu_vfio_dma_map (s->vfio, id,sizeof (*id), true, &iova); + r =qemu_vfio_dma_map (s->vfio, id,sizeof (*id), true, &iova, errp);if (r) { -error_setg (errp,"Cannot map buffer for DMA" ); +error_prepend (errp,"Cannot map buffer for DMA: " ); goto out; }
@@ -990,7 +990,7 @@ try_map: r =qemu_vfio_dma_map (s->vfio, qiov->iov[i].iov_base, qiov->iov[i].iov_len, - true, &iova); + true, &iova,NULL );if (r == -ENOMEM && retry) { retry = false;trace_nvme_dma_flush_queue_wait (s);
@@ -1437,7 +1437,7 @@ static void nvme_register_buf(BlockDriverState *bs, void *host, size_t size)int ret;BDRVNVMeState *s = bs->opaque; - ret =qemu_vfio_dma_map (s->vfio, host, size, false,NULL ); + ret =qemu_vfio_dma_map (s->vfio, host, size, false,NULL ,NULL );if (ret) {/* FIXME: we may run out of IOVA addresses after repeated * bdrv_register_buf/bdrv_unregister_buf, because nvme_vfio_dma_unmap
util/vfio-helpers.c +7 -5
@@ -486,7 +486,7 @@ static void qemu_vfio_ram_block_added(RAMBlockNotifier *n, {QEMUVFIOState *s =container_of (n, QEMUVFIOState, ram_notifier);trace_qemu_vfio_ram_block_added (s, host, size); -qemu_vfio_dma_map (s, host, size, false,NULL ); +qemu_vfio_dma_map (s, host, size, false,NULL ,NULL ); } static void qemu_vfio_ram_block_removed(RAMBlockNotifier *n,
@@ -501,6 +501,7 @@ static void qemu_vfio_ram_block_removed(RAMBlockNotifier *n,static int qemu_vfio_init_ramblock (RAMBlock *rb,void *opaque) { +Error *local_err =NULL ;void *host_addr =qemu_ram_get_host_addr (rb);ram_addr_t length =qemu_ram_get_used_length (rb);int ret;
@@ -509,10 +510,11 @@ static int qemu_vfio_init_ramblock(RAMBlock *rb, void *opaque)if (!host_addr) {return 0 ; } - ret =qemu_vfio_dma_map (s, host_addr, length, false,NULL ); + ret =qemu_vfio_dma_map (s, host_addr, length, false,NULL , &local_err);if (ret) { -fprintf (stderr,"qemu_vfio_init_ramblock: failed %p %" PRId64"\n" , - host_addr, (uint64_t )length); +error_reportf_err (local_err, +"qemu_vfio_init_ramblock: failed %p %" PRId64":" , + host_addr, (uint64_t )length); }return 0 ; }
@@ -754,7 +756,7 @@ qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size, uint64_t *iova)* mapping status within this area is not allowed). */ int qemu_vfio_dma_map (QEMUVFIOState *s,void *host,size_t size, -bool temporary,uint64_t *iova) +bool temporary,uint64_t *iova,Error **errp) {int ret =0 ;int index;
Signature · 1 line
2.26.2
PATCH 12/16 util/vfio-helpers: Let qemu_vfio_verify_mappings() use error_report()
In reply to Philippe Mathieu-DaudéInstead of displaying the error on stderr, use error_report() which also report to the monitor.
--- util/vfio-helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
util/vfio-helpers.c +2 -2
@@ -691,13 +691,13 @@ static bool qemu_vfio_verify_mappings(QEMUVFIOState *s)if (QEMU_VFIO_DEBUG ) {for (i =0 ; i < s->nr_mappings -1 ; ++i) {if (!(s->mappings[i].host < s->mappings[i +1 ].host)) { -fprintf (stderr,"item %d not sorted!\n" , i); +error_report ("item %d not sorted!" , i);qemu_vfio_dump_mappings (s);return false; }if (!(s->mappings[i].host + s->mappings[i].size <= s->mappings[i +1 ].host)) { -fprintf (stderr,"item %d overlap with next!\n" , i); +error_report ("item %d overlap with next!" , i);qemu_vfio_dump_mappings (s);return false; }
Signature · 1 line
2.26.2
PATCH 14/16 util/vfio-helpers: Introduce qemu_vfio_pci_msix_set_irq()
In reply to Philippe Mathieu-DaudéIntroduce qemu_vfio_pci_msix_set_irq() to set the event notifier of a specific MSIX IRQ. All other registered IRQs are left unmodified.
--- include/qemu/vfio-helpers.h | 2 ++ util/vfio-helpers.c | 35 +++++++++++++++++++++++++++++++++++ util/trace-events | 1 + 3 files changed, 38 insertions(+)
include/qemu/vfio-helpers.h +2 -0
@@ -33,5 +33,7 @@ int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e, int irq_type, Error **errp);int qemu_vfio_pci_msix_init_irqs (QEMUVFIOState *s,unsigned *irq_count,Error **errp); +int qemu_vfio_pci_msix_set_irq (QEMUVFIOState *s,unsigned irq_index, +EventNotifier *notifier,Error **errp);#endif
util/vfio-helpers.c +35 -0
@@ -232,6 +232,41 @@ int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e,return 0 ; } +/** +* Initialize a MSIX IRQ and register its event notifier. +* @irq_index: MSIX IRQ index +* @notifier: notifier for the MSIX IRQ +*/ +int qemu_vfio_pci_msix_set_irq (QEMUVFIOState *s,unsigned irq_index, +EventNotifier *notifier,Error **errp) +{ +int r; +int fd =event_notifier_get_fd (notifier); +size_t irq_set_size; +struct vfio_irq_set *irq_set; + +trace_qemu_vfio_pci_msix_set_irq (irq_index, fd); + irq_set_size =sizeof (*irq_set) +sizeof (int32_t ); + irq_set =g_malloc0 (irq_set_size); +/* Get to a known IRQ state */ + *irq_set = (struct vfio_irq_set ) { + .argsz = irq_set_size, + .flags =VFIO_IRQ_SET_DATA_EVENTFD |VFIO_IRQ_SET_ACTION_TRIGGER , + .index =VFIO_PCI_MSIX_IRQ_INDEX , + .start = irq_index, + .count =1 , + }; + ((int32_t *)&irq_set->data)[0 ] = fd; + r =ioctl (s->device,VFIO_DEVICE_SET_IRQS , irq_set); +g_free (irq_set); +if (r) { +error_setg_errno (errp, errno,"Failed to setup device interrupt #%u" , + irq_index); +return -errno; + } +return 0 ; +} +/** * Initialize device MSIX IRQs and register event notifiers. * @irq_count: pointer to number of MSIX IRQs to initialize
util/trace-events +1 -0
@@ -88,6 +88,7 @@ qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *io qemu_vfio_dma_mapped(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64" size 0x%zx" qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" qemu_vfio_msix_info_irqs(uint32_t count, unsigned asked) "msix irqs %"PRIu32" (asked: %u)" +qemu_vfio_pci_msix_set_irq(unsigned irq_index, int fd) "msix irq %u notifier_fd %d" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitmask: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")"
Signature · 1 line
2.26.2
PATCH 15/16 block/nvme: Switch to using the MSIX API
In reply to Philippe Mathieu-DaudéIn preparation of using multiple IRQs, switch to using the recently introduced MSIX API. Instead of allocating and assigning IRQ in a single step, we now have to use two distinct calls.
--- block/nvme.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
block/nvme.c +12 -2
@@ -691,6 +691,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,Error *local_err =NULL ;volatile NvmeBar *regs =NULL ;size_t min_page_size =4096 ; +unsigned irq_count =MSIX_IRQ_COUNT ;qemu_co_mutex_init (&s->dma_map_lock);qemu_co_queue_init (&s->dma_flush_queue);
@@ -784,8 +785,17 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, } } - ret =qemu_vfio_pci_init_irq (s->vfio, s->irq_notifier, -VFIO_PCI_MSIX_IRQ_INDEX , errp); + ret =qemu_vfio_pci_msix_init_irqs (s->vfio, &irq_count, errp); +if (ret) { +if (ret == -EOVERFLOW ) { +error_append_hint (errp,"%u IRQs requested but only %u available\n" , +MSIX_IRQ_COUNT , irq_count); + } + goto out; + } + + ret =qemu_vfio_pci_msix_set_irq (s->vfio,MSIX_SHARED_IRQ_IDX , + s->irq_notifier, errp);if (ret) { goto out; }
Signature · 1 line
2.26.2
Re: [PATCH 02/16] util/vfio-helpers: Improve reporting unsupported IOMMU type
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
Change the confuse "VFIO IOMMU check failed" error message by the explicit "VFIO IOMMU Type1 is not supported" once.
Example on POWER:
$ qemu-system-ppc64 -drive if=none,id=nvme0,file=nvme://0001:01:00.0/1,format=raw qemu-system-ppc64: -drive if=none,id=nvme0,file=nvme://0001:01:00.0/1,format=raw: VFIO IOMMU Type1 is not supported
Quoted 6 lines
Suggested-by Alex Williamson <[email protected]>Reviewed-by Fam Zheng <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/vfio-helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [PATCH 01/16] block/nvme: Correct minimum device page size
In reply to Philippe Mathieu-DaudéQuoted 9 lines · Philippe Mathieu-Daudé
While trying to simplify the code using a macro, we forgot the 12-bit shift... Correct that.
Fixes fad1eb68862 ("block/nvme: Use register definitions from 'block/nvme.h'")Reported-by Eric Auger <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [PATCH 03/16] util/vfio-helpers: Pass minimum page size to qemu_vfio_open_pci()
In reply to Philippe Mathieu-Daudéblock/nvme.c static int nvme_init(BlockDriverState *bs, const char *device, int namespace, · line 728
Quoted 6 lines · Philippe Mathieu-Daudé
block/nvme.c +1
-1@@ -724,7 +725,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, goto out; } - s->page_size =MAX (4096 ,1u << (12 +NVME_CAP_MPSMIN (cap))); + s->page_size =MAX (min_page_size,1u << (12 +NVME_CAP_MPSMIN (cap)));
Is there a guarantee that the NVMe drive supports our min_page_size?
Stefan
Re: [PATCH 05/16] util/vfio-helpers: Trace PCI I/O config accesses
In reply to Philippe Mathieu-DaudéQuoted 6 lines · Philippe Mathieu-Daudé
We sometime get kernel panic with some devices on Aarch64 hosts. Alex Williamson suggests it might be broken PCIe root complex. Add trace event to record the latest I/O access before crashing. In case, assert our accesses are aligned.
Quoted 6 lines
Reviewed-by Fam Zheng <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/vfio-helpers.c | 8 ++++++++ util/trace-events | 2 ++ 2 files changed, 10 insertions(+)
Re: [PATCH 08/16] util/vfio-helpers: Improve DMA trace events
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
For debugging purpose, trace where DMA regions are mapped.
Reviewed-by Fam Zheng <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/vfio-helpers.c | 3 ++- util/trace-events | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)
Re: [PATCH 07/16] util/vfio-helpers: Trace where BARs are mapped
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
For debugging purpose, trace where a BAR is mapped.
Reviewed-by Fam Zheng <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/vfio-helpers.c | 2 ++ util/trace-events | 1 + 2 files changed, 3 insertions(+)
Re: [PATCH 06/16] util/vfio-helpers: Trace PCI BAR region info
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
For debug purpose, trace BAR regions info.
Reviewed-by Fam Zheng <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/vfio-helpers.c | 8 ++++++++ util/trace-events | 1 + 2 files changed, 9 insertions(+)
Re: [PATCH 09/16] util/vfio-helpers: Convert vfio_dump_mapping to trace events
In reply to Philippe Mathieu-DaudéQuoted 11 lines · Philippe Mathieu-Daudé
The
QEMU_VFIO_DEBUGdefinition is only modifiable at build-time. Trace events can be enabled at run-time. As we prefer the latter, convertqemu_vfio_dump_mappings()to use trace events instead offprintf().Reviewed-by Fam Zheng <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/vfio-helpers.c | 19 ++++--------------- util/trace-events | 1 + 2 files changed, 5 insertions(+), 15 deletions(-)
Re: [PATCH 10/16] util/vfio-helpers: Let qemu_vfio_dma_map() propagate Error
In reply to Philippe Mathieu-DaudéQuoted 5 lines · Philippe Mathieu-Daudé
Currently
qemu_vfio_dma_map()displays errors on stderr. When using management interface, this information is simply lost. Passqemu_vfio_dma_map()an Error* argument so it can propagate the error to callers.
Quoted 7 lines
Reviewed-by Fam Zheng <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/qemu/vfio-helpers.h | 2 +- block/nvme.c | 14 +++++++------- util/vfio-helpers.c | 12 +++++++----- 3 files changed, 15 insertions(+), 13 deletions(-)
Re: [PATCH 12/16] util/vfio-helpers: Let qemu_vfio_verify_mappings() use error_report()
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
Instead of displaying the error on stderr, use
error_report()which also report to the monitor.Reviewed-by Fam Zheng <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/vfio-helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Re: [PATCH 11/16] util/vfio-helpers: Let qemu_vfio_do_mapping() propagate Error
In reply to Philippe Mathieu-DaudéQuoted 9 lines · Philippe Mathieu-Daudé
Pass
qemu_vfio_do_mapping()an Error* argument so it can propagate any error to callers. Replaceerror_report()which only report to the monitor by the more genericerror_setg_errno().Reviewed-by Fam Zheng <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/vfio-helpers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Re: [PATCH 13/16] util/vfio-helpers: Introduce qemu_vfio_pci_msix_init_irqs()
In reply to Philippe Mathieu-DaudéQuoted 7 lines · Philippe Mathieu-Daudé
qemu_vfio_pci_init_irq()allows us to initialize any type of IRQ, but only one. Introduceqemu_vfio_pci_msix_init_irqs()which is specific to MSIX IRQ type, and allow us to use multiple IRQs (thus passing multiple eventfd notifiers).
All eventfd notifiers are initialized with the special '-1' value meaning "un-assigned".
Quoted 6 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/qemu/vfio-helpers.h | 6 +++- util/vfio-helpers.c | 65 ++++++++++++++++++++++++++++++++++++- util/trace-events | 1 + 3 files changed, 70 insertions(+), 2 deletions(-)
Re: [PATCH 14/16] util/vfio-helpers: Introduce qemu_vfio_pci_msix_set_irq()
In reply to Philippe Mathieu-DaudéQuoted 10 lines · Philippe Mathieu-Daudé
Introduce
qemu_vfio_pci_msix_set_irq()to set the event notifier of a specific MSIX IRQ. All other registered IRQs are left unmodified.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/qemu/vfio-helpers.h | 2 ++ util/vfio-helpers.c | 35 +++++++++++++++++++++++++++++++++++ util/trace-events | 1 + 3 files changed, 38 insertions(+)
Re: [PATCH 15/16] block/nvme: Switch to using the MSIX API
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
In preparation of using multiple IRQs, switch to using the recently introduced MSIX API. Instead of allocating and assigning IRQ in a single step, we now have to use two distinct calls.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- block/nvme.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
Re: [PATCH 16/16] util/vfio-helpers: Remove now unused qemu_vfio_pci_init_irq()
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
Our only user, the NVMe block driver, switched to the MSIX API. As this function is now unused, remove it.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/qemu/vfio-helpers.h | 2 -- util/vfio-helpers.c | 43 ------------------------------------- 2 files changed, 45 deletions(-)
Re: [PATCH 04/16] util/vfio-helpers: Report error when IOMMU page size is not supported
In reply to Philippe Mathieu-DaudéQuoted 11 lines · Philippe Mathieu-Daudé
This driver uses the host page size to align its memory regions, but this size is not always compatible with the IOMMU. Add a check if the size matches, and bails out providing a hint what is the minimum page size the driver should use.
Suggested-by Alex Williamson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/vfio-helpers.c | 28 ++++++++++++++++++++++++++-- util/trace-events | 1 + 2 files changed, 27 insertions(+), 2 deletions(-)
Re: [PATCH 03/16] util/vfio-helpers: Pass minimum page size to qemu_vfio_open_pci()
In reply to Stefan HajnocziQuoted 9 lines · Stefan Hajnoczi
block/nvme.c static int nvme_init(BlockDriverState *bs, const char *device, int namespace, · line 728
Quoted 6 lines · Philippe Mathieu-Daudé
block/nvme.c +1
-1@@ -724,7 +725,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, goto out; } - s->page_size =MAX (4096 ,1u << (12 +NVME_CAP_MPSMIN (cap))); + s->page_size =MAX (min_page_size,1u << (12 +NVME_CAP_MPSMIN (cap)));Is there a guarantee that the NVMe drive supports our
min_page_size?
No, good point!
Quoted 3 lines
Stefan