From nobody Mon Feb 9 13:39:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599136163; cv=none; d=zohomail.com; s=zohoarc; b=mvldujYtOqoRKgT8ReA/goeAIsVucpMjbVmvldOJ4bboKQC7ZYxOvafTrBbKOpxzoRhi6P/A63ONOukbNz4AEo1J+qB6uPdNJkFpH6A+iKmz8YVnHBSXu8f6B0ZOHtKT9DCdFjdSWiKOFPMxDpY131oKTtYUB9ZLFBMFxEfHRrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599136163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=NpnignYWyGxwS894GY8oMk/a6JEblSgZ3kZBOAlqf6A=; b=Mw4fvzS/f32vLHuaGvXJWFAwc98uMbR7AbrcbbftGtx0x5r8N80t/4WLXByxLAvoci6Br16I5sOfZJpHqzdE5IYPDTVzkonreRWIgvnYMXLD+UcPdfU6Cwf6VTWcuMBPw6pzoZGvzc74SCVXaIcWlPaihnox+kgKPP2mzvYDKhw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1599136162486353.57572734608334; Thu, 3 Sep 2020 05:29:22 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-541-RjP3tR66MqiEEl8cUw34Bw-1; Thu, 03 Sep 2020 08:29:20 -0400 Received: by mail-wr1-f69.google.com with SMTP id y3so1010681wrl.21 for ; Thu, 03 Sep 2020 05:29:20 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id f6sm5522520wme.32.2020.09.03.05.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 05:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599136161; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NpnignYWyGxwS894GY8oMk/a6JEblSgZ3kZBOAlqf6A=; b=EHuRz5ldh7m30rNP6kcSn7OglEJNee23uWnD1qbqDSwGfoAPCJpwQB9o8oLJyAXJc1+tlM 0xOgw/2znYP0ZrIGKntH+3yLhQKHk13tP0yGX/grE4vrkyM1Oq5Fx53vWQKcDyYXgOGkt+ Upgi4BS6XPkdbtYVlJRxbyzEZvuzOpA= X-MC-Unique: RjP3tR66MqiEEl8cUw34Bw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NpnignYWyGxwS894GY8oMk/a6JEblSgZ3kZBOAlqf6A=; b=QZTOVQ97/nqE0Z155GbIVDW3baqOnuDHYT8BFb5aLaBBQSZi7Oeb/HaeW15qP4qAwK r/Jj6KGXefl2ctzHnjHKipjhEMzWTZpue2Fsc+uBoDXZrUA40t5fXrsMvp0xCxDaeDWR 1pf+430Eeo1tyu3i08r+VH1zo0cib1YZItrKevcgihPxIhaFcZ0ifWOJ/SFuS2wHYYk3 d3K/LXe22VTEolDcCmB+NU0WE4X2UQSQPVVpyF24Bb6R9Du0qtuYAZ2zXdz6oLJdOkZl qL5M+4eNDx0b1fWu9eFjPpCoFgSJ0M0xTwu0G6ann3lMOo4MyZK8Eczy74GwxmAuY3w9 /Buw== X-Gm-Message-State: AOAM533u3IXfjljYVkqzWUQswBs4oXo8FYHyKzTPODwEipI+H8Rj8a4g fT2/yWZRQKwMQ8p1IpDqkJdtwTMLtQRk10sCfF9sIGtsNVf+DgDeSeb+8lnhsa33xOkPvcbxsZB yho9+LJ96g/OkRA== X-Received: by 2002:adf:dfc3:: with SMTP id q3mr2143363wrn.238.1599136159153; Thu, 03 Sep 2020 05:29:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxR9VEDlF2c2hXScIfRFO6BMVLUh++Phr1HzLZP45Ib7PyZQGziMgfXkk+UlgLLkTuTZ0hqUg== X-Received: by 2002:adf:dfc3:: with SMTP id q3mr2143341wrn.238.1599136158915; Thu, 03 Sep 2020 05:29:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Klaus Jensen , Fam Zheng , Max Reitz , Keith Busch , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Stefano Garzarella Subject: [PATCH v7 15/15] block/nvme: Use an array of EventNotifier Date: Thu, 3 Sep 2020 14:28:03 +0200 Message-Id: <20200903122803.405265-16-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903122803.405265-1-philmd@redhat.com> References: <20200903122803.405265-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @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 Reviewed-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index e3719d3bd14..24e6e7f0866 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -106,6 +106,12 @@ QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) !=3D 0= x1000); #define INDEX_ADMIN 0 #define INDEX_IO(n) (1 + n) =20 +/* This driver shares a single MSIX IRQ for the admin and I/O queues */ +enum { + MSIX_SHARED_IRQ_IDX =3D 0, + MSIX_IRQ_COUNT =3D 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]; =20 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) =20 static void nvme_handle_event(EventNotifier *n) { - BDRVNVMeState *s =3D container_of(n, BDRVNVMeState, irq_notifier); + BDRVNVMeState *s =3D container_of(n, BDRVNVMeState, + irq_notifier[MSIX_SHARED_IRQ_IDX]); =20 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 =3D opaque; - BDRVNVMeState *s =3D container_of(e, BDRVNVMeState, irq_notifier); + BDRVNVMeState *s =3D container_of(e, BDRVNVMeState, + irq_notifier[MSIX_SHARED_IRQ_IDX]); =20 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 =3D g_strdup(device); s->nsid =3D namespace; s->aio_context =3D bdrv_get_aio_context(bs); - ret =3D event_notifier_init(&s->irq_notifier, 0); + ret =3D 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, } } =20 - ret =3D qemu_vfio_pci_init_irq(s->vfio, &s->irq_notifier, + ret =3D 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); =20 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); =20 @@ -1381,7 +1391,8 @@ static void nvme_detach_aio_context(BlockDriverState = *bs) q->completion_bh =3D NULL; } =20 - 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); } =20 @@ -1391,7 +1402,7 @@ static void nvme_attach_aio_context(BlockDriverState = *bs, BDRVNVMeState *s =3D bs->opaque; =20 s->aio_context =3D new_context; - aio_set_event_notifier(new_context, &s->irq_notifier, + aio_set_event_notifier(new_context, &s->irq_notifier[MSIX_SHARED_IRQ_I= DX], false, nvme_handle_event, nvme_poll_cb); =20 for (int i =3D 0; i < s->nr_queues; i++) { --=20 2.26.2