From patchwork Sat May 6 12:59:53 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: 98757 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp564681qge; Sat, 6 May 2017 06:01:26 -0700 (PDT) X-Received: by 10.84.136.70 with SMTP id 64mr72594226plk.82.1494075686443; Sat, 06 May 2017 06:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494075686; cv=none; d=google.com; s=arc-20160816; b=A0DTl2qBZLgM88GAKVZ6qn1JXz2a5Oy6agvFWg4fWkeV8Lougztm4R5CoLh6qqXntf 3cC+I5a+SbPJ4Mf++9PzoUZYlmLG2bEVAO84Kt5xemtmjBSMxMTSVFZgq1IoMB8HRTh/ d7DvD2OEBBGThTv7RaON76CvAfgw3xHol+VPwLuUgrAcCXYpxh/1Mw25d5YQPMMPPsJv u/u+ihgrHwcSIsPNYF5/E/WcurXt28+kULUiLh6fPjWgodScdya53tDq0lB0VJ4ZHCDi lDdj7DNOV+2QdYebo9vaaieC9ti6OiyPdP4+ry5dSaRomMhGtLAcJzP1SMtYfRDprDnS 9aXw== 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=d6C++Txunash6T860GI6PqJK04Q4FCRBN1hf1WN93Ug=; b=pYsWIEWqIKHPB9MnnUO4fIZbo6VNd+ZsGJqZ5smetsn4FZ/4VkQezkNySngxW3eSmn 5YNbb66DRpcbLTIUHB7s+5eAYksBqA+XcbYrJapFz8rDTDc4PQVNlkKYD7q+Jxdv4nh/ G818fbgYXJOs/BIiUX7W/buBpou9RlMVgPxT9XlFMrfiqECnStPnvx3/HQmK6jhPwf9a nskH3KJqbPuiBlCvsNHHJjPn/b6RpuaTYInWFnCMcFEgMnrZKamntWM3NXXE2rOTBgL7 xKetNcjtiAJx2dgVnHDDdLKy2t7b6QUQT1vlt6/dbVJyrUh6ypZWKsJwv1n4vBgFvlH0 r/Ag== 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 o69si8163261pfj.161.2017.05.06.06.01.26; Sat, 06 May 2017 06:01:26 -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 S1751290AbdEFNBA (ORCPT + 1 other); Sat, 6 May 2017 09:01:00 -0400 Received: from foss.arm.com ([217.140.101.70]:59192 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753816AbdEFNAw (ORCPT ); Sat, 6 May 2017 09:00:52 -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 2A1EB164F; Sat, 6 May 2017 06:00:51 -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 ABB963F41F; Sat, 6 May 2017 06:00:44 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , 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" Cc: Ofir Drang , Gilad Ben-Yossef , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fsdevel@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Subject: [RFC 04/10] crypto: move gcm to generic async completion Date: Sat, 6 May 2017 15:59:53 +0300 Message-Id: <1494075602-5061-5-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1494075602-5061-1-git-send-email-gilad@benyossef.com> References: <1494075602-5061-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 | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) -- 2.1.4 diff --git a/crypto/gcm.c b/crypto/gcm.c index b7ad808..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,23 +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 == -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;