idxd: Rearrange logic in spdk_idxd_process_events
If we don't find a completion, break out of the loop at the top. This removes a level of indentation but most importantly makes it very clear that we only remove elements from ops_outstanding from the front of the list. Signed-off-by: Ben Walker <benjamin.walker@intel.com> Change-Id: I5e8784a5af5449c14ff7015bc8e6062e6aee6b4e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12257 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Dong Yi <dongx.yi@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
parent
da744fc9e0
commit
863200c7d4
@ -1267,51 +1267,7 @@ spdk_idxd_process_events(struct spdk_idxd_io_channel *chan)
|
|||||||
assert(chan != NULL);
|
assert(chan != NULL);
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(op, &chan->ops_outstanding, link, tmp) {
|
TAILQ_FOREACH_SAFE(op, &chan->ops_outstanding, link, tmp) {
|
||||||
if (IDXD_COMPLETION(op->hw.status)) {
|
if (!IDXD_COMPLETION(op->hw.status)) {
|
||||||
|
|
||||||
TAILQ_REMOVE(&chan->ops_outstanding, op, link);
|
|
||||||
rc++;
|
|
||||||
|
|
||||||
if (spdk_unlikely(IDXD_FAILURE(op->hw.status))) {
|
|
||||||
status = -EINVAL;
|
|
||||||
_dump_sw_error_reg(chan);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (op->desc->opcode) {
|
|
||||||
case IDXD_OPCODE_BATCH:
|
|
||||||
SPDK_DEBUGLOG(idxd, "Complete batch %p\n", op->batch);
|
|
||||||
break;
|
|
||||||
case IDXD_OPCODE_CRC32C_GEN:
|
|
||||||
case IDXD_OPCODE_COPY_CRC:
|
|
||||||
if (spdk_likely(status == 0 && op->crc_dst != NULL)) {
|
|
||||||
*op->crc_dst = op->hw.crc32c_val;
|
|
||||||
*op->crc_dst ^= ~0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case IDXD_OPCODE_COMPARE:
|
|
||||||
if (spdk_likely(status == 0)) {
|
|
||||||
status = op->hw.result;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
cb_fn = op->cb_fn;
|
|
||||||
cb_arg = op->cb_arg;
|
|
||||||
op->hw.status = 0;
|
|
||||||
if (op->desc->opcode == IDXD_OPCODE_BATCH) {
|
|
||||||
_free_batch(op->batch, chan);
|
|
||||||
TAILQ_INSERT_HEAD(&chan->ops_pool, op, link);
|
|
||||||
} else if (!op->batch) {
|
|
||||||
TAILQ_INSERT_HEAD(&chan->ops_pool, op, link);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cb_fn) {
|
|
||||||
cb_fn(cb_arg, status);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* reset the status */
|
|
||||||
status = 0;
|
|
||||||
} else {
|
|
||||||
/*
|
/*
|
||||||
* oldest locations are at the head of the list so if
|
* oldest locations are at the head of the list so if
|
||||||
* we've polled a location that hasn't completed, bail
|
* we've polled a location that hasn't completed, bail
|
||||||
@ -1319,6 +1275,49 @@ spdk_idxd_process_events(struct spdk_idxd_io_channel *chan)
|
|||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TAILQ_REMOVE(&chan->ops_outstanding, op, link);
|
||||||
|
rc++;
|
||||||
|
|
||||||
|
if (spdk_unlikely(IDXD_FAILURE(op->hw.status))) {
|
||||||
|
status = -EINVAL;
|
||||||
|
_dump_sw_error_reg(chan);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (op->desc->opcode) {
|
||||||
|
case IDXD_OPCODE_BATCH:
|
||||||
|
SPDK_DEBUGLOG(idxd, "Complete batch %p\n", op->batch);
|
||||||
|
break;
|
||||||
|
case IDXD_OPCODE_CRC32C_GEN:
|
||||||
|
case IDXD_OPCODE_COPY_CRC:
|
||||||
|
if (spdk_likely(status == 0 && op->crc_dst != NULL)) {
|
||||||
|
*op->crc_dst = op->hw.crc32c_val;
|
||||||
|
*op->crc_dst ^= ~0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IDXD_OPCODE_COMPARE:
|
||||||
|
if (spdk_likely(status == 0)) {
|
||||||
|
status = op->hw.result;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cb_fn = op->cb_fn;
|
||||||
|
cb_arg = op->cb_arg;
|
||||||
|
op->hw.status = 0;
|
||||||
|
if (op->desc->opcode == IDXD_OPCODE_BATCH) {
|
||||||
|
_free_batch(op->batch, chan);
|
||||||
|
TAILQ_INSERT_HEAD(&chan->ops_pool, op, link);
|
||||||
|
} else if (!op->batch) {
|
||||||
|
TAILQ_INSERT_HEAD(&chan->ops_pool, op, link);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cb_fn) {
|
||||||
|
cb_fn(cb_arg, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reset the status */
|
||||||
|
status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Submit any built-up batch */
|
/* Submit any built-up batch */
|
||||||
|
Loading…
Reference in New Issue
Block a user