mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 10:45:49 +00:00
crypto: sahara - do not resize req->src when doing hash operations
[ Upstream commita3c6f4f4d2
] 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:5a2bb93f59
("crypto: sahara - add support for SHA1/256") Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
eae15c43be
commit
490adf8be7
@ -887,24 +887,6 @@ static int sahara_sha_hw_context_descriptor_create(struct sahara_dev *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sahara_walk_and_recalc(struct scatterlist *sg, unsigned int nbytes)
|
||||
{
|
||||
if (!sg || !sg->length)
|
||||
return nbytes;
|
||||
|
||||
while (nbytes && sg) {
|
||||
if (nbytes <= sg->length) {
|
||||
sg->length = nbytes;
|
||||
sg_mark_end(sg);
|
||||
break;
|
||||
}
|
||||
nbytes -= sg->length;
|
||||
sg = sg_next(sg);
|
||||
}
|
||||
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
static int sahara_sha_prepare_request(struct ahash_request *req)
|
||||
{
|
||||
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
|
||||
@ -941,36 +923,20 @@ static int sahara_sha_prepare_request(struct ahash_request *req)
|
||||
hash_later, 0);
|
||||
}
|
||||
|
||||
/* nbytes should now be multiple of blocksize */
|
||||
req->nbytes = req->nbytes - hash_later;
|
||||
|
||||
sahara_walk_and_recalc(req->src, req->nbytes);
|
||||
|
||||
rctx->total = len - hash_later;
|
||||
/* have data from previous operation and current */
|
||||
if (rctx->buf_cnt && req->nbytes) {
|
||||
sg_init_table(rctx->in_sg_chain, 2);
|
||||
sg_set_buf(rctx->in_sg_chain, rctx->rembuf, rctx->buf_cnt);
|
||||
|
||||
sg_chain(rctx->in_sg_chain, 2, req->src);
|
||||
|
||||
rctx->total = req->nbytes + rctx->buf_cnt;
|
||||
rctx->in_sg = rctx->in_sg_chain;
|
||||
|
||||
req->src = rctx->in_sg_chain;
|
||||
/* only data from previous operation */
|
||||
} else if (rctx->buf_cnt) {
|
||||
if (req->src)
|
||||
rctx->in_sg = req->src;
|
||||
else
|
||||
rctx->in_sg = rctx->in_sg_chain;
|
||||
/* buf was copied into rembuf above */
|
||||
rctx->in_sg = rctx->in_sg_chain;
|
||||
sg_init_one(rctx->in_sg, rctx->rembuf, rctx->buf_cnt);
|
||||
rctx->total = rctx->buf_cnt;
|
||||
/* no data from previous operation */
|
||||
} else {
|
||||
rctx->in_sg = req->src;
|
||||
rctx->total = req->nbytes;
|
||||
req->src = rctx->in_sg;
|
||||
}
|
||||
|
||||
/* on next call, we only have the remaining data in the buffer */
|
||||
|
Loading…
Reference in New Issue
Block a user