aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2015-10-18 12:24:47 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-10-20 10:11:08 -0400
commitab270e7055e0aa9d4dc3bf419cdfdde340174978 (patch)
tree29103e1ead15edaf40f78d1790c5c6f62454d8bf
parentaee84a7e6ed515f0f217317ff261a15db4bff0bb (diff)
crypto: marvell/cesa - rearrange handling for sw padded hashes
Rearrange the last request handling for hashes which require software padding. We prepare the padding to be appended, and then append as much of the padding to any existing data that's already queued up, adding an operation block and launching the operation. Any remainder is then appended as a separate operation. This ensures that the hardware only ever sees multiples of the hash block size to be operated on for software padded hashes, thus ensuring that the engine always indicates that it has finished the calculation. 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.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c
index d282716e0ca7..f4d5a7223560 100644
--- a/drivers/crypto/marvell/hash.c
+++ b/drivers/crypto/marvell/hash.c
@@ -559,38 +559,30 @@ mv_cesa_ahash_dma_last_req(struct mv_cesa_tdma_chain *chain,
559 559
560 trailerlen = mv_cesa_ahash_pad_req(creq, ahashdreq->padding); 560 trailerlen = mv_cesa_ahash_pad_req(creq, ahashdreq->padding);
561 561
562 if (frag_len) { 562 len = min(CESA_SA_SRAM_PAYLOAD_SIZE - frag_len, trailerlen);
563 op = mv_cesa_dma_add_frag(chain, &creq->op_tmpl, frag_len, 563 if (len) {
564 flags); 564 ret = mv_cesa_dma_add_data_transfer(chain,
565 if (IS_ERR(op))
566 return op;
567 } else {
568 op = NULL;
569 }
570
571 if (op) {
572 len = min(CESA_SA_SRAM_PAYLOAD_SIZE - dma_iter->base.op_len,
573 trailerlen);
574 if (len) {
575 ret = mv_cesa_dma_add_data_transfer(chain,
576 CESA_SA_DATA_SRAM_OFFSET + 565 CESA_SA_DATA_SRAM_OFFSET +
577 dma_iter->base.op_len, 566 frag_len,
578 ahashdreq->padding_dma, 567 ahashdreq->padding_dma,
579 len, CESA_TDMA_DST_IN_SRAM, 568 len, CESA_TDMA_DST_IN_SRAM,
580 flags); 569 flags);
581 if (ret) 570 if (ret)
582 return ERR_PTR(ret); 571 return ERR_PTR(ret);
583 572
584 mv_cesa_update_op_cfg(op, CESA_SA_DESC_CFG_MID_FRAG, 573 op = mv_cesa_dma_add_frag(chain, &creq->op_tmpl, frag_len + len,
585 CESA_SA_DESC_CFG_FRAG_MSK); 574 flags);
586 mv_cesa_set_mac_op_frag_len(op, 575 if (IS_ERR(op))
587 dma_iter->base.op_len + len); 576 return op;
588 padoff += len;
589 }
590 }
591 577
592 if (padoff >= trailerlen) 578 mv_cesa_update_op_cfg(op, CESA_SA_DESC_CFG_MID_FRAG,
593 return op; 579 CESA_SA_DESC_CFG_FRAG_MSK);
580
581 if (len == trailerlen)
582 return op;
583
584 padoff += len;
585 }
594 586
595 if (!mv_cesa_mac_op_is_first_frag(&creq->op_tmpl)) 587 if (!mv_cesa_mac_op_is_first_frag(&creq->op_tmpl))
596 mv_cesa_update_op_cfg(&creq->op_tmpl, 588 mv_cesa_update_op_cfg(&creq->op_tmpl,