This commit simplifies and streamlines the logic in the core
iaa_compress() and iaa_decompress() routines, eliminates branches, etc.
This makes it easier to add improvements such as polling for job
completions, essential to accomplish batching with hardware
parallelism.
Signed-off-by: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
---
drivers/crypto/intel/iaa/iaa_crypto_main.c | 114 ++++++++++++---------
1 file changed, 67 insertions(+), 47 deletions(-)
diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/intel/iaa/iaa_crypto_main.c
index 5cb7c930158e..38b4be0c10b0 100644
--- a/drivers/crypto/intel/iaa/iaa_crypto_main.c
+++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c
@@ -1792,7 +1792,34 @@ static int iaa_compress(struct crypto_tfm *tfm, struct acomp_req *req,
desc->src2_size = sizeof(struct aecs_comp_table_record);
desc->completion_addr = idxd_desc->compl_dma;
- if (ctx->use_irq) {
+ if (likely(!ctx->use_irq)) {
+ ret = idxd_submit_desc(wq, idxd_desc);
+ if (ret) {
+ dev_dbg(dev, "submit_desc failed ret=%d\n", ret);
+ goto out;
+ }
+
+ /* Update stats */
+ update_total_comp_calls();
+ update_wq_comp_calls(wq);
+
+ if (ctx->async_mode)
+ return -EINPROGRESS;
+
+ ret = check_completion(dev, idxd_desc->iax_completion, true, false);
+ if (ret) {
+ dev_dbg(dev, "check_completion failed ret=%d\n", ret);
+ goto out;
+ }
+
+ *dlen = idxd_desc->iax_completion->output_size;
+
+ /* Update stats */
+ update_total_comp_bytes_out(*dlen);
+ update_wq_comp_bytes(wq, *dlen);
+
+ *compression_crc = idxd_desc->iax_completion->crc;
+ } else {
desc->flags |= IDXD_OP_FLAG_RCI;
idxd_desc->crypto.req = req;
@@ -1800,40 +1827,23 @@ static int iaa_compress(struct crypto_tfm *tfm, struct acomp_req *req,
idxd_desc->crypto.src_addr = src_addr;
idxd_desc->crypto.dst_addr = dst_addr;
idxd_desc->crypto.compress = true;
- }
-
- ret = idxd_submit_desc(wq, idxd_desc);
- if (ret) {
- dev_dbg(dev, "submit_desc failed ret=%d\n", ret);
- goto err;
- }
- /* Update stats */
- update_total_comp_calls();
- update_wq_comp_calls(wq);
+ ret = idxd_submit_desc(wq, idxd_desc);
+ if (ret) {
+ dev_dbg(dev, "submit_desc failed ret=%d\n", ret);
+ goto out;
+ }
- if (ctx->async_mode) {
- ret = -EINPROGRESS;
- goto out;
- }
+ /* Update stats */
+ update_total_comp_calls();
+ update_wq_comp_calls(wq);
- ret = check_completion(dev, idxd_desc->iax_completion, true, false);
- if (ret) {
- dev_dbg(dev, "check_completion failed ret=%d\n", ret);
- goto err;
+ return -EINPROGRESS;
}
- *dlen = idxd_desc->iax_completion->output_size;
-
- /* Update stats */
- update_total_comp_bytes_out(*dlen);
- update_wq_comp_bytes(wq, *dlen);
-
- *compression_crc = idxd_desc->iax_completion->crc;
-
-err:
- idxd_free_desc(wq, idxd_desc);
out:
+ idxd_free_desc(wq, idxd_desc);
+
return ret;
}
@@ -1888,7 +1898,22 @@ static int iaa_decompress(struct crypto_tfm *tfm, struct acomp_req *req,
desc->src1_size = slen;
desc->completion_addr = idxd_desc->compl_dma;
- if (ctx->use_irq) {
+ if (likely(!ctx->use_irq)) {
+ ret = idxd_submit_desc(wq, idxd_desc);
+ if (ret) {
+ dev_dbg(dev, "submit_desc failed ret=%d\n", ret);
+ goto fallback_software_decomp;
+ }
+
+ /* Update stats */
+ update_total_decomp_calls();
+ update_wq_decomp_calls(wq);
+
+ if (ctx->async_mode)
+ return -EINPROGRESS;
+
+ ret = check_completion(dev, idxd_desc->iax_completion, false, false);
+ } else {
desc->flags |= IDXD_OP_FLAG_RCI;
idxd_desc->crypto.req = req;
@@ -1896,25 +1921,20 @@ static int iaa_decompress(struct crypto_tfm *tfm, struct acomp_req *req,
idxd_desc->crypto.src_addr = src_addr;
idxd_desc->crypto.dst_addr = dst_addr;
idxd_desc->crypto.compress = false;
- }
- ret = idxd_submit_desc(wq, idxd_desc);
- if (ret) {
- dev_dbg(dev, "submit_desc failed ret=%d\n", ret);
- goto fallback_software_decomp;
- }
+ ret = idxd_submit_desc(wq, idxd_desc);
+ if (ret) {
+ dev_dbg(dev, "submit_desc failed ret=%d\n", ret);
+ goto fallback_software_decomp;
+ }
- /* Update stats */
- update_total_decomp_calls();
- update_wq_decomp_calls(wq);
+ /* Update stats */
+ update_total_decomp_calls();
+ update_wq_decomp_calls(wq);
- if (ctx->async_mode) {
- ret = -EINPROGRESS;
- goto out;
+ return -EINPROGRESS;
}
- ret = check_completion(dev, idxd_desc->iax_completion, false, false);
-
fallback_software_decomp:
if (ret) {
dev_dbg(dev, "%s: desc allocation/submission/check_completion failed ret=%d\n", __func__, ret);
@@ -1929,7 +1949,7 @@ static int iaa_decompress(struct crypto_tfm *tfm, struct acomp_req *req,
if (ret) {
pr_err("%s: iaa decompress failed: deflate-generic fallback error ret=%d\n",
__func__, ret);
- goto err;
+ goto out;
}
} else {
req->dlen = idxd_desc->iax_completion->output_size;
@@ -1941,10 +1961,10 @@ static int iaa_decompress(struct crypto_tfm *tfm, struct acomp_req *req,
*dlen = req->dlen;
-err:
+out:
if (idxd_desc)
idxd_free_desc(wq, idxd_desc);
-out:
+
return ret;
}
--
2.27.0