diff options
author | Uri Simchoni <uri@jdland.co.il> | 2010-04-08 12:26:34 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2010-04-13 04:50:47 -0400 |
commit | f565e67ec1b8f4a95d21550f9b879fe86b4132e0 (patch) | |
tree | 6b28a4f9cc75145f985615087b6e33e59cec550c /drivers/crypto | |
parent | 6bc6fcd609080461682c5cc0a1e3bf4345d6419d (diff) |
crypto: mv_cesa - Fix situation where the dest sglist is organized differently than the source sglist
Bugfix for situations where the destination scatterlist has a different
buffer structure than the source scatterlist (e.g. source has one 2K
buffer and dest has 2 1K buffers)
Signed-off-by: Uri Simchoni <uri@jdland.co.il>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/mv_cesa.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c index 37d9f0688e75..018a95ce0c9b 100644 --- a/drivers/crypto/mv_cesa.c +++ b/drivers/crypto/mv_cesa.c | |||
@@ -242,6 +242,8 @@ static void dequeue_complete_req(void) | |||
242 | struct ablkcipher_request *req = cpg->cur_req; | 242 | struct ablkcipher_request *req = cpg->cur_req; |
243 | void *buf; | 243 | void *buf; |
244 | int ret; | 244 | int ret; |
245 | int need_copy_len = cpg->p.crypt_len; | ||
246 | int sram_offset = 0; | ||
245 | 247 | ||
246 | cpg->p.total_req_bytes += cpg->p.crypt_len; | 248 | cpg->p.total_req_bytes += cpg->p.crypt_len; |
247 | do { | 249 | do { |
@@ -257,14 +259,16 @@ static void dequeue_complete_req(void) | |||
257 | buf = cpg->p.dst_sg_it.addr; | 259 | buf = cpg->p.dst_sg_it.addr; |
258 | buf += cpg->p.dst_start; | 260 | buf += cpg->p.dst_start; |
259 | 261 | ||
260 | dst_copy = min(cpg->p.crypt_len, cpg->p.sg_dst_left); | 262 | dst_copy = min(need_copy_len, cpg->p.sg_dst_left); |
261 | |||
262 | memcpy(buf, cpg->sram + SRAM_DATA_OUT_START, dst_copy); | ||
263 | 263 | ||
264 | memcpy(buf, | ||
265 | cpg->sram + SRAM_DATA_OUT_START + sram_offset, | ||
266 | dst_copy); | ||
267 | sram_offset += dst_copy; | ||
264 | cpg->p.sg_dst_left -= dst_copy; | 268 | cpg->p.sg_dst_left -= dst_copy; |
265 | cpg->p.crypt_len -= dst_copy; | 269 | need_copy_len -= dst_copy; |
266 | cpg->p.dst_start += dst_copy; | 270 | cpg->p.dst_start += dst_copy; |
267 | } while (cpg->p.crypt_len > 0); | 271 | } while (need_copy_len > 0); |
268 | 272 | ||
269 | BUG_ON(cpg->eng_st != ENGINE_W_DEQUEUE); | 273 | BUG_ON(cpg->eng_st != ENGINE_W_DEQUEUE); |
270 | if (cpg->p.total_req_bytes < req->nbytes) { | 274 | if (cpg->p.total_req_bytes < req->nbytes) { |