Commit c2fa2d50 authored by Changpeng Liu's avatar Changpeng Liu Committed by Jim Harris
Browse files

nvmf/vfio-user: unregister the memory region whether controller is active or not



The controller may be freed eailer than endpoint, so we still
need to unregister the memory region from SPDK.  The case
can happen when removing the listener while VM is connected.

Change-Id: I95d49cefdbff3e0bdea316fac824ef8b218fcd2c
Signed-off-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10378


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
parent 69dc63da
Loading
Loading
Loading
Loading
+18 −19
Original line number Diff line number Diff line
@@ -1617,9 +1617,7 @@ memory_region_remove_cb(vfu_ctx_t *vfu_ctx, vfu_dma_info_t *info)
	}

	assert(endpoint != NULL);
	if (endpoint->ctrlr == NULL) {
		return 0;
	}
	if (endpoint->ctrlr != NULL) {
		ctrlr = endpoint->ctrlr;

		SPDK_DEBUGLOG(nvmf_vfio, "%s: unmap IOVA %#lx-%#lx\n", ctrlr_id(ctrlr),
@@ -1642,6 +1640,7 @@ memory_region_remove_cb(vfu_ctx_t *vfu_ctx, vfu_dma_info_t *info)
			}
		}
		pthread_mutex_unlock(&endpoint->lock);
	}

	if (info->prot == (PROT_WRITE | PROT_READ)) {
		ret = spdk_mem_unregister(info->mapping.iov_base, info->mapping.iov_len);