* [PATCH] RDMA/mlx5: Fix state and counter desync on loopback enable failure
@ 2026-06-01 9:58 lirongqing
2026-06-05 17:03 ` Jason Gunthorpe
0 siblings, 1 reply; 2+ messages in thread
From: lirongqing @ 2026-06-01 9:58 UTC (permalink / raw)
To: Leon Romanovsky, Jason Gunthorpe, linux-rdma; +Cc: Li RongQing
From: Li RongQing <lirongqing@baidu.com>
In mlx5_ib_enable_lb(), dev->lb.enabled was unconditionally set
to true even if mlx5_nic_vport_update_local_lb() failed.
Fix this by only setting dev->lb.enabled on success. On failure,
roll back the reference counters and return the error.
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
drivers/infiniband/hw/mlx5/main.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index c7ae46e..870f00f 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -2023,6 +2023,9 @@ int mlx5_ib_enable_lb(struct mlx5_ib_dev *dev, bool td, bool qp)
dev->lb.qps == 1) {
if (!dev->lb.enabled) {
err = mlx5_nic_vport_update_local_lb(dev->mdev, true);
+ if (err)
+ goto err_rollback;
+
dev->lb.enabled = true;
}
}
@@ -2030,6 +2033,14 @@ int mlx5_ib_enable_lb(struct mlx5_ib_dev *dev, bool td, bool qp)
mutex_unlock(&dev->lb.mutex);
return err;
+
+err_rollback:
+ if (td)
+ dev->lb.user_td--;
+ if (qp)
+ dev->lb.qps--;
+ mutex_unlock(&dev->lb.mutex);
+ return err;
}
void mlx5_ib_disable_lb(struct mlx5_ib_dev *dev, bool td, bool qp)
--
2.9.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] RDMA/mlx5: Fix state and counter desync on loopback enable failure
2026-06-01 9:58 [PATCH] RDMA/mlx5: Fix state and counter desync on loopback enable failure lirongqing
@ 2026-06-05 17:03 ` Jason Gunthorpe
0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2026-06-05 17:03 UTC (permalink / raw)
To: lirongqing; +Cc: Leon Romanovsky, linux-rdma
On Mon, Jun 01, 2026 at 05:58:18AM -0400, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> In mlx5_ib_enable_lb(), dev->lb.enabled was unconditionally set
> to true even if mlx5_nic_vport_update_local_lb() failed.
>
> Fix this by only setting dev->lb.enabled on success. On failure,
> roll back the reference counters and return the error.
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> drivers/infiniband/hw/mlx5/main.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
Applied to for-next, thanks
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-05 17:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-01 9:58 [PATCH] RDMA/mlx5: Fix state and counter desync on loopback enable failure lirongqing
2026-06-05 17:03 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox