vdpa/mlx5: should keep avail_index despite device status
A VM with mlx5 vDPA has below warnings while being reset: vhost VQ 0 ring restore failed: -1: Resource temporarily unavailable (11) vhost VQ 1 ring restore failed: -1: Resource temporarily unavailable (11) We should allow userspace emulating the virtio device be able to get to vq's avail_index, regardless of vDPA device status. Save the index that was last seen when virtq was stopped, so that userspace doesn't complain. Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com> Link: https://lore.kernel.org/r/1601583511-15138-1-git-send-email-si-wei.liu@oracle.com Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Eli Cohen <elic@nvidia.com>
This commit is contained in:
Родитель
7ed9e3d97c
Коммит
3176e974a7
|
@ -1133,15 +1133,17 @@ static void suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *m
|
||||||
if (!mvq->initialized)
|
if (!mvq->initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (query_virtqueue(ndev, mvq, &attr)) {
|
|
||||||
mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mvq->fw_state != MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY)
|
if (mvq->fw_state != MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (modify_virtqueue(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND))
|
if (modify_virtqueue(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND))
|
||||||
mlx5_vdpa_warn(&ndev->mvdev, "modify to suspend failed\n");
|
mlx5_vdpa_warn(&ndev->mvdev, "modify to suspend failed\n");
|
||||||
|
|
||||||
|
if (query_virtqueue(ndev, mvq, &attr)) {
|
||||||
|
mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mvq->avail_idx = attr.available_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void suspend_vqs(struct mlx5_vdpa_net *ndev)
|
static void suspend_vqs(struct mlx5_vdpa_net *ndev)
|
||||||
|
@ -1411,8 +1413,14 @@ static int mlx5_vdpa_get_vq_state(struct vdpa_device *vdev, u16 idx, struct vdpa
|
||||||
struct mlx5_virtq_attr attr;
|
struct mlx5_virtq_attr attr;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!mvq->initialized)
|
/* If the virtq object was destroyed, use the value saved at
|
||||||
return -EAGAIN;
|
* the last minute of suspend_vq. This caters for userspace
|
||||||
|
* that cares about emulating the index after vq is stopped.
|
||||||
|
*/
|
||||||
|
if (!mvq->initialized) {
|
||||||
|
state->avail_index = mvq->avail_idx;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
err = query_virtqueue(ndev, mvq, &attr);
|
err = query_virtqueue(ndev, mvq, &attr);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче