Commit 09e65ee9 authored by Si-Wei Liu's avatar Si-Wei Liu Committed by Michael S. Tsirkin

vdpa/mlx5: should not activate virtq object when suspended

Otherwise the virtqueue object to instate could point to invalid address
that was unmapped from the MTT:

  mlx5_core 0000:41:04.2: mlx5_cmd_out_err:782:(pid 8321):
  CREATE_GENERAL_OBJECT(0xa00) op_mod(0xd) failed, status
  bad parameter(0x3), syndrome (0x5fa1c), err(-22)

Fixes: cae15c2e ("vdpa/mlx5: Implement susupend virtqueue callback")
Cc: Eli Cohen <elic@nvidia.com>
Signed-off-by: default avatarSi-Wei Liu <si-wei.liu@oracle.com>
Reviewed-by: default avatarEli Cohen <elic@nvidia.com>

Message-Id: <1676424640-11673-1-git-send-email-si-wei.liu@oracle.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
parent aed8efdd
...@@ -96,6 +96,7 @@ struct mlx5_vdpa_dev { ...@@ -96,6 +96,7 @@ struct mlx5_vdpa_dev {
struct mlx5_control_vq cvq; struct mlx5_control_vq cvq;
struct workqueue_struct *wq; struct workqueue_struct *wq;
unsigned int group2asid[MLX5_VDPA_NUMVQ_GROUPS]; unsigned int group2asid[MLX5_VDPA_NUMVQ_GROUPS];
bool suspended;
}; };
int mlx5_vdpa_alloc_pd(struct mlx5_vdpa_dev *dev, u32 *pdn, u16 uid); int mlx5_vdpa_alloc_pd(struct mlx5_vdpa_dev *dev, u32 *pdn, u16 uid);
......
...@@ -2438,7 +2438,7 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev, ...@@ -2438,7 +2438,7 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev,
if (err) if (err)
goto err_mr; goto err_mr;
if (!(mvdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) if (!(mvdev->status & VIRTIO_CONFIG_S_DRIVER_OK) || mvdev->suspended)
goto err_mr; goto err_mr;
restore_channels_info(ndev); restore_channels_info(ndev);
...@@ -2606,6 +2606,7 @@ static int mlx5_vdpa_reset(struct vdpa_device *vdev) ...@@ -2606,6 +2606,7 @@ static int mlx5_vdpa_reset(struct vdpa_device *vdev)
clear_vqs_ready(ndev); clear_vqs_ready(ndev);
mlx5_vdpa_destroy_mr(&ndev->mvdev); mlx5_vdpa_destroy_mr(&ndev->mvdev);
ndev->mvdev.status = 0; ndev->mvdev.status = 0;
ndev->mvdev.suspended = false;
ndev->cur_num_vqs = 0; ndev->cur_num_vqs = 0;
ndev->mvdev.cvq.received_desc = 0; ndev->mvdev.cvq.received_desc = 0;
ndev->mvdev.cvq.completed_desc = 0; ndev->mvdev.cvq.completed_desc = 0;
...@@ -2852,6 +2853,8 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev) ...@@ -2852,6 +2853,8 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev)
struct mlx5_vdpa_virtqueue *mvq; struct mlx5_vdpa_virtqueue *mvq;
int i; int i;
mlx5_vdpa_info(mvdev, "suspending device\n");
down_write(&ndev->reslock); down_write(&ndev->reslock);
ndev->nb_registered = false; ndev->nb_registered = false;
mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); mlx5_notifier_unregister(mvdev->mdev, &ndev->nb);
...@@ -2861,6 +2864,7 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev) ...@@ -2861,6 +2864,7 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev)
suspend_vq(ndev, mvq); suspend_vq(ndev, mvq);
} }
mlx5_vdpa_cvq_suspend(mvdev); mlx5_vdpa_cvq_suspend(mvdev);
mvdev->suspended = true;
up_write(&ndev->reslock); up_write(&ndev->reslock);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment