From 7abf75c2b5b29b7e1125b9b5fd4d4905499b91a5 Mon Sep 17 00:00:00 2001 From: paul luse Date: Thu, 5 Aug 2021 12:31:17 -0400 Subject: [PATCH] lib/idxd: pre translate the completion address for batch entries Signed-off-by: paul luse Change-Id: I9df51acc2bbd3deffcb172c0fd3e7012ec3d4b3b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9100 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- lib/idxd/idxd.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/idxd/idxd.c b/lib/idxd/idxd.c index 71cb7a053..3b3eb90d0 100644 --- a/lib/idxd/idxd.c +++ b/lib/idxd/idxd.c @@ -247,23 +247,34 @@ spdk_idxd_configure_chan(struct spdk_idxd_io_channel *chan) /* Populate the batches */ TAILQ_FOREACH(batch, &chan->batch_pool, link) { - batch->user_desc = spdk_zmalloc(DESC_PER_BATCH * sizeof(struct idxd_hw_desc), - 0x40, NULL, - SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA); + batch->user_desc = desc = spdk_zmalloc(DESC_PER_BATCH * sizeof(struct idxd_hw_desc), + 0x40, NULL, + SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA); if (batch->user_desc == NULL) { SPDK_ERRLOG("Failed to allocate batch descriptor memory\n"); rc = -ENOMEM; goto err_user_desc_or_op; } - batch->user_ops = spdk_zmalloc(DESC_PER_BATCH * sizeof(struct idxd_ops), - 0x40, NULL, - SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA); + batch->user_ops = op = spdk_zmalloc(DESC_PER_BATCH * sizeof(struct idxd_ops), + 0x40, NULL, + SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA); if (batch->user_ops == NULL) { SPDK_ERRLOG("Failed to allocate user completion memory\n"); rc = -ENOMEM; goto err_user_desc_or_op; } + + for (i = 0; i < DESC_PER_BATCH; i++) { + rc = _vtophys(&op->hw, &desc->completion_addr, sizeof(struct idxd_hw_comp_record)); + if (rc) { + SPDK_ERRLOG("Failed to translate batch entry completion memory\n"); + rc = -ENOMEM; + goto err_user_desc_or_op; + } + op++; + desc++; + } } chan->portal = chan->idxd->impl->portal_get_addr(chan->idxd); @@ -794,8 +805,6 @@ _idxd_prep_batch_cmd(struct spdk_idxd_io_channel *chan, spdk_idxd_req_cb cb_fn, { struct idxd_hw_desc *desc; struct idxd_ops *op; - uint64_t op_hw_addr; - int rc; if (_is_batch_valid(batch, chan) == false) { SPDK_ERRLOG("Attempt to add to an invalid batch.\n"); @@ -811,18 +820,12 @@ _idxd_prep_batch_cmd(struct spdk_idxd_io_channel *chan, spdk_idxd_req_cb cb_fn, desc = *_desc = &batch->user_desc[batch->index]; op = *_op = &batch->user_ops[batch->index]; - rc = _vtophys(&op->hw, &op_hw_addr, sizeof(struct idxd_hw_comp_record)); - if (rc) { - return rc; - } - op->desc = desc; SPDK_DEBUGLOG(idxd, "Prep batch %p index %u\n", batch, batch->index); batch->index++; desc->flags = IDXD_FLAG_COMPLETION_ADDR_VALID | IDXD_FLAG_REQUEST_COMPLETION; - desc->completion_addr = op_hw_addr; op->cb_arg = cb_arg; op->cb_fn = cb_fn; op->batch = batch;