From 2eaae37dedd6ac61e551043b5755be3a76813211 Mon Sep 17 00:00:00 2001 From: John Levon Date: Tue, 16 Aug 2022 08:47:15 +0000 Subject: [PATCH] nvmf/vfio-user: complete queue deletion on correct thread If the queue was on another poll group, we need to send a message back to the admin CQ's thread to post the completion from the correct context. Signed-off-by: John Levon Change-Id: I997987d5d6b822a1a5124f54fc29ce5d7f03190d Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14057 Tested-by: SPDK CI Jenkins Reviewed-by: Swapnil Ingle Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris Community-CI: Mellanox Build Bot --- lib/nvmf/vfio_user.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 290e69b59..66e4060e3 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -1624,6 +1624,10 @@ post_completion(struct nvmf_vfio_user_ctrlr *ctrlr, struct nvmf_vfio_user_cq *cq return 0; } + if (cq->qid == 0) { + assert(spdk_get_thread() == cq->thread); + } + if (cq_is_full(cq)) { SPDK_ERRLOG("%s: cqid:%d full (tail=%d, head=%d)\n", ctrlr_id(ctrlr), cq->qid, *cq_tailp(cq), @@ -2117,10 +2121,19 @@ vfio_user_qpair_delete_cb(void *cb_arg) { struct vfio_user_delete_sq_ctx *ctx = cb_arg; struct nvmf_vfio_user_ctrlr *vu_ctrlr = ctx->vu_ctrlr; + struct nvmf_vfio_user_cq *admin_cq = vu_ctrlr->cqs[0]; - post_completion(vu_ctrlr, vu_ctrlr->cqs[0], 0, 0, ctx->delete_io_sq_cmd.cid, - SPDK_NVME_SC_SUCCESS, SPDK_NVME_SCT_GENERIC); - free(ctx); + if (admin_cq->thread != spdk_get_thread()) { + assert(admin_cq->thread != NULL); + spdk_thread_send_msg(admin_cq->thread, + vfio_user_qpair_delete_cb, + cb_arg); + } else { + post_completion(vu_ctrlr, vu_ctrlr->cqs[0], 0, 0, + ctx->delete_io_sq_cmd.cid, + SPDK_NVME_SC_SUCCESS, SPDK_NVME_SCT_GENERIC); + free(ctx); + } } /*