From patchwork Wed Jan 29 09:27:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Krishna Chatradhi X-Patchwork-Id: 3550301 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4D941C02DC for ; Wed, 29 Jan 2014 09:27:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 79FE02017A for ; Wed, 29 Jan 2014 09:27:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7700920170 for ; Wed, 29 Jan 2014 09:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752186AbaA2J1N (ORCPT ); Wed, 29 Jan 2014 04:27:13 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:62445 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750953AbaA2J1I (ORCPT ); Wed, 29 Jan 2014 04:27:08 -0500 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N0500839OX67940@mailout1.samsung.com>; Wed, 29 Jan 2014 18:27:06 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.123]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 8B.56.10092.A69C8E25; Wed, 29 Jan 2014 18:27:06 +0900 (KST) X-AuditID: cbfee68f-b7f156d00000276c-2a-52e8c96a7f3b Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id C1.A0.28157.A69C8E25; Wed, 29 Jan 2014 18:27:06 +0900 (KST) Received: from username-ubuntu.sisodomain.com ([107.108.83.161]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N0500DO1OX2GA30@mmp1.samsung.com>; Wed, 29 Jan 2014 18:27:06 +0900 (KST) From: Naveen Krishna Chatradhi To: linux-crypto@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, vzapolskiy@gmail.com, herbert@gondor.apana.org.au, naveenkrishna.ch@gmail.com, cpgs@samsung.com, devicetree@vger.kernel.org, Naveen Krishna Ch Subject: [PATCH 9/9 v5] crypto:s5p-sss: Look for the next request in the queue Date: Wed, 29 Jan 2014 14:57:01 +0530 Message-id: <1390987621-19019-1-git-send-email-ch.naveen@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHLMWRmVeSWpSXmKPExsWyRsSkWjfr5Isgg2N3zSzuPj/MaPHykKbF /CPnWC26X8lY3L/3k8ni8q45bBYzzu9jsli07T+zxdk5h5gcOD12zrrL7rHtgKpH35ZVjB6f N8kFsERx2aSk5mSWpRbp2yVwZaxYsZ65YKZwxfLG98wNjNf5uxg5OSQETCTOfb7OBmGLSVy4 tx7I5uIQEljKKNG69T8jTNHKkweYIRKLGCUen17KDuH0M0nsXPibGaSKTcBM4uCi1ewgtoiA s8Tv5jWsIDazwBlGif1vgOIcHMICfhIXd1uDhFkEVCVmdG9lBgnzCrhK/L9sCmJKCChIzJlk AzJdQqCdXeL8tGksEOUCEt8mH2KBqJGV2HSAGeI0SYmDK26wTGAUXMDIsIpRNLUguaA4Kb3I WK84Mbe4NC9dLzk/dxMjMGxP/3vWv4Px7gHrQ4zJQOMmMkuJJucDwz6vJN7Q2MzIwtTE1NjI 3NKMNGElcd77D5OChATSE0tSs1NTC1KL4otKc1KLDzEycXBKNTB26H5/IWUyn1ebceW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000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Naveen Krishna Ch 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 Ch --- This is a new fix in this patchset, tested with dm-crypt/ecryptfs drivers/crypto/s5p-sss.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c index 5bd3bd9..d37cbfc 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) } s5p_set_dma_outdata(dev, dev->sg_dst); - } else + } else { s5p_aes_complete(dev, err); + + dev->busy = true; + tasklet_schedule(&dev->tasklet); + } } static void s5p_aes_rx(struct s5p_aes_dev *dev) @@ -469,10 +473,13 @@ static void s5p_tasklet_cb(unsigned long data) spin_lock_irqsave(&dev->lock, flags); backlog = crypto_get_backlog(&dev->queue); async_req = crypto_dequeue_request(&dev->queue); - spin_unlock_irqrestore(&dev->lock, flags); - if (!async_req) + if (!async_req) { + dev->busy = false; + spin_unlock_irqrestore(&dev->lock, flags); return; + } + spin_unlock_irqrestore(&dev->lock, flags); if (backlog) backlog->complete(backlog, -EINPROGRESS); @@ -491,14 +498,13 @@ static int s5p_aes_handle_req(struct s5p_aes_dev *dev, int err; spin_lock_irqsave(&dev->lock, flags); + err = ablkcipher_enqueue_request(&dev->queue, req); if (dev->busy) { - err = -EAGAIN; spin_unlock_irqrestore(&dev->lock, flags); goto exit; } dev->busy = true; - err = ablkcipher_enqueue_request(&dev->queue, req); spin_unlock_irqrestore(&dev->lock, flags); tasklet_schedule(&dev->tasklet); @@ -688,6 +694,7 @@ static int s5p_aes_probe(struct platform_device *pdev) } } + pdata->busy = false; pdata->variant = variant; pdata->dev = dev; platform_set_drvdata(pdev, pdata);