From patchwork Wed Oct 18 07:00:42 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: 116220 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp5744774qgn; Wed, 18 Oct 2017 00:04:29 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBqrci0wcWrqtDaxVJl/JH8G78grZ5AlKMXEyo0isRubDYyubeNkw+W2EQoRmtzS4zPXlca X-Received: by 10.101.74.193 with SMTP id c1mr13171789pgu.260.1508310269234; Wed, 18 Oct 2017 00:04:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508310269; cv=none; d=google.com; s=arc-20160816; b=L3v7k0eo4amRi/m6dlJqEfMYtc+vf3DmtM8Rt6LQ0jZ54Lvk3bzu/i7xaQbRY7aQtz wliw7qcfmqwcidk8VxNQoJV9F+gVM/jf1CC3C+Dor/8XV1syQ3hei/RedSJJEmeFG5YJ Y0veCXhaC2scxUXZiERkOvEB09fBc2qNUtDpB7KgCkSxvKs8IxO+p9UWpVEulWWPnPw9 thgaELlu/kcdCUoHtNQoCN/Zxb3FVO3dpED6io+AKdEa6NSOI0L1xnvDeVk+Esw/yIyc 5y/T3qyEC/16d5sIKHDCYSk0d35NaRPW9gTbzIaSBFqZlm60LlkPrBHxVhVHQPA0JWz9 HM3g== 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=MfZrwxucL22mKAcu7KqCue81zlD8VRpnG42XZPur3jQ=; b=v7TrXeNsJsmXxpMkI2004h6uztypeQcOunEvIsjAv7quLtv8ydqLxhBAaIsppKKoca TnNLNOrW7IMCXYclUzs0eGyl2gNLd07NrWrlSjD8WiiJ1lfOzby6fvov4vcjk8sSqZRM qLJkpDru3cYSVE0IVlSRYcI/pVPSFnyTMsAX/zvpp4RKoRkmYkzxqff7C5zfIB5w7+B9 Ql4Lr3PBz9yKp5erJRfo3gzt5yjv5IanUQuDeBwbzK9QCqP9TE2RSYrO+3xA73Xy7oOO hAXbIe+TcubA6f8Uam8LBas5BHMiFbiMBqsI4RBwv6etZF/Ws+MKtXEY5RDhRreFnYIH MsBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 u13si6540664pgq.234.2017.10.18.00.04.28; Wed, 18 Oct 2017 00:04:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966653AbdJRHE0 (ORCPT + 27 others); Wed, 18 Oct 2017 03:04:26 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:33716 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966601AbdJRHEV (ORCPT ); Wed, 18 Oct 2017 03:04:21 -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 569591529; Wed, 18 Oct 2017 00:04:21 -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 3AAA73F590; Wed, 18 Oct 2017 00:04:13 -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, Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Steffen Klassert , Alexey Kuznetsov , Hideaki YOSHIFUJI , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" Cc: Ofir Drang , 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-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 Subject: [PATCH v10 10/20] crypto: move gcm to generic async completion Date: Wed, 18 Oct 2017 08:00:42 +0100 Message-Id: <1508310057-25369-11-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508310057-25369-1-git-send-email-gilad@benyossef.com> References: <1508310057-25369-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.7.4 diff --git a/crypto/gcm.c b/crypto/gcm.c index 80cf6cf..8589681 100644 --- a/crypto/gcm.c +++ b/crypto/gcm.c @@ -17,7 +17,6 @@ #include #include #include "internal.h" -#include #include #include #include @@ -79,11 +78,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; @@ -99,17 +93,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) { @@ -120,7 +103,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; @@ -141,21 +124,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 == -EBUSY) { - 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;