From e7f3142ca29c936b8c97607c710cdcde19ea9a6d Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Mon, 15 Mar 2021 22:45:07 +0800 Subject: [PATCH] nvmf/vfio-user: eliminate unmap_q function unmap_q is only be called in unmap_qp, so remove this function to make the code more clear to read. Change-Id: I627c7a1efdcb85476cb618fced8b0bfc2d8f1f62 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6886 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Reviewed-by: Ben Walker --- lib/nvmf/vfio_user.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 24895ce38..030d6aede 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -670,18 +670,6 @@ lookup_io_q(struct nvmf_vfio_user_ctrlr *ctrlr, const uint16_t qid, const bool i return q; } -static void -unmap_q(vfu_ctx_t *vfu_ctx, struct nvme_q *q) -{ - if (q == NULL) { - return; - } - if (q->addr != NULL) { - vfu_unmap_sg(vfu_ctx, &q->sg, &q->iov, 1); - q->addr = NULL; - } -} - static void unmap_qp(struct nvmf_vfio_user_qpair *qp) { @@ -695,9 +683,15 @@ unmap_qp(struct nvmf_vfio_user_qpair *qp) SPDK_DEBUGLOG(nvmf_vfio, "%s: destroy I/O QP%d\n", ctrlr_id(ctrlr), qp->qpair.qid); - unmap_q(ctrlr->endpoint->vfu_ctx, &qp->sq); - unmap_q(ctrlr->endpoint->vfu_ctx, &qp->cq); + if (qp->sq.addr != NULL) { + vfu_unmap_sg(ctrlr->endpoint->vfu_ctx, &qp->sq.sg, &qp->sq.iov, 1); + qp->sq.addr = NULL; + } + if (qp->cq.addr != NULL) { + vfu_unmap_sg(ctrlr->endpoint->vfu_ctx, &qp->cq.sg, &qp->cq.iov, 1); + qp->cq.addr = NULL; + } } /* @@ -1154,7 +1148,6 @@ memory_region_remove_cb(vfu_ctx_t *vfu_ctx, uint64_t iova, uint64_t len) return 0; } - static int nvmf_vfio_user_prop_req_rsp(struct nvmf_vfio_user_req *req, void *cb_arg) {