[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 16/64] block/nvme: Use an array of EventNotifier
From: |
Kevin Wolf |
Subject: |
[PULL 16/64] block/nvme: Use an array of EventNotifier |
Date: |
Mon, 7 Sep 2020 13:08:48 +0200 |
From: Philippe Mathieu-Daudé <philmd@redhat.com>
In preparation of using multiple IRQ (thus multiple eventfds)
make BDRVNVMeState::irq_notifier an array (for now of a single
element, the admin queue notifier).
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200821195359.1285345-16-philmd@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/nvme.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/block/nvme.c b/block/nvme.c
index e3719d3bd1..24e6e7f086 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -106,6 +106,12 @@ QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) != 0x1000);
#define INDEX_ADMIN 0
#define INDEX_IO(n) (1 + n)
+/* This driver shares a single MSIX IRQ for the admin and I/O queues */
+enum {
+ MSIX_SHARED_IRQ_IDX = 0,
+ MSIX_IRQ_COUNT = 1
+};
+
struct BDRVNVMeState {
AioContext *aio_context;
QEMUVFIOState *vfio;
@@ -120,7 +126,7 @@ struct BDRVNVMeState {
/* How many uint32_t elements does each doorbell entry take. */
size_t doorbell_scale;
bool write_cache_supported;
- EventNotifier irq_notifier;
+ EventNotifier irq_notifier[MSIX_IRQ_COUNT];
uint64_t nsze; /* Namespace size reported by identify command */
int nsid; /* The namespace id to read/write data. */
@@ -631,7 +637,8 @@ static bool nvme_poll_queues(BDRVNVMeState *s)
static void nvme_handle_event(EventNotifier *n)
{
- BDRVNVMeState *s = container_of(n, BDRVNVMeState, irq_notifier);
+ BDRVNVMeState *s = container_of(n, BDRVNVMeState,
+ irq_notifier[MSIX_SHARED_IRQ_IDX]);
trace_nvme_handle_event(s);
event_notifier_test_and_clear(n);
@@ -683,7 +690,8 @@ out_error:
static bool nvme_poll_cb(void *opaque)
{
EventNotifier *e = opaque;
- BDRVNVMeState *s = container_of(e, BDRVNVMeState, irq_notifier);
+ BDRVNVMeState *s = container_of(e, BDRVNVMeState,
+ irq_notifier[MSIX_SHARED_IRQ_IDX]);
trace_nvme_poll_cb(s);
return nvme_poll_queues(s);
@@ -705,7 +713,7 @@ static int nvme_init(BlockDriverState *bs, const char
*device, int namespace,
s->device = g_strdup(device);
s->nsid = namespace;
s->aio_context = bdrv_get_aio_context(bs);
- ret = event_notifier_init(&s->irq_notifier, 0);
+ ret = event_notifier_init(&s->irq_notifier[MSIX_SHARED_IRQ_IDX], 0);
if (ret) {
error_setg(errp, "Failed to init event notifier");
return ret;
@@ -784,12 +792,13 @@ static int nvme_init(BlockDriverState *bs, const char
*device, int namespace,
}
}
- ret = qemu_vfio_pci_init_irq(s->vfio, &s->irq_notifier,
+ ret = qemu_vfio_pci_init_irq(s->vfio, s->irq_notifier,
VFIO_PCI_MSIX_IRQ_INDEX, errp);
if (ret) {
goto out;
}
- aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier,
+ aio_set_event_notifier(bdrv_get_aio_context(bs),
+ &s->irq_notifier[MSIX_SHARED_IRQ_IDX],
false, nvme_handle_event, nvme_poll_cb);
nvme_identify(bs, namespace, &local_err);
@@ -872,9 +881,10 @@ static void nvme_close(BlockDriverState *bs)
nvme_free_queue_pair(s->queues[i]);
}
g_free(s->queues);
- aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier,
+ aio_set_event_notifier(bdrv_get_aio_context(bs),
+ &s->irq_notifier[MSIX_SHARED_IRQ_IDX],
false, NULL, NULL);
- event_notifier_cleanup(&s->irq_notifier);
+ event_notifier_cleanup(&s->irq_notifier[MSIX_SHARED_IRQ_IDX]);
qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->regs, 0, NVME_BAR_SIZE);
qemu_vfio_close(s->vfio);
@@ -1381,7 +1391,8 @@ static void nvme_detach_aio_context(BlockDriverState *bs)
q->completion_bh = NULL;
}
- aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier,
+ aio_set_event_notifier(bdrv_get_aio_context(bs),
+ &s->irq_notifier[MSIX_SHARED_IRQ_IDX],
false, NULL, NULL);
}
@@ -1391,7 +1402,7 @@ static void nvme_attach_aio_context(BlockDriverState *bs,
BDRVNVMeState *s = bs->opaque;
s->aio_context = new_context;
- aio_set_event_notifier(new_context, &s->irq_notifier,
+ aio_set_event_notifier(new_context, &s->irq_notifier[MSIX_SHARED_IRQ_IDX],
false, nvme_handle_event, nvme_poll_cb);
for (int i = 0; i < s->nr_queues; i++) {
--
2.25.4
- [PULL 10/64] block/nvme: Replace qemu_try_blockalign0 by qemu_try_blockalign/memset, (continued)
- [PULL 10/64] block/nvme: Replace qemu_try_blockalign0 by qemu_try_blockalign/memset, Kevin Wolf, 2020/09/07
- [PULL 11/64] block/nvme: Replace qemu_try_blockalign(bs) by qemu_try_memalign(pg_sz), Kevin Wolf, 2020/09/07
- [PULL 12/64] block/nvme: Simplify nvme_init_queue() arguments, Kevin Wolf, 2020/09/07
- [PULL 13/64] block/nvme: Replace BDRV_POLL_WHILE by AIO_WAIT_WHILE, Kevin Wolf, 2020/09/07
- [PULL 08/64] block/nvme: Rename local variable, Kevin Wolf, 2020/09/07
- [PULL 14/64] block/nvme: Simplify nvme_create_queue_pair() arguments, Kevin Wolf, 2020/09/07
- [PULL 15/64] block/nvme: Extract nvme_poll_queue(), Kevin Wolf, 2020/09/07
- [PULL 17/64] block: Add child access functions, Kevin Wolf, 2020/09/07
- [PULL 18/64] block: Add chain helper functions, Kevin Wolf, 2020/09/07
- [PULL 19/64] block: bdrv_cow_child() for bdrv_has_zero_init(), Kevin Wolf, 2020/09/07
- [PULL 16/64] block/nvme: Use an array of EventNotifier,
Kevin Wolf <=
- [PULL 20/64] block: bdrv_set_backing_hd() is about bs->backing, Kevin Wolf, 2020/09/07
- [PULL 21/64] block: Include filters when freezing backing chain, Kevin Wolf, 2020/09/07
- [PULL 23/64] block: Add bdrv_supports_compressed_writes(), Kevin Wolf, 2020/09/07
- [PULL 24/64] throttle: Support compressed writes, Kevin Wolf, 2020/09/07
- [PULL 26/64] block: Use bdrv_filter_(bs|child) where obvious, Kevin Wolf, 2020/09/07
- [PULL 22/64] block: Drop bdrv_is_encrypted(), Kevin Wolf, 2020/09/07
- [PULL 27/64] block: Use CAFs in block status functions, Kevin Wolf, 2020/09/07
- [PULL 25/64] copy-on-read: Support compressed writes, Kevin Wolf, 2020/09/07
- [PULL 28/64] stream: Deal with filters, Kevin Wolf, 2020/09/07
- [PULL 30/64] block: Use bdrv_cow_child() in bdrv_co_truncate(), Kevin Wolf, 2020/09/07