Skip to content

Commit 8432502

Browse files
dtatuleamstsirkin
authored andcommitted
vdpa/mlx5: Consolidate all VQ modify to Ready to use resume_vq()
There are a few more places modifying the VQ to Ready directly. Let's consolidate them into resume_vq(). The redundant warnings for resume_vq() errors can also be dropped. There is one special case that needs to be handled for virtio-vdpa: the initialized flag must be set to true earlier in setup_vq() so that resume_vq() doesn't return early. Reviewed-by: Cosmin Ratiu <[email protected]> Acked-by: Eugenio Pérez <[email protected]> Signed-off-by: Dragos Tatulea <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent b89bb34 commit 8432502

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ static void free_fixed_resources(struct mlx5_vdpa_net *ndev);
160160
static void mvqs_set_defaults(struct mlx5_vdpa_net *ndev);
161161
static int setup_vq_resources(struct mlx5_vdpa_net *ndev, bool filled);
162162
static void teardown_vq_resources(struct mlx5_vdpa_net *ndev);
163+
static int resume_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq);
163164

164165
static bool mlx5_vdpa_debug;
165166

@@ -1500,16 +1501,14 @@ static int setup_vq(struct mlx5_vdpa_net *ndev,
15001501
if (err)
15011502
goto err_vq;
15021503

1504+
mvq->initialized = true;
1505+
15031506
if (mvq->ready) {
1504-
err = modify_virtqueue_state(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY);
1505-
if (err) {
1506-
mlx5_vdpa_warn(&ndev->mvdev, "failed to modify to ready vq idx %d(%d)\n",
1507-
idx, err);
1507+
err = resume_vq(ndev, mvq);
1508+
if (err)
15081509
goto err_modify;
1509-
}
15101510
}
15111511

1512-
mvq->initialized = true;
15131512
return 0;
15141513

15151514
err_modify:
@@ -2422,7 +2421,6 @@ static void mlx5_vdpa_set_vq_ready(struct vdpa_device *vdev, u16 idx, bool ready
24222421
struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
24232422
struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
24242423
struct mlx5_vdpa_virtqueue *mvq;
2425-
int err;
24262424

24272425
if (!mvdev->actual_features)
24282426
return;
@@ -2439,14 +2437,10 @@ static void mlx5_vdpa_set_vq_ready(struct vdpa_device *vdev, u16 idx, bool ready
24392437
if (!ready) {
24402438
suspend_vq(ndev, mvq);
24412439
} else {
2442-
err = modify_virtqueue_state(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY);
2443-
if (err) {
2444-
mlx5_vdpa_warn(mvdev, "modify VQ %d to ready failed (%d)\n", idx, err);
2440+
if (resume_vq(ndev, mvq))
24452441
ready = false;
2446-
}
24472442
}
24482443

2449-
24502444
mvq->ready = ready;
24512445
}
24522446

0 commit comments

Comments
 (0)