Skip to content

Commit c660aa7

Browse files
opanait-wrgregkh
authored andcommitted
crypto: sahara - do not resize req->src when doing hash operations
[ Upstream commit a3c6f4f4d249cecaf2f34471aadbfb4f4ef57298 ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 08489b1 commit c660aa7

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
@@ -886,24 +886,6 @@ static int sahara_sha_hw_context_descriptor_create(struct sahara_dev *dev,
886886
return 0;
887887
}
888888

889-
static int sahara_walk_and_recalc(struct scatterlist *sg, unsigned int nbytes)
890-
{
891-
if (!sg || !sg->length)
892-
return nbytes;
893-
894-
while (nbytes && sg) {
895-
if (nbytes <= sg->length) {
896-
sg->length = nbytes;
897-
sg_mark_end(sg);
898-
break;
899-
}
900-
nbytes -= sg->length;
901-
sg = sg_next(sg);
902-
}
903-
904-
return nbytes;
905-
}
906-
907889
static int sahara_sha_prepare_request(struct ahash_request *req)
908890
{
909891
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
@@ -940,36 +922,20 @@ static int sahara_sha_prepare_request(struct ahash_request *req)
940922
hash_later, 0);
941923
}
942924

943-
/* nbytes should now be multiple of blocksize */
944-
req->nbytes = req->nbytes - hash_later;
945-
946-
sahara_walk_and_recalc(req->src, req->nbytes);
947-
925+
rctx->total = len - hash_later;
948926
/* have data from previous operation and current */
949927
if (rctx->buf_cnt && req->nbytes) {
950928
sg_init_table(rctx->in_sg_chain, 2);
951929
sg_set_buf(rctx->in_sg_chain, rctx->rembuf, rctx->buf_cnt);
952-
953930
sg_chain(rctx->in_sg_chain, 2, req->src);
954-
955-
rctx->total = req->nbytes + rctx->buf_cnt;
956931
rctx->in_sg = rctx->in_sg_chain;
957-
958-
req->src = rctx->in_sg_chain;
959932
/* only data from previous operation */
960933
} else if (rctx->buf_cnt) {
961-
if (req->src)
962-
rctx->in_sg = req->src;
963-
else
964-
rctx->in_sg = rctx->in_sg_chain;
965-
/* buf was copied into rembuf above */
934+
rctx->in_sg = rctx->in_sg_chain;
966935
sg_init_one(rctx->in_sg, rctx->rembuf, rctx->buf_cnt);
967-
rctx->total = rctx->buf_cnt;
968936
/* no data from previous operation */
969937
} else {
970938
rctx->in_sg = req->src;
971-
rctx->total = req->nbytes;
972-
req->src = rctx->in_sg;
973939
}
974940

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

0 commit comments

Comments
 (0)