From patchwork Thu Aug 24 14:19:04 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: 110928 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp8564181ybm; Thu, 24 Aug 2017 07:23:07 -0700 (PDT) X-Received: by 10.84.196.164 with SMTP id l33mr7098992pld.198.1503584587519; Thu, 24 Aug 2017 07:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503584587; cv=none; d=google.com; s=arc-20160816; b=FwgVEYYCBAxu7wrxDX9PwveCnLhtLAFCys4LihjbvIf1LSAziSamIkoKLIPaoUG4+n whcgZjRKkGebeE4F5SCtlc3IJsYnNNL8bEdZ7Gqdxh/vun7b7jc7abF1ofnplZYN/iIr g4IQhhMzpOldaJ8OuhixMyX85OkX9pBchUwz9Y45A5O1Pkjr8c3/Ytpv8k8eAL7b2okV CkD8v5AiOLEJG61goyNJ1Z4EDHho4xvd8lr0RBJ/ehbt/M3naAvbLU11lQPXwAd2QGpD Pb/z5GfB5lonDMBIeFWeW6AzpcTbvpZ/z+LGmwUdELUS+CUN01FjOe7IEpwbAhxGglnM 7Iog== 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=ZEEwY7S0lvfkzX5eSnqpbx2gek6uifwcDnkIXVl4mV0=; b=gHhxviPL1VrQcd51//n5mOjKM1r2VqKAlhMOy4+KDzLDpNJ1XbrZjhdxM5GQn6VwZq 9BqMKRNF2hzYQb/q9I6kHQlCaG8mEcL7rL1Y4gJZlXXaYhD//9hUXJbkhdt2izj1mi5p /CbBNEF3arfGovK3KPJabM2jaLhUHHxIWGXw6UJ54Ew4HjpwB4nyf0CQ2tPHKyr7/nux 9ubjiBvBdiszAlunphNNk0wAFPmZIfWXnb6yNuQICYJ1cbrni0wJyjlRvdDs/S76+49B SRFwOPCW6d+yNiGHAGkp2Z7yiul1eqV/9ICLYZETWSXpVqJzn5RunZj+yyPf/wzzCYRI 5TYQ== 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 g15si3171602plk.490.2017.08.24.07.23.06; Thu, 24 Aug 2017 07:23:07 -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 S1753956AbdHXOXF (ORCPT + 26 others); Thu, 24 Aug 2017 10:23:05 -0400 Received: from foss.arm.com ([217.140.101.70]:42398 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753092AbdHXOXA (ORCPT ); Thu, 24 Aug 2017 10:23:00 -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 393AD1B55; Thu, 24 Aug 2017 07:23:00 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.132]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 47B6E3F540; Thu, 24 Aug 2017 07:22:52 -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 v7 17/19] crypto: qce: move to generic async completion Date: Thu, 24 Aug 2017 17:19:04 +0300 Message-Id: <1503584350-7831-18-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1503584350-7831-1-git-send-email-gilad@benyossef.com> References: <1503584350-7831-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 The qce 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 --- drivers/crypto/qce/sha.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) -- 2.1.4 diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 47e114a..53227d7 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -349,28 +349,12 @@ static int qce_ahash_digest(struct ahash_request *req) return qce->async_req_enqueue(tmpl->qce, &req->base); } -struct qce_ahash_result { - struct completion completion; - int error; -}; - -static void qce_digest_complete(struct crypto_async_request *req, int error) -{ - struct qce_ahash_result *result = req->data; - - if (error == -EINPROGRESS) - return; - - result->error = error; - complete(&result->completion); -} - static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen) { unsigned int digestsize = crypto_ahash_digestsize(tfm); struct qce_sha_ctx *ctx = crypto_tfm_ctx(&tfm->base); - struct qce_ahash_result result; + struct crypto_wait wait; struct ahash_request *req; struct scatterlist sg; unsigned int blocksize; @@ -405,9 +389,9 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, goto err_free_ahash; } - init_completion(&result.completion); + crypto_init_wait(&wait); ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - qce_digest_complete, &result); + crypto_req_done, &wait); crypto_ahash_clear_flags(ahash_tfm, ~0); buf = kzalloc(keylen + QCE_MAX_ALIGN_SIZE, GFP_KERNEL); @@ -420,13 +404,7 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, sg_init_one(&sg, buf, keylen); ahash_request_set_crypt(req, &sg, ctx->authkey, keylen); - ret = crypto_ahash_digest(req); - if (ret == -EINPROGRESS || ret == -EBUSY) { - ret = wait_for_completion_interruptible(&result.completion); - if (!ret) - ret = result.error; - } - + ret = crypto_wait_req(crypto_ahash_digest(req), &wait); if (ret) crypto_ahash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);