From patchwork Thu Jan 26 16:07:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrille Pitchen X-Patchwork-Id: 9539727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2001C604A0 for ; Thu, 26 Jan 2017 16:24:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0ECA3205F6 for ; Thu, 26 Jan 2017 16:24:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03B3F2818E; Thu, 26 Jan 2017 16:24:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 91E2F205F6 for ; Thu, 26 Jan 2017 16:24:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cWmq7-0006Ox-4X; Thu, 26 Jan 2017 16:23:59 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cWmpb-0005yi-I7 for linux-arm-kernel@bombadil.infradead.org; Thu, 26 Jan 2017 16:23:27 +0000 Received: from smtpout.microchip.com ([198.175.253.82] helo=email.microchip.com) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cWmdg-0001kQ-N2 for linux-arm-kernel@lists.infradead.org; Thu, 26 Jan 2017 16:11:10 +0000 Received: from tenerife.corp.atmel.com (10.10.76.4) by chn-sv-exch06.mchp-main.com (10.10.76.107) with Microsoft SMTP Server id 14.3.181.6; Thu, 26 Jan 2017 09:10:46 -0700 From: Cyrille Pitchen To: , , Subject: [PATCH v3 05/12] crypto: atmel-sha: add atmel_sha_wait_for_data_ready() Date: Thu, 26 Jan 2017 17:07:50 +0100 Message-ID: <6dfd52ed532de56f5bcc3857b8bd96029360089e.1485443478.git.cyrille.pitchen@atmel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAC+NgFjrEKsWRWlGSWpSXmKPExsXCxeXDotsm3xVh8HXvtOO8Fve+n2e2mHO+hcWi+5WMxabH11gt7t/7yWRxedccNotvl5vZLaaeXsviwOGx4NdWFo9PV64weWxZeZPJY9sBVY/NS+o9Pm+SC2CLYs3MS8qvSGDNmP3gMUvBXO6KD08VGhiXcHYxcnEICaxnlHg0ezNzFyMnB5uAocTbB0dZQWwRgUCJhS2vGEGKmAXWMUq0NL8FKxIWCJDoaJ0PVsQioCrxeOtCRhCbVyBeYvWso2A1EgJyEjfPdYLZnAK2Eit/rWYDsYUEbCS677yFqheUODnzCQuIzSwgIXHwxQtmiBo1oMUroOYESvT8v8cKYTtJ/F85kx3CtpM4PP0ilO0gcf/+DDaYmoNbn0PZ2hLbX+2D6tWR2HawnwXCtpXYM2MiE4TtLvHg0XIo21di1sMGqJooiVP9n1knMErMQnLqLCSnLmBkWsUo7ezhpxscpusa4exhYKaXm5xRoJubmJmnl5yfu4kREqHZOxiPzI84xCjJwaQkyntTuzNCiC8pP6UyI7E4I76oNCe1+BCjDAeHkgRvqGxXhJBgUWp6akVaZg4wVcCkmTg4DzFKcPAoifBmgNTwFhck5hZnpkPkTzFKSonzhssAJQRAEhmleXC9lxhFpYR5T4sC5XgKUotyM0sg4rcYhTkeMgmx5OXnpUoB3ckABBqMrxjFORiVhCGW8GTmlcDteAW0nglo/QXmdpD1JYkIKakGxhOWYu8dBE+aGnSU+H+PnuKtY+S9gFF1Q/CcN38z9jbN8HGYKr3AOWXB6pclUtKh/I97X/QHyvU5/D7TL7xh6sSOOP+a4uq+r4mtexsWu33xa3ij90pxfukXbWUx3e+JXbrcVdEF965F7Jt8/9LdK9u2RSeLn1Cvf+o1xV9FYT/3iSW6dnuZlViKMxINtZiLihMB CZTScVUDAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170126_161109_043352_D633C587 X-CRM114-Status: GOOD ( 11.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: smueller@chronox.de, Cyrille Pitchen , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch simply defines a helper function to test the 'Data Ready' flag of the Status Register. It also gives a chance for the crypto request to be processed synchronously if this 'Data Ready' flag is already set when polling the Status Register. Indeed, running synchronously avoid the latency of the 'Data Ready' interrupt. When the 'Data Ready' flag has not been set yet, we enable the associated interrupt and resume processing the crypto request asynchronously from the 'done' task just as before. Signed-off-by: Cyrille Pitchen --- drivers/crypto/atmel-sha.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c index b29a4e5bc404..be0d72cf4352 100644 --- a/drivers/crypto/atmel-sha.c +++ b/drivers/crypto/atmel-sha.c @@ -434,6 +434,19 @@ static void atmel_sha_write_ctrl(struct atmel_sha_dev *dd, int dma) atmel_sha_write(dd, SHA_MR, valmr); } +static inline int atmel_sha_wait_for_data_ready(struct atmel_sha_dev *dd, + atmel_sha_fn_t resume) +{ + u32 isr = atmel_sha_read(dd, SHA_ISR); + + if (unlikely(isr & SHA_INT_DATARDY)) + return resume(dd); + + dd->resume = resume; + atmel_sha_write(dd, SHA_IER, SHA_INT_DATARDY); + return -EINPROGRESS; +} + static int atmel_sha_xmit_cpu(struct atmel_sha_dev *dd, const u8 *buf, size_t length, int final) {