diff --git a/lib/idxd/idxd.c b/lib/idxd/idxd.c index 9b15c478ee..cc18ad1562 100644 --- a/lib/idxd/idxd.c +++ b/lib/idxd/idxd.c @@ -417,28 +417,6 @@ _idxd_prep_batch_cmd(struct spdk_idxd_io_channel *chan, spdk_idxd_req_cb cb_fn, return 0; } -static int -_idxd_batch_prep_nop(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch) -{ - struct idxd_hw_desc *desc; - struct idxd_ops *op; - int rc; - - /* Common prep. */ - rc = _idxd_prep_batch_cmd(chan, NULL, NULL, batch, &desc, &op); - if (rc) { - return rc; - } - - /* Command specific. */ - desc->opcode = IDXD_OPCODE_NOOP; - - if (chan->idxd->impl->nop_check && chan->idxd->impl->nop_check(chan->idxd)) { - desc->xfer_size = 1; - } - return 0; -} - static struct idxd_batch * idxd_batch_create(struct spdk_idxd_io_channel *chan) { @@ -509,30 +487,32 @@ idxd_batch_submit(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch, return idxd_batch_cancel(chan, batch); } - if (batch->index < MIN_USER_DESC_COUNT) { - /* DSA needs at least MIN_USER_DESC_COUNT for a batch, add a NOP to make it so. */ - if (_idxd_batch_prep_nop(chan, batch)) { - return -EINVAL; - } - } - /* Common prep. */ rc = _idxd_prep_command(chan, cb_fn, cb_arg, &desc, &op); if (rc) { return rc; } - /* Command specific. */ - desc->opcode = IDXD_OPCODE_BATCH; - desc->desc_list_addr = batch->user_desc_addr; - desc->desc_count = batch->index; - op->batch = batch; - assert(batch->index <= DESC_PER_BATCH); + if (batch->index == 1) { + uint64_t completion_addr; - /* Add the batch elements completion contexts to the outstanding list to be polled. */ - for (i = 0 ; i < batch->index; i++) { - TAILQ_INSERT_TAIL(&chan->ops_outstanding, (struct idxd_ops *)&batch->user_ops[i], - link); + /* If there's only one command, convert it away from a batch. */ + completion_addr = desc->completion_addr; + memcpy(desc, &batch->user_desc[0], sizeof(*desc)); + desc->completion_addr = completion_addr; + } else { + /* Command specific. */ + desc->opcode = IDXD_OPCODE_BATCH; + desc->desc_list_addr = batch->user_desc_addr; + desc->desc_count = batch->index; + op->batch = batch; + assert(batch->index <= DESC_PER_BATCH); + + /* Add the batch elements completion contexts to the outstanding list to be polled. */ + for (i = 0 ; i < batch->index; i++) { + TAILQ_INSERT_TAIL(&chan->ops_outstanding, (struct idxd_ops *)&batch->user_ops[i], + link); + } } /* Submit operation. */ diff --git a/lib/idxd/idxd.h b/lib/idxd/idxd.h index 17c27f5d03..eae3f1efcb 100644 --- a/lib/idxd/idxd.h +++ b/lib/idxd/idxd.h @@ -64,7 +64,6 @@ static inline void movdir64b(void *dst, const void *src) /* The following sets up a max desc count per batch of 32 */ #define LOG2_WQ_MAX_BATCH 5 /* 2^5 = 32 */ #define DESC_PER_BATCH (1 << LOG2_WQ_MAX_BATCH) -#define MIN_USER_DESC_COUNT 2 #define LOG2_WQ_MAX_XFER 30 /* 2^30 = 1073741824 */ #define WQCFG_NUM_DWORDS 8