[PATCH v14 1/2] crypto: qce - keep the device resumed until the request completes
From: Bartosz Golaszewski
Date: Tue Dec 01 2026 - 11:07:19 EST
qce_handle_queue() only holds a runtime PM reference until it returns but
the request completes later from the DMA callback. Autosuspend can then
turn off the clocks and drop the interconnect vote while the transfer is
still in flight.
Take the reference before dispatching the request and release it in
qce_async_request_done() or on dispatch failure.
Cc: stable@xxxxxxxxxxxxxxx
Fixes: 6f5569203bb6 ("crypto: qce - Add runtime PM and interconnect bandwidth scaling support")
Tested-by: Kuldeep Singh <kuldeep.singh@xxxxxxxxxxxxxxxx>
Tested-by: Pankaj Patil <pankaj.patil@xxxxxxxxxxxxxxxx>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
---
drivers/crypto/qce/core.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c
index ddb4df3d227f801e566422491b488c5fcb777717..204e330f530946988b831201c2165b8420f73ee1 100644
--- a/drivers/crypto/qce/core.c
+++ b/drivers/crypto/qce/core.c
@@ -92,12 +92,7 @@ static int qce_handle_queue(struct qce_device *qce,
struct crypto_async_request *req)
{
struct crypto_async_request *async_req, *backlog;
- int ret, err;
-
- PM_RUNTIME_ACQUIRE_AUTOSUSPEND(qce->dev, pm);
- ret = PM_RUNTIME_ACQUIRE_ERR(&pm);
- if (ret)
- return ret;
+ int ret = 0, err;
scoped_guard(mutex, &qce->lock) {
if (req)
@@ -121,8 +116,21 @@ static int qce_handle_queue(struct qce_device *qce,
crypto_request_complete(backlog, -EINPROGRESS);
}
+ /*
+ * The request completes asynchronously in qce_async_request_done().
+ * Keep the device resumed until then, or autosuspend could gate the
+ * engine clocks while the DMA is still in flight.
+ */
+ err = pm_runtime_resume_and_get(qce->dev);
+ if (err) {
+ qce->result = err;
+ schedule_work(&qce->done_work);
+ return ret;
+ }
+
err = qce_handle_request(async_req);
if (err) {
+ pm_runtime_put_autosuspend(qce->dev);
qce->result = err;
schedule_work(&qce->done_work);
}
@@ -155,6 +163,7 @@ static int qce_async_request_enqueue(struct qce_device *qce,
static void qce_async_request_done(struct qce_device *qce, int ret)
{
+ pm_runtime_put_autosuspend(qce->dev);
qce->result = ret;
schedule_work(&qce->done_work);
}
--
2.47.3