All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] crypto: sahara - avoid needlessly saving and restoring sahara_ctx
@ 2016-01-13 17:52 Fabio Estevam
  2016-01-13 17:52 ` [PATCH v2 2/3] crypto: sahara - fill the statesize field Fabio Estevam
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Fabio Estevam @ 2016-01-13 17:52 UTC (permalink / raw)
  To: herbert
  Cc: marex, s.trumtrar, thomas.lendacky, linux, linux-crypto, Fabio Estevam

From: Fabio Estevam <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>
---
Changes since v1:
- Newly introduced in this series

 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 f68c24a..53c7a9a 100644
--- a/drivers/crypto/sahara.c
+++ b/drivers/crypto/sahara.c
@@ -1155,26 +1155,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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-02-03 11:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-13 17:52 [PATCH v2 1/3] crypto: sahara - avoid needlessly saving and restoring sahara_ctx Fabio Estevam
2016-01-13 17:52 ` [PATCH v2 2/3] crypto: sahara - fill the statesize field Fabio Estevam
2016-01-13 17:52 ` [PATCH v2 3/3] crypto: mxs-dcp - provide statesize and import/export() Fabio Estevam
2016-01-25 14:10   ` Herbert Xu
2016-01-25 14:07 ` [PATCH v2 1/3] crypto: sahara - avoid needlessly saving and restoring sahara_ctx Herbert Xu
2016-02-02 13:41   ` Fabio Estevam
2016-02-02 14:43     ` Herbert Xu
2016-02-02 17:18       ` Fabio Estevam
2016-02-03 11:22         ` Herbert Xu

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.