Skip to content

Commit

Permalink
vdpa/mlx5: fix queue enable drain CQ
Browse files Browse the repository at this point in the history
[ upstream commit 32fbcf3139fbff04651b3fe173e9f3457f105221 ]

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: 24969c7 ("vdpa/mlx5: reuse event queues")

Signed-off-by: Yajun Wu <yajunw@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
  • Loading branch information
yajwu authored and bluca committed Mar 7, 2024
1 parent 9b6bdd0 commit 49dfcc6
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions drivers/vdpa/mlx5/mlx5_vdpa_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -658,6 +666,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)),
Expand Down

0 comments on commit 49dfcc6

Please sign in to comment.