From: Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
dledford@redhat.com, haggaie@mellanox.com,
Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
Subject: [PATCH v11 2/2] IB/mlx5: Fix loopback threshold/accounting in regular path
Date: Wed, 15 Apr 2026 01:19:46 +0100 [thread overview]
Message-ID: <20260415002001.25702-3-prathameshdeshpande7@gmail.com> (raw)
In-Reply-To: <20260415002001.25702-1-prathameshdeshpande7@gmail.com>
In regular (non-MP) loopback enable/disable paths, threshold logic uses a
hardcoded user_td baseline and does not rollback counters when HW enable
fails.
Use a TD-capability-aware baseline for user_td transitions, and rollback
user_td/qps accounting if mlx5_nic_vport_update_local_lb() fails.
Per review, keep MP helper behavior unchanged.
Fixes: 08aae7860450 ("RDMA/mlx5: Fix vport loopback forcing for MPV device")
Signed-off-by: Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
---
drivers/infiniband/hw/mlx5/main.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index b3b297bc2f2b..6b1182b18702 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -2005,8 +2005,14 @@ static void mlx5_ib_disable_lb_mp(struct mlx5_core_dev *master,
lb_state->force_enable = false;
}
+static inline u32 mlx5_ib_lb_td_base(struct mlx5_core_dev *mdev)
+{
+ return MLX5_CAP_GEN(mdev, log_max_transport_domain) ? 1 : 0;
+}
+
int mlx5_ib_enable_lb(struct mlx5_ib_dev *dev, bool td, bool qp)
{
+ u32 td_base = mlx5_ib_lb_td_base(dev->mdev);
int err = 0;
if (dev->lb.force_enable)
@@ -2018,11 +2024,18 @@ int mlx5_ib_enable_lb(struct mlx5_ib_dev *dev, bool td, bool qp)
if (qp)
dev->lb.qps++;
- if (dev->lb.user_td == 2 ||
+ if (dev->lb.user_td == td_base + 1 ||
dev->lb.qps == 1) {
if (!dev->lb.enabled) {
err = mlx5_nic_vport_update_local_lb(dev->mdev, true);
- dev->lb.enabled = true;
+ if (err) {
+ if (td)
+ dev->lb.user_td--;
+ if (qp)
+ dev->lb.qps--;
+ } else {
+ dev->lb.enabled = true;
+ }
}
}
@@ -2033,6 +2046,8 @@ int mlx5_ib_enable_lb(struct mlx5_ib_dev *dev, bool td, bool qp)
void mlx5_ib_disable_lb(struct mlx5_ib_dev *dev, bool td, bool qp)
{
+ u32 td_base = mlx5_ib_lb_td_base(dev->mdev);
+
if (dev->lb.force_enable)
return;
@@ -2042,7 +2057,7 @@ void mlx5_ib_disable_lb(struct mlx5_ib_dev *dev, bool td, bool qp)
if (qp)
dev->lb.qps--;
- if (dev->lb.user_td == 1 &&
+ if (dev->lb.user_td <= td_base &&
dev->lb.qps == 0) {
if (dev->lb.enabled) {
mlx5_nic_vport_update_local_lb(dev->mdev, false);
--
2.43.0
prev parent reply other threads:[~2026-04-15 0:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 0:19 [PATCH v11 0/2] IB/mlx5: Fix loopback rollback and threshold accounting Prathamesh Deshpande
2026-04-15 0:19 ` [PATCH v11 1/2] IB/mlx5: Fix transport-domain rollback and initialize lb mutex earlier Prathamesh Deshpande
2026-04-15 0:19 ` Prathamesh Deshpande [this message]
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=20260415002001.25702-3-prathameshdeshpande7@gmail.com \
--to=prathameshdeshpande7@gmail.com \
--cc=dledford@redhat.com \
--cc=haggaie@mellanox.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.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