Skip to content

Commit fc89d7f

Browse files
committed
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael Tsirkin: "Some virtio / vhost / vdpa fixes accumulated so far" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: tools/virtio: Ignore virtio-trace/trace-agent vdpa_sim: set last_used_idx as last_avail_idx in vdpasim_queue_ready vhost-vdpa: free iommu domain after last use during cleanup vdpa/mlx5: should not activate virtq object when suspended vp_vdpa: fix the crash in hot unplug with vp_vdpa
2 parents eeac8ed + ae43c20 commit fc89d7f

File tree

6 files changed

+21
-3
lines changed

6 files changed

+21
-3
lines changed

drivers/vdpa/mlx5/core/mlx5_vdpa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ struct mlx5_vdpa_dev {
9696
struct mlx5_control_vq cvq;
9797
struct workqueue_struct *wq;
9898
unsigned int group2asid[MLX5_VDPA_NUMVQ_GROUPS];
99+
bool suspended;
99100
};
100101

101102
int mlx5_vdpa_alloc_pd(struct mlx5_vdpa_dev *dev, u32 *pdn, u16 uid);

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2438,7 +2438,7 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev,
24382438
if (err)
24392439
goto err_mr;
24402440

2441-
if (!(mvdev->status & VIRTIO_CONFIG_S_DRIVER_OK))
2441+
if (!(mvdev->status & VIRTIO_CONFIG_S_DRIVER_OK) || mvdev->suspended)
24422442
goto err_mr;
24432443

24442444
restore_channels_info(ndev);
@@ -2606,6 +2606,7 @@ static int mlx5_vdpa_reset(struct vdpa_device *vdev)
26062606
clear_vqs_ready(ndev);
26072607
mlx5_vdpa_destroy_mr(&ndev->mvdev);
26082608
ndev->mvdev.status = 0;
2609+
ndev->mvdev.suspended = false;
26092610
ndev->cur_num_vqs = 0;
26102611
ndev->mvdev.cvq.received_desc = 0;
26112612
ndev->mvdev.cvq.completed_desc = 0;
@@ -2852,6 +2853,8 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev)
28522853
struct mlx5_vdpa_virtqueue *mvq;
28532854
int i;
28542855

2856+
mlx5_vdpa_info(mvdev, "suspending device\n");
2857+
28552858
down_write(&ndev->reslock);
28562859
ndev->nb_registered = false;
28572860
mlx5_notifier_unregister(mvdev->mdev, &ndev->nb);
@@ -2861,6 +2864,7 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev)
28612864
suspend_vq(ndev, mvq);
28622865
}
28632866
mlx5_vdpa_cvq_suspend(mvdev);
2867+
mvdev->suspended = true;
28642868
up_write(&ndev->reslock);
28652869
return 0;
28662870
}

drivers/vdpa/vdpa_sim/vdpa_sim.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
6868
(uintptr_t)vq->device_addr);
6969

7070
vq->vring.last_avail_idx = last_avail_idx;
71+
72+
/*
73+
* Since vdpa_sim does not support receive inflight descriptors as a
74+
* destination of a migration, let's set both avail_idx and used_idx
75+
* the same at vq start. This is how vhost-user works in a
76+
* VHOST_SET_VRING_BASE call.
77+
*
78+
* Although the simple fix is to set last_used_idx at
79+
* vdpasim_set_vq_state, it would be reset at vdpasim_queue_ready.
80+
*/
81+
vq->vring.last_used_idx = last_avail_idx;
7182
vq->vring.notify = vdpasim_vq_notify;
7283
}
7384

drivers/vdpa/virtio_pci/vp_vdpa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,8 @@ static void vp_vdpa_remove(struct pci_dev *pdev)
645645
struct virtio_pci_modern_device *mdev = NULL;
646646

647647
mdev = vp_vdpa_mgtdev->mdev;
648-
vp_modern_remove(mdev);
649648
vdpa_mgmtdev_unregister(&vp_vdpa_mgtdev->mgtdev);
649+
vp_modern_remove(mdev);
650650
kfree(vp_vdpa_mgtdev->mgtdev.id_table);
651651
kfree(mdev);
652652
kfree(vp_vdpa_mgtdev);

drivers/vhost/vdpa.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,7 @@ static int vhost_vdpa_alloc_domain(struct vhost_vdpa *v)
11691169

11701170
err_attach:
11711171
iommu_domain_free(v->domain);
1172+
v->domain = NULL;
11721173
return ret;
11731174
}
11741175

@@ -1213,6 +1214,7 @@ static void vhost_vdpa_cleanup(struct vhost_vdpa *v)
12131214
vhost_vdpa_remove_as(v, asid);
12141215
}
12151216

1217+
vhost_vdpa_free_domain(v);
12161218
vhost_dev_cleanup(&v->vdev);
12171219
kfree(v->vdev.vqs);
12181220
}
@@ -1285,7 +1287,6 @@ static int vhost_vdpa_release(struct inode *inode, struct file *filep)
12851287
vhost_vdpa_clean_irq(v);
12861288
vhost_vdpa_reset(v);
12871289
vhost_dev_stop(&v->vdev);
1288-
vhost_vdpa_free_domain(v);
12891290
vhost_vdpa_config_put(v);
12901291
vhost_vdpa_cleanup(v);
12911292
mutex_unlock(&d->mutex);

tools/virtio/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
*.d
33
virtio_test
44
vringh_test
5+
virtio-trace/trace-agent

0 commit comments

Comments
 (0)