aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2015-10-18 12:24:21 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-10-20 10:11:06 -0400
commitd9bba4c3ebbc65b9113624eb1690bed776fb6106 (patch)
tree3da1f44504ef1fabae330f30e377da40a921af42
parent0971d09a8566abd6640acdbe3fd304e67e257bd3 (diff)
crypto: marvell/cesa - use presence of scatterlist to determine data load
Use the presence of the scatterlist to determine whether we should load any new user data to the engine. The following shall always be true at this point: iter.base.op_len == 0 === iter.src.sg In doing so, we can: 1. eliminate the test for iter.base.op_len inside the loop, which makes the loop operation more obvious and understandable. 2. move the operation generation for the cache-only case. This prepares the code for the next step in its transformation, and also uncovers a bug that will be fixed in the next patch. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/marvell/hash.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c
index d2a947ec1aeb..3497d7015ca7 100644
--- a/drivers/crypto/marvell/hash.c
+++ b/drivers/crypto/marvell/hash.c
@@ -627,7 +627,27 @@ static int mv_cesa_ahash_dma_req_init(struct ahash_request *req)
627 if (ret) 627 if (ret)
628 goto err_free_tdma; 628 goto err_free_tdma;
629 629
630 if (creq->cache_ptr && !iter.base.op_len) { 630 if (iter.src.sg) {
631 /*
632 * Add all the new data, inserting an operation block and
633 * launch command between each full SRAM block-worth of
634 * data.
635 */
636 do {
637 ret = mv_cesa_dma_add_op_transfers(&chain, &iter.base,
638 &iter.src, flags);
639 if (ret)
640 goto err_free_tdma;
641
642 op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl,
643 iter.base.op_len, flags);
644 if (IS_ERR(op)) {
645 ret = PTR_ERR(op);
646 goto err_free_tdma;
647 }
648 } while (mv_cesa_ahash_req_iter_next_op(&iter));
649 } else if (creq->cache_ptr) {
650 /* Account for the data that was in the cache. */
631 op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl, 651 op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl,
632 creq->cache_ptr, flags); 652 creq->cache_ptr, flags);
633 if (IS_ERR(op)) { 653 if (IS_ERR(op)) {
@@ -636,23 +656,6 @@ static int mv_cesa_ahash_dma_req_init(struct ahash_request *req)
636 } 656 }
637 } 657 }
638 658
639 do {
640 if (!iter.base.op_len)
641 break;
642
643 ret = mv_cesa_dma_add_op_transfers(&chain, &iter.base,
644 &iter.src, flags);
645 if (ret)
646 goto err_free_tdma;
647
648 op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl,
649 iter.base.op_len, flags);
650 if (IS_ERR(op)) {
651 ret = PTR_ERR(op);
652 goto err_free_tdma;
653 }
654 } while (mv_cesa_ahash_req_iter_next_op(&iter));
655
656 op = mv_cesa_ahash_dma_last_req(&chain, &iter, creq, op, flags); 659 op = mv_cesa_ahash_dma_last_req(&chain, &iter, creq, op, flags);
657 if (IS_ERR(op)) { 660 if (IS_ERR(op)) {
658 ret = PTR_ERR(op); 661 ret = PTR_ERR(op);