From patchwork Sun Oct 15 09:20:03 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: 115877 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2530607qgn; Sun, 15 Oct 2017 02:25:34 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TLY6j1vOr/7rtC2XPiXgSSOdp1sKcvgjz6MFPfx9XHdBFtOtyNhO9EVk+3RAAnimqOjwTd X-Received: by 10.98.75.77 with SMTP id y74mr2031263pfa.78.1508059534383; Sun, 15 Oct 2017 02:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508059534; cv=none; d=google.com; s=arc-20160816; b=oSKMWcb12mJDEHJ9uwYzqoeyQ8I3aK5lCwfSqEhKUWZ78uZ1lak5Frmm7UCKBCD2uE +NxLOrHvA8LfDmDSHthOHUgXERJIX9H0+Fsrs6PbYSnb0ij0b80ZPkfgcBqHDFbxwpXT rqcZFJPPZ35wcnFbIPR5+f9hxuvk95G47QMIIz+E5ArPJkFEEY43KNBtIufFl8sv+P25 lKKJajIcfQNkUmKwxxYHJe2I4yYMEez0OBRQwcq0gld06YEtjojHAy4lTn77CCYEdlq1 sp9ocwErH/4Y6weBvPLp5zFu2bpHP94LYxwHl1mxA7SkbUkdmKbAxl1kWHJ/F8cAzwCO LHNg== 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=qMMe51WYIxsnTlBJLya4v4/BwQ/aJkvc/8TOHu3rvN4=; b=zGGH2R/vlniYgUwsMWJOfHn+ejHcnLxjai9fCJ6mh07I8KfAT3n6GWg0g0uDtewle3 T0JnUxQuSDY+oU2kZanGLa5I3H6ISIOZFQz0h2o1K4uiz9deLXFQvlrCXOsU9gGiIlif yDxIKfzWMHGV4zJILtnfSZPpW/RuH/lPrD89X+crDl+R5i9IurA/n/bKYF3j6kOgEaHg RD/uh3iuCszoV5ug+C3nLGCt1hJk/xDrj5W/1k9CvgwxTBfE3gLgUu5bhadhiIAMy+yy 8/x/6OKw5KtyfFx0aXL4leCc0kg8IRblEo2KMS8Bq933mWNl07QN1BNUWkjnXDdBwsvS 5QEg== 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 o14si2753352pgr.430.2017.10.15.02.25.34; Sun, 15 Oct 2017 02:25:34 -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 S1752945AbdJOJZc (ORCPT + 27 others); Sun, 15 Oct 2017 05:25:32 -0400 Received: from foss.arm.com ([217.140.101.70]:48114 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752617AbdJOJZ2 (ORCPT ); Sun, 15 Oct 2017 05:25:28 -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 CB8D31AD7; Sun, 15 Oct 2017 02:25:27 -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 BCFD93F3E1; Sun, 15 Oct 2017 02:25: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, 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 v9 18/20] crypto: qce: move to generic async completion Date: Sun, 15 Oct 2017 10:20:03 +0100 Message-Id: <1508059209-25529-19-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508059209-25529-1-git-send-email-gilad@benyossef.com> References: <1508059209-25529-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.7.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);