Skip to content

Commit 972db38

Browse files
Yishai Hadasrleon
authored andcommitted
RDMA/mlx5: Remove the redundant MLX5_IB_STAGE_UAR stage
The MLX5_IB_STAGE_UAR stage in the RDMA driver is redundant and should be removed. Responsibility for initializing the device's UAR pointer (mdev->priv.uar) lies with mlx5_core, which already sets it during the mlx5_load() process. At present, the RDMA UAR stage overwrites this pointer, which was correctly initialized by mlx5_core, creating the risk of inconsistency. Ownership and management of the UAR pointer should remain exclusively within mlx5_core. In the current upstream code, we luckily receive the same pointer, since mlx5_get_uars_page() still finds available BF registers for that UAR, allowing it to be shared. However, future changes in mlx5_core may expose this flaw. For instance, if mlx5_alloc_bfreg() is invoked twice before the RDMA UAR stage runs, the RDMA driver may overwrite the UAR allocated by mlx5_core. This could lead to real bugs. For example, if mlx5_ib is unloaded (rmmod), it might free the UAR, leaving mlx5_core with a dangling reference to an invalid UAR. Signed-off-by: Yishai Hadas <[email protected]> Reviewed-by: Fan Li <[email protected]> Link: https://patch.msgid.link/feaa84ec6f20468b4935c439923e9266122a93d0.1747134130.git.leon@kernel.org Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 21508c8 commit 972db38

File tree

2 files changed

+0
-18
lines changed

2 files changed

+0
-18
lines changed

drivers/infiniband/hw/mlx5/main.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4422,17 +4422,6 @@ static void mlx5_ib_stage_cong_debugfs_cleanup(struct mlx5_ib_dev *dev)
44224422
mlx5_core_native_port_num(dev->mdev) - 1);
44234423
}
44244424

4425-
static int mlx5_ib_stage_uar_init(struct mlx5_ib_dev *dev)
4426-
{
4427-
dev->mdev->priv.uar = mlx5_get_uars_page(dev->mdev);
4428-
return PTR_ERR_OR_ZERO(dev->mdev->priv.uar);
4429-
}
4430-
4431-
static void mlx5_ib_stage_uar_cleanup(struct mlx5_ib_dev *dev)
4432-
{
4433-
mlx5_put_uars_page(dev->mdev, dev->mdev->priv.uar);
4434-
}
4435-
44364425
static int mlx5_ib_stage_bfrag_init(struct mlx5_ib_dev *dev)
44374426
{
44384427
int err;
@@ -4662,9 +4651,6 @@ static const struct mlx5_ib_profile pf_profile = {
46624651
STAGE_CREATE(MLX5_IB_STAGE_CONG_DEBUGFS,
46634652
mlx5_ib_stage_cong_debugfs_init,
46644653
mlx5_ib_stage_cong_debugfs_cleanup),
4665-
STAGE_CREATE(MLX5_IB_STAGE_UAR,
4666-
mlx5_ib_stage_uar_init,
4667-
mlx5_ib_stage_uar_cleanup),
46684654
STAGE_CREATE(MLX5_IB_STAGE_BFREG,
46694655
mlx5_ib_stage_bfrag_init,
46704656
mlx5_ib_stage_bfrag_cleanup),
@@ -4722,9 +4708,6 @@ const struct mlx5_ib_profile raw_eth_profile = {
47224708
STAGE_CREATE(MLX5_IB_STAGE_CONG_DEBUGFS,
47234709
mlx5_ib_stage_cong_debugfs_init,
47244710
mlx5_ib_stage_cong_debugfs_cleanup),
4725-
STAGE_CREATE(MLX5_IB_STAGE_UAR,
4726-
mlx5_ib_stage_uar_init,
4727-
mlx5_ib_stage_uar_cleanup),
47284711
STAGE_CREATE(MLX5_IB_STAGE_BFREG,
47294712
mlx5_ib_stage_bfrag_init,
47304713
mlx5_ib_stage_bfrag_cleanup),

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,6 @@ enum mlx5_ib_stages {
10061006
MLX5_IB_STAGE_ODP,
10071007
MLX5_IB_STAGE_COUNTERS,
10081008
MLX5_IB_STAGE_CONG_DEBUGFS,
1009-
MLX5_IB_STAGE_UAR,
10101009
MLX5_IB_STAGE_BFREG,
10111010
MLX5_IB_STAGE_PRE_IB_REG_UMR,
10121011
MLX5_IB_STAGE_WHITELIST_UID,

0 commit comments

Comments
 (0)