Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@nvidia.com>
Cc: Patrisious Haddad <phaddad@nvidia.com>,
	linux-rdma@vger.kernel.org, Mark Zhang <markzhang@nvidia.com>
Subject: Re: [PATCH rdma-rc] RDMA/mlx5: Fix bind QP error cleanup flow
Date: Thu, 20 Feb 2025 13:23:33 +0100	[thread overview]
Message-ID: <1229cbb2-b7b9-4b47-8276-62bd9c79a7ce@linux.dev> (raw)
In-Reply-To: <25dfefddb0ebefa668c32e06a94d84e3216257cf.1740033937.git.leon@kernel.org>

在 2025/2/20 7:47, Leon Romanovsky 写道:
> From: Patrisious Haddad <phaddad@nvidia.com>
> 
> When there is a failure during bind QP, the cleanup flow destroys the
> counter regardless if it is the one that created it or not, which is
> problematic since if it isn't the one that created it, that counter could
> still be in use.
> 
> Fix that by destroying the counter only if it was created during this call.
> 
> Fixes: 45842fc627c7 ("IB/mlx5: Support statistic q counter configuration")
> Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
> Reviewed-by: Mark Zhang <markzhang@nvidia.com>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>   drivers/infiniband/hw/mlx5/counters.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx5/counters.c b/drivers/infiniband/hw/mlx5/counters.c
> index 4f6c1968a2ee..81cfa74147a1 100644
> --- a/drivers/infiniband/hw/mlx5/counters.c
> +++ b/drivers/infiniband/hw/mlx5/counters.c
> @@ -546,6 +546,7 @@ static int mlx5_ib_counter_bind_qp(struct rdma_counter *counter,
>   				   struct ib_qp *qp)
>   {
>   	struct mlx5_ib_dev *dev = to_mdev(qp->device);
> +	bool new = false;
>   	int err;
>   
>   	if (!counter->id) {
> @@ -560,6 +561,7 @@ static int mlx5_ib_counter_bind_qp(struct rdma_counter *counter,
>   			return err;
>   		counter->id =
>   			MLX5_GET(alloc_q_counter_out, out, counter_set_id);
> +		new = true;
It seems that there is no other better method except that a new bool 
variable is used. IMO, this method can fix this problem.

Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>

Zhu Yanjun

>   	}
>   
>   	err = mlx5_ib_qp_set_counter(qp, counter);
> @@ -569,8 +571,10 @@ static int mlx5_ib_counter_bind_qp(struct rdma_counter *counter,
>   	return 0;
>   
>   fail_set_counter:
> -	mlx5_ib_counter_dealloc(counter);
> -	counter->id = 0;
> +	if (new) {
> +		mlx5_ib_counter_dealloc(counter);
> +		counter->id = 0;
> +	}
>   
>   	return err;
>   }


  reply	other threads:[~2025-02-20 12:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-20  6:47 [PATCH rdma-rc] RDMA/mlx5: Fix bind QP error cleanup flow Leon Romanovsky
2025-02-20 12:23 ` Zhu Yanjun [this message]
2025-02-23  8:33   ` Leon Romanovsky
2025-02-23  8:35 ` Leon Romanovsky

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=1229cbb2-b7b9-4b47-8276-62bd9c79a7ce@linux.dev \
    --to=yanjun.zhu@linux.dev \
    --cc=jgg@nvidia.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=markzhang@nvidia.com \
    --cc=phaddad@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