]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
IB/mlx5: Verify that Q counters are supported
authorKamal Heib <kamalh@mellanox.com>
Wed, 18 Jan 2017 12:10:32 +0000 (14:10 +0200)
committerTim Gardner <tim.gardner@canonical.com>
Mon, 20 Mar 2017 11:24:55 +0000 (05:24 -0600)
BugLink: http://bugs.launchpad.net/bugs/1674288
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>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/infiniband/hw/mlx5/main.c

index 1cce06f14c840ce92c54a8da7a9eaef1d8fd3cb4..94d7eb035c58a37aa6b00c3d064c97772a8b0ced 100644 (file)
@@ -3242,9 +3242,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)
@@ -3272,7 +3274,8 @@ err_dev:
        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);
@@ -3302,7 +3305,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);