@@ -297,21 +297,20 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
297
297
298
298
struct scatterlist * dst = req -> dst ;
299
299
struct scatterlist * src = req -> src ;
300
- const int nents = sg_nents (req -> src );
300
+ int dst_nents = sg_nents (dst );
301
301
302
302
const int out_off = DCP_BUF_SZ ;
303
303
uint8_t * in_buf = sdcp -> coh -> aes_in_buf ;
304
304
uint8_t * out_buf = sdcp -> coh -> aes_out_buf ;
305
305
306
- uint8_t * out_tmp , * src_buf , * dst_buf = NULL ;
307
306
uint32_t dst_off = 0 ;
307
+ uint8_t * src_buf = NULL ;
308
308
uint32_t last_out_len = 0 ;
309
309
310
310
uint8_t * key = sdcp -> coh -> aes_key ;
311
311
312
312
int ret = 0 ;
313
- int split = 0 ;
314
- unsigned int i , len , clen , rem = 0 , tlen = 0 ;
313
+ unsigned int i , len , clen , tlen = 0 ;
315
314
int init = 0 ;
316
315
bool limit_hit = false;
317
316
@@ -329,7 +328,7 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
329
328
memset (key + AES_KEYSIZE_128 , 0 , AES_KEYSIZE_128 );
330
329
}
331
330
332
- for_each_sg (req -> src , src , nents , i ) {
331
+ for_each_sg (req -> src , src , sg_nents ( src ) , i ) {
333
332
src_buf = sg_virt (src );
334
333
len = sg_dma_len (src );
335
334
tlen += len ;
@@ -354,34 +353,17 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
354
353
* submit the buffer.
355
354
*/
356
355
if (actx -> fill == out_off || sg_is_last (src ) ||
357
- limit_hit ) {
356
+ limit_hit ) {
358
357
ret = mxs_dcp_run_aes (actx , req , init );
359
358
if (ret )
360
359
return ret ;
361
360
init = 0 ;
362
361
363
- out_tmp = out_buf ;
362
+ sg_pcopy_from_buffer (dst , dst_nents , out_buf ,
363
+ actx -> fill , dst_off );
364
+ dst_off += actx -> fill ;
364
365
last_out_len = actx -> fill ;
365
- while (dst && actx -> fill ) {
366
- if (!split ) {
367
- dst_buf = sg_virt (dst );
368
- dst_off = 0 ;
369
- }
370
- rem = min (sg_dma_len (dst ) - dst_off ,
371
- actx -> fill );
372
-
373
- memcpy (dst_buf + dst_off , out_tmp , rem );
374
- out_tmp += rem ;
375
- dst_off += rem ;
376
- actx -> fill -= rem ;
377
-
378
- if (dst_off == sg_dma_len (dst )) {
379
- dst = sg_next (dst );
380
- split = 0 ;
381
- } else {
382
- split = 1 ;
383
- }
384
- }
366
+ actx -> fill = 0 ;
385
367
}
386
368
} while (len );
387
369
0 commit comments