Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1567572

[PATCH v3 05/12] crypto: atmel-sha: add atmel_sha_wait_for_data_ready()

From Cyrille Pitchen <cyrille.pitchen@atmel.com>
Newsgroups linux.kernel
Subject [PATCH v3 05/12] crypto: atmel-sha: add atmel_sha_wait_for_data_ready()
Date 2017-01-26 17:20 +0100
Message-ID <t3UWe-16V-29@gated-at.bofh.it> (permalink)
References <t3UMy-13x-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <cyrille.pitchen@atmel.com>
---
 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)
 {
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 00/12] crypto: atmel-authenc: add support to authenc(hmac(shaX),Y(aes)) modes Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:10 +0100
  [PATCH v3 09/12] crypto: atmel-sha: add support to hmac(shaX) Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:20 +0100
  [PATCH v3 04/12] crypto: atmel-sha: redefine SHA_FLAGS_SHA* flags to match SHA_MR_ALGO_SHA* Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:20 +0100
  [PATCH v3 06/12] crypto: atmel-sha: add SHA_MR_MODE_IDATAR0 Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:20 +0100
  [PATCH v3 01/12] crypto: atmel-sha: create function to get an Atmel SHA device Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:20 +0100
  [PATCH v3 10/12] crypto: atmel-aes: fix atmel_aes_handle_queue() Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:20 +0100
  [PATCH v3 12/12] crypto: atmel-sha: add verbose debug facilities to print hw register names Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:20 +0100
  [PATCH v3 05/12] crypto: atmel-sha: add atmel_sha_wait_for_data_ready() Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:20 +0100
  [PATCH v3 03/12] crypto: atmel-sha: make atmel_sha_done_task more generic Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:20 +0100
  [PATCH v3 02/12] crypto: atmel-sha: update request queue management to make it more generic Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:20 +0100
  [PATCH v3 11/12] crypto: atmel-authenc: add support to authenc(hmac(shaX),Y(aes)) modes Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:20 +0100
  [PATCH v3 07/12] crypto: atmel-sha: add atmel_sha_cpu_start() Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:20 +0100
  [PATCH v3 08/12] crypto: atmel-sha: add simple DMA transfers Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-01-26 17:20 +0100

csiph-web