All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabio Estevam <fabio.estevam@nxp.com>
To: <herbert@gondor.apana.org.au>
Cc: <s.trumtrar@pengutronix.de>, <marex@denx.de>,
	<linux@arm.linux.org.uk>, <linux-crypto@vger.kernel.org>,
	Fabio Estevam <fabio.estevam@nxp.com>
Subject: [PATCH v3 2/3] crypto: sahara - avoid needlessly saving and restoring sahara_ctx
Date: Wed, 3 Feb 2016 10:46:51 -0200	[thread overview]
Message-ID: <1454503612-21344-2-git-send-email-fabio.estevam@nxp.com> (raw)
In-Reply-To: <1454503612-21344-1-git-send-email-fabio.estevam@nxp.com>

Based on commit 434b421241f2d0 ("crypto: caam - avoid needlessly saving and
restoring caam_hash_ctx") from Russell King.

When exporting and importing the hash state, we will only export and
import into hashes which share the same struct crypto_ahash pointer.
(See hash_accept->af_alg_accept->hash_accept_parent.)

This means that saving the sahara_ctx structure on export, and
restoring it on import is a waste of resources.  So, remove this code.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/crypto/sahara.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c
index 7e8147d..9db09b6 100644
--- a/drivers/crypto/sahara.c
+++ b/drivers/crypto/sahara.c
@@ -1162,26 +1162,18 @@ static int sahara_sha_digest(struct ahash_request *req)
 
 static int sahara_sha_export(struct ahash_request *req, void *out)
 {
-	struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
-	struct sahara_ctx *ctx = crypto_ahash_ctx(ahash);
 	struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);
 
-	memcpy(out, ctx, sizeof(struct sahara_ctx));
-	memcpy(out + sizeof(struct sahara_sha_reqctx), rctx,
-	       sizeof(struct sahara_sha_reqctx));
+	memcpy(out, rctx, sizeof(struct sahara_sha_reqctx));
 
 	return 0;
 }
 
 static int sahara_sha_import(struct ahash_request *req, const void *in)
 {
-	struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
-	struct sahara_ctx *ctx = crypto_ahash_ctx(ahash);
 	struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);
 
-	memcpy(ctx, in, sizeof(struct sahara_ctx));
-	memcpy(rctx, in + sizeof(struct sahara_sha_reqctx),
-	       sizeof(struct sahara_sha_reqctx));
+	memcpy(rctx, in, sizeof(struct sahara_sha_reqctx));
 
 	return 0;
 }
-- 
1.9.1

  reply	other threads:[~2016-02-03 13:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-03 12:46 [PATCH v3 1/3] crypto: sahara - remove unneeded mutex in the exported state Fabio Estevam
2016-02-03 12:46 ` Fabio Estevam [this message]
2016-02-03 12:46 ` [PATCH v3 3/3] crypto: sahara - fill the statesize field Fabio Estevam
2016-02-06  7:48 ` [PATCH v3 1/3] crypto: sahara - remove unneeded mutex in the exported state Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454503612-21344-2-git-send-email-fabio.estevam@nxp.com \
    --to=fabio.estevam@nxp.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=marex@denx.de \
    --cc=s.trumtrar@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.