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 <john.levon@nutanix.com>
Change-Id: Ia5e5b91b7dc696a558eb0ad59cc554abced47cca
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14901
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
John Levon 2022-10-10 11:19:32 +01:00 committed by Tomasz Zawadzki
parent 64db53f1aa
commit 36dfcca2b4

View File

@ -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;
}