From 36dfcca2b490e0866c9076042753125212274a3b Mon Sep 17 00:00:00 2001 From: John Levon Date: Mon, 10 Oct 2022 11:19:32 +0100 Subject: [PATCH] nvmf/vfio-user: switch from shadow doorbells when freeing Some reset/disable paths are freeing the shadow doorbells without switching the SQs back to BAR0. Fix this up, and add a small cleanup when initializing the shadow doorbells. Signed-off-by: John Levon Change-Id: Ia5e5b91b7dc696a558eb0ad59cc554abced47cca Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14901 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/nvmf/vfio_user.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 919c35d87..af3fa3104 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -912,6 +912,8 @@ vfio_user_ctrlr_switch_doorbells(struct nvmf_vfio_user_ctrlr *ctrlr, bool shadow if (sq != NULL) { sq->dbl_tailp = doorbells + queue_index(sq->qid, false); + + ctrlr->sqs[i]->need_rearm = shadow; } if (cq != NULL) { @@ -2287,9 +2289,6 @@ handle_doorbell_buffer_config(struct nvmf_vfio_user_ctrlr *ctrlr, struct spdk_nv */ for (uint16_t i = 0; i < NVMF_VFIO_USER_DEFAULT_MAX_QPAIRS_PER_CTRLR; ++i) { sdbl->eventidxs[queue_index(i, true)] = NVMF_VFIO_USER_EVENTIDX_POLL; - if (ctrlr->sqs[i] != NULL) { - ctrlr->sqs[i]->need_rearm = true; - } } /* Update controller. */ @@ -2647,6 +2646,7 @@ disable_ctrlr(struct nvmf_vfio_user_ctrlr *vu_ctrlr) nvmf_ctrlr_abort_aer(vu_ctrlr->ctrlr); /* Free the shadow doorbell buffer. */ + vfio_user_ctrlr_switch_doorbells(vu_ctrlr, false); free_sdbl(vu_ctrlr->endpoint->vfu_ctx, vu_ctrlr->sdbl); vu_ctrlr->sdbl = NULL; } @@ -3429,6 +3429,7 @@ vfio_user_device_reset(vfu_ctx_t *vfu_ctx, vfu_reset_type_t type) /* FIXME: LOST_CONN case ? */ if (ctrlr->sdbl != NULL) { + vfio_user_ctrlr_switch_doorbells(ctrlr, false); free_sdbl(vfu_ctx, ctrlr->sdbl); ctrlr->sdbl = NULL; }