All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] vdpa/mlx5: Use write memory barrier after updating CQ index
@ 2020-12-09 14:00 Eli Cohen
  2020-12-10  9:11   ` Jason Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Cohen @ 2020-12-09 14:00 UTC (permalink / raw)
  To: mst, jasowang, virtualization, linux-kernel
  Cc: lulu, maxime.coquelin, 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.

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>
---
V0 -> V1
Use dma_wmb() instead of wmb()

 drivers/vdpa/mlx5/net/mlx5_vnet.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index db87abc3cb60..43b0069ff8b1 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -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);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] vdpa/mlx5: Use write memory barrier after updating CQ index
  2020-12-09 14:00 [PATCH v1] vdpa/mlx5: Use write memory barrier after updating CQ index Eli Cohen
@ 2020-12-10  9:11   ` Jason Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2020-12-10  9:11 UTC (permalink / raw)
  To: Eli Cohen, mst, virtualization, linux-kernel; +Cc: lulu, maxime.coquelin


On 2020/12/9 下午10:00, Eli Cohen wrote:
> 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>
> ---
> V0 -> V1
> Use dma_wmb() instead of wmb()


Acked-by: Jason Wang <jasowang@redhat.com>


>
>   drivers/vdpa/mlx5/net/mlx5_vnet.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index db87abc3cb60..43b0069ff8b1 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -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);


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] vdpa/mlx5: Use write memory barrier after updating CQ index
@ 2020-12-10  9:11   ` Jason Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2020-12-10  9:11 UTC (permalink / raw)
  To: Eli Cohen, mst, virtualization, linux-kernel; +Cc: maxime.coquelin, lulu


On 2020/12/9 下午10:00, Eli Cohen wrote:
> 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>
> ---
> V0 -> V1
> Use dma_wmb() instead of wmb()


Acked-by: Jason Wang <jasowang@redhat.com>


>
>   drivers/vdpa/mlx5/net/mlx5_vnet.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index db87abc3cb60..43b0069ff8b1 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -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);

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-10  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 14:00 [PATCH v1] vdpa/mlx5: Use write memory barrier after updating CQ index Eli Cohen
2020-12-10  9:11 ` Jason Wang
2020-12-10  9:11   ` Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.