Commit 98837abc authored by Joel Fernandes's avatar Joel Fernandes Committed by Herbert Xu

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: default avatarJoel Fernandes <joelf@ti.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 1bf95cca
...@@ -169,6 +169,7 @@ struct omap_aes_dev { ...@@ -169,6 +169,7 @@ struct omap_aes_dev {
struct dma_chan *dma_lch_out; struct dma_chan *dma_lch_out;
int in_sg_len; int in_sg_len;
int out_sg_len; int out_sg_len;
int pio_only;
const struct omap_aes_pdata *pdata; const struct omap_aes_pdata *pdata;
}; };
...@@ -408,6 +409,16 @@ static int omap_aes_crypt_dma(struct crypto_tfm *tfm, ...@@ -408,6 +409,16 @@ static int omap_aes_crypt_dma(struct crypto_tfm *tfm,
struct dma_slave_config cfg; struct dma_slave_config cfg;
int ret; int ret;
if (dd->pio_only) {
scatterwalk_start(&dd->in_walk, dd->in_sg);
scatterwalk_start(&dd->out_walk, dd->out_sg);
/* Enable DATAIN interrupt and let it take
care of the rest */
omap_aes_write(dd, AES_REG_IRQ_ENABLE(dd), 0x2);
return 0;
}
dma_sync_sg_for_device(dd->dev, dd->in_sg, in_sg_len, DMA_TO_DEVICE); dma_sync_sg_for_device(dd->dev, dd->in_sg, in_sg_len, DMA_TO_DEVICE);
memset(&cfg, 0, sizeof(cfg)); memset(&cfg, 0, sizeof(cfg));
...@@ -477,21 +488,25 @@ static int omap_aes_crypt_dma_start(struct omap_aes_dev *dd) ...@@ -477,21 +488,25 @@ static int omap_aes_crypt_dma_start(struct omap_aes_dev *dd)
pr_debug("total: %d\n", dd->total); pr_debug("total: %d\n", dd->total);
err = dma_map_sg(dd->dev, dd->in_sg, dd->in_sg_len, DMA_TO_DEVICE); if (!dd->pio_only) {
if (!err) { err = dma_map_sg(dd->dev, dd->in_sg, dd->in_sg_len,
dev_err(dd->dev, "dma_map_sg() error\n"); DMA_TO_DEVICE);
return -EINVAL; if (!err) {
} dev_err(dd->dev, "dma_map_sg() error\n");
return -EINVAL;
}
err = dma_map_sg(dd->dev, dd->out_sg, dd->out_sg_len, DMA_FROM_DEVICE); err = dma_map_sg(dd->dev, dd->out_sg, dd->out_sg_len,
if (!err) { DMA_FROM_DEVICE);
dev_err(dd->dev, "dma_map_sg() error\n"); if (!err) {
return -EINVAL; dev_err(dd->dev, "dma_map_sg() error\n");
return -EINVAL;
}
} }
err = omap_aes_crypt_dma(tfm, dd->in_sg, dd->out_sg, dd->in_sg_len, err = omap_aes_crypt_dma(tfm, dd->in_sg, dd->out_sg, dd->in_sg_len,
dd->out_sg_len); dd->out_sg_len);
if (err) { if (err && !dd->pio_only) {
dma_unmap_sg(dd->dev, dd->in_sg, dd->in_sg_len, DMA_TO_DEVICE); dma_unmap_sg(dd->dev, dd->in_sg, dd->in_sg_len, DMA_TO_DEVICE);
dma_unmap_sg(dd->dev, dd->out_sg, dd->out_sg_len, dma_unmap_sg(dd->dev, dd->out_sg, dd->out_sg_len,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
...@@ -594,9 +609,11 @@ static void omap_aes_done_task(unsigned long data) ...@@ -594,9 +609,11 @@ static void omap_aes_done_task(unsigned long data)
pr_debug("enter done_task\n"); pr_debug("enter done_task\n");
dma_sync_sg_for_cpu(dd->dev, dd->in_sg, dd->in_sg_len, DMA_FROM_DEVICE); if (!dd->pio_only) {
dma_sync_sg_for_device(dd->dev, dd->out_sg, dd->out_sg_len,
omap_aes_crypt_dma_stop(dd); DMA_FROM_DEVICE);
omap_aes_crypt_dma_stop(dd);
}
omap_aes_finish_req(dd, 0); omap_aes_finish_req(dd, 0);
omap_aes_handle_queue(dd, NULL); omap_aes_handle_queue(dd, NULL);
......
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