aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorJoel Fernandes <joelf@ti.com>2013-08-17 22:42:30 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2013-08-21 07:28:03 -0400
commit98837abc86ebd26c1518c91cc5e2a9344837e6a8 (patch)
treef051c4e4ec11b168b3e28b961f1cd80c2ece731c /drivers/crypto
parent1bf95cca8f407cc0d6f21708fdbb17d1dd531bec (diff)
crypto: omap-aes - PIO mode: platform data for OMAP4/AM437x and trigger
We initialize the scatter gather walk lists needed for PIO mode and avoid all DMA paths such as mapping/unmapping buffers by checking for the pio_only flag. Signed-off-by: Joel Fernandes <joelf@ti.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/omap-aes.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
index 9909f93255b4..685535e4c78d 100644
--- a/drivers/crypto/omap-aes.c
+++ b/drivers/crypto/omap-aes.c
@@ -169,6 +169,7 @@ struct omap_aes_dev {
169 struct dma_chan *dma_lch_out; 169 struct dma_chan *dma_lch_out;
170 int in_sg_len; 170 int in_sg_len;
171 int out_sg_len; 171 int out_sg_len;
172 int pio_only;
172 const struct omap_aes_pdata *pdata; 173 const struct omap_aes_pdata *pdata;
173}; 174};
174 175
@@ -408,6 +409,16 @@ static int omap_aes_crypt_dma(struct crypto_tfm *tfm,
408 struct dma_slave_config cfg; 409 struct dma_slave_config cfg;
409 int ret; 410 int ret;
410 411
412 if (dd->pio_only) {
413 scatterwalk_start(&dd->in_walk, dd->in_sg);
414 scatterwalk_start(&dd->out_walk, dd->out_sg);
415
416 /* Enable DATAIN interrupt and let it take
417 care of the rest */
418 omap_aes_write(dd, AES_REG_IRQ_ENABLE(dd), 0x2);
419 return 0;
420 }
421
411 dma_sync_sg_for_device(dd->dev, dd->in_sg, in_sg_len, DMA_TO_DEVICE); 422 dma_sync_sg_for_device(dd->dev, dd->in_sg, in_sg_len, DMA_TO_DEVICE);
412 423
413 memset(&cfg, 0, sizeof(cfg)); 424 memset(&cfg, 0, sizeof(cfg));
@@ -477,21 +488,25 @@ static int omap_aes_crypt_dma_start(struct omap_aes_dev *dd)
477 488
478 pr_debug("total: %d\n", dd->total); 489 pr_debug("total: %d\n", dd->total);
479 490
480 err = dma_map_sg(dd->dev, dd->in_sg, dd->in_sg_len, DMA_TO_DEVICE); 491 if (!dd->pio_only) {
481 if (!err) { 492 err = dma_map_sg(dd->dev, dd->in_sg, dd->in_sg_len,
482 dev_err(dd->dev, "dma_map_sg() error\n"); 493 DMA_TO_DEVICE);
483 return -EINVAL; 494 if (!err) {
484 } 495 dev_err(dd->dev, "dma_map_sg() error\n");
496 return -EINVAL;
497 }
485 498
486 err = dma_map_sg(dd->dev, dd->out_sg, dd->out_sg_len, DMA_FROM_DEVICE); 499 err = dma_map_sg(dd->dev, dd->out_sg, dd->out_sg_len,
487 if (!err) { 500 DMA_FROM_DEVICE);
488 dev_err(dd->dev, "dma_map_sg() error\n"); 501 if (!err) {
489 return -EINVAL; 502 dev_err(dd->dev, "dma_map_sg() error\n");
503 return -EINVAL;
504 }
490 } 505 }
491 506
492 err = omap_aes_crypt_dma(tfm, dd->in_sg, dd->out_sg, dd->in_sg_len, 507 err = omap_aes_crypt_dma(tfm, dd->in_sg, dd->out_sg, dd->in_sg_len,
493 dd->out_sg_len); 508 dd->out_sg_len);
494 if (err) { 509 if (err && !dd->pio_only) {
495 dma_unmap_sg(dd->dev, dd->in_sg, dd->in_sg_len, DMA_TO_DEVICE); 510 dma_unmap_sg(dd->dev, dd->in_sg, dd->in_sg_len, DMA_TO_DEVICE);
496 dma_unmap_sg(dd->dev, dd->out_sg, dd->out_sg_len, 511 dma_unmap_sg(dd->dev, dd->out_sg, dd->out_sg_len,
497 DMA_FROM_DEVICE); 512 DMA_FROM_DEVICE);
@@ -594,9 +609,11 @@ static void omap_aes_done_task(unsigned long data)
594 609
595 pr_debug("enter done_task\n"); 610 pr_debug("enter done_task\n");
596 611
597 dma_sync_sg_for_cpu(dd->dev, dd->in_sg, dd->in_sg_len, DMA_FROM_DEVICE); 612 if (!dd->pio_only) {
598 613 dma_sync_sg_for_device(dd->dev, dd->out_sg, dd->out_sg_len,
599 omap_aes_crypt_dma_stop(dd); 614 DMA_FROM_DEVICE);
615 omap_aes_crypt_dma_stop(dd);
616 }
600 omap_aes_finish_req(dd, 0); 617 omap_aes_finish_req(dd, 0);
601 omap_aes_handle_queue(dd, NULL); 618 omap_aes_handle_queue(dd, NULL);
602 619