Commit 640eec52 authored by LABBE Corentin's avatar LABBE Corentin Committed by Herbert Xu

crypto: sahara - dma_map_sg can handle chained SG

The sahara driver use two dma_map_sg path according to SG are chained
or not.
Since dma_map_sg can handle both case, clean the code with all
references to sg chained.

Thus removing the sahara_sha_unmap_sg function.
Signed-off-by: default avatarLABBE Corentin <clabbe.montjoie@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 13fb8fd7
...@@ -173,7 +173,6 @@ struct sahara_aes_reqctx { ...@@ -173,7 +173,6 @@ struct sahara_aes_reqctx {
* @sg_in_idx: number of hw links * @sg_in_idx: number of hw links
* @in_sg: scatterlist for input data * @in_sg: scatterlist for input data
* @in_sg_chain: scatterlists for chained input data * @in_sg_chain: scatterlists for chained input data
* @in_sg_chained: specifies if chained scatterlists are used or not
* @total: total number of bytes for transfer * @total: total number of bytes for transfer
* @last: is this the last block * @last: is this the last block
* @first: is this the first block * @first: is this the first block
...@@ -191,7 +190,6 @@ struct sahara_sha_reqctx { ...@@ -191,7 +190,6 @@ struct sahara_sha_reqctx {
unsigned int sg_in_idx; unsigned int sg_in_idx;
struct scatterlist *in_sg; struct scatterlist *in_sg;
struct scatterlist in_sg_chain[2]; struct scatterlist in_sg_chain[2];
bool in_sg_chained;
size_t total; size_t total;
unsigned int last; unsigned int last;
unsigned int first; unsigned int first;
...@@ -801,26 +799,8 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev, ...@@ -801,26 +799,8 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev,
return -EINVAL; return -EINVAL;
} }
if (rctx->in_sg_chained) {
i = start;
sg = dev->in_sg; sg = dev->in_sg;
while (sg) { ret = dma_map_sg(dev->device, dev->in_sg, dev->nb_in_sg, DMA_TO_DEVICE);
ret = dma_map_sg(dev->device, sg, 1,
DMA_TO_DEVICE);
if (!ret)
return -EFAULT;
dev->hw_link[i]->len = sg->length;
dev->hw_link[i]->p = sg->dma_address;
dev->hw_link[i]->next = dev->hw_phys_link[i + 1];
sg = sg_next(sg);
i += 1;
}
dev->hw_link[i-1]->next = 0;
} else {
sg = dev->in_sg;
ret = dma_map_sg(dev->device, dev->in_sg, dev->nb_in_sg,
DMA_TO_DEVICE);
if (!ret) if (!ret)
return -EFAULT; return -EFAULT;
...@@ -834,7 +814,6 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev, ...@@ -834,7 +814,6 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev,
sg = sg_next(sg); sg = sg_next(sg);
} }
} }
}
return i; return i;
} }
...@@ -980,7 +959,6 @@ static int sahara_sha_prepare_request(struct ahash_request *req) ...@@ -980,7 +959,6 @@ static int sahara_sha_prepare_request(struct ahash_request *req)
rctx->total = req->nbytes + rctx->buf_cnt; rctx->total = req->nbytes + rctx->buf_cnt;
rctx->in_sg = rctx->in_sg_chain; rctx->in_sg = rctx->in_sg_chain;
rctx->in_sg_chained = true;
req->src = rctx->in_sg_chain; req->src = rctx->in_sg_chain;
/* only data from previous operation */ /* only data from previous operation */
} else if (rctx->buf_cnt) { } else if (rctx->buf_cnt) {
...@@ -991,13 +969,11 @@ static int sahara_sha_prepare_request(struct ahash_request *req) ...@@ -991,13 +969,11 @@ static int sahara_sha_prepare_request(struct ahash_request *req)
/* buf was copied into rembuf above */ /* buf was copied into rembuf above */
sg_init_one(rctx->in_sg, rctx->rembuf, rctx->buf_cnt); sg_init_one(rctx->in_sg, rctx->rembuf, rctx->buf_cnt);
rctx->total = rctx->buf_cnt; rctx->total = rctx->buf_cnt;
rctx->in_sg_chained = false;
/* no data from previous operation */ /* no data from previous operation */
} else { } else {
rctx->in_sg = req->src; rctx->in_sg = req->src;
rctx->total = req->nbytes; rctx->total = req->nbytes;
req->src = rctx->in_sg; req->src = rctx->in_sg;
rctx->in_sg_chained = false;
} }
/* on next call, we only have the remaining data in the buffer */ /* on next call, we only have the remaining data in the buffer */
...@@ -1006,23 +982,6 @@ static int sahara_sha_prepare_request(struct ahash_request *req) ...@@ -1006,23 +982,6 @@ static int sahara_sha_prepare_request(struct ahash_request *req)
return -EINPROGRESS; return -EINPROGRESS;
} }
static void sahara_sha_unmap_sg(struct sahara_dev *dev,
struct sahara_sha_reqctx *rctx)
{
struct scatterlist *sg;
if (rctx->in_sg_chained) {
sg = dev->in_sg;
while (sg) {
dma_unmap_sg(dev->device, sg, 1, DMA_TO_DEVICE);
sg = sg_next(sg);
}
} else {
dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
DMA_TO_DEVICE);
}
}
static int sahara_sha_process(struct ahash_request *req) static int sahara_sha_process(struct ahash_request *req)
{ {
struct sahara_dev *dev = dev_ptr; struct sahara_dev *dev = dev_ptr;
...@@ -1062,7 +1021,8 @@ static int sahara_sha_process(struct ahash_request *req) ...@@ -1062,7 +1021,8 @@ static int sahara_sha_process(struct ahash_request *req)
} }
if (rctx->sg_in_idx) if (rctx->sg_in_idx)
sahara_sha_unmap_sg(dev, rctx); dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
DMA_TO_DEVICE);
memcpy(rctx->context, dev->context_base, rctx->context_size); memcpy(rctx->context, dev->context_base, rctx->context_size);
......
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