Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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")
Signed-off-by: Eli Cohen <elic@nvidia.com>
Link: https://lore.kernel.org/r/20201209140004.15892-1-elic@nvidia.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Eli Cohen and committed by
Michael S. Tsirkin
83ef73b2 db1e8bb6

+5
+5
drivers/vdpa/mlx5/net/mlx5_vnet.c
··· 464 464 static void mlx5_vdpa_handle_completions(struct mlx5_vdpa_virtqueue *mvq, int num) 465 465 { 466 466 mlx5_cq_set_ci(&mvq->cq.mcq); 467 + 468 + /* make sure CQ cosumer update is visible to the hardware before updating 469 + * RX doorbell record. 470 + */ 471 + dma_wmb(); 467 472 rx_post(&mvq->vqqp, num); 468 473 if (mvq->event_cb.callback) 469 474 mvq->event_cb.callback(mvq->event_cb.private);