diff options
author | Kamal Heib <kamalh@mellanox.com> | 2017-01-18 07:10:32 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-18 07:14:35 -0400 |
commit | c8186699527b5b0ee080e510afac9a3db797aa1b (patch) | |
tree | 261df9d0797806d4bd90337113093200be8908e1 | |
parent | 8fed8fc18839d7aec7ea046d79eb814dce6255c3 (diff) |
IB/mlx5: Verify that Q counters are supported
commit 45bded2c216da6010184ac5ebe88c27f73439009 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: 0837e86a7a34 ('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>
-rw-r--r-- | drivers/infiniband/hw/mlx5/main.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 4cab29ea394c..11bfa27b022c 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c | |||
@@ -3141,9 +3141,11 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) | |||
3141 | if (err) | 3141 | if (err) |
3142 | goto err_rsrc; | 3142 | goto err_rsrc; |
3143 | 3143 | ||
3144 | err = mlx5_ib_alloc_q_counters(dev); | 3144 | if (MLX5_CAP_GEN(dev->mdev, max_qp_cnt)) { |
3145 | if (err) | 3145 | err = mlx5_ib_alloc_q_counters(dev); |
3146 | goto err_odp; | 3146 | if (err) |
3147 | goto err_odp; | ||
3148 | } | ||
3147 | 3149 | ||
3148 | err = ib_register_device(&dev->ib_dev, NULL); | 3150 | err = ib_register_device(&dev->ib_dev, NULL); |
3149 | if (err) | 3151 | if (err) |
@@ -3171,7 +3173,8 @@ err_dev: | |||
3171 | ib_unregister_device(&dev->ib_dev); | 3173 | ib_unregister_device(&dev->ib_dev); |
3172 | 3174 | ||
3173 | err_q_cnt: | 3175 | err_q_cnt: |
3174 | mlx5_ib_dealloc_q_counters(dev); | 3176 | if (MLX5_CAP_GEN(dev->mdev, max_qp_cnt)) |
3177 | mlx5_ib_dealloc_q_counters(dev); | ||
3175 | 3178 | ||
3176 | err_odp: | 3179 | err_odp: |
3177 | mlx5_ib_odp_remove_one(dev); | 3180 | mlx5_ib_odp_remove_one(dev); |
@@ -3201,7 +3204,8 @@ static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context) | |||
3201 | 3204 | ||
3202 | mlx5_remove_roce_notifier(dev); | 3205 | mlx5_remove_roce_notifier(dev); |
3203 | ib_unregister_device(&dev->ib_dev); | 3206 | ib_unregister_device(&dev->ib_dev); |
3204 | mlx5_ib_dealloc_q_counters(dev); | 3207 | if (MLX5_CAP_GEN(dev->mdev, max_qp_cnt)) |
3208 | mlx5_ib_dealloc_q_counters(dev); | ||
3205 | destroy_umrc_res(dev); | 3209 | destroy_umrc_res(dev); |
3206 | mlx5_ib_odp_remove_one(dev); | 3210 | mlx5_ib_odp_remove_one(dev); |
3207 | destroy_dev_resources(&dev->devr); | 3211 | destroy_dev_resources(&dev->devr); |