From: Jason Gunthorpe <jgg@nvidia.com>
To: Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
Cc: Leon Romanovsky <leon@kernel.org>,
Patrisious Haddad <phaddad@nvidia.com>,
Mark Bloch <mbloch@nvidia.com>,
Doug Ledford <dledford@redhat.com>,
Haggai Eran <haggaie@nvidia.com>, Majd Dibbiny <majd@nvidia.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v12 1/2] IB/mlx5: Fix transport-domain rollback and initialize lb mutex earlier
Date: Tue, 2 Jun 2026 21:29:36 -0300 [thread overview]
Message-ID: <20260603002936.GA1171492@nvidia.com> (raw)
In-Reply-To: <20260510222258.6654-2-prathameshdeshpande7@gmail.com>
On Sun, May 10, 2026 at 11:22:53PM +0100, Prathamesh Deshpande wrote:
> mlx5_ib_alloc_transport_domain() allocates a transport domain and then
> may fail in mlx5_ib_enable_lb(). In that case, the allocated TD is leaked.
>
> Fix this by deallocating the TD when mlx5_ib_enable_lb() returns an
> error. Also return 0 explicitly in the no-loopback-capability success
> branch, and move dev->lb.mutex initialization to mlx5_ib_stage_init_init().
>
> Destroy dev->lb.mutex in the matching cleanup path and in init failure
> paths after the mutex is initialized.
To many things in one patch
> @@ -2068,9 +2068,13 @@ static int mlx5_ib_alloc_transport_domain(struct mlx5_ib_dev *dev, u32 *tdn,
> if ((MLX5_CAP_GEN(dev->mdev, port_type) != MLX5_CAP_PORT_TYPE_ETH) ||
> (!MLX5_CAP_GEN(dev->mdev, disable_local_lb_uc) &&
> !MLX5_CAP_GEN(dev->mdev, disable_local_lb_mc)))
> - return err;
> + return 0;
> +
> + err = mlx5_ib_enable_lb(dev, true, false);
> + if (err)
> + mlx5_cmd_dealloc_transport_domain(dev->mdev, *tdn, uid);
>
> - return mlx5_ib_enable_lb(dev, true, false);
> + return err;
> }
This seems like it might be reasonable
But mutex_destroy is only a debugging feature, we don't need to rework
code to carefully destroy it in error paths.. It should be init'd when
the memory is allocated and free'd when the memory is destroyed.
> - if ((MLX5_CAP_GEN(dev->mdev, port_type) == MLX5_CAP_PORT_TYPE_ETH) &&
> - (MLX5_CAP_GEN(dev->mdev, disable_local_lb_uc) ||
> - MLX5_CAP_GEN(dev->mdev, disable_local_lb_mc)))
> - mutex_init(&dev->lb.mutex);
Though I am wondering why someone did this..
Jason
next prev parent reply other threads:[~2026-06-03 0:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-10 22:22 [PATCH v12 0/2] IB/mlx5: Fix loopback rollback and threshold accounting Prathamesh Deshpande
2026-05-10 22:22 ` [PATCH v12 1/2] IB/mlx5: Fix transport-domain rollback and initialize lb mutex earlier Prathamesh Deshpande
2026-06-03 0:29 ` Jason Gunthorpe [this message]
2026-05-10 22:22 ` [PATCH v12 2/2] IB/mlx5: Fix loopback threshold/accounting in regular path Prathamesh Deshpande
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=20260603002936.GA1171492@nvidia.com \
--to=jgg@nvidia.com \
--cc=dledford@redhat.com \
--cc=haggaie@nvidia.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=majd@nvidia.com \
--cc=mbloch@nvidia.com \
--cc=phaddad@nvidia.com \
--cc=prathameshdeshpande7@gmail.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