Skip to contentSkip to conversation

Set of fixes

PATCH In review Leon Romanovsky 2 participants 9 messages Jan 13, 2021 – Jan 20, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Set of fixes

From: Leon Romanovsky <[email protected]>

Small set of fixes for -next, only Aharon's fix has potential to be taken to the -rc.

Thanks

Aharon Landau (1):
RDMA/umem: Avoid undefined behavior of rounddown_pow_of_two

Mark Bloch (1):
RDMA/mlx5: Fix wrong free of blue flame register on error

Parav Pandit (3):
IB/mlx5: Fix error unwinding when set_has_smi_cap fails IB/mlx5: Add mutex destroy call to cap_mask_mutex mutex IB/mlx5: Make function static

 drivers/infiniband/core/umem.c       |  2 +-
 drivers/infiniband/hw/mlx5/mad.c     |  4 ++--
 drivers/infiniband/hw/mlx5/main.c    | 15 +++++++--------
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  2 --
 4 files changed, 10 insertions(+), 13 deletions(-)

--
2.29.2

#1 lore raw

PATCH 1/5 RDMA/umem: Avoid undefined behavior of rounddown_pow_of_two

From: Aharon Landau <[email protected]>

rounddown_pow_of_two is undefined when the input is 0. Therefore we need to avoid it in ib_umem_find_best_pgsz and return 0. Otherwise, it could result in incorrect page size.

Fixes 3361c29e9279 ("RDMA/umem: Use simpler logic for ib_umem_find_best_pgsz()")
---
 drivers/infiniband/core/umem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/umem.c +1 -1
index 95be8cc75d2e..baaf1bf22941 100644
@@ -137,7 +137,7 @@ unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,
 	 */
 	if (mask)
 		pgsz_bitmap &= GENMASK(count_trailing_zeros(mask), 0);
-	return rounddown_pow_of_two(pgsz_bitmap);
+	return pgsz_bitmap ? rounddown_pow_of_two(pgsz_bitmap) : 0;
 }
 EXPORT_SYMBOL(ib_umem_find_best_pgsz);
 

--
2.29.2

#2 lore raw

PATCH 2/5 IB/mlx5: Fix error unwinding when set_has_smi_cap fails

In reply to Leon Romanovsky

From: Parav Pandit <[email protected]>

When set_has_smi_cap() fails, multiport master cleanup is missed. Fix it by doing correct error unwinding.

Fixes a989ea01cb10 ("RDMA/mlx5: Move SMI caps logic")
---
 drivers/infiniband/hw/mlx5/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/main.c +1 -1
index 36f8ae4fe619..4f21e561f73e 100644
@@ -3978,7 +3978,7 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
 
 	err = set_has_smi_cap(dev);
 	if (err)
-		return err;
+		goto err_mp;
 
 	if (!mlx5_core_mp_enabled(mdev)) {
 		for (i = 1; i <= dev->num_ports; i++) {

--
2.29.2

#3 lore raw

PATCH 3/5 IB/mlx5: Add mutex destroy call to cap_mask_mutex mutex

In reply to Leon Romanovsky

From: Parav Pandit <[email protected]>

Mutex destroy call for device's cap_mask_mutex mutex is missing, let's add it to annotate destruction.

Fixes e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
---
 drivers/infiniband/hw/mlx5/main.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/infiniband/hw/mlx5/main.c +5 -6
index 4f21e561f73e..84309bcd67d5 100644
@@ -3951,7 +3951,7 @@ static void mlx5_ib_stage_init_cleanup(struct mlx5_ib_dev *dev)
 	mlx5_ib_cleanup_multiport_master(dev);
 	WARN_ON(!xa_empty(&dev->odp_mkeys));
 	cleanup_srcu_struct(&dev->odp_srcu);
-
+	mutex_destroy(&dev->cap_mask_mutex);
 	WARN_ON(!xa_empty(&dev->sig_mrs));
 	WARN_ON(!bitmap_empty(dev->dm.memic_alloc_pages, MLX5_MAX_MEMIC_PAGES));
 }
@@ -4002,6 +4002,10 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
 	dev->ib_dev.dev.parent		= mdev->device;
 	dev->ib_dev.lag_flags		= RDMA_LAG_FLAGS_HASH_ALL_SLAVES;
 
+	err = init_srcu_struct(&dev->odp_srcu);
+	if (err)
+		goto err_mp;
+
 	mutex_init(&dev->cap_mask_mutex);
 	INIT_LIST_HEAD(&dev->qp_list);
 	spin_lock_init(&dev->reset_flow_resource_lock);
@@ -4011,11 +4015,6 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
 
 	spin_lock_init(&dev->dm.lock);
 	dev->dm.dev = mdev;
-
-	err = init_srcu_struct(&dev->odp_srcu);
-	if (err)
-		goto err_mp;
-
 	return 0;
 
 err_mp:

--
2.29.2

#4 lore raw

PATCH 4/5 IB/mlx5: Make function static

In reply to Leon Romanovsky

From: Parav Pandit <[email protected]>

mlx5_query_mad_ifc_smp_attr_node_info() is internal to mad.c Hence, make it static.

---
 drivers/infiniband/hw/mlx5/mad.c     | 4 ++--
 drivers/infiniband/hw/mlx5/mlx5_ib.h | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/mad.c +2 -2
index 9bb9bb058932..53dec6063245 100644
@@ -308,8 +308,8 @@ int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port)
 	return err;
 }
 
-int mlx5_query_mad_ifc_smp_attr_node_info(struct ib_device *ibdev,
-					  struct ib_smp *out_mad)
+static int mlx5_query_mad_ifc_smp_attr_node_info(struct ib_device *ibdev,
+						 struct ib_smp *out_mad)
 {
 	struct ib_smp *in_mad = NULL;
 	int err = -ENOMEM;
drivers/infiniband/hw/mlx5/mlx5_ib.h +0 -2
index b0fdc1b08e06..acc56eaa7356 100644
@@ -1280,8 +1280,6 @@ int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 int mlx5_ib_alloc_xrcd(struct ib_xrcd *xrcd, struct ib_udata *udata);
 int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd, struct ib_udata *udata);
 int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port);
-int mlx5_query_mad_ifc_smp_attr_node_info(struct ib_device *ibdev,
-					  struct ib_smp *out_mad);
 int mlx5_query_mad_ifc_system_image_guid(struct ib_device *ibdev,
 					 __be64 *sys_image_guid);
 int mlx5_query_mad_ifc_max_pkeys(struct ib_device *ibdev,

--
2.29.2

#5 lore raw

PATCH 5/5 RDMA/mlx5: Fix wrong free of blue flame register on error

In reply to Leon Romanovsky

From: Mark Bloch <[email protected]>

If the allocation of the fast path blue flame register fails, the driver should free the regular blue flame register.

Fixes 16c1975f1032 ("IB/mlx5: Create profile infrastructure to add and remove stage")
---
 drivers/infiniband/hw/mlx5/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/main.c +1 -1
index 84309bcd67d5..427221a13fbc 100644
@@ -4340,7 +4340,7 @@ static int mlx5_ib_stage_bfrag_init(struct mlx5_ib_dev *dev)
 
 	err = mlx5_alloc_bfreg(dev->mdev, &dev->fp_bfreg, false, true);
 	if (err)
-		mlx5_free_bfreg(dev->mdev, &dev->fp_bfreg);
+		mlx5_free_bfreg(dev->mdev, &dev->bfreg);
 
 	return err;
 }

--
2.29.2

maintainer
#6 lore raw
In reply to Leon Romanovsky
Quoted 3 lines · Leon Romanovsky

RDMA/umem: Avoid undefined behavior of rounddown_pow_of_two RDMA/mlx5: Fix wrong free of blue flame register on error IB/mlx5: Fix error unwinding when set_has_smi_cap fails

I took these ones to for-rc

Thanks,
Jason

#7 lore raw
Quoted 7 lines · Jason Gunthorpe
Quoted 3 lines · Leon Romanovsky

RDMA/umem: Avoid undefined behavior of rounddown_pow_of_two RDMA/mlx5: Fix wrong free of blue flame register on error IB/mlx5: Fix error unwinding when set_has_smi_cap fails

I took these ones to for-rc

It is your call, personally, I'm sending two types of patches to -rc:
crashes and "new bugs".

Thanks

Quoted 3 lines

Thanks,
Jason

maintainer
#8 lore raw
In reply to Leon Romanovsky
Quoted 9 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Small set of fixes for -next, only Aharon's fix has potential to be taken to the -rc.

Thanks

IB/mlx5: Add mutex destroy call to cap_mask_mutex mutex IB/mlx5: Make function static

These two applied to for-next, thanks

Jason