From patchwork Thu Jun 15 07:56:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Tenart X-Patchwork-Id: 9788265 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 12411602CB for ; Thu, 15 Jun 2017 08:00:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03ED427F88 for ; Thu, 15 Jun 2017 08:00:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBAA5283FD; Thu, 15 Jun 2017 08:00:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 988B027F88 for ; Thu, 15 Jun 2017 08:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752402AbdFOIAH (ORCPT ); Thu, 15 Jun 2017 04:00:07 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:53416 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752120AbdFOIAG (ORCPT ); Thu, 15 Jun 2017 04:00:06 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id BB44921E5A; Thu, 15 Jun 2017 10:00:04 +0200 (CEST) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 936EF21E42; Thu, 15 Jun 2017 10:00:04 +0200 (CEST) From: Antoine Tenart To: herbert@gondor.apana.org.au, davem@davemloft.net Cc: Antoine Tenart , thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, oferh@marvell.com, igall@marvell.com, nadavh@marvell.com, linux-crypto@vger.kernel.org Subject: [PATCH 07/13] crypto: inside-secure - update the context and request later Date: Thu, 15 Jun 2017 09:56:23 +0200 Message-Id: <20170615075629.30907-8-antoine.tenart@free-electrons.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170615075629.30907-1-antoine.tenart@free-electrons.com> References: <20170615075629.30907-1-antoine.tenart@free-electrons.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This move the context and request updates at the end of the cipher and hash send() functions. This way the context and request fields are set only when everything else was successful in the send() functions. Signed-off-by: Antoine Tenart --- drivers/crypto/inside-secure/safexcel_cipher.c | 7 +++---- drivers/crypto/inside-secure/safexcel_hash.c | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c index 8eea4d30db31..6037cdfc1f16 100644 --- a/drivers/crypto/inside-secure/safexcel_cipher.c +++ b/drivers/crypto/inside-secure/safexcel_cipher.c @@ -190,8 +190,6 @@ static int safexcel_aes_send(struct crypto_async_request *async, int nr_src, nr_dst, n_cdesc = 0, n_rdesc = 0, queued = req->cryptlen; int i, ret = 0; - request->req = &req->base; - if (req->src == req->dst) { nr_src = dma_map_sg(priv->dev, req->src, sg_nents_for_len(req->src, req->cryptlen), @@ -264,10 +262,11 @@ static int safexcel_aes_send(struct crypto_async_request *async, n_rdesc++; } - ctx->base.handle_result = safexcel_handle_result; - spin_unlock_bh(&priv->ring[ring].egress_lock); + request->req = &req->base; + ctx->base.handle_result = safexcel_handle_result; + *commands = n_cdesc; *results = n_rdesc; return 0; diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c index 6eee1a502225..4e526372464f 100644 --- a/drivers/crypto/inside-secure/safexcel_hash.c +++ b/drivers/crypto/inside-secure/safexcel_hash.c @@ -198,9 +198,6 @@ static int safexcel_ahash_send(struct crypto_async_request *async, int ring, len -= extra; } - request->req = &areq->base; - ctx->base.handle_result = safexcel_handle_result; - spin_lock_bh(&priv->ring[ring].egress_lock); /* Add a command descriptor for the cached data, if any */ @@ -291,9 +288,12 @@ static int safexcel_ahash_send(struct crypto_async_request *async, int ring, goto cdesc_rollback; } - req->processed += len; spin_unlock_bh(&priv->ring[ring].egress_lock); + req->processed += len; + request->req = &areq->base; + ctx->base.handle_result = safexcel_handle_result; + *commands = n_cdesc; *results = 1; return 0;