linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] crypto: caam: save caam memory to support crypto engine retry mechanism.
@ 2021-11-22 11:32 Gaurav Jain
  2021-11-23 17:10 ` Horia Geantă
  2021-12-03  5:06 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Gaurav Jain @ 2021-11-22 11:32 UTC (permalink / raw)
  To: Horia Geanta, Pankaj Gupta, Varun Sethi, Herbert Xu,
	David S . Miller, Iuliana Prodan
  Cc: linux-crypto, linux-kernel, linux-imx, Gaurav Jain

When caam queue is full (-ENOSPC), caam frees descriptor memory.
crypto-engine checks if retry support is true and h/w queue
is full(-ENOSPC), then requeue the crypto request.
During processing the requested descriptor again, caam gives below error.
(caam_jr 30902000.jr: 40000006: DECO: desc idx 0: Invalid KEY Command).

This patch adds a check to return when caam input ring is full
and retry support is true. so descriptor memory is not freed
and requeued request can be processed again.

Fixes: 2d653936eb2cf ("crypto: caam - enable crypto-engine retry mechanism")
Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/caam/caamalg.c  | 6 ++++++
 drivers/crypto/caam/caamhash.c | 3 +++
 drivers/crypto/caam/caampkc.c  | 3 +++
 3 files changed, 12 insertions(+)

diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index 8697ae53b063..d3d8bb0a6990 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -1533,6 +1533,9 @@ static int aead_do_one_req(struct crypto_engine *engine, void *areq)
 
 	ret = caam_jr_enqueue(ctx->jrdev, desc, aead_crypt_done, req);
 
+	if (ret == -ENOSPC && engine->retry_support)
+		return ret;
+
 	if (ret != -EINPROGRESS) {
 		aead_unmap(ctx->jrdev, rctx->edesc, req);
 		kfree(rctx->edesc);
@@ -1762,6 +1765,9 @@ static int skcipher_do_one_req(struct crypto_engine *engine, void *areq)
 
 	ret = caam_jr_enqueue(ctx->jrdev, desc, skcipher_crypt_done, req);
 
+	if (ret == -ENOSPC && engine->retry_support)
+		return ret;
+
 	if (ret != -EINPROGRESS) {
 		skcipher_unmap(ctx->jrdev, rctx->edesc, req);
 		kfree(rctx->edesc);
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index e8a6d8bc43b5..36ef738e4a18 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -765,6 +765,9 @@ static int ahash_do_one_req(struct crypto_engine *engine, void *areq)
 
 	ret = caam_jr_enqueue(jrdev, desc, state->ahash_op_done, req);
 
+	if (ret == -ENOSPC && engine->retry_support)
+		return ret;
+
 	if (ret != -EINPROGRESS) {
 		ahash_unmap(jrdev, state->edesc, req, 0);
 		kfree(state->edesc);
diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c
index bf6275ffc4aa..886727576710 100644
--- a/drivers/crypto/caam/caampkc.c
+++ b/drivers/crypto/caam/caampkc.c
@@ -380,6 +380,9 @@ static int akcipher_do_one_req(struct crypto_engine *engine, void *areq)
 
 	ret = caam_jr_enqueue(jrdev, desc, req_ctx->akcipher_op_done, req);
 
+	if (ret == -ENOSPC && engine->retry_support)
+		return ret;
+
 	if (ret != -EINPROGRESS) {
 		rsa_pub_unmap(jrdev, req_ctx->edesc, req);
 		rsa_io_unmap(jrdev, req_ctx->edesc, req);
-- 
2.25.1


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

* Re: [PATCH v2] crypto: caam: save caam memory to support crypto engine retry mechanism.
  2021-11-22 11:32 [PATCH v2] crypto: caam: save caam memory to support crypto engine retry mechanism Gaurav Jain
@ 2021-11-23 17:10 ` Horia Geantă
  2021-12-03  5:06 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Horia Geantă @ 2021-11-23 17:10 UTC (permalink / raw)
  To: Gaurav Jain, Pankaj Gupta, Varun Sethi, Herbert Xu,
	David S . Miller, Iuliana Prodan
  Cc: linux-crypto, linux-kernel, dl-linux-imx

On 11/22/2021 1:33 PM, Gaurav Jain wrote:
> When caam queue is full (-ENOSPC), caam frees descriptor memory.
> crypto-engine checks if retry support is true and h/w queue
> is full(-ENOSPC), then requeue the crypto request.
> During processing the requested descriptor again, caam gives below error.
> (caam_jr 30902000.jr: 40000006: DECO: desc idx 0: Invalid KEY Command).
> 
> This patch adds a check to return when caam input ring is full
> and retry support is true. so descriptor memory is not freed
> and requeued request can be processed again.
> 
> Fixes: 2d653936eb2cf ("crypto: caam - enable crypto-engine retry mechanism")
> Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>
> Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Again, please don't copy R-b tags from internal reviews.

I am fine with the patch.

Thanks,
Horia

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

* Re: [PATCH v2] crypto: caam: save caam memory to support crypto engine retry mechanism.
  2021-11-22 11:32 [PATCH v2] crypto: caam: save caam memory to support crypto engine retry mechanism Gaurav Jain
  2021-11-23 17:10 ` Horia Geantă
@ 2021-12-03  5:06 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2021-12-03  5:06 UTC (permalink / raw)
  To: Gaurav Jain
  Cc: Horia Geanta, Pankaj Gupta, Varun Sethi, David S . Miller,
	Iuliana Prodan, linux-crypto, linux-kernel, linux-imx

On Mon, Nov 22, 2021 at 05:02:34PM +0530, Gaurav Jain wrote:
> When caam queue is full (-ENOSPC), caam frees descriptor memory.
> crypto-engine checks if retry support is true and h/w queue
> is full(-ENOSPC), then requeue the crypto request.
> During processing the requested descriptor again, caam gives below error.
> (caam_jr 30902000.jr: 40000006: DECO: desc idx 0: Invalid KEY Command).
> 
> This patch adds a check to return when caam input ring is full
> and retry support is true. so descriptor memory is not freed
> and requeued request can be processed again.
> 
> Fixes: 2d653936eb2cf ("crypto: caam - enable crypto-engine retry mechanism")
> Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>
> Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
> ---
>  drivers/crypto/caam/caamalg.c  | 6 ++++++
>  drivers/crypto/caam/caamhash.c | 3 +++
>  drivers/crypto/caam/caampkc.c  | 3 +++
>  3 files changed, 12 insertions(+)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2021-12-03  5:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22 11:32 [PATCH v2] crypto: caam: save caam memory to support crypto engine retry mechanism Gaurav Jain
2021-11-23 17:10 ` Horia Geantă
2021-12-03  5:06 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).