From: Depei Yang <yangdepei@hygon.cn>
To: <linux-crypto@vger.kernel.org>
Cc: Tom Lendacky <thomas.lendacky@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Gary R Hook <gary.hook@amd.com>, <linux-kernel@vger.kernel.org>,
Depei Yang <yangdepei@hygon.cn>, Shan Chen <chenshan@hygon.cn>,
Yongwei Xu <xuyongwei@hygon.cn>,
Xiaochen Shen <shenxiaochen@hygon.cn>
Subject: [PATCH 05/11] crypto: ccp - split v5 command submission from queue run
Date: Wed, 25 Nov 2026 15:46:03 +0800 [thread overview]
Message-ID: <c2a7b7a4303dfd79e95a61658b33706a20bc58ad.1795588986.git.yangdepei@hygon.cn> (raw)
In-Reply-To: <cover.1795588986.git.yangdepei@hygon.cn>
ccp5_do_cmd() copies one descriptor into the ring and immediately runs
the queue and waits for the completion. Some engines prepare several
descriptors for a single operation and only need the queue run once.
Split the descriptor copy from running the queue. ccp5_do_cmd() keeps
its behaviour by calling both helpers back to back; the SM engines will
run the queue through the new ->run action once a whole batch has been
submitted.
Reviewed-by: Shan Chen <chenshan@hygon.cn>
Tested-by: Yongwei Xu <xuyongwei@hygon.cn>
Signed-off-by: Depei Yang <yangdepei@hygon.cn>
---
drivers/crypto/ccp/ccp-dev-v5.c | 38 ++++++++++++++++++++++++++-------
drivers/crypto/ccp/ccp-dev.h | 1 +
2 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
index 372ccf7d1c8b..f7c107b93ccc 100644
--- a/drivers/crypto/ccp/ccp-dev-v5.c
+++ b/drivers/crypto/ccp/ccp-dev-v5.c
@@ -218,14 +218,12 @@ static unsigned int ccp5_get_free_slots(struct ccp_cmd_queue *cmd_q)
return n % COMMANDS_PER_QUEUE; /* Always one unused spot */
}
-static int ccp5_do_cmd(struct ccp5_desc *desc,
- struct ccp_cmd_queue *cmd_q)
+static void ccp5_submit_cmd(struct ccp5_desc *desc,
+ struct ccp_cmd_queue *cmd_q)
{
__le32 *mP;
u32 *dP;
- u32 tail;
- int i;
- int ret = 0;
+ int i;
cmd_q->total_ops++;
@@ -233,6 +231,7 @@ static int ccp5_do_cmd(struct ccp5_desc *desc,
CCP5_CMD_IOC(desc) = 1;
CCP5_CMD_SOC(desc) = 0;
}
+
mutex_lock(&cmd_q->q_mutex);
mP = (__le32 *)&cmd_q->qbase[cmd_q->qidx];
@@ -242,6 +241,16 @@ static int ccp5_do_cmd(struct ccp5_desc *desc,
cmd_q->qidx = (cmd_q->qidx + 1) % COMMANDS_PER_QUEUE;
+ mutex_unlock(&cmd_q->q_mutex);
+}
+
+static int ccp5_run_queue(struct ccp_cmd_queue *cmd_q, bool wait)
+{
+ u32 tail;
+ int ret = 0;
+
+ mutex_lock(&cmd_q->q_mutex);
+
/* The data used by this command must be flushed to memory */
wmb();
@@ -253,7 +262,7 @@ static int ccp5_do_cmd(struct ccp5_desc *desc,
iowrite32(cmd_q->qcontrol | CMD5_Q_RUN, cmd_q->reg_control);
mutex_unlock(&cmd_q->q_mutex);
- if (CCP5_CMD_IOC(desc)) {
+ if (wait) {
/* Wait for the job to complete */
ret = wait_event_interruptible(cmd_q->int_queue,
cmd_q->int_rcvd);
@@ -262,8 +271,7 @@ static int ccp5_do_cmd(struct ccp5_desc *desc,
* moving the head pointer
*/
if (cmd_q->cmd_error)
- ccp_log_error(cmd_q->ccp,
- cmd_q->cmd_error);
+ ccp_log_error(cmd_q->ccp, cmd_q->cmd_error);
iowrite32(tail, cmd_q->reg_head_lo);
if (!ret)
ret = -EIO;
@@ -274,6 +282,19 @@ static int ccp5_do_cmd(struct ccp5_desc *desc,
return ret;
}
+static int ccp5_run_cmd(struct ccp_op *op)
+{
+ return ccp5_run_queue(op->cmd_q, op->ioc);
+}
+
+static int ccp5_do_cmd(struct ccp5_desc *desc,
+ struct ccp_cmd_queue *cmd_q)
+{
+ ccp5_submit_cmd(desc, cmd_q);
+
+ return ccp5_run_queue(cmd_q, CCP5_CMD_IOC(desc));
+}
+
static int ccp5_perform_aes(struct ccp_op *op)
{
struct ccp5_desc desc;
@@ -1111,6 +1132,7 @@ static const struct ccp_actions ccp5_actions = {
.rsa = ccp5_perform_rsa,
.passthru = ccp5_perform_passthru,
.ecc = ccp5_perform_ecc,
+ .run = ccp5_run_cmd,
.sballoc = ccp_lsb_alloc,
.sbfree = ccp_lsb_free,
.init = ccp5_init,
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index ef88962ff6e6..16d5ea7773e2 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -659,6 +659,7 @@ struct ccp_actions {
int (*rsa)(struct ccp_op *);
int (*passthru)(struct ccp_op *);
int (*ecc)(struct ccp_op *);
+ int (*run)(struct ccp_op *op);
u32 (*sballoc)(struct ccp_cmd_queue *, unsigned int);
void (*sbfree)(struct ccp_cmd_queue *, unsigned int, unsigned int);
unsigned int (*get_free_slots)(struct ccp_cmd_queue *);
--
2.34.1
next prev parent reply other threads:[~2026-11-25 7:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 7:45 [PATCH 00/11] crypto: ccp - add Hygon SM3/SM4 support Depei Yang
2026-11-25 7:45 ` [PATCH 01/11] crypto: ccp - fix LSB region mask calculation Depei Yang
2026-11-25 7:46 ` [PATCH 02/11] crypto: ccp - acknowledge queue interrupt before waking waiter Depei Yang
2026-11-25 7:46 ` [PATCH 03/11] crypto: ccp - add engine capability and version information Depei Yang
2026-11-25 7:46 ` [PATCH 04/11] crypto: ccp - register algorithms only for supported engines Depei Yang
2026-11-25 7:46 ` Depei Yang [this message]
2026-11-25 7:46 ` [PATCH 06/11] crypto: ccp - add SM3/SM4 command definitions Depei Yang
2026-11-25 7:46 ` [PATCH 07/11] crypto: ccp - add Hygon CCP device IDs and vdata Depei Yang
2026-11-25 7:46 ` [PATCH 08/11] crypto: ccp - handle only supported interrupts in v5 irq bh Depei Yang
2026-11-25 7:46 ` [PATCH 09/11] crypto: ccp - detect the Hygon CCP engines from the version register Depei Yang
2026-11-25 7:46 ` [PATCH 10/11] crypto: ccp - add SM4 engine and skcipher algorithms Depei Yang
2026-11-25 7:46 ` [PATCH 11/11] crypto: ccp - add SM3 engine and ahash algorithms Depei Yang
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=c2a7b7a4303dfd79e95a61658b33706a20bc58ad.1795588986.git.yangdepei@hygon.cn \
--to=yangdepei@hygon.cn \
--cc=chenshan@hygon.cn \
--cc=davem@davemloft.net \
--cc=gary.hook@amd.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shenxiaochen@hygon.cn \
--cc=thomas.lendacky@amd.com \
--cc=xuyongwei@hygon.cn \
/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®