History

vdpa/mlx5: Initialize CVQ vringh only once

Currently, CVQ vringh is initialized inside setup_virtqueues() which is called every time a memory update is done. This is undesirable since it resets all the context of the vring, including the available and used indices. Move the initialization to mlx5_vdpa_set_status() when VIRTIO_CONFIG_S_DRIVER_OK is set.

Eli Cohen committed 4 years ago

Commit ace92521 parent 40f2f3e1 file · +20 −11Browse files

Unified · Split

drivers/vdpa/mlx5/net/mlx5_vnet.c+20−11
@@ -2176,7 +2176,6 @@ static int verify_driver_features(struct mlx5_vdpa_dev *mvdev, u64 features) · 2175 unmodified lines
21762176 static int setup_virtqueues(struct mlx5_vdpa_dev *mvdev)
21772177 {
21782178 struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
2179− struct mlx5_control_vq *cvq = &mvdev->cvq;
21802179 int err;
21812180 int i;
21822181
@@ -2186,16 +2185,6 @@ static int setup_virtqueues(struct mlx5_vdpa_dev *mvdev) · 3 unmodified lines
21862185 goto err_vq;
21872186 }
21882187
2189− if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)) {
2190− err = vringh_init_iotlb(&cvq->vring, mvdev->actual_features,
2191− MLX5_CVQ_MAX_ENT, false,
2192− (struct vring_desc *)(uintptr_t)cvq->desc_addr,
2193− (struct vring_avail *)(uintptr_t)cvq->driver_addr,
2194− (struct vring_used *)(uintptr_t)cvq->device_addr);
2195− if (err)
2196− goto err_vq;
2197− }
2198−
21992188 return 0;
22002189
22012190 err_vq:
@@ -2468,6 +2457,21 @@ static void clear_vqs_ready(struct mlx5_vdpa_net *ndev) · 266 unmodified lines
24682457 ndev->mvdev.cvq.ready = false;
24692458 }
24702459
2460+static int setup_cvq_vring(struct mlx5_vdpa_dev *mvdev)
2461+{
2462+ struct mlx5_control_vq *cvq = &mvdev->cvq;
2463+ int err = 0;
2464+
2465+ if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ))
2466+ err = vringh_init_iotlb(&cvq->vring, mvdev->actual_features,
2467+ MLX5_CVQ_MAX_ENT, false,
2468+ (struct vring_desc *)(uintptr_t)cvq->desc_addr,
2469+ (struct vring_avail *)(uintptr_t)cvq->driver_addr,
2470+ (struct vring_used *)(uintptr_t)cvq->device_addr);
2471+
2472+ return err;
2473+}
2474+
24712475 static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status)
24722476 {
24732477 struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
@@ -2480,6 +2484,11 @@ static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status) · 6 unmodified lines
24802484
24812485 if ((status ^ ndev->mvdev.status) & VIRTIO_CONFIG_S_DRIVER_OK) {
24822486 if (status & VIRTIO_CONFIG_S_DRIVER_OK) {
2487+ err = setup_cvq_vring(mvdev);
2488+ if (err) {
2489+ mlx5_vdpa_warn(mvdev, "failed to setup control VQ vring\n");
2490+ goto err_setup;
2491+ }
24832492 err = setup_driver(mvdev);
24842493 if (err) {
24852494 mlx5_vdpa_warn(mvdev, "failed to setup driver\n");