From 9a70b6375d42fda41a9c64ea1dbf642fc8e8d05f Mon Sep 17 00:00:00 2001 From: paul luse Date: Fri, 5 Feb 2021 10:32:39 -0500 Subject: [PATCH] idxd: update low level lib and poller to indicate busy/idle Signed-off-by: paul luse Change-Id: I0acb74bd679e924977fb058a29ee947734e7aa83 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6287 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- include/spdk/idxd.h | 3 ++- lib/idxd/idxd.c | 5 ++++- module/accel/idxd/accel_engine_idxd.c | 27 +++++++++++++-------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/include/spdk/idxd.h b/include/spdk/idxd.h index 6c35a3756..b7674627e 100644 --- a/include/spdk/idxd.h +++ b/include/spdk/idxd.h @@ -391,8 +391,9 @@ int spdk_idxd_submit_crc32c(struct spdk_idxd_io_channel *chan, uint32_t *dst, vo * Check for completed requests on an IDXD channel. * * \param chan IDXD channel to check for completions. + * \return number of operations completed. */ -void spdk_idxd_process_events(struct spdk_idxd_io_channel *chan); +int spdk_idxd_process_events(struct spdk_idxd_io_channel *chan); /** * Returns an IDXD channel for a given IDXD device. diff --git a/lib/idxd/idxd.c b/lib/idxd/idxd.c index ad503da95..b08a7d093 100644 --- a/lib/idxd/idxd.c +++ b/lib/idxd/idxd.c @@ -1391,17 +1391,19 @@ _dump_error_reg(struct spdk_idxd_io_channel *chan) #define IDXD_COMPLETION(x) ((x) > (0) ? (1) : (0)) #define IDXD_FAILURE(x) ((x) > (1) ? (1) : (0)) #define IDXD_SW_ERROR(x) ((x) &= (0x1) ? (1) : (0)) -void +int spdk_idxd_process_events(struct spdk_idxd_io_channel *chan) { struct idxd_comp *comp_ctx, *tmp; uint64_t sw_error_0; int status = 0; + int rc = 0; TAILQ_FOREACH_SAFE(comp_ctx, &chan->comp_ctx_oustanding, link, tmp) { if (IDXD_COMPLETION(comp_ctx->hw.status)) { TAILQ_REMOVE(&chan->comp_ctx_oustanding, comp_ctx, link); + rc++; if (spdk_unlikely(IDXD_FAILURE(comp_ctx->hw.status))) { sw_error_0 = _idxd_read_8(chan->idxd, IDXD_SWERR_OFFSET); @@ -1445,6 +1447,7 @@ spdk_idxd_process_events(struct spdk_idxd_io_channel *chan) } } } + return rc; } SPDK_LOG_REGISTER_COMPONENT(idxd) diff --git a/module/accel/idxd/accel_engine_idxd.c b/module/accel/idxd/accel_engine_idxd.c index 9ac8ffc72..0ea88bbc2 100644 --- a/module/accel/idxd/accel_engine_idxd.c +++ b/module/accel/idxd/accel_engine_idxd.c @@ -194,24 +194,23 @@ idxd_poll(void *arg) { struct idxd_io_channel *chan = arg; struct spdk_accel_task *task = NULL; + int count; - spdk_idxd_process_events(chan->chan); + count = spdk_idxd_process_events(chan->chan); /* Check if there are any pending ops to process if the channel is active */ - if (chan->state != IDXD_CHANNEL_ACTIVE) { - return -1; + if (chan->state == IDXD_CHANNEL_ACTIVE) { + /* Submit queued tasks */ + if (!TAILQ_EMPTY(&chan->queued_tasks)) { + task = TAILQ_FIRST(&chan->queued_tasks); + + TAILQ_INIT(&chan->queued_tasks); + + idxd_submit_tasks(task->accel_ch->engine_ch, task); + } } - /* Submit queued tasks */ - if (!TAILQ_EMPTY(&chan->queued_tasks)) { - task = TAILQ_FIRST(&chan->queued_tasks); - - TAILQ_INIT(&chan->queued_tasks); - - idxd_submit_tasks(task->accel_ch->engine_ch, task); - } - - return -1; + return count > 0 ? SPDK_POLLER_BUSY : SPDK_POLLER_IDLE; } static size_t @@ -323,7 +322,7 @@ idxd_create_cb(void *io_device, void *ctx_buf) } chan->dev = dev; - chan->poller = spdk_poller_register(idxd_poll, chan, 0); + chan->poller = SPDK_POLLER_REGISTER(idxd_poll, chan, 0); TAILQ_INIT(&chan->queued_tasks); /*