All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
	Leon Romanovsky <leonro@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Subject: [net 14/16] net/mlx5: Don't overwrite HCA capabilities when setting MSI-X count
Date: Tue, 18 May 2021 23:05:21 -0700	[thread overview]
Message-ID: <20210519060523.17875-15-saeed@kernel.org> (raw)
In-Reply-To: <20210519060523.17875-1-saeed@kernel.org>

From: Leon Romanovsky <leonro@nvidia.com>

During driver probe of device that has dynamic MSI-X feature enabled,
the following error is printed in some FW flavour (not released yet).

 mlx5_core 0000:06:00.0: firmware version: 4.7.4387
 mlx5_core 0000:06:00.0: 126.016 Gb/s available PCIe bandwidth (8.0 GT/s PCIe x16 link)
 mlx5_core 0000:06:00.0: mlx5_cmd_check:777:(pid 70599): SET_HCA_CAP(0x109) op_mod(0x0) failed, status bad parameter(0x3), syndrome (0x0)
 mlx5_core 0000:06:00.0: set_hca_cap:622:(pid 70599): handle_hca_cap failed
 mlx5_core 0000:06:00.0: mlx5_function_setup:1045:(pid 70599): set_hca_cap failed
 mlx5_core 0000:06:00.0: probe_one:1465:(pid 70599): mlx5_init_one failed with error code -22
 mlx5_core: probe of 0000:06:00.0 failed with error -22

In order to make the setting capability of MSI-X future proof, let's
query the current capabilities first.

Fixes: 604774add516 ("net/mlx5: Dynamically assign MSI-X vectors count")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../net/ethernet/mellanox/mlx5/core/pci_irq.c | 22 ++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
index 1f907df5b3a2..c3373fb1cd7f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
@@ -95,9 +95,10 @@ int mlx5_get_default_msix_vec_count(struct mlx5_core_dev *dev, int num_vfs)
 int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id,
 			    int msix_vec_count)
 {
-	int sz = MLX5_ST_SZ_BYTES(set_hca_cap_in);
+	int query_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out);
+	int set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in);
+	void *hca_cap = NULL, *query_cap = NULL, *cap;
 	int num_vf_msix, min_msix, max_msix;
-	void *hca_cap, *cap;
 	int ret;
 
 	num_vf_msix = MLX5_CAP_GEN_MAX(dev, num_total_dynamic_vf_msix);
@@ -116,11 +117,20 @@ int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id,
 	if (msix_vec_count > max_msix)
 		return -EOVERFLOW;
 
-	hca_cap = kzalloc(sz, GFP_KERNEL);
-	if (!hca_cap)
-		return -ENOMEM;
+	query_cap = kzalloc(query_sz, GFP_KERNEL);
+	hca_cap = kzalloc(set_sz, GFP_KERNEL);
+	if (!hca_cap || !query_cap) {
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	ret = mlx5_vport_get_other_func_cap(dev, function_id, query_cap);
+	if (ret)
+		goto out;
 
 	cap = MLX5_ADDR_OF(set_hca_cap_in, hca_cap, capability);
+	memcpy(cap, MLX5_ADDR_OF(query_hca_cap_out, query_cap, capability),
+	       MLX5_UN_SZ_BYTES(hca_cap_union));
 	MLX5_SET(cmd_hca_cap, cap, dynamic_msix_table_size, msix_vec_count);
 
 	MLX5_SET(set_hca_cap_in, hca_cap, opcode, MLX5_CMD_OP_SET_HCA_CAP);
@@ -130,7 +140,9 @@ int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id,
 	MLX5_SET(set_hca_cap_in, hca_cap, op_mod,
 		 MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE << 1);
 	ret = mlx5_cmd_exec_in(dev, set_hca_cap, hca_cap);
+out:
 	kfree(hca_cap);
+	kfree(query_cap);
 	return ret;
 }
 
-- 
2.31.1


  parent reply	other threads:[~2021-05-19  6:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19  6:05 [pull request][net 00/16] mlx5 fixes 2021-05-18 Saeed Mahameed
2021-05-19  6:05 ` [net 01/16] {net, RDMA}/mlx5: Fix override of log_max_qp by other device Saeed Mahameed
2021-05-19 19:30   ` patchwork-bot+netdevbpf
2021-05-19  6:05 ` [net 02/16] net/mlx5e: Fix nullptr in add_vlan_push_action() Saeed Mahameed
2021-05-19  6:05 ` [net 03/16] net/mlx5: Set reformat action when needed for termination rules Saeed Mahameed
2021-05-19  6:05 ` [net 04/16] net/mlx5: Fix err prints and return when creating termination table Saeed Mahameed
2021-05-19  6:05 ` [net 05/16] net/mlx5: SF, Fix show state inactive when its inactivated Saeed Mahameed
2021-05-19  6:05 ` [net 06/16] net/mlx5e: Fix nullptr in mlx5e_tc_add_fdb_flow() Saeed Mahameed
2021-05-19  6:05 ` [net 07/16] net/mlx5e: Fix null deref accessing lag dev Saeed Mahameed
2021-05-19  6:05 ` [net 08/16] net/mlx5e: Make sure fib dev exists in fib event Saeed Mahameed
2021-05-19  6:05 ` [net 09/16] net/mlx5e: reset XPS on error flow if netdev isn't registered yet Saeed Mahameed
2021-05-19  6:05 ` [net 10/16] net/mlx5e: Fix multipath lag activation Saeed Mahameed
2021-05-19  6:05 ` [net 11/16] net/mlx5e: Reject mirroring on source port change encap rules Saeed Mahameed
2021-05-19  6:05 ` [net 12/16] net/mlx5e: Fix error path of updating netdev queues Saeed Mahameed
2021-05-19  6:05 ` [net 13/16] {net,vdpa}/mlx5: Configure interface MAC into mpfs L2 table Saeed Mahameed
2021-05-19  6:05 ` Saeed Mahameed [this message]
2021-05-19  6:05 ` [net 15/16] net/mlx5: Set term table as an unmanaged flow table Saeed Mahameed
2021-05-19  6:05 ` [net 16/16] mlx5e: add add missing BH locking around napi_schdule() Saeed Mahameed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210519060523.17875-15-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=leonro@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.