[PATCH 02/11] crypto: ccp - acknowledge queue interrupt before waking waiter

From: Depei Yang

Date: Wed Nov 25 2026 - 02:46:47 EST


ccp5_irq_bh() and ccp_irq_bh() set int_rcvd before writing the interrupt
status back to the device. A waiting queue thread can then start the
next command before the previous completion has been acknowledged; the
stale write-back clears the new completion bit as well, and the thread
waits for an interrupt that will never be raised again. The wait has no
timeout, so the queue stays stuck.

Acknowledge the interrupt before making int_rcvd visible. The v5 handler
was observed to wedge a queue thread under concurrent crypto load; the
v3 handler uses the same ordering and gets the same treatment.

Fixes: 4b394a232df7 ("crypto: ccp - Let a v5 CCP provide the same function as v3")
Fixes: 63b945091a07 ("crypto: ccp - CCP device driver and interface support")
Cc: stable@xxxxxxxxxxxxxxx
Reviewed-by: Shan Chen <chenshan@xxxxxxxx>
Tested-by: Yongwei Xu <xuyongwei@xxxxxxxx>
Signed-off-by: Depei Yang <yangdepei@xxxxxxxx>
---
drivers/crypto/ccp/ccp-dev-v3.c | 9 ++++++---
drivers/crypto/ccp/ccp-dev-v5.c | 9 ++++++---
2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-dev-v3.c b/drivers/crypto/ccp/ccp-dev-v3.c
index d92de4ad31ac..02f7575e8f9b 100644
--- a/drivers/crypto/ccp/ccp-dev-v3.c
+++ b/drivers/crypto/ccp/ccp-dev-v3.c
@@ -343,10 +343,13 @@ static void ccp_irq_bh(unsigned long data)
if ((q_int & cmd_q->int_err) && !cmd_q->cmd_error)
cmd_q->cmd_error = CMD_Q_ERROR(cmd_q->q_status);

- cmd_q->int_rcvd = 1;
-
- /* Acknowledge the interrupt and wake the kthread */
+ /*
+ * Acknowledge the interrupt before waking the kthread,
+ * otherwise a fast waiter can start a new command while
+ * the old interrupt is still pending.
+ */
iowrite32(q_int, ccp->io_regs + IRQ_STATUS_REG);
+ cmd_q->int_rcvd = 1;
wake_up_interruptible(&cmd_q->int_queue);
}
}
diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
index 4a546224af79..bf76743845e3 100644
--- a/drivers/crypto/ccp/ccp-dev-v5.c
+++ b/drivers/crypto/ccp/ccp-dev-v5.c
@@ -754,10 +754,13 @@ static void ccp5_irq_bh(unsigned long data)
if ((status & INT_ERROR) && !cmd_q->cmd_error)
cmd_q->cmd_error = CMD_Q_ERROR(cmd_q->q_status);

- cmd_q->int_rcvd = 1;
-
- /* Acknowledge the interrupt and wake the kthread */
+ /*
+ * Acknowledge the interrupt before waking the kthread,
+ * otherwise a fast waiter can start a new command while
+ * the old interrupt is still pending.
+ */
iowrite32(status, cmd_q->reg_interrupt_status);
+ cmd_q->int_rcvd = 1;
wake_up_interruptible(&cmd_q->int_queue);
}
}
--
2.34.1