vdpa/mlx5: fix virtq cleaning
authorMatan Azrad <matan@nvidia.com>
Mon, 1 Mar 2021 10:41:31 +0000 (10:41 +0000)
committerChenbo Xia <chenbo.xia@intel.com>
Wed, 31 Mar 2021 08:37:10 +0000 (10:37 +0200)
The HW virtq object can be destroyed either when the device is closed or
when the state of the virtq becomes disabled.

Some parameters of the virtq should continue to be managed when the
virtq state is changed but all of them must be initialized when the
device is closed.

Wrongly, the enable parameter stayed on when the device is closed what
might cause creation of invalid virtq in the next time a device is
assigned to the driver.

Clean all the virtqs memory when the device is closed.

Fixes: c47d6e83334e ("vdpa/mlx5: support queue update")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@nvidia.com>
Acked-by: Xueming Li <xuemingl@nvidia.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/vdpa/mlx5/mlx5_vdpa_virtq.c

index ef2642a..024c5c4 100644 (file)
@@ -103,13 +103,8 @@ mlx5_vdpa_virtqs_release(struct mlx5_vdpa_priv *priv)
        for (i = 0; i < priv->nr_virtqs; i++) {
                virtq = &priv->virtqs[i];
                mlx5_vdpa_virtq_unset(virtq);
-               if (virtq->counters) {
+               if (virtq->counters)
                        claim_zero(mlx5_devx_cmd_destroy(virtq->counters));
-                       virtq->counters = NULL;
-                       memset(&virtq->reset, 0, sizeof(virtq->reset));
-               }
-               memset(virtq->err_time, 0, sizeof(virtq->err_time));
-               virtq->n_retry = 0;
        }
        for (i = 0; i < priv->num_lag_ports; i++) {
                if (priv->tiss[i]) {
@@ -126,6 +121,7 @@ mlx5_vdpa_virtqs_release(struct mlx5_vdpa_priv *priv)
                priv->virtq_db_addr = NULL;
        }
        priv->features = 0;
+       memset(priv->virtqs, 0, sizeof(*virtq) * priv->nr_virtqs);
        priv->nr_virtqs = 0;
 }