Skip to content

Commit

Permalink
IB/mlx5: Verify that Q counters are supported
Browse files Browse the repository at this point in the history
commit 45bded2 upstream.

Make sure that the Q counters are supported by the FW before trying
to allocate/deallocte them, this will avoid driver load failure when
they aren't supported by the FW.

Fixes: 0837e86 ('IB/mlx5: Add per port counters')
Signed-off-by: Kamal Heib <kamalh@mellanox.com>
Reviewed-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Kamal Heib authored and Greg Kroah-Hartman committed Mar 18, 2017
1 parent dc37bb8 commit 42b16ff
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/infiniband/hw/mlx5/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3233,9 +3233,11 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
if (err)
goto err_rsrc;

err = mlx5_ib_alloc_q_counters(dev);
if (err)
goto err_odp;
if (MLX5_CAP_GEN(dev->mdev, max_qp_cnt)) {
err = mlx5_ib_alloc_q_counters(dev);
if (err)
goto err_odp;
}

err = ib_register_device(&dev->ib_dev, NULL);
if (err)
Expand Down Expand Up @@ -3263,7 +3265,8 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
ib_unregister_device(&dev->ib_dev);

err_q_cnt:
mlx5_ib_dealloc_q_counters(dev);
if (MLX5_CAP_GEN(dev->mdev, max_qp_cnt))
mlx5_ib_dealloc_q_counters(dev);

err_odp:
mlx5_ib_odp_remove_one(dev);
Expand Down Expand Up @@ -3293,7 +3296,8 @@ static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context)

mlx5_remove_netdev_notifier(dev);
ib_unregister_device(&dev->ib_dev);
mlx5_ib_dealloc_q_counters(dev);
if (MLX5_CAP_GEN(dev->mdev, max_qp_cnt))
mlx5_ib_dealloc_q_counters(dev);
destroy_umrc_res(dev);
mlx5_ib_odp_remove_one(dev);
destroy_dev_resources(&dev->devr);
Expand Down

0 comments on commit 42b16ff

Please sign in to comment.