Skip to content

Commit a3c6f4f

Browse files
opanait-wrherbertx
authored andcommitted
crypto: sahara - do not resize req->src when doing hash operations
When testing sahara sha256 speed performance with tcrypt (mode=404) on imx53-qsrb board, multiple "Invalid numbers of src SG." errors are reported. This was traced to sahara_walk_and_recalc() resizing req->src and causing the subsequent dma_map_sg() call to fail. Now that the previous commit fixed sahara_sha_hw_links_create() to take into account the actual request size, rather than relying on sg->length values, the resize operation is no longer necessary. Therefore, remove sahara_walk_and_recalc() and simplify associated logic. Fixes: 5a2bb93 ("crypto: sahara - add support for SHA1/256") Signed-off-by: Ovidiu Panait <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 7bafa74 commit a3c6f4f

File tree

1 file changed

+2
-36
lines changed

1 file changed

+2
-36
lines changed

drivers/crypto/sahara.c

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -884,24 +884,6 @@ static int sahara_sha_hw_context_descriptor_create(struct sahara_dev *dev,
884884
return 0;
885885
}
886886

887-
static int sahara_walk_and_recalc(struct scatterlist *sg, unsigned int nbytes)
888-
{
889-
if (!sg || !sg->length)
890-
return nbytes;
891-
892-
while (nbytes && sg) {
893-
if (nbytes <= sg->length) {
894-
sg->length = nbytes;
895-
sg_mark_end(sg);
896-
break;
897-
}
898-
nbytes -= sg->length;
899-
sg = sg_next(sg);
900-
}
901-
902-
return nbytes;
903-
}
904-
905887
static int sahara_sha_prepare_request(struct ahash_request *req)
906888
{
907889
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
@@ -938,36 +920,20 @@ static int sahara_sha_prepare_request(struct ahash_request *req)
938920
hash_later, 0);
939921
}
940922

941-
/* nbytes should now be multiple of blocksize */
942-
req->nbytes = req->nbytes - hash_later;
943-
944-
sahara_walk_and_recalc(req->src, req->nbytes);
945-
923+
rctx->total = len - hash_later;
946924
/* have data from previous operation and current */
947925
if (rctx->buf_cnt && req->nbytes) {
948926
sg_init_table(rctx->in_sg_chain, 2);
949927
sg_set_buf(rctx->in_sg_chain, rctx->rembuf, rctx->buf_cnt);
950-
951928
sg_chain(rctx->in_sg_chain, 2, req->src);
952-
953-
rctx->total = req->nbytes + rctx->buf_cnt;
954929
rctx->in_sg = rctx->in_sg_chain;
955-
956-
req->src = rctx->in_sg_chain;
957930
/* only data from previous operation */
958931
} else if (rctx->buf_cnt) {
959-
if (req->src)
960-
rctx->in_sg = req->src;
961-
else
962-
rctx->in_sg = rctx->in_sg_chain;
963-
/* buf was copied into rembuf above */
932+
rctx->in_sg = rctx->in_sg_chain;
964933
sg_init_one(rctx->in_sg, rctx->rembuf, rctx->buf_cnt);
965-
rctx->total = rctx->buf_cnt;
966934
/* no data from previous operation */
967935
} else {
968936
rctx->in_sg = req->src;
969-
rctx->total = req->nbytes;
970-
req->src = rctx->in_sg;
971937
}
972938

973939
/* on next call, we only have the remaining data in the buffer */

0 commit comments

Comments
 (0)