All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilad Ben-Yossef <gilad-6S/DczAoZh3WXxRugSxzZg@public.gmane.org>
To: Herbert Xu
	<herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>,
	"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	Jonathan Corbet <corbet-T1hC0tSOHrs@public.gmane.org>,
	David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Tom Lendacky <thomas.lendacky-5C7GfCeVMHo@public.gmane.org>,
	Gary Hook <gary.hook-5C7GfCeVMHo@public.gmane.org>,
	Boris Brezillon
	<boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Arnaud Ebalard <arno-LkuqDEemtHBg9hUCZPvPmw@public.gmane.org>,
	Matthias Brugger
	<matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Alasdair Kergon <agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Mike Snitzer <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	Shaohua Li <shli-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Steve French <sfrench-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>,
	"Theodore Y. Ts'o" <tytso-3s7WtUTddSA@public.gmane.org>,
	Jaegeuk Kim <jaegeuk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Mimi Zohar
	<zohar-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
	Dmitry Kasatkin
	<dmitry.kasatkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	James Morris
	<james.l.morris-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	"Serge E. Hallyn" <serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org>,
	linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	keyrings-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel@lists
Cc: Ofir Drang <ofir.drang-5wv7dgnIgG8@public.gmane.org>
Subject: [PATCH v7 18/19] crypto: mediatek: move to generic async completion
Date: Thu, 24 Aug 2017 17:19:05 +0300	[thread overview]
Message-ID: <1503584350-7831-19-git-send-email-gilad__32656.6662094139$1503584756$gmane$org@benyossef.com> (raw)
In-Reply-To: <1503584350-7831-1-git-send-email-gilad-6S/DczAoZh3WXxRugSxzZg@public.gmane.org>

The mediatek driver starts several async crypto ops and waits for their
completions. Move it over to generic code doing the same.

Signed-off-by: Gilad Ben-Yossef <gilad-6S/DczAoZh3WXxRugSxzZg@public.gmane.org>
Acked-by: Ryder Lee <ryder.lee-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
 drivers/crypto/mediatek/mtk-aes.c | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)

diff --git a/drivers/crypto/mediatek/mtk-aes.c b/drivers/crypto/mediatek/mtk-aes.c
index 9e845e8..e2c7c95 100644
--- a/drivers/crypto/mediatek/mtk-aes.c
+++ b/drivers/crypto/mediatek/mtk-aes.c
@@ -137,11 +137,6 @@ struct mtk_aes_gcm_ctx {
 	struct crypto_skcipher *ctr;
 };
 
-struct mtk_aes_gcm_setkey_result {
-	int err;
-	struct completion completion;
-};
-
 struct mtk_aes_drv {
 	struct list_head dev_list;
 	/* Device list lock */
@@ -936,17 +931,6 @@ static int mtk_aes_gcm_crypt(struct aead_request *req, u64 mode)
 				    &req->base);
 }
 
-static void mtk_gcm_setkey_done(struct crypto_async_request *req, int err)
-{
-	struct mtk_aes_gcm_setkey_result *result = req->data;
-
-	if (err == -EINPROGRESS)
-		return;
-
-	result->err = err;
-	complete(&result->completion);
-}
-
 /*
  * Because of the hardware limitation, we need to pre-calculate key(H)
  * for the GHASH operation. The result of the encryption operation
@@ -962,7 +946,7 @@ static int mtk_aes_gcm_setkey(struct crypto_aead *aead, const u8 *key,
 		u32 hash[4];
 		u8 iv[8];
 
-		struct mtk_aes_gcm_setkey_result result;
+		struct crypto_wait wait;
 
 		struct scatterlist sg[1];
 		struct skcipher_request req;
@@ -1002,22 +986,17 @@ static int mtk_aes_gcm_setkey(struct crypto_aead *aead, const u8 *key,
 	if (!data)
 		return -ENOMEM;
 
-	init_completion(&data->result.completion);
+	crypto_init_wait(&data->wait);
 	sg_init_one(data->sg, &data->hash, AES_BLOCK_SIZE);
 	skcipher_request_set_tfm(&data->req, ctr);
 	skcipher_request_set_callback(&data->req, CRYPTO_TFM_REQ_MAY_SLEEP |
 				      CRYPTO_TFM_REQ_MAY_BACKLOG,
-				      mtk_gcm_setkey_done, &data->result);
+				      crypto_req_done, &data->wait);
 	skcipher_request_set_crypt(&data->req, data->sg, data->sg,
 				   AES_BLOCK_SIZE, data->iv);
 
-	err = crypto_skcipher_encrypt(&data->req);
-	if (err == -EINPROGRESS || err == -EBUSY) {
-		err = wait_for_completion_interruptible(
-			&data->result.completion);
-		if (!err)
-			err = data->result.err;
-	}
+	err = crypto_wait_req(crypto_skcipher_encrypt(&data->req),
+			      &data->wait);
 	if (err)
 		goto out;
 
-- 
2.1.4

  parent reply	other threads:[~2017-08-24 14:19 UTC|newest]

Thread overview: 182+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 14:18 [PATCH v7 00/19] simplify crypto wait for async op Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` [PATCH v7 01/19] crypto: change transient busy return code to -EAGAIN Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18 ` [PATCH v7 02/19] crypto: ccp: use -EAGAIN for transient busy indication Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18 ` [PATCH v7 03/19] crypto: remove redundant backlog checks on EBUSY Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18 ` [PATCH v7 04/19] crypto: marvell/cesa: " Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` [PATCH v7 05/19] crypto: introduce crypto wait for async op Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18 ` [PATCH v7 06/19] crypto: move algif to generic async completion Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` [PATCH v7 07/19] crypto: move pub key " Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` [PATCH v7 08/19] crypto: move drbg " Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` [PATCH v7 09/19] crypto: move gcm " Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` [PATCH v7 10/19] crypto: move testmgr " Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18 ` [PATCH v7 11/19] fscrypt: move " Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18 ` [PATCH v7 12/19] dm: move dm-verity " Gilad Ben-Yossef
2017-08-24 14:18 ` Gilad Ben-Yossef
     [not found] ` <1503584350-7831-1-git-send-email-gilad-6S/DczAoZh3WXxRugSxzZg@public.gmane.org>
2017-08-24 14:18   ` [PATCH v7 01/19] crypto: change transient busy return code to -EAGAIN Gilad Ben-Yossef
2017-08-24 14:18   ` [PATCH v7 02/19] crypto: ccp: use -EAGAIN for transient busy indication Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` [PATCH v7 03/19] crypto: remove redundant backlog checks on EBUSY Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` [PATCH v7 04/19] crypto: marvell/cesa: " Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` [PATCH v7 05/19] crypto: introduce crypto wait for async op Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` [PATCH v7 06/19] crypto: move algif to generic async completion Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` [PATCH v7 07/19] crypto: move pub key " Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` [PATCH v7 08/19] crypto: move drbg " Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` [PATCH v7 09/19] crypto: move gcm " Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18     ` Gilad Ben-Yossef
2017-08-24 14:18     ` Gilad Ben-Yossef
2017-08-24 14:18     ` Gilad Ben-Yossef
2017-08-24 14:18     ` Gilad Ben-Yossef
2017-08-24 14:18   ` [PATCH v7 10/19] crypto: move testmgr " Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` [PATCH v7 11/19] fscrypt: move " Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:18   ` [PATCH v7 12/19] dm: move dm-verity " Gilad Ben-Yossef
2017-08-24 14:18     ` Gilad Ben-Yossef
2017-08-24 14:18     ` Gilad Ben-Yossef
2017-08-24 14:18     ` Gilad Ben-Yossef
2017-08-24 14:18     ` Gilad Ben-Yossef
2017-08-24 14:18   ` Gilad Ben-Yossef
2017-08-24 14:19   ` [PATCH v7 13/19] cifs: move " Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` [PATCH v7 14/19] ima: " Gilad Ben-Yossef
2017-08-24 14:19   ` [PATCH v7 15/19] crypto: tcrypt: " Gilad Ben-Yossef
2017-08-24 14:19   ` [PATCH v7 16/19] crypto: talitos: " Gilad Ben-Yossef
2017-08-24 14:19   ` [PATCH v7 17/19] crypto: qce: " Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` [PATCH v7 18/19] crypto: mediatek: " Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef [this message]
2017-08-24 14:19   ` [PATCH v7 19/19] crypto: adapt api sample to use async. op wait Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-31 12:31   ` [PATCH v7 00/19] simplify crypto wait for async op Harsh Jain
2017-08-31 12:43     ` Harsh Jain
2017-08-31 12:31     ` Harsh Jain
2017-08-31 12:31     ` Harsh Jain
2017-08-31 12:31     ` Harsh Jain
2017-09-03  6:09     ` Gilad Ben-Yossef
     [not found]     ` <CAFXBA=n6W_n1P=NKHEUAgpaDDrdmh4QwB4aYma9xyio7UFP3Vw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-09-03  6:17       ` Gilad Ben-Yossef
2017-09-03  6:17         ` Gilad Ben-Yossef
2017-09-03  6:17         ` Gilad Ben-Yossef
2017-09-03  6:17         ` Gilad Ben-Yossef
2017-09-03  6:17         ` Gilad Ben-Yossef
2017-09-05 11:23         ` Harsh Jain
2017-09-05 11:35           ` Harsh Jain
2017-09-05 11:23           ` Harsh Jain
2017-09-05 11:23           ` Harsh Jain
2017-09-05 11:23           ` Harsh Jain
2017-09-05 12:16           ` Gilad Ben-Yossef
2017-09-05 12:16             ` Gilad Ben-Yossef
2017-09-05 12:16             ` Gilad Ben-Yossef
2017-09-05 12:16             ` Gilad Ben-Yossef
2017-09-05 12:16             ` Gilad Ben-Yossef
2017-08-24 14:19 ` [PATCH v7 13/19] cifs: move to generic async completion Gilad Ben-Yossef
2017-08-24 14:19 ` Gilad Ben-Yossef
2017-08-24 14:19 ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19 ` [PATCH v7 14/19] ima: " Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19 ` [PATCH v7 15/19] crypto: tcrypt: " Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19 ` [PATCH v7 16/19] crypto: talitos: " Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19 ` [PATCH v7 17/19] crypto: qce: " Gilad Ben-Yossef
2017-08-24 14:19 ` Gilad Ben-Yossef
2017-08-24 14:19 ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19 ` [PATCH v7 18/19] crypto: mediatek: " Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19 ` Gilad Ben-Yossef
2017-08-24 14:19 ` Gilad Ben-Yossef
2017-08-24 14:19 ` [PATCH v7 19/19] crypto: adapt api sample to use async. op wait Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19   ` Gilad Ben-Yossef
2017-08-24 14:19 ` Gilad Ben-Yossef
2017-08-24 14:19 ` Gilad Ben-Yossef

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='1503584350-7831-19-git-send-email-gilad__32656.6662094139$1503584756$gmane$org@benyossef.com' \
    --to=gilad-6s/dczaozh3wxxrugsxzzg@public.gmane.org \
    --cc=agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=arno-LkuqDEemtHBg9hUCZPvPmw@public.gmane.org \
    --cc=boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=corbet-T1hC0tSOHrs@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dmitry.kasatkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=gary.hook-5C7GfCeVMHo@public.gmane.org \
    --cc=herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org \
    --cc=jaegeuk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=james.l.morris-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=keyrings-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-arm-kernel@lists \
    --cc=linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=ofir.drang-5wv7dgnIgG8@public.gmane.org \
    --cc=serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org \
    --cc=sfrench-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org \
    --cc=shli-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=thomas.lendacky-5C7GfCeVMHo@public.gmane.org \
    --cc=tytso-3s7WtUTddSA@public.gmane.org \
    --cc=zohar-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.