Skip to content

Commit d18344c

Browse files
lin755herbertx
authored andcommitted
crypto: hisilicon/qm - implement for querying hardware tasks status.
This patch adds a function hisi_qm_is_q_updated to check if the task is ready in hardware queue when user polls an UACCE queue.This prevents users from repeatedly querying whether the accelerator has completed tasks, which wastes CPU resources. Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent cac6f1b commit d18344c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • drivers/crypto/hisilicon

drivers/crypto/hisilicon/qm.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2926,6 +2926,23 @@ static void hisi_qm_uacce_stop_queue(struct uacce_queue *q)
29262926
hisi_qm_stop_qp(q->priv);
29272927
}
29282928

2929+
static int hisi_qm_is_q_updated(struct uacce_queue *q)
2930+
{
2931+
struct hisi_qp *qp = q->priv;
2932+
struct qm_cqe *cqe = qp->cqe + qp->qp_status.cq_head;
2933+
int updated = 0;
2934+
2935+
while (QM_CQE_PHASE(cqe) == qp->qp_status.cqc_phase) {
2936+
/* make sure to read data from memory */
2937+
dma_rmb();
2938+
qm_cq_head_update(qp);
2939+
cqe = qp->cqe + qp->qp_status.cq_head;
2940+
updated = 1;
2941+
}
2942+
2943+
return updated;
2944+
}
2945+
29292946
static void qm_set_sqctype(struct uacce_queue *q, u16 type)
29302947
{
29312948
struct hisi_qm *qm = q->uacce->priv;
@@ -2971,6 +2988,7 @@ static const struct uacce_ops uacce_qm_ops = {
29712988
.stop_queue = hisi_qm_uacce_stop_queue,
29722989
.mmap = hisi_qm_uacce_mmap,
29732990
.ioctl = hisi_qm_uacce_ioctl,
2991+
.is_q_updated = hisi_qm_is_q_updated,
29742992
};
29752993

29762994
static int qm_alloc_uacce(struct hisi_qm *qm)

0 commit comments

Comments
 (0)