qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>, "Fam Zheng" <fam@euphon.net>,
	qemu-block@nongnu.org, "Max Reitz" <mreitz@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [RFC PATCH 3/3] util/vfio-helpers: Let qemu_vfio_pci_init_irq take IRQ index argument
Date: Tue, 11 Aug 2020 19:28:45 +0200	[thread overview]
Message-ID: <20200811172845.16698-4-philmd@redhat.com> (raw)
In-Reply-To: <20200811172845.16698-1-philmd@redhat.com>

Add a new 'index' argument to qemu_vfio_pci_init_irq() to be able
to initialize other IRQs than IRQ #0. Adapt the single user of this
API in nvme_init().

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 include/qemu/vfio-helpers.h |  2 +-
 block/nvme.c                |  2 +-
 util/vfio-helpers.c         | 12 +++++++++---
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h
index 1f057c2b9e..ff63e75096 100644
--- a/include/qemu/vfio-helpers.h
+++ b/include/qemu/vfio-helpers.h
@@ -27,6 +27,6 @@ void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index,
 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 irq_type, unsigned index, Error **errp);
 
 #endif
diff --git a/block/nvme.c b/block/nvme.c
index 374e268915..2b3986b66d 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -757,7 +757,7 @@ 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);
+                                 VFIO_PCI_MSIX_IRQ_INDEX, 0, errp);
     if (ret) {
         goto out;
     }
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
index 3ad7e6be52..ba9a869364 100644
--- a/util/vfio-helpers.c
+++ b/util/vfio-helpers.c
@@ -173,10 +173,11 @@ void qemu_vfio_pci_unmap_bar(QEMUVFIOState *s, int index, void *bar,
 }
 
 /**
- * Initialize device IRQ with @irq_type and register an event notifier.
+ * Initialize device IRQ @index with @irq_type
+ * and register an event notifier.
  */
 int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e,
-                           int irq_type, Error **errp)
+                           int irq_type, unsigned index, Error **errp)
 {
     int r;
     struct vfio_irq_set *irq_set;
@@ -193,6 +194,11 @@ int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e,
         return -EINVAL;
     }
     trace_qemu_vfio_pci_init_irq(irq_info.count);
+    if (index >= irq_info.count) {
+        error_setg(errp, "Device has %"PRIu32" interrupts (requested index %u)",
+                   irq_info.count, index);
+        return -EINVAL;
+    }
 
     irq_set_size = sizeof(*irq_set) + sizeof(int32_t);
     irq_set = g_malloc0(irq_set_size);
@@ -202,7 +208,7 @@ int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e,
         .argsz = irq_set_size,
         .flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER,
         .index = irq_info.index,
-        .start = 0,
+        .start = index,
         .count = 1,
     };
 
-- 
2.21.3



  parent reply	other threads:[~2020-08-11 17:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-11 17:28 [RFC PATCH 0/3] util/vfio-helpers: Fixes to allow using multiple IRQs Philippe Mathieu-Daudé
2020-08-11 17:28 ` [RFC PATCH 1/3] util/vfio-helpers: Store eventfd using int32_t type Philippe Mathieu-Daudé
2020-08-11 17:28 ` [RFC PATCH 2/3] util/vfio-helpers: Add trace event to display device IRQs available Philippe Mathieu-Daudé
2020-08-11 18:11   ` Alex Williamson
2020-08-11 17:28 ` Philippe Mathieu-Daudé [this message]
2020-08-11 18:17   ` [RFC PATCH 3/3] util/vfio-helpers: Let qemu_vfio_pci_init_irq take IRQ index argument Alex Williamson
2020-08-11 17:30 ` [RFC PATCH 0/3] util/vfio-helpers: Fixes to allow using multiple IRQs Philippe Mathieu-Daudé

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=20200811172845.16698-4-philmd@redhat.com \
    --to=philmd@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=fam@euphon.net \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).