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>
This commit is contained in:
parent
bd274b1085
commit
e41bbebdde
|
@ -602,6 +602,7 @@ static int mv_cesa_ahash_dma_req_init(struct ahash_request *req)
|
||||||
struct mv_cesa_tdma_chain chain;
|
struct mv_cesa_tdma_chain chain;
|
||||||
struct mv_cesa_ahash_dma_iter iter;
|
struct mv_cesa_ahash_dma_iter iter;
|
||||||
struct mv_cesa_op_ctx *op = NULL;
|
struct mv_cesa_op_ctx *op = NULL;
|
||||||
|
unsigned int frag_len;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
dreq->chain.first = NULL;
|
dreq->chain.first = NULL;
|
||||||
|
@ -631,25 +632,34 @@ static int mv_cesa_ahash_dma_req_init(struct ahash_request *req)
|
||||||
/*
|
/*
|
||||||
* Add all the new data, inserting an operation block and
|
* Add all the new data, inserting an operation block and
|
||||||
* launch command between each full SRAM block-worth of
|
* launch command between each full SRAM block-worth of
|
||||||
* data.
|
* data. We intentionally do not add the final op block.
|
||||||
*/
|
*/
|
||||||
do {
|
while (true) {
|
||||||
ret = mv_cesa_dma_add_op_transfers(&chain, &iter.base,
|
ret = mv_cesa_dma_add_op_transfers(&chain, &iter.base,
|
||||||
&iter.src, flags);
|
&iter.src, flags);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_free_tdma;
|
goto err_free_tdma;
|
||||||
|
|
||||||
|
frag_len = iter.base.op_len;
|
||||||
|
|
||||||
|
if (!mv_cesa_ahash_req_iter_next_op(&iter))
|
||||||
|
break;
|
||||||
|
|
||||||
op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl,
|
op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl,
|
||||||
iter.base.op_len, flags);
|
frag_len, flags);
|
||||||
if (IS_ERR(op)) {
|
if (IS_ERR(op)) {
|
||||||
ret = PTR_ERR(op);
|
ret = PTR_ERR(op);
|
||||||
goto err_free_tdma;
|
goto err_free_tdma;
|
||||||
}
|
}
|
||||||
} while (mv_cesa_ahash_req_iter_next_op(&iter));
|
}
|
||||||
} else if (iter.base.op_len) {
|
} else {
|
||||||
/* Account for the data that was in the cache. */
|
/* Account for the data that was in the cache. */
|
||||||
op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl,
|
frag_len = iter.base.op_len;
|
||||||
iter.base.op_len, flags);
|
}
|
||||||
|
|
||||||
|
if (frag_len) {
|
||||||
|
op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl, frag_len,
|
||||||
|
flags);
|
||||||
if (IS_ERR(op)) {
|
if (IS_ERR(op)) {
|
||||||
ret = PTR_ERR(op);
|
ret = PTR_ERR(op);
|
||||||
goto err_free_tdma;
|
goto err_free_tdma;
|
||||||
|
|
Loading…
Reference in New Issue