summaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorNaveen Krishna Chatradhi <ch.naveen@samsung.com>2014-05-08 09:58:15 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2014-05-08 09:58:15 -0400
commitdc5e3f1953b8bbfa6a7e8854d352c7da007ec6d9 (patch)
tree4f05f8f3245710265398dfc76e37a433a81f6a15 /drivers/crypto
parentc1eb7ef2656b0bf176c0a699df4f8830fa09d9aa (diff)
crypto: s5p-sss - Look for the next request in the queue
Currently, the driver enqueues a request only if the busy bit is false. And every request initiates a dequeue. If 2 requests arrive simultaneously, only one of them will be dequeued. To avoid this senario, we will enqueue the next request irrespective of the system condition (that is what queue is here for). Also schedule at a tasklet immediatly after the current request is done. The tasklet will dequeue the next request in the queue, giving continuous loop. tasklet will exit if there are no requests in the queue. Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com> CC: David S. Miller <davem@davemloft.net> CC: <linux-samsung-soc@vger.kernel.org> Acked-by: Vladimir Zapolskiy <vz@mleia.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/s5p-sss.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index ea7d4788f311..47c568ec2474 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -330,8 +330,12 @@ static void s5p_aes_tx(struct s5p_aes_dev *dev)
330 } 330 }
331 331
332 s5p_set_dma_outdata(dev, dev->sg_dst); 332 s5p_set_dma_outdata(dev, dev->sg_dst);
333 } else 333 } else {
334 s5p_aes_complete(dev, err); 334 s5p_aes_complete(dev, err);
335
336 dev->busy = true;
337 tasklet_schedule(&dev->tasklet);
338 }
335} 339}
336 340
337static void s5p_aes_rx(struct s5p_aes_dev *dev) 341static void s5p_aes_rx(struct s5p_aes_dev *dev)
@@ -469,10 +473,13 @@ static void s5p_tasklet_cb(unsigned long data)
469 spin_lock_irqsave(&dev->lock, flags); 473 spin_lock_irqsave(&dev->lock, flags);
470 backlog = crypto_get_backlog(&dev->queue); 474 backlog = crypto_get_backlog(&dev->queue);
471 async_req = crypto_dequeue_request(&dev->queue); 475 async_req = crypto_dequeue_request(&dev->queue);
472 spin_unlock_irqrestore(&dev->lock, flags);
473 476
474 if (!async_req) 477 if (!async_req) {
478 dev->busy = false;
479 spin_unlock_irqrestore(&dev->lock, flags);
475 return; 480 return;
481 }
482 spin_unlock_irqrestore(&dev->lock, flags);
476 483
477 if (backlog) 484 if (backlog)
478 backlog->complete(backlog, -EINPROGRESS); 485 backlog->complete(backlog, -EINPROGRESS);
@@ -491,14 +498,13 @@ static int s5p_aes_handle_req(struct s5p_aes_dev *dev,
491 int err; 498 int err;
492 499
493 spin_lock_irqsave(&dev->lock, flags); 500 spin_lock_irqsave(&dev->lock, flags);
501 err = ablkcipher_enqueue_request(&dev->queue, req);
494 if (dev->busy) { 502 if (dev->busy) {
495 err = -EAGAIN;
496 spin_unlock_irqrestore(&dev->lock, flags); 503 spin_unlock_irqrestore(&dev->lock, flags);
497 goto exit; 504 goto exit;
498 } 505 }
499 dev->busy = true; 506 dev->busy = true;
500 507
501 err = ablkcipher_enqueue_request(&dev->queue, req);
502 spin_unlock_irqrestore(&dev->lock, flags); 508 spin_unlock_irqrestore(&dev->lock, flags);
503 509
504 tasklet_schedule(&dev->tasklet); 510 tasklet_schedule(&dev->tasklet);
@@ -683,6 +689,7 @@ static int s5p_aes_probe(struct platform_device *pdev)
683 } 689 }
684 } 690 }
685 691
692 pdata->busy = false;
686 pdata->variant = variant; 693 pdata->variant = variant;
687 pdata->dev = dev; 694 pdata->dev = dev;
688 platform_set_drvdata(pdev, pdata); 695 platform_set_drvdata(pdev, pdata);