All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: hisilicon/qm - implement for querying hardware tasks status.
@ 2021-06-18  9:36 Wenkai Lin
  2021-06-24  7:36 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Wenkai Lin @ 2021-06-18  9:36 UTC (permalink / raw)
  To: herbert, davem; +Cc: linux-kernel, linux-crypto, prime.zeng, wangzhou1

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>
---
 drivers/crypto/hisilicon/qm.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index 5807094..1d67f94 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -2926,6 +2926,23 @@ static void hisi_qm_uacce_stop_queue(struct uacce_queue *q)
 	hisi_qm_stop_qp(q->priv);
 }
 
+static int hisi_qm_is_q_updated(struct uacce_queue *q)
+{
+	struct hisi_qp *qp = q->priv;
+	struct qm_cqe *cqe = qp->cqe + qp->qp_status.cq_head;
+	int updated = 0;
+
+	while (QM_CQE_PHASE(cqe) == qp->qp_status.cqc_phase) {
+		/* make sure to read data from memory */
+		dma_rmb();
+		qm_cq_head_update(qp);
+		cqe = qp->cqe + qp->qp_status.cq_head;
+		updated = 1;
+	}
+
+	return updated;
+}
+
 static void qm_set_sqctype(struct uacce_queue *q, u16 type)
 {
 	struct hisi_qm *qm = q->uacce->priv;
@@ -2971,6 +2988,7 @@ static const struct uacce_ops uacce_qm_ops = {
 	.stop_queue = hisi_qm_uacce_stop_queue,
 	.mmap = hisi_qm_uacce_mmap,
 	.ioctl = hisi_qm_uacce_ioctl,
+	.is_q_updated = hisi_qm_is_q_updated,
 };
 
 static int qm_alloc_uacce(struct hisi_qm *qm)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: hisilicon/qm - implement for querying hardware tasks status.
  2021-06-18  9:36 [PATCH] crypto: hisilicon/qm - implement for querying hardware tasks status Wenkai Lin
@ 2021-06-24  7:36 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2021-06-24  7:36 UTC (permalink / raw)
  To: Wenkai Lin; +Cc: davem, linux-kernel, linux-crypto, prime.zeng, wangzhou1

On Fri, Jun 18, 2021 at 05:36:06PM +0800, Wenkai Lin wrote:
> 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>
> ---
>  drivers/crypto/hisilicon/qm.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-24  7:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18  9:36 [PATCH] crypto: hisilicon/qm - implement for querying hardware tasks status Wenkai Lin
2021-06-24  7:36 ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.