mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Liming Sun <limings@nvidia.com>,
	Vadim Pasternak <vadimp@nvidia.com>,
	David Thompson <davthompson@nvidia.com>,
	Mark Gross <markgross@kernel.org>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/1] platform/mellanox: fix potential race in mlxbf-tmfifo driver
Date: Tue, 9 May 2023 10:38:51 +0200	[thread overview]
Message-ID: <2d6a1063-34ad-70ca-3d1c-0be2143ff3f4@redhat.com> (raw)
In-Reply-To: <b98c0ab61d644ba38fa9b3fd1607b138b0dd820b.1682518748.git.limings@nvidia.com>

Vadim,

On 4/26/23 16:23, Liming Sun wrote:
> This commit adds memory barrier for the 'vq' update in function
> mlxbf_tmfifo_virtio_find_vqs() to avoid potential race due to
> out-of-order memory write. It also adds barrier for the 'is_ready'
> flag to make sure the initializations are visible before this flag
> is checked.
> 
> Signed-off-by: Liming Sun <limings@nvidia.com>

Can you review this patch please ?

Regards,

Hans




> ---
>  drivers/platform/mellanox/mlxbf-tmfifo.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c b/drivers/platform/mellanox/mlxbf-tmfifo.c
> index 91a077c35b8b..a79318e90a13 100644
> --- a/drivers/platform/mellanox/mlxbf-tmfifo.c
> +++ b/drivers/platform/mellanox/mlxbf-tmfifo.c
> @@ -784,7 +784,7 @@ static void mlxbf_tmfifo_rxtx(struct mlxbf_tmfifo_vring *vring, bool is_rx)
>  	fifo = vring->fifo;
>  
>  	/* Return if vdev is not ready. */
> -	if (!fifo->vdev[devid])
> +	if (!fifo || !fifo->vdev[devid])
>  		return;
>  
>  	/* Return if another vring is running. */
> @@ -980,9 +980,13 @@ static int mlxbf_tmfifo_virtio_find_vqs(struct virtio_device *vdev,
>  
>  		vq->num_max = vring->num;
>  
> +		vq->priv = vring;
> +
> +		/* Make vq update visible before using it. */
> +		virtio_mb(false);
> +
>  		vqs[i] = vq;
>  		vring->vq = vq;
> -		vq->priv = vring;
>  	}
>  
>  	return 0;
> @@ -1302,6 +1306,9 @@ static int mlxbf_tmfifo_probe(struct platform_device *pdev)
>  
>  	mod_timer(&fifo->timer, jiffies + MLXBF_TMFIFO_TIMER_INTERVAL);
>  
> +	/* Make all updates visible before setting the 'is_ready' flag. */
> +	virtio_mb(false);
> +
>  	fifo->is_ready = true;
>  	return 0;
>  


  reply	other threads:[~2023-05-09  8:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-26 14:23 Liming Sun
2023-05-09  8:38 ` Hans de Goede [this message]
2023-05-09  9:35 ` Vadim Pasternak
2023-05-09  9:56   ` Hans de Goede

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=2d6a1063-34ad-70ca-3d1c-0be2143ff3f4@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=davthompson@nvidia.com \
    --cc=limings@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=vadimp@nvidia.com \
    /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

all inboxes | Powered by JetHome®