From patchwork Sun Oct 15 09:20: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: 115878 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2530780qgn; Sun, 15 Oct 2017 02:25:49 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDQFFuk9RQGY2+d2vCks5PM/mpvWOXF7BRnj7cUkQCqUBI/Yk8D5JVDMr/A3xARkzlaPdFd X-Received: by 10.84.218.14 with SMTP id q14mr6127109pli.111.1508059549510; Sun, 15 Oct 2017 02:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508059549; cv=none; d=google.com; s=arc-20160816; b=QrzNm71iStGwZKhdvU6upHcuNDo01SsGrb9o4RDL462It1bx7dBls40nbPEM+oBELx ZiQei8oqUDaR+RngzEt3UViGxZwhfN72JdBJhF30m2c/uanGsa0xMhV5PqIJDuuTtVwe DreLrXB4LhJM1cyoVQALmsSzJlNGamuoHvJtOvCOM8OXUDvAdhkMC3NQ5Oj88G4gj2WS Kkrz5xTI4TD1af2OQS/g22z0nERW5CGGW/h6Prq6lYizGD2p55aJbiQsHYMgp60xerQ+ EsZslXJ1InMLBtMNOyJ03FM08ixoPJ8BcDhsooqGnyAFkPjlLJ9MDSNuhqiye4wal8cg OcBA== 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=Ux8kW1Be35okv7ZpIihY85HrHpN1sgkI6gJXZ907llg=; b=IpCLMi7mtbqKLa/Ku5GcUV/mUY27mtw+OGqWFZTD3qYMSmc9zypgMEK2Lx2zWI9PJe QEAfEfrWLQBAd9R/QYSA7RyBpnaHhHegqCPpB6yc4bmRVXAm/EhfPVUef/0s+Gr6vwJp WOrf6o5ibQtlzaShYKkoKJwwA9pfPsGp9y4PVbslLqw+k1I6Otb3cDNuP+7D2GvlSp3Y IYaEelB/d55TpFWsA1rVzmV4h09GncI0uqcFRwwiUXcyym6Vk2gO6E7eusVcIpKgmSh2 R1IEBPpGxzEX9iH6DPbDjLJCY92YcwJZr5t8xTkniFImMGrRBXzPS9/5RIarmKGzwDfv gmtA== 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 m63si2807607pld.93.2017.10.15.02.25.49; Sun, 15 Oct 2017 02:25:49 -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 S1752999AbdJOJZs (ORCPT + 27 others); Sun, 15 Oct 2017 05:25:48 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:48168 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752951AbdJOJZn (ORCPT ); Sun, 15 Oct 2017 05:25:43 -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 90B771AFA; Sun, 15 Oct 2017 02:25:42 -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 501073F3E1; Sun, 15 Oct 2017 02:25:34 -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 19/20] crypto: mediatek: move to generic async completion Date: Sun, 15 Oct 2017 10:20:04 +0100 Message-Id: <1508059209-25529-20-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 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.7.4 diff --git a/drivers/crypto/mediatek/mtk-aes.c b/drivers/crypto/mediatek/mtk-aes.c index 32aa587..c2058cf 100644 --- a/drivers/crypto/mediatek/mtk-aes.c +++ b/drivers/crypto/mediatek/mtk-aes.c @@ -138,11 +138,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 */ @@ -942,17 +937,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 @@ -968,7 +952,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; @@ -1008,22 +992,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;