virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Eli Cohen <elic@nvidia.com>
Cc: linux-kernel@vger.kernel.org, lulu@redhat.com,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] vdpa/mlx5: Use write memory barrier after updating CQ index
Date: Tue, 8 Dec 2020 16:45:04 -0500	[thread overview]
Message-ID: <20201208164356-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20201206105719.123753-1-elic@nvidia.com>

On Sun, Dec 06, 2020 at 12:57:19PM +0200, Eli Cohen wrote:
> Make sure to put 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.
> 
> Change-Id: Ib0ae4c118cce524c9f492b32569179f3c1f04cc1
> Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
> Signed-off-by: Eli Cohen <elic@nvidia.com>

Aren't both memory writes? And given that, isn't dma_wmb() sufficient
here?


> ---
>  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 1f4089c6f9d7..295f46eea2a5 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -478,6 +478,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.
> +	 */
> +	wmb();
>  	rx_post(&mvq->vqqp, num);
>  	if (mvq->event_cb.callback)
>  		mvq->event_cb.callback(mvq->event_cb.private);
> -- 
> 2.27.0

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

  parent reply	other threads:[~2020-12-08 21:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201206105719.123753-1-elic@nvidia.com>
2020-12-07  2:51 ` [PATCH] vdpa/mlx5: Use write memory barrier after updating CQ index Jason Wang
     [not found]   ` <20201208091500.GA17763@mtl-vdi-166.wap.labs.mlnx>
2020-12-08 13:53     ` Michael S. Tsirkin
2020-12-08 21:45 ` Michael S. Tsirkin [this message]
     [not found]   ` <20201209060230.GA57362@mtl-vdi-166.wap.labs.mlnx>
2020-12-09  6:46     ` Michael S. Tsirkin
     [not found]       ` <20201209065846.GA59515@mtl-vdi-166.wap.labs.mlnx>
2020-12-09  8:05         ` Michael S. Tsirkin
     [not found]           ` <20201209093836.GA62204@mtl-vdi-166.wap.labs.mlnx>
2020-12-09 12:47             ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201208164356-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=elic@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lulu@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).