linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rdma-next 0/5] Set of fixes
@ 2021-01-13 12:16 Leon Romanovsky
  2021-01-13 12:16 ` [PATCH rdma-next 1/5] RDMA/umem: Avoid undefined behavior of rounddown_pow_of_two Leon Romanovsky
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Leon Romanovsky @ 2021-01-13 12:16 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, Aharon Landau, linux-rdma, Maor Gottlieb,
	Mark Bloch, Parav Pandit

From: Leon Romanovsky <leonro@nvidia.com>

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH rdma-next 1/5] RDMA/umem: Avoid undefined behavior of rounddown_pow_of_two
  2021-01-13 12:16 [PATCH rdma-next 0/5] Set of fixes Leon Romanovsky
@ 2021-01-13 12:16 ` Leon Romanovsky
  2021-01-13 12:17 ` [PATCH rdma-next 2/5] IB/mlx5: Fix error unwinding when set_has_smi_cap fails Leon Romanovsky
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2021-01-13 12:16 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Aharon Landau, linux-rdma, Maor Gottlieb, Mark Bloch, Parav Pandit

From: Aharon Landau <aharonl@nvidia.com>

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()")
Signed-off-by: Aharon Landau <aharonl@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/core/umem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 95be8cc75d2e..baaf1bf22941 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH rdma-next 2/5] IB/mlx5: Fix error unwinding when set_has_smi_cap fails
  2021-01-13 12:16 [PATCH rdma-next 0/5] Set of fixes Leon Romanovsky
  2021-01-13 12:16 ` [PATCH rdma-next 1/5] RDMA/umem: Avoid undefined behavior of rounddown_pow_of_two Leon Romanovsky
@ 2021-01-13 12:17 ` Leon Romanovsky
  2021-01-13 12:17 ` [PATCH rdma-next 3/5] IB/mlx5: Add mutex destroy call to cap_mask_mutex mutex Leon Romanovsky
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2021-01-13 12:17 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Parav Pandit, Aharon Landau, linux-rdma, Maor Gottlieb, Mark Bloch

From: Parav Pandit <parav@nvidia.com>

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")
Signed-off-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx5/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 36f8ae4fe619..4f21e561f73e 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH rdma-next 3/5] IB/mlx5: Add mutex destroy call to cap_mask_mutex mutex
  2021-01-13 12:16 [PATCH rdma-next 0/5] Set of fixes Leon Romanovsky
  2021-01-13 12:16 ` [PATCH rdma-next 1/5] RDMA/umem: Avoid undefined behavior of rounddown_pow_of_two Leon Romanovsky
  2021-01-13 12:17 ` [PATCH rdma-next 2/5] IB/mlx5: Fix error unwinding when set_has_smi_cap fails Leon Romanovsky
@ 2021-01-13 12:17 ` Leon Romanovsky
  2021-01-13 12:17 ` [PATCH rdma-next 4/5] IB/mlx5: Make function static Leon Romanovsky
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2021-01-13 12:17 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Parav Pandit, Aharon Landau, linux-rdma, Maor Gottlieb, Mark Bloch

From: Parav Pandit <parav@nvidia.com>

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")
Signed-off-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx5/main.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 4f21e561f73e..84309bcd67d5 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH rdma-next 4/5] IB/mlx5: Make function static
  2021-01-13 12:16 [PATCH rdma-next 0/5] Set of fixes Leon Romanovsky
                   ` (2 preceding siblings ...)
  2021-01-13 12:17 ` [PATCH rdma-next 3/5] IB/mlx5: Add mutex destroy call to cap_mask_mutex mutex Leon Romanovsky
@ 2021-01-13 12:17 ` Leon Romanovsky
  2021-01-13 12:17 ` [PATCH rdma-next 5/5] RDMA/mlx5: Fix wrong free of blue flame register on error Leon Romanovsky
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2021-01-13 12:17 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Parav Pandit, Aharon Landau, linux-rdma, Maor Gottlieb, Mark Bloch

From: Parav Pandit <parav@nvidia.com>

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

Signed-off-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx5/mad.c     | 4 ++--
 drivers/infiniband/hw/mlx5/mlx5_ib.h | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/mad.c b/drivers/infiniband/hw/mlx5/mad.c
index 9bb9bb058932..53dec6063245 100644
--- a/drivers/infiniband/hw/mlx5/mad.c
+++ b/drivers/infiniband/hw/mlx5/mad.c
@@ -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;
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index b0fdc1b08e06..acc56eaa7356 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH rdma-next 5/5] RDMA/mlx5: Fix wrong free of blue flame register on error
  2021-01-13 12:16 [PATCH rdma-next 0/5] Set of fixes Leon Romanovsky
                   ` (3 preceding siblings ...)
  2021-01-13 12:17 ` [PATCH rdma-next 4/5] IB/mlx5: Make function static Leon Romanovsky
@ 2021-01-13 12:17 ` Leon Romanovsky
  2021-01-14 17:04 ` [PATCH rdma-next 0/5] Set of fixes Jason Gunthorpe
  2021-01-20  0:15 ` Jason Gunthorpe
  6 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2021-01-13 12:17 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Mark Bloch, Aharon Landau, linux-rdma, Maor Gottlieb,
	Parav Pandit, Hans Petter Selasky

From: Mark Bloch <mbloch@nvidia.com>

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")
Reported-by: Hans Petter Selasky <hanss@nvidia.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx5/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 84309bcd67d5..427221a13fbc 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH rdma-next 0/5] Set of fixes
  2021-01-13 12:16 [PATCH rdma-next 0/5] Set of fixes Leon Romanovsky
                   ` (4 preceding siblings ...)
  2021-01-13 12:17 ` [PATCH rdma-next 5/5] RDMA/mlx5: Fix wrong free of blue flame register on error Leon Romanovsky
@ 2021-01-14 17:04 ` Jason Gunthorpe
  2021-01-14 17:36   ` Leon Romanovsky
  2021-01-20  0:15 ` Jason Gunthorpe
  6 siblings, 1 reply; 9+ messages in thread
From: Jason Gunthorpe @ 2021-01-14 17:04 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Doug Ledford, Leon Romanovsky, Aharon Landau, linux-rdma,
	Maor Gottlieb, Mark Bloch, Parav Pandit

On Wed, Jan 13, 2021 at 02:16:58PM +0200, Leon Romanovsky wrote:

>   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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH rdma-next 0/5] Set of fixes
  2021-01-14 17:04 ` [PATCH rdma-next 0/5] Set of fixes Jason Gunthorpe
@ 2021-01-14 17:36   ` Leon Romanovsky
  0 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2021-01-14 17:36 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Doug Ledford, Aharon Landau, linux-rdma, Maor Gottlieb,
	Mark Bloch, Parav Pandit

On Thu, Jan 14, 2021 at 01:04:11PM -0400, Jason Gunthorpe wrote:
> On Wed, Jan 13, 2021 at 02:16:58PM +0200, Leon Romanovsky wrote:
>
> >   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

>
> Thanks,
> Jason

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH rdma-next 0/5] Set of fixes
  2021-01-13 12:16 [PATCH rdma-next 0/5] Set of fixes Leon Romanovsky
                   ` (5 preceding siblings ...)
  2021-01-14 17:04 ` [PATCH rdma-next 0/5] Set of fixes Jason Gunthorpe
@ 2021-01-20  0:15 ` Jason Gunthorpe
  6 siblings, 0 replies; 9+ messages in thread
From: Jason Gunthorpe @ 2021-01-20  0:15 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Doug Ledford, Leon Romanovsky, Aharon Landau, linux-rdma,
	Maor Gottlieb, Mark Bloch, Parav Pandit

On Wed, Jan 13, 2021 at 02:16:58PM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-01-20  0:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13 12:16 [PATCH rdma-next 0/5] Set of fixes Leon Romanovsky
2021-01-13 12:16 ` [PATCH rdma-next 1/5] RDMA/umem: Avoid undefined behavior of rounddown_pow_of_two Leon Romanovsky
2021-01-13 12:17 ` [PATCH rdma-next 2/5] IB/mlx5: Fix error unwinding when set_has_smi_cap fails Leon Romanovsky
2021-01-13 12:17 ` [PATCH rdma-next 3/5] IB/mlx5: Add mutex destroy call to cap_mask_mutex mutex Leon Romanovsky
2021-01-13 12:17 ` [PATCH rdma-next 4/5] IB/mlx5: Make function static Leon Romanovsky
2021-01-13 12:17 ` [PATCH rdma-next 5/5] RDMA/mlx5: Fix wrong free of blue flame register on error Leon Romanovsky
2021-01-14 17:04 ` [PATCH rdma-next 0/5] Set of fixes Jason Gunthorpe
2021-01-14 17:36   ` Leon Romanovsky
2021-01-20  0:15 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).