qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: yuval.shaia@oracle.com, marcel.apfelbaum@gmail.com,
	kamalheib1@gmail.com, philmd@redhat.com, dgilbert@redhat.com
Subject: [Qemu-devel] [PATCH PULL 06/11] hw/rdma: Free all MAD receive buffers when device is closed
Date: Sat, 23 Feb 2019 16:16:39 +0200	[thread overview]
Message-ID: <20190223141644.6609-7-marcel.apfelbaum@gmail.com> (raw)
In-Reply-To: <20190223141644.6609-1-marcel.apfelbaum@gmail.com>

From: Yuval Shaia <yuval.shaia@oracle.com>

When device is going down free all saved MAD buffers.

Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
Reviewed-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Message-Id: <20190213065357.16076-7-yuval.shaia@oracle.com>
Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
---
 hw/rdma/rdma_backend.c    | 34 +++++++++++++++++++++++++++++++++-
 hw/rdma/vmw/pvrdma_main.c |  2 ++
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index 0fb4842970..e8ee205b5f 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -64,6 +64,33 @@ static inline void complete_work(enum ibv_wc_status status, uint32_t vendor_err,
     comp_handler(ctx, &wc);
 }
 
+static void free_cqe_ctx(gpointer data, gpointer user_data)
+{
+    BackendCtx *bctx;
+    RdmaDeviceResources *rdma_dev_res = user_data;
+    unsigned long cqe_ctx_id = GPOINTER_TO_INT(data);
+
+    bctx = rdma_rm_get_cqe_ctx(rdma_dev_res, cqe_ctx_id);
+    if (bctx) {
+        rdma_rm_dealloc_cqe_ctx(rdma_dev_res, cqe_ctx_id);
+    }
+    g_free(bctx);
+}
+
+static void clean_recv_mads(RdmaBackendDev *backend_dev)
+{
+    unsigned long cqe_ctx_id;
+
+    do {
+        cqe_ctx_id = rdma_protected_qlist_pop_int64(&backend_dev->
+                                                    recv_mads_list);
+        if (cqe_ctx_id != -ENOENT) {
+            free_cqe_ctx(GINT_TO_POINTER(cqe_ctx_id),
+                         backend_dev->rdma_dev_res);
+        }
+    } while (cqe_ctx_id != -ENOENT);
+}
+
 static int rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, struct ibv_cq *ibcq)
 {
     int i, ne, total_ne = 0;
@@ -1037,6 +1064,11 @@ static int mad_init(RdmaBackendDev *backend_dev, CharBackend *mad_chr_be)
     return 0;
 }
 
+static void mad_stop(RdmaBackendDev *backend_dev)
+{
+    clean_recv_mads(backend_dev);
+}
+
 static void mad_fini(RdmaBackendDev *backend_dev)
 {
     disable_rdmacm_mux_async(backend_dev);
@@ -1224,12 +1256,12 @@ void rdma_backend_start(RdmaBackendDev *backend_dev)
 
 void rdma_backend_stop(RdmaBackendDev *backend_dev)
 {
+    mad_stop(backend_dev);
     stop_backend_thread(&backend_dev->comp_thread);
 }
 
 void rdma_backend_fini(RdmaBackendDev *backend_dev)
 {
-    rdma_backend_stop(backend_dev);
     mad_fini(backend_dev);
     g_hash_table_destroy(ah_hash);
     ibv_destroy_comp_channel(backend_dev->channel);
diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c
index 8ffe79ceca..90dc9b191b 100644
--- a/hw/rdma/vmw/pvrdma_main.c
+++ b/hw/rdma/vmw/pvrdma_main.c
@@ -361,6 +361,8 @@ static void pvrdma_fini(PCIDevice *pdev)
 
     pvrdma_qp_ops_fini();
 
+    rdma_backend_stop(&dev->backend_dev);
+
     rdma_rm_fini(&dev->rdma_dev_res, &dev->backend_dev,
                  dev->backend_eth_device_name);
 
-- 
2.17.1

  parent reply	other threads:[~2019-02-23 14:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-23 14:16 [Qemu-devel] [PATCH PULL 00/11] RDMA queue Marcel Apfelbaum
2019-02-23 14:16 ` [Qemu-devel] [PATCH PULL 01/11] contrib/rdmacm-mux: Fix out-of-bounds risk Marcel Apfelbaum
2019-02-23 14:16 ` [Qemu-devel] [PATCH PULL 02/11] hw/rdma: Switch to generic error reporting way Marcel Apfelbaum
2019-02-23 14:16 ` [Qemu-devel] [PATCH PULL 03/11] hw/rdma: Introduce protected qlist Marcel Apfelbaum
2019-02-23 14:16 ` [Qemu-devel] [PATCH PULL 04/11] hw/rdma: Protect against concurrent execution of poll_cq Marcel Apfelbaum
2019-02-23 14:16 ` [Qemu-devel] [PATCH PULL 05/11] {monitor, hw/pvrdma}: Expose device internals via monitor interface Marcel Apfelbaum
2019-02-23 14:16 ` Marcel Apfelbaum [this message]
2019-02-23 14:16 ` [Qemu-devel] [PATCH PULL 07/11] hw/rdma: Free all receive buffers when QP is destroyed Marcel Apfelbaum
2019-02-23 14:16 ` [Qemu-devel] [PATCH PULL 08/11] hw/pvrdma: Delete unneeded function argument Marcel Apfelbaum
2019-02-23 14:16 ` [Qemu-devel] [PATCH PULL 09/11] hw/pvrdma: Delete pvrdma_exit function Marcel Apfelbaum
2019-02-23 14:16 ` [Qemu-devel] [PATCH PULL 10/11] hw/pvrdma: Unregister from shutdown notifier when device goes down Marcel Apfelbaum
2019-02-23 14:16 ` [Qemu-devel] [PATCH PULL 11/11] hw/rdma: another clang compilation fix Marcel Apfelbaum
2019-02-26 16:48 ` [Qemu-devel] [PATCH PULL 00/11] RDMA queue Peter Maydell
2019-02-26 18:40   ` Marcel Apfelbaum
2019-02-27  9:46   ` Yuval Shaia

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=20190223141644.6609-7-marcel.apfelbaum@gmail.com \
    --to=marcel.apfelbaum@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=kamalheib1@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yuval.shaia@oracle.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).