From patchwork Mon Aug 21 14:05: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: 110544 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1333637qge; Mon, 21 Aug 2017 07:09:46 -0700 (PDT) X-Received: by 10.84.209.232 with SMTP id y95mr13151819plh.426.1503324586133; Mon, 21 Aug 2017 07:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503324586; cv=none; d=google.com; s=arc-20160816; b=MH7fS/1i2MB1z0yUY2eJd1PXlWpuH9UR/aJ2qOwu8bGfSIeAo2t86TVD/ha9YP3DO2 TG6n9OEEh6GmCIZGEsbCL3lQlc/1rfc+A7OhTiY1CIpeR9r+xplzPIhULZBfedaLNrEQ XKrDf27hapOhjRvAXxyBnLKmzbODj0thRj7ApPyvqQg/qVboFUnUQly+G3zs0dR8k5lv rFoPHHNl1LNUpQYhFGOsJonHXGYk8JrAxdiH4+IldvVl2o3XkaigZqSiR4wg6ox+z3Bm RnB/OFhEsOi5B6r15EPFgXnNjqc1+V5ZqzJY8Dc5mPm7h2mWAuxWaXM31RAon0GdnAkP OYHw== 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=A7zELhOaEjZb/+lrLAbPp1vdePqcxK/3gRtFdVYfz7A=; b=b6ShjQz10rBOqhy+/zmwcqcJqlccp+ewLAvme/SoC6l2qkGsZ1h00meiaAbv8Uqgv+ 847ud2IM4kX0vFNo/mQ/pn2gc+EhJrkrwHyAulEI+raREoWd5p/Gc6m+AVJigV9WO1lC 0NL7eXCo2FV/EJENLZgztj4gEyLOZSinUD2u/GP5myRbhhbDILB6550j1Gmwu70fGf/G GOjwCfWNQ/a6zwuo9ypSC6UFpESG7hM+37sGWLSFEr8EmsxC43SF8y/nE3sLGEU396fy 4OXxIq9qeL5MtzaGDnBeTD3jQjSoIekAd2Gzqqs+2kWnXsKYebImOVExP9nrql9oHwQG gU+A== 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 s191si1108778pgc.236.2017.08.21.07.09.45; Mon, 21 Aug 2017 07:09:46 -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 S932091AbdHUOJn (ORCPT + 26 others); Mon, 21 Aug 2017 10:09:43 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:58574 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754453AbdHUOJi (ORCPT ); Mon, 21 Aug 2017 10:09:38 -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 F1C111B33; Mon, 21 Aug 2017 07:09:37 -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 C41C03F540; Mon, 21 Aug 2017 07:09:28 -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 v6 18/19] crypto: mediatek: move to generic async completion Date: Mon, 21 Aug 2017 17:05:04 +0300 Message-Id: <1503324309-13673-19-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1503324309-13673-1-git-send-email-gilad@benyossef.com> References: <1503324309-13673-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 mediatek 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 Acked-by: Ryder Lee --- drivers/crypto/mediatek/mtk-aes.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) -- 2.1.4 diff --git a/drivers/crypto/mediatek/mtk-aes.c b/drivers/crypto/mediatek/mtk-aes.c index 9e845e8..e2c7c95 100644 --- a/drivers/crypto/mediatek/mtk-aes.c +++ b/drivers/crypto/mediatek/mtk-aes.c @@ -137,11 +137,6 @@ struct mtk_aes_gcm_ctx { struct crypto_skcipher *ctr; }; -struct mtk_aes_gcm_setkey_result { - int err; - struct completion completion; -}; - struct mtk_aes_drv { struct list_head dev_list; /* Device list lock */ @@ -936,17 +931,6 @@ static int mtk_aes_gcm_crypt(struct aead_request *req, u64 mode) &req->base); } -static void mtk_gcm_setkey_done(struct crypto_async_request *req, int err) -{ - struct mtk_aes_gcm_setkey_result *result = req->data; - - if (err == -EINPROGRESS) - return; - - result->err = err; - complete(&result->completion); -} - /* * Because of the hardware limitation, we need to pre-calculate key(H) * for the GHASH operation. The result of the encryption operation @@ -962,7 +946,7 @@ static int mtk_aes_gcm_setkey(struct crypto_aead *aead, const u8 *key, u32 hash[4]; u8 iv[8]; - struct mtk_aes_gcm_setkey_result result; + struct crypto_wait wait; struct scatterlist sg[1]; struct skcipher_request req; @@ -1002,22 +986,17 @@ static int mtk_aes_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, AES_BLOCK_SIZE); skcipher_request_set_tfm(&data->req, ctr); skcipher_request_set_callback(&data->req, CRYPTO_TFM_REQ_MAY_SLEEP | CRYPTO_TFM_REQ_MAY_BACKLOG, - mtk_gcm_setkey_done, &data->result); + crypto_req_done, &data->wait); skcipher_request_set_crypt(&data->req, data->sg, data->sg, AES_BLOCK_SIZE, 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;