Linux-Crypto Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] crypto: engine - do not requeue in case of fatal error
@ 2020-05-19 22:17 Iuliana Prodan
  2020-05-20  8:17 ` Horia Geantă
  2020-05-28  7:34 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Iuliana Prodan @ 2020-05-19 22:17 UTC (permalink / raw)
  To: Herbert Xu, Baolin Wang, Ard Biesheuvel, Horia Geanta
  Cc: Aymen Sghaier, David S. Miller, linux-crypto, linux-kernel,
	linux-imx, Iuliana Prodan

Now, in crypto-engine, if hardware queue is full (-ENOSPC),
requeue request regardless of MAY_BACKLOG flag.
If hardware throws any other error code (like -EIO, -EINVAL,
-ENOMEM, etc.) only MAY_BACKLOG requests are enqueued back into
crypto-engine's queue, since the others can be dropped.
The latter case can be fatal error, so those cannot be recovered from.
For example, in CAAM driver, -EIO is returned in case the job descriptor
is broken, so there is no possibility to fix the job descriptor.
Therefore, these errors might be fatal error, so we shouldn’t
requeue the request. This will just be pass back and forth between
crypto-engine and hardware.

Fixes: 6a89f492f8e5 ("crypto: engine - support for parallel requests based on retry mechanism")
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
---
 crypto/crypto_engine.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c
index 412149e..3655d9d 100644
--- a/crypto/crypto_engine.c
+++ b/crypto/crypto_engine.c
@@ -169,13 +169,10 @@ static void crypto_pump_requests(struct crypto_engine *engine,
 		/*
 		 * If hardware queue is full (-ENOSPC), requeue request
 		 * regardless of backlog flag.
-		 * If hardware throws any other error code,
-		 * requeue only backlog requests.
 		 * Otherwise, unprepare and complete the request.
 		 */
 		if (!engine->retry_support ||
-		    ((ret != -ENOSPC) &&
-		    !(async_req->flags & CRYPTO_TFM_REQ_MAY_BACKLOG))) {
+		    (ret != -ENOSPC)) {
 			dev_err(engine->dev,
 				"Failed to do one request from queue: %d\n",
 				ret);
-- 
2.1.0


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

* Re: [PATCH] crypto: engine - do not requeue in case of fatal error
  2020-05-19 22:17 [PATCH] crypto: engine - do not requeue in case of fatal error Iuliana Prodan
@ 2020-05-20  8:17 ` Horia Geantă
  2020-05-28  7:34 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Horia Geantă @ 2020-05-20  8:17 UTC (permalink / raw)
  To: Iuliana Prodan, Herbert Xu, Baolin Wang, Ard Biesheuvel
  Cc: Aymen Sghaier, David S. Miller, linux-crypto, linux-kernel, dl-linux-imx

On 5/20/2020 1:17 AM, Iuliana Prodan wrote:
> Now, in crypto-engine, if hardware queue is full (-ENOSPC),
> requeue request regardless of MAY_BACKLOG flag.
> If hardware throws any other error code (like -EIO, -EINVAL,
> -ENOMEM, etc.) only MAY_BACKLOG requests are enqueued back into
> crypto-engine's queue, since the others can be dropped.
> The latter case can be fatal error, so those cannot be recovered from.
> For example, in CAAM driver, -EIO is returned in case the job descriptor
> is broken, so there is no possibility to fix the job descriptor.
> Therefore, these errors might be fatal error, so we shouldn’t
> requeue the request. This will just be pass back and forth between
> crypto-engine and hardware.
> 
> Fixes: 6a89f492f8e5 ("crypto: engine - support for parallel requests based on retry mechanism")
> Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Reported-by: Horia Geantă <horia.geanta@nxp.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>

Thanks,
Horia

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

* Re: [PATCH] crypto: engine - do not requeue in case of fatal error
  2020-05-19 22:17 [PATCH] crypto: engine - do not requeue in case of fatal error Iuliana Prodan
  2020-05-20  8:17 ` Horia Geantă
@ 2020-05-28  7:34 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2020-05-28  7:34 UTC (permalink / raw)
  To: Iuliana Prodan
  Cc: Baolin Wang, Ard Biesheuvel, Horia Geanta, Aymen Sghaier,
	David S. Miller, linux-crypto, linux-kernel, linux-imx

On Wed, May 20, 2020 at 01:17:25AM +0300, Iuliana Prodan wrote:
> Now, in crypto-engine, if hardware queue is full (-ENOSPC),
> requeue request regardless of MAY_BACKLOG flag.
> If hardware throws any other error code (like -EIO, -EINVAL,
> -ENOMEM, etc.) only MAY_BACKLOG requests are enqueued back into
> crypto-engine's queue, since the others can be dropped.
> The latter case can be fatal error, so those cannot be recovered from.
> For example, in CAAM driver, -EIO is returned in case the job descriptor
> is broken, so there is no possibility to fix the job descriptor.
> Therefore, these errors might be fatal error, so we shouldn’t
> requeue the request. This will just be pass back and forth between
> crypto-engine and hardware.
> 
> Fixes: 6a89f492f8e5 ("crypto: engine - support for parallel requests based on retry mechanism")
> Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
> ---
>  crypto/crypto_engine.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)

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, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-19 22:17 [PATCH] crypto: engine - do not requeue in case of fatal error Iuliana Prodan
2020-05-20  8:17 ` Horia Geantă
2020-05-28  7:34 ` Herbert Xu

Linux-Crypto Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-crypto/0 linux-crypto/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-crypto linux-crypto/ https://lore.kernel.org/linux-crypto \
		linux-crypto@vger.kernel.org
	public-inbox-index linux-crypto

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-crypto


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git