From 1d4a88104d3a3e0e0aab6f895ebb726819051d3e Mon Sep 17 00:00:00 2001 From: John Levon Date: Mon, 28 Jun 2021 22:22:48 +0000 Subject: [PATCH] vfio-user: correct return code for library context poller Currently, the poller that calls vfu_run_ctx() always returns SPDK_POLLER_BUSY. Update libvfio-user and adjust the API usage so that it can accurately report SPDK_POLLER_IDLE when needed. Additionally, renaming the poller to better reflect its meaning: it's not just for mmio handlers, but libvfio-user handling in general. Signed-off-by: John Levon Change-Id: I5e598241ac0a692f03ee36242ff977c4e6f14987 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8568 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu Reviewed-by: Aleksey Marchuk --- lib/nvmf/vfio_user.c | 17 ++++++++++------- libvfio-user | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index b735ed576..8924eac67 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -164,7 +164,7 @@ struct nvmf_vfio_user_ctrlr { uint32_t num_connected_qps; struct spdk_thread *thread; - struct spdk_poller *mmio_poller; + struct spdk_poller *vfu_ctx_poller; uint16_t cntlid; @@ -1885,7 +1885,7 @@ _free_ctrlr(void *ctx) free_qp(ctrlr, i); } - spdk_poller_unregister(&ctrlr->mmio_poller); + spdk_poller_unregister(&ctrlr->vfu_ctx_poller); free(ctrlr); } @@ -2244,8 +2244,11 @@ vfio_user_destroy_ctrlr(struct nvmf_vfio_user_ctrlr *ctrlr) return 0; } +/* + * Poll for and process any incoming vfio-user messages. + */ static int -vfio_user_poll_mmio(void *ctx) +vfio_user_poll_vfu_ctx(void *ctx) { struct nvmf_vfio_user_ctrlr *ctrlr = ctx; int ret; @@ -2255,8 +2258,8 @@ vfio_user_poll_mmio(void *ctx) /* This will call access_bar0_fn() if there are any writes * to the portion of the BAR that is not mmap'd */ ret = vfu_run_ctx(ctrlr->endpoint->vfu_ctx); - if (spdk_unlikely(ret != 0)) { - spdk_poller_unregister(&ctrlr->mmio_poller); + if (spdk_unlikely(ret == -1)) { + spdk_poller_unregister(&ctrlr->vfu_ctx_poller); /* initiator shutdown or reset, waiting for another re-connect */ if (errno == ENOTCONN) { @@ -2267,7 +2270,7 @@ vfio_user_poll_mmio(void *ctx) fail_ctrlr(ctrlr); } - return SPDK_POLLER_BUSY; + return ret != 0 ? SPDK_POLLER_BUSY : SPDK_POLLER_IDLE; } static int @@ -2301,7 +2304,7 @@ handle_queue_connect_rsp(struct nvmf_vfio_user_req *req, void *cb_arg) if (nvmf_qpair_is_admin_queue(&qpair->qpair)) { ctrlr->cntlid = qpair->qpair.ctrlr->cntlid; ctrlr->thread = spdk_get_thread(); - ctrlr->mmio_poller = SPDK_POLLER_REGISTER(vfio_user_poll_mmio, ctrlr, 0); + ctrlr->vfu_ctx_poller = SPDK_POLLER_REGISTER(vfio_user_poll_vfu_ctx, ctrlr, 0); } else { /* For I/O queues this command was generated in response to an * ADMIN I/O CREATE SUBMISSION QUEUE command which has not yet diff --git a/libvfio-user b/libvfio-user index 3fe0df484..677a541ca 160000 --- a/libvfio-user +++ b/libvfio-user @@ -1 +1 @@ -Subproject commit 3fe0df4843508ffc3517e82e9256c0e2d02932bd +Subproject commit 677a541ca1f42d1f32a0371bbdf32005bdbd871d