From: Yajun Wu <yajunw@nvidia.com>
To: <matan@nvidia.com>, <maxime.coquelin@redhat.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Cc: <dev@dpdk.org>, <thomas@monjalon.net>, <mkashani@nvidia.com>,
<stable@dpdk.org>
Subject: [PATCH] vdpa/mlx5: fix queue enable drain CQ
Date: Thu, 25 Jan 2024 11:17:55 +0800 [thread overview]
Message-ID: <20240125031755.657102-1-yajunw@nvidia.com> (raw)
For the case: `ethtool -L eth0 combined xxx` in VM, VQ will disable
and enable without calling device close. In such case, need add
drain CQ before reuse/reset event QP.
Fixes: 24969c7b62 ("vdpa/mlx5: reuse event queues")
Cc: stable@dpdk.org
Signed-off-by: Yajun Wu <yajunw@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/vdpa/mlx5/mlx5_vdpa_event.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
index 9557c1042e..32430614d5 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
@@ -244,22 +244,30 @@ mlx5_vdpa_queues_complete(struct mlx5_vdpa_priv *priv)
return max;
}
+static void
+mlx5_vdpa_drain_cq_one(struct mlx5_vdpa_priv *priv,
+ struct mlx5_vdpa_virtq *virtq)
+{
+ struct mlx5_vdpa_cq *cq = &virtq->eqp.cq;
+
+ mlx5_vdpa_queue_complete(cq);
+ if (cq->cq_obj.cq) {
+ cq->cq_obj.cqes[0].wqe_counter = rte_cpu_to_be_16(UINT16_MAX);
+ virtq->eqp.qp_pi = 0;
+ if (!cq->armed)
+ mlx5_vdpa_cq_arm(priv, cq);
+ }
+}
+
void
mlx5_vdpa_drain_cq(struct mlx5_vdpa_priv *priv)
{
+ struct mlx5_vdpa_virtq *virtq;
unsigned int i;
for (i = 0; i < priv->caps.max_num_virtio_queues; i++) {
- struct mlx5_vdpa_cq *cq = &priv->virtqs[i].eqp.cq;
-
- mlx5_vdpa_queue_complete(cq);
- if (cq->cq_obj.cq) {
- cq->cq_obj.cqes[0].wqe_counter =
- rte_cpu_to_be_16(UINT16_MAX);
- priv->virtqs[i].eqp.qp_pi = 0;
- if (!cq->armed)
- mlx5_vdpa_cq_arm(priv, cq);
- }
+ virtq = &priv->virtqs[i];
+ mlx5_vdpa_drain_cq_one(priv, virtq);
}
}
@@ -632,6 +640,7 @@ mlx5_vdpa_event_qp_prepare(struct mlx5_vdpa_priv *priv, uint16_t desc_n,
if (eqp->cq.cq_obj.cq != NULL && log_desc_n == eqp->cq.log_desc_n) {
/* Reuse existing resources. */
eqp->cq.callfd = callfd;
+ mlx5_vdpa_drain_cq_one(priv, virtq);
/* FW will set event qp to error state in q destroy. */
if (reset && !mlx5_vdpa_qps2rst2rts(eqp))
rte_write32(rte_cpu_to_be_32(RTE_BIT32(log_desc_n)),
--
2.27.0
next reply other threads:[~2024-01-25 3:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-25 3:17 Yajun Wu [this message]
2024-02-06 13:17 ` Maxime Coquelin
2024-02-06 14:06 ` Maxime Coquelin
2024-02-06 14:58 ` Maxime Coquelin
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=20240125031755.657102-1-yajunw@nvidia.com \
--to=yajunw@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=maxime.coquelin@redhat.com \
--cc=mkashani@nvidia.com \
--cc=stable@dpdk.org \
--cc=thomas@monjalon.net \
--cc=viacheslavo@nvidia.com \
/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;
as well as URLs for NNTP newsgroup(s).