diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-10-18 12:24:16 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-10-20 10:11:06 -0400 |
commit | 0971d09a8566abd6640acdbe3fd304e67e257bd3 (patch) | |
tree | 2ef65aeb95e6632552f2d1665e7e30d65c5df464 | |
parent | 2f396a91d1d01a423fd87b7c6ff71600d06b9c05 (diff) |
crypto: marvell/cesa - move mv_cesa_dma_add_frag() calls
Move the calls to mv_cesa_dma_add_frag() into the parent function,
mv_cesa_ahash_dma_req_init(). This is in preparation to changing
when we generate the operation blocks, as we need to avoid generating
a block for a partial hash block at the end of the user data.
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.c | 71 |
1 files changed, 29 insertions, 42 deletions
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c index 3811ec0dd694..d2a947ec1aeb 100644 --- a/drivers/crypto/marvell/hash.c +++ b/drivers/crypto/marvell/hash.c | |||
@@ -499,51 +499,23 @@ mv_cesa_dma_add_frag(struct mv_cesa_tdma_chain *chain, | |||
499 | return op; | 499 | return op; |
500 | } | 500 | } |
501 | 501 | ||
502 | static struct mv_cesa_op_ctx * | 502 | static int |
503 | mv_cesa_ahash_dma_add_cache(struct mv_cesa_tdma_chain *chain, | 503 | mv_cesa_ahash_dma_add_cache(struct mv_cesa_tdma_chain *chain, |
504 | struct mv_cesa_ahash_dma_iter *dma_iter, | 504 | struct mv_cesa_ahash_dma_iter *dma_iter, |
505 | struct mv_cesa_ahash_req *creq, | 505 | struct mv_cesa_ahash_req *creq, |
506 | gfp_t flags) | 506 | gfp_t flags) |
507 | { | 507 | { |
508 | struct mv_cesa_ahash_dma_req *ahashdreq = &creq->req.dma; | 508 | struct mv_cesa_ahash_dma_req *ahashdreq = &creq->req.dma; |
509 | struct mv_cesa_op_ctx *op = NULL; | ||
510 | int ret; | ||
511 | 509 | ||
512 | if (!creq->cache_ptr) | 510 | if (!creq->cache_ptr) |
513 | return NULL; | 511 | return 0; |
514 | |||
515 | ret = mv_cesa_dma_add_data_transfer(chain, | ||
516 | CESA_SA_DATA_SRAM_OFFSET, | ||
517 | ahashdreq->cache_dma, | ||
518 | creq->cache_ptr, | ||
519 | CESA_TDMA_DST_IN_SRAM, | ||
520 | flags); | ||
521 | if (ret) | ||
522 | return ERR_PTR(ret); | ||
523 | |||
524 | if (!dma_iter->base.op_len) | ||
525 | op = mv_cesa_dma_add_frag(chain, &creq->op_tmpl, | ||
526 | creq->cache_ptr, flags); | ||
527 | |||
528 | return op; | ||
529 | } | ||
530 | |||
531 | static struct mv_cesa_op_ctx * | ||
532 | mv_cesa_ahash_dma_add_data(struct mv_cesa_tdma_chain *chain, | ||
533 | struct mv_cesa_ahash_dma_iter *dma_iter, | ||
534 | struct mv_cesa_ahash_req *creq, | ||
535 | gfp_t flags) | ||
536 | { | ||
537 | int ret; | ||
538 | |||
539 | /* Add input transfers */ | ||
540 | ret = mv_cesa_dma_add_op_transfers(chain, &dma_iter->base, | ||
541 | &dma_iter->src, flags); | ||
542 | if (ret) | ||
543 | return ERR_PTR(ret); | ||
544 | 512 | ||
545 | return mv_cesa_dma_add_frag(chain, &creq->op_tmpl, dma_iter->base.op_len, | 513 | return mv_cesa_dma_add_data_transfer(chain, |
546 | flags); | 514 | CESA_SA_DATA_SRAM_OFFSET, |
515 | ahashdreq->cache_dma, | ||
516 | creq->cache_ptr, | ||
517 | CESA_TDMA_DST_IN_SRAM, | ||
518 | flags); | ||
547 | } | 519 | } |
548 | 520 | ||
549 | static struct mv_cesa_op_ctx * | 521 | static struct mv_cesa_op_ctx * |
@@ -647,19 +619,34 @@ static int mv_cesa_ahash_dma_req_init(struct ahash_request *req) | |||
647 | mv_cesa_tdma_desc_iter_init(&chain); | 619 | mv_cesa_tdma_desc_iter_init(&chain); |
648 | mv_cesa_ahash_req_iter_init(&iter, req); | 620 | mv_cesa_ahash_req_iter_init(&iter, req); |
649 | 621 | ||
650 | op = mv_cesa_ahash_dma_add_cache(&chain, &iter, | 622 | /* |
651 | creq, flags); | 623 | * Add the cache (left-over data from a previous block) first. |
652 | if (IS_ERR(op)) { | 624 | * This will never overflow the SRAM size. |
653 | ret = PTR_ERR(op); | 625 | */ |
626 | ret = mv_cesa_ahash_dma_add_cache(&chain, &iter, creq, flags); | ||
627 | if (ret) | ||
654 | goto err_free_tdma; | 628 | goto err_free_tdma; |
629 | |||
630 | if (creq->cache_ptr && !iter.base.op_len) { | ||
631 | op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl, | ||
632 | creq->cache_ptr, flags); | ||
633 | if (IS_ERR(op)) { | ||
634 | ret = PTR_ERR(op); | ||
635 | goto err_free_tdma; | ||
636 | } | ||
655 | } | 637 | } |
656 | 638 | ||
657 | do { | 639 | do { |
658 | if (!iter.base.op_len) | 640 | if (!iter.base.op_len) |
659 | break; | 641 | break; |
660 | 642 | ||
661 | op = mv_cesa_ahash_dma_add_data(&chain, &iter, | 643 | ret = mv_cesa_dma_add_op_transfers(&chain, &iter.base, |
662 | creq, flags); | 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); | ||
663 | if (IS_ERR(op)) { | 650 | if (IS_ERR(op)) { |
664 | ret = PTR_ERR(op); | 651 | ret = PTR_ERR(op); |
665 | goto err_free_tdma; | 652 | goto err_free_tdma; |