linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Leon Romanovsky <leon@kernel.org>
Cc: Doug Ledford <dledford@redhat.com>,
	Maor Gottlieb <maorg@mellanox.com>,
	linux-rdma@vger.kernel.org, Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH rdma-rc 1/3] RDMA/mlx5: Use xa_lock_irqsave when access to SRQ table
Date: Tue, 7 Jul 2020 08:43:03 -0300	[thread overview]
Message-ID: <20200707114303.GY25301@ziepe.ca> (raw)
In-Reply-To: <20200707110612.882962-2-leon@kernel.org>

On Tue, Jul 07, 2020 at 02:06:10PM +0300, Leon Romanovsky wrote:
> Fixes: b02a29eb8841 ("mlx5: Convert mlx5_srq_table to XArray")

This didn't introduce the bug, when things were converted to xarray it
already had the wrong spinlock type.

I'm surprised this is only been found now since it has been wrong for
years. Did something else change?

> Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
>  drivers/infiniband/hw/mlx5/srq_cmd.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx5/srq_cmd.c b/drivers/infiniband/hw/mlx5/srq_cmd.c
> index 6f5eadc4d183..be0e5469dad0 100644
> +++ b/drivers/infiniband/hw/mlx5/srq_cmd.c
> @@ -82,12 +82,13 @@ struct mlx5_core_srq *mlx5_cmd_get_srq(struct mlx5_ib_dev *dev, u32 srqn)
>  {
>  	struct mlx5_srq_table *table = &dev->srq_table;
>  	struct mlx5_core_srq *srq;
> +	unsigned long flags;
>  
> -	xa_lock(&table->array);
> +	xa_lock_irqsave(&table->array, flags);
>  	srq = xa_load(&table->array, srqn);
>  	if (srq)
>  		refcount_inc(&srq->common.refcount);
> -	xa_unlock(&table->array);
> +	xa_unlock_irqrestore(&table->array, flags);

This and other places can just be xa_lock_irq as we are not in an atomic
context here.
  
>  	return srq;
>  }
> @@ -644,6 +645,7 @@ static int srq_event_notifier(struct notifier_block *nb,
>  	struct mlx5_srq_table *table;
>  	struct mlx5_core_srq *srq;
>  	struct mlx5_eqe *eqe;
> +	unsigned long flags;
>  	u32 srqn;
>  
>  	if (type != MLX5_EVENT_TYPE_SRQ_CATAS_ERROR &&
> @@ -655,11 +657,11 @@ static int srq_event_notifier(struct notifier_block *nb,
>  	eqe = data;
>  	srqn = be32_to_cpu(eqe->data.qp_srq.qp_srq_n) & 0xffffff;
>  
> -	xa_lock(&table->array);
> +	xa_lock_irqsave(&table->array, flags);
>  	srq = xa_load(&table->array, srqn);
>  	if (srq)
>  		refcount_inc(&srq->common.refcount);
> -	xa_unlock(&table->array);
> +	xa_unlock_irqrestore(&table->array, flags);

This change isn't needed, the notifier is always called from an IRQ
context

Jason

  reply	other threads:[~2020-07-07 11:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 11:06 [PATCH rdma-rc 0/3] Fixes to mlx5_ib driver Leon Romanovsky
2020-07-07 11:06 ` [PATCH rdma-rc 1/3] RDMA/mlx5: Use xa_lock_irqsave when access to SRQ table Leon Romanovsky
2020-07-07 11:43   ` Jason Gunthorpe [this message]
2020-07-07 12:09     ` Leon Romanovsky
2020-07-07 11:06 ` [PATCH rdma-rc 2/3] IB/mlx5: Fix 50G per lane indication Leon Romanovsky
2020-07-07 11:06 ` [PATCH rdma-rc 3/3] RDMA/mlx5: Set PD pointers for the error flow unwind Leon Romanovsky
2020-07-08 23:26 ` [PATCH rdma-rc 0/3] Fixes to mlx5_ib driver Jason Gunthorpe

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=20200707114303.GY25301@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=dledford@redhat.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=maorg@mellanox.com \
    --cc=willy@infradead.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).