Commit 2b352489 authored by Tero Kristo's avatar Tero Kristo Committed by Herbert Xu

crypto: omap-sham - fix buffer handling for split test cases

Current buffer handling logic fails in a case where the buffer contains
existing data from previous update which is divisible by block size.
This results in a block size of data to be left missing from the sg
list going out to the hw accelerator, ending up in stalling the
crypto accelerator driver (the last request never completes fully due
to missing data.)

Fix this by passing the total size of the data instead of the data size
of current request, and also parsing the buffer contents within the
prepare request handling.
Signed-off-by: default avatarTero Kristo <t-kristo@ti.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 891dcbbb
...@@ -740,11 +740,12 @@ static int omap_sham_align_sgs(struct scatterlist *sg, ...@@ -740,11 +740,12 @@ static int omap_sham_align_sgs(struct scatterlist *sg,
struct scatterlist *sg_tmp = sg; struct scatterlist *sg_tmp = sg;
int new_len; int new_len;
int offset = rctx->offset; int offset = rctx->offset;
int bufcnt = rctx->bufcnt;
if (!sg || !sg->length || !nbytes) if (!sg || !sg->length || !nbytes)
return 0; return 0;
new_len = nbytes - offset; new_len = nbytes;
if (offset) if (offset)
list_ok = false; list_ok = false;
...@@ -763,6 +764,16 @@ static int omap_sham_align_sgs(struct scatterlist *sg, ...@@ -763,6 +764,16 @@ static int omap_sham_align_sgs(struct scatterlist *sg,
while (nbytes > 0 && sg_tmp) { while (nbytes > 0 && sg_tmp) {
n++; n++;
if (bufcnt) {
if (!IS_ALIGNED(bufcnt, bs)) {
aligned = false;
break;
}
nbytes -= bufcnt;
bufcnt = 0;
continue;
}
#ifdef CONFIG_ZONE_DMA #ifdef CONFIG_ZONE_DMA
if (page_zonenum(sg_page(sg_tmp)) != ZONE_DMA) { if (page_zonenum(sg_page(sg_tmp)) != ZONE_DMA) {
aligned = false; aligned = false;
...@@ -859,7 +870,7 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update) ...@@ -859,7 +870,7 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update)
if (rctx->bufcnt) if (rctx->bufcnt)
memcpy(rctx->dd->xmit_buf, rctx->buffer, rctx->bufcnt); memcpy(rctx->dd->xmit_buf, rctx->buffer, rctx->bufcnt);
ret = omap_sham_align_sgs(req->src, nbytes, bs, final, rctx); ret = omap_sham_align_sgs(req->src, rctx->total, bs, final, rctx);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment