mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chenghai Huang <huangchenghai2@huawei.com>
To: <herbert@gondor.apana.org.au>, <davem@davemloft.net>
Cc: <linux-kernel@vger.kernel.org>, <linux-crypto@vger.kernel.org>,
	<liulongfang@huawei.com>, <qianweili@huawei.com>,
	<wangzhou1@hisilicon.com>, <linwenkai6@hisilicon.com>
Subject: [PATCH 1/4] crypto: engine - clear busy and recheck running in the retry pump loop
Date: Mon, 9 Nov 2026 15:35:53 +0800	[thread overview]
Message-ID: <20261109073556.2517351-2-huangchenghai2@huawei.com> (raw)
In-Reply-To: <20261109073556.2517351-1-huangchenghai2@huawei.com>

The retry pump loop jumps back to the dequeue path directly, skipping
the idle check that clears engine->busy and rechecks engine->running.

When the loop drains the queue it exits with busy still set, and
crypto_transfer_request() queues a pump only when the engine is not
busy: if the loop ends with the inline error completion in req_err_1,
which queues no pump, the next request is enqueued with nothing to run
it and the engine queue stalls. crypto_engine_stop() also spins
waiting for the stale busy flag, up to failing with -EBUSY, and the
loop keeps submitting to hardware after stop was requested because it
never rechecks running.

Jump to the idle check instead: the loop now clears busy and exits
when the queue is empty, and stops submitting once the engine is no
longer running. Engines without retry support are unaffected.

Fixes: 6a89f492f8e5 ("crypto: engine - support for parallel requests based on retry mechanism")
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
 crypto/crypto_engine.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c
index 3d07dd5de4fa..5b669038acb4 100644
--- a/crypto/crypto_engine.c
+++ b/crypto/crypto_engine.c
@@ -82,6 +82,7 @@ static void crypto_pump_requests(struct crypto_engine *engine,
 	if (!engine->retry_support && engine->cur_req)
 		goto out;
 
+check_idle:
 	/* Check if the engine queue is idle */
 	if (!crypto_queue_len(&engine->queue) || !engine->running) {
 		if (!engine->busy)
@@ -98,7 +99,6 @@ static void crypto_pump_requests(struct crypto_engine *engine,
 		goto out;
 	}
 
-start_request:
 	/* Get the fist request from the engine queue to handle */
 	backlog = crypto_get_backlog(&engine->queue);
 	async_req = crypto_dequeue_request(&engine->queue);
@@ -161,7 +161,7 @@ static void crypto_pump_requests(struct crypto_engine *engine,
 	/* If retry mechanism is supported, send new requests to engine */
 	if (engine->retry_support) {
 		spin_lock_irqsave(&engine->queue_lock, flags);
-		goto start_request;
+		goto check_idle;
 	}
 	return;
 
-- 
2.43.0


  reply	other threads:[~2026-11-09  7:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09  7:35 [PATCH 0/4] crypto: engine - add acomp support and adapt Hisilicon HPRE and ZIP drivers Chenghai Huang
2026-11-09  7:35 ` Chenghai Huang [this message]
2026-11-09  7:35 ` [PATCH 2/4] crypto: engine - add acomp support Chenghai Huang
2026-11-09  7:35 ` [PATCH 3/4] crypto: hisilicon/hpre - use crypto engine framework Chenghai Huang
2026-11-09  7:35 ` [PATCH 4/4] crypto: hisilicon/zip - adapt to use crypto engine Chenghai Huang

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=20261109073556.2517351-2-huangchenghai2@huawei.com \
    --to=huangchenghai2@huawei.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linwenkai6@hisilicon.com \
    --cc=liulongfang@huawei.com \
    --cc=qianweili@huawei.com \
    --cc=wangzhou1@hisilicon.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®