Skip to contentSkip to conversation

vdpa/mlx5: Use write memory barrier after updating CQ index

PATCH In review Eli Cohen 2 participants 2 messages Dec 9, 2020 – Dec 10, 2020

Subsystems (2)
lore
Share & tools
lore

Eli Cohen

author
#0 lore raw

PATCH 1/1 vdpa/mlx5: Use write memory barrier after updating CQ index

Make sure to put dma write memory barrier after updating CQ consumer index so the hardware knows that there are available CQE slots in the queue.

Failure to do this can cause the update of the RX doorbell record to get updated before the CQ consumer index resulting in CQ overrun.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")

---
V0 -> V1
Use dma_wmb() instead of wmb()

 drivers/vdpa/mlx5/net/mlx5_vnet.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/vdpa/mlx5/net/mlx5_vnet.c +5 -0
index db87abc3cb60..43b0069ff8b1 100644
@@ -479,6 +479,11 @@ static int mlx5_vdpa_poll_one(struct mlx5_vdpa_cq *vcq)
 static void mlx5_vdpa_handle_completions(struct mlx5_vdpa_virtqueue *mvq, int num)
 {
 	mlx5_cq_set_ci(&mvq->cq.mcq);
+
+	/* make sure CQ cosumer update is visible to the hardware before updating
+	 * RX doorbell record.
+	 */
+	dma_wmb();
 	rx_post(&mvq->vqqp, num);
 	if (mvq->event_cb.callback)
 		mvq->event_cb.callback(mvq->event_cb.private);
Signature · 1 line
2.27.0
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Eli Cohen

Make sure to put dma write memory barrier after updating CQ consumer index so the hardware knows that there are available CQE slots in the queue.

Quoted 8 lines

Failure to do this can cause the update of the RX doorbell record to get updated before the CQ consumer index resulting in CQ overrun.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")

---
V0 -> V1
Use dma_wmb() instead of wmb()

Quoted 10 lines
  drivers/vdpa/mlx5/net/mlx5_vnet.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/vdpa/mlx5/net/mlx5_vnet.c +0 -0
index db87abc3cb60..43b0069ff8b1 100644
@@ -479,6 +479,11 @@ static int mlx5_vdpa_poll_one(struct mlx5_vdpa_cq *vcq)
  static void mlx5_vdpa_handle_completions(struct mlx5_vdpa_virtqueue *mvq, int num)

drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_poll_one(struct mlx5_vdpa_cq *vcq) · line 489

Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +5 -0
  {
  	mlx5_cq_set_ci(&mvq->cq.mcq);
+
+	/* make sure CQ cosumer update is visible to the hardware before updating
+	 * RX doorbell record.
+	 */
+	dma_wmb();
  	rx_post(&mvq->vqqp, num);
  	if (mvq->event_cb.callback)
  		mvq->event_cb.callback(mvq->event_cb.private);

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization