From patchwork Thu Dec 22 16:15:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrille Pitchen X-Patchwork-Id: 9485261 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 D5E88600BA for ; Thu, 22 Dec 2016 16:17:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C780326220 for ; Thu, 22 Dec 2016 16:17:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC5E92711E; Thu, 22 Dec 2016 16:17:56 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8271C26220 for ; Thu, 22 Dec 2016 16:17:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cK62Z-0005fi-So; Thu, 22 Dec 2016 16:16:23 +0000 Received: from smtpout.microchip.com ([198.175.253.82] helo=email.microchip.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cK61m-0004IV-OL for linux-arm-kernel@lists.infradead.org; Thu, 22 Dec 2016 16:15:35 +0000 Received: from tenerife.corp.atmel.com (10.10.76.4) by chn-sv-exch07.mchp-main.com (10.10.76.108) with Microsoft SMTP Server id 14.3.181.6; Thu, 22 Dec 2016 09:15:31 -0700 From: Cyrille Pitchen To: , , Subject: [PATCH 05/12] crypto: atmel-sha: add atmel_sha_wait_for_data_ready() Date: Thu, 22 Dec 2016 17:15:10 +0100 Message-ID: <4acd571517ee8919b65765de30da2b8e8a73bbed.1482422983.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+NgFupiVWLjYuHi8mHRVf4THWHw9fncN7wWhxdOYbR48L6TxWLa9HfMFvc+bWO06JiyismBNYAhijUzLym/IoE1Y/aDxywFc7krPjxVaGBcwtnFyMUhJLCeUeLWtQ6WLkZODjYBQ4m3D46ygtgiAoESC1teMYIUMQtMZ5R4sPodO0hCWMBXYkX3ZkYQm0VAVWLLlivMIDavQLxE/9HtTCC2hICcxM1znWBxTgFbicd374ENFRKwkfi/8i4rRL2gxMmZT8AWMwtISBx88YIZokYNaPEKZog5gRKTzhyCsp0knq+7yQZh20kcnn6RHcJ2kOha8Buu5unji1C2tsT2V/tYIWwdiW0H+1kgbFuJPTMmQt3pLvHg0XIo21di1sMGqJooibYlm9kmMErMQnLqLCSnLmBkWsUo7ezhpxscpusa4exhYK6Xm5xRoJubmJmnl5yfu4kREk85OxgnT/I/xCjJwaQkyrt10vlwIb6k/JTKjMTijPii0pzU4kOMEhw8SiK8/MuAcrzFBYm5xZnpMCkZDg4lCd7HS4FSgkWp6akVaZk5JalFEOlTjJJS4rwfQZICIH0ZpXlwuUuMolLCvFEgOZ6C1KLczBKI+C1GYY6HTEIsefl5qVJAJzIAgQbjK0ZxDkYlYV5pkBt4MvNK4E54BXQdE9B163afBrmuJBEhJdXAWKEv4izTvPDg/YMtTakXdh3Q/K7A+fDWpw98NQteaIps65J67GA1x7/7+h32tswNj2aXrDN/cHSBvvWhLy+08g4cEBdZkvz/Q4n72v45j9enOGecbqr7aqC3Mm2nB7t1U0/Kh6u2kxz3pnDGN2wQua5+7OqcGRYG8pkzBTx822TZMm64uOfeUmIpzkg01GIuKk4EAB9s94sdAwAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161222_081534_951196_87C22810 X-CRM114-Status: GOOD ( 10.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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) {