From patchwork Sun Jul 2 14:42:00 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: 106868 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8297486obb; Sun, 2 Jul 2017 07:50:05 -0700 (PDT) X-Received: by 10.98.85.196 with SMTP id j187mr5330981pfb.19.1499007005143; Sun, 02 Jul 2017 07:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499007005; cv=none; d=google.com; s=arc-20160816; b=ldHw692/SaZ+vb5Yct6itnYKrXKOa4p7Thbdo+vXZXO22HA9bwe8VUUTf1ARsJ1Rd5 w3tkMavtG2zfEhYcCEpWBTsaXPO9s9sCQDpg3cxwM4kEgHLP7NCl4ylnT+/Npk4hUDJu VaNDjp/7kalDtIUMx6j5jJHKJred+dG0wkY6TgOyT5D3CUv634GCp7G0Y8dU/68q/+wn HxrOS/jqb3ucKJuSSjRqBBCHacdI4wvEWaDCjNCfDMtvaG6N9KOGhdcAaAAh11nJa8sE RROHN/tFPwxvG0wnIIWhYS+LhgzXph03vIPl0a0occejcp1PKh9Qmv3k5SUHXo7SrIHg h+yg== 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=IpO9WY3n0iy6qRhnC7gV9XsZJQSs0iNF6ZSgh3S2UOU=; b=z3aPtWlAq+knZDjbhLX2b+x0qOJeYiDRd8Fmu0evVyOcD0epHUEqETGHcpuKV4DLAT g+mTRah7/a7Mhn3TCnY8cUCIxBHufIiXo2J51gQbB36VlbDSgz6du1E1a18ExQNQEXmo HLYgMA3UYf5Y5mizKQFoapht9rCkfZ9VKujKEeZeEYhQXGyaYiM4XWgkeMqj5KOr5Fl9 xvMdrVRHwiZiYbbPAyj4nJjo63m1DxKHOdnOnCP9OqAap0pn6WR/88DUhMp4GDHH4K2D H+0fdqLwLvRBwgFz+dDajah+/UsTJ/LQc8QhLybbXj9NdgBLZIctY3znxSxo359kBxKq mN/Q== 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 i127si10301592pgc.170.2017.07.02.07.50.04; Sun, 02 Jul 2017 07:50:05 -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 S1752302AbdGBOtx (ORCPT + 1 other); Sun, 2 Jul 2017 10:49:53 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54350 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752421AbdGBOqn (ORCPT ); Sun, 2 Jul 2017 10:46:43 -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 D22DA344; Sun, 2 Jul 2017 07:46:26 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 393E33F578; Sun, 2 Jul 2017 07:46:19 -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 , 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, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 18/28] crypto: move gcm to generic async completion Date: Sun, 2 Jul 2017 17:42:00 +0300 Message-Id: <1499006535-19760-19-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-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 gcm is starting an async. crypto op and waiting for it complete. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef --- crypto/gcm.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) -- 2.1.4 diff --git a/crypto/gcm.c b/crypto/gcm.c index ffac821..fb923a5 100644 --- a/crypto/gcm.c +++ b/crypto/gcm.c @@ -16,7 +16,6 @@ #include #include #include "internal.h" -#include #include #include #include @@ -78,11 +77,6 @@ struct crypto_gcm_req_priv_ctx { } u; }; -struct crypto_gcm_setkey_result { - int err; - struct completion completion; -}; - static struct { u8 buf[16]; struct scatterlist sg; @@ -98,17 +92,6 @@ static inline struct crypto_gcm_req_priv_ctx *crypto_gcm_reqctx( return (void *)PTR_ALIGN((u8 *)aead_request_ctx(req), align + 1); } -static void crypto_gcm_setkey_done(struct crypto_async_request *req, int err) -{ - struct crypto_gcm_setkey_result *result = req->data; - - if (err == -EINPROGRESS) - return; - - result->err = err; - complete(&result->completion); -} - static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key, unsigned int keylen) { @@ -119,7 +102,7 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key, be128 hash; u8 iv[16]; - struct crypto_gcm_setkey_result result; + struct crypto_wait wait; struct scatterlist sg[1]; struct skcipher_request req; @@ -140,21 +123,18 @@ static int crypto_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, sizeof(data->hash)); skcipher_request_set_tfm(&data->req, ctr); skcipher_request_set_callback(&data->req, CRYPTO_TFM_REQ_MAY_SLEEP | CRYPTO_TFM_REQ_MAY_BACKLOG, - crypto_gcm_setkey_done, - &data->result); + crypto_req_done, + &data->wait); skcipher_request_set_crypt(&data->req, data->sg, data->sg, sizeof(data->hash), data->iv); - err = crypto_skcipher_encrypt(&data->req); - if (err == -EINPROGRESS || err == -EIOCBQUEUED) { - wait_for_completion(&data->result.completion); - err = data->result.err; - } + err = crypto_wait_req(crypto_skcipher_encrypt(&data->req), + &data->wait); if (err) goto out;