Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753217AbdCPOey (ORCPT ); Thu, 16 Mar 2017 10:34:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60798 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753070AbdCPOew (ORCPT ); Thu, 16 Mar 2017 10:34:52 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kamal Heib , Mark Bloch , Leon Romanovsky , Doug Ledford Subject: [PATCH 4.9 44/44] IB/mlx5: Verify that Q counters are supported Date: Thu, 16 Mar 2017 23:30:09 +0900 Message-Id: <20170316142927.769104488@linuxfoundation.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170316142925.994282609@linuxfoundation.org> References: <20170316142925.994282609@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1797 Lines: 62 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kamal Heib 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 Reviewed-by: Mark Bloch Signed-off-by: Leon Romanovsky Signed-off-by: Doug Ledford Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/mlx5/main.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) --- 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_cor 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) @@ -3171,7 +3173,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); @@ -3201,7 +3204,8 @@ static void mlx5_ib_remove(struct mlx5_c mlx5_remove_roce_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);