diff options
| author | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-10-18 12:24:32 -0400 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-10-20 10:11:07 -0400 |
| commit | e41bbebddec44f7c06585f42686b2a529513fc6a (patch) | |
| tree | 9767ea139acedeadd70f7eb857c80f3970b6092c /drivers/crypto/marvell | |
| parent | bd274b10856b91f702fa767114aa7e6ac45b933d (diff) | |
crypto: marvell/cesa - avoid adding final operation within loop
Avoid adding the final operation within the loop, but instead add it
outside. We combine this with the handling for the no-data case.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/marvell')
| -rw-r--r-- | drivers/crypto/marvell/hash.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c index de1d854aedf3..ce457d6e900e 100644 --- a/drivers/crypto/marvell/hash.c +++ b/drivers/crypto/marvell/hash.c | |||
| @@ -602,6 +602,7 @@ static int mv_cesa_ahash_dma_req_init(struct ahash_request *req) | |||
| 602 | struct mv_cesa_tdma_chain chain; | 602 | struct mv_cesa_tdma_chain chain; |
| 603 | struct mv_cesa_ahash_dma_iter iter; | 603 | struct mv_cesa_ahash_dma_iter iter; |
| 604 | struct mv_cesa_op_ctx *op = NULL; | 604 | struct mv_cesa_op_ctx *op = NULL; |
| 605 | unsigned int frag_len; | ||
| 605 | int ret; | 606 | int ret; |
| 606 | 607 | ||
| 607 | dreq->chain.first = NULL; | 608 | dreq->chain.first = NULL; |
| @@ -631,25 +632,34 @@ static int mv_cesa_ahash_dma_req_init(struct ahash_request *req) | |||
| 631 | /* | 632 | /* |
| 632 | * Add all the new data, inserting an operation block and | 633 | * Add all the new data, inserting an operation block and |
| 633 | * launch command between each full SRAM block-worth of | 634 | * launch command between each full SRAM block-worth of |
| 634 | * data. | 635 | * data. We intentionally do not add the final op block. |
| 635 | */ | 636 | */ |
| 636 | do { | 637 | while (true) { |
| 637 | ret = mv_cesa_dma_add_op_transfers(&chain, &iter.base, | 638 | ret = mv_cesa_dma_add_op_transfers(&chain, &iter.base, |
| 638 | &iter.src, flags); | 639 | &iter.src, flags); |
| 639 | if (ret) | 640 | if (ret) |
| 640 | goto err_free_tdma; | 641 | goto err_free_tdma; |
| 641 | 642 | ||
| 643 | frag_len = iter.base.op_len; | ||
| 644 | |||
| 645 | if (!mv_cesa_ahash_req_iter_next_op(&iter)) | ||
| 646 | break; | ||
| 647 | |||
| 642 | op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl, | 648 | op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl, |
| 643 | iter.base.op_len, flags); | 649 | frag_len, flags); |
| 644 | if (IS_ERR(op)) { | 650 | if (IS_ERR(op)) { |
| 645 | ret = PTR_ERR(op); | 651 | ret = PTR_ERR(op); |
| 646 | goto err_free_tdma; | 652 | goto err_free_tdma; |
| 647 | } | 653 | } |
| 648 | } while (mv_cesa_ahash_req_iter_next_op(&iter)); | 654 | } |
| 649 | } else if (iter.base.op_len) { | 655 | } else { |
| 650 | /* Account for the data that was in the cache. */ | 656 | /* Account for the data that was in the cache. */ |
| 651 | op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl, | 657 | frag_len = iter.base.op_len; |
| 652 | iter.base.op_len, flags); | 658 | } |
| 659 | |||
| 660 | if (frag_len) { | ||
| 661 | op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl, frag_len, | ||
| 662 | flags); | ||
| 653 | if (IS_ERR(op)) { | 663 | if (IS_ERR(op)) { |
| 654 | ret = PTR_ERR(op); | 664 | ret = PTR_ERR(op); |
| 655 | goto err_free_tdma; | 665 | goto err_free_tdma; |
