From patchwork Tue Sep 5 12:38:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 111686 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp2786780qge; Tue, 5 Sep 2017 05:44:05 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4sXFoh0bI4Q9qqbX6Eyi4MslCkwLwCaMNKF5wBoTJLr0fz+r/X/8Sx97BVoVrvg2lOYsCt X-Received: by 10.99.99.197 with SMTP id x188mr3875859pgb.49.1504615444880; Tue, 05 Sep 2017 05:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504615444; cv=none; d=google.com; s=arc-20160816; b=cVti+5hSsnlaFpZbHGdQZNX0bvT3dsVnMfUg7Yv8PqLFH65+7yHOzA+Cbd8Zqd9pQ4 gr6pWTwvy4L1ryhs8+P1jCyENsGMXS6T4PeVc9CUs7A68wV+Ja/sfkPR3AhWPfOJPtEZ 8PdD5K9DRGXunY/vThGlb5gTVZydCOurV1zx1FcQY3hh1hGIrtKtf4PA7AXSQjh2HWcE RBIdG8BPjNXhtqsQtCph4NWgSgWcIi5Rc5lSKHnNOPAbf1kauh1z4qYOpjcY5MAR2UVG w3m6BjYKHoR+1lWLyme9Tx6KiJa+WIyfjkCZjPatsLQvqMPQN8g0ph80QrocAlF7b0Hw LIug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=A7zELhOaEjZb/+lrLAbPp1vdePqcxK/3gRtFdVYfz7A=; b=JWTkbtF2iU/8CkaL42jx5a3ElReG7g9sz45sk77LvxHdasMm5SOeD8PSD/18L2tCh3 oZW4tx8tWRYh4UM8Jmyrt+zGvfND9RENX+FaZBP3ARVfc3c4qePD75okpnaFH4RYWBGY nc8+BCJ1n+t4DmflPEwlrwUw9+4weEJ01fx1C0yCzZc+F9MLIPPZCUSCEwiqim9xBHTS wa+KgDu5/Unk2YwWpb63RN3eEx46SvIt/bFurCW/lx2gVJbLxVN+DulSm1FqvBg1hUgD 04Le/TYG1vx5uwxKSZuUqDDZStck17zmoaf6FAmb386kCFeYn7sVlS//F8XGLBkL07I8 9vRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12si305855plk.324.2017.09.05.05.44.04; Tue, 05 Sep 2017 05:44:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752333AbdIEMoD (ORCPT + 1 other); Tue, 5 Sep 2017 08:44:03 -0400 Received: from foss.arm.com ([217.140.101.70]:39976 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752121AbdIEMn7 (ORCPT ); Tue, 5 Sep 2017 08:43:59 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 795D2165C; Tue, 5 Sep 2017 05:43:58 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 406FF3F3E1; Tue, 5 Sep 2017 05:43:48 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Steffen Klassert , Alexey Kuznetsov , Hideaki YOSHIFUJI , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, netdev@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v8 19/20] crypto: mediatek: move to generic async completion Date: Tue, 5 Sep 2017 15:38:58 +0300 Message-Id: <1504615144-29770-20-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504615144-29770-1-git-send-email-gilad@benyossef.com> References: <1504615144-29770-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.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 Acked-by: Ryder Lee --- drivers/crypto/mediatek/mtk-aes.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) -- 2.1.4 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;