Skip to content

Commit 75e8564

Browse files
rleonSaeed Mahameed
authored andcommitted
net/mlx5: Don't overwrite HCA capabilities when setting MSI-X count
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: 604774a ("net/mlx5: Dynamically assign MSI-X vectors count") Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 7c9f131 commit 75e8564

File tree

1 file changed

+17
-5
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+17
-5
lines changed

drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ int mlx5_get_default_msix_vec_count(struct mlx5_core_dev *dev, int num_vfs)
9595
int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id,
9696
int msix_vec_count)
9797
{
98-
int sz = MLX5_ST_SZ_BYTES(set_hca_cap_in);
98+
int query_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out);
99+
int set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in);
100+
void *hca_cap = NULL, *query_cap = NULL, *cap;
99101
int num_vf_msix, min_msix, max_msix;
100-
void *hca_cap, *cap;
101102
int ret;
102103

103104
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,
116117
if (msix_vec_count > max_msix)
117118
return -EOVERFLOW;
118119

119-
hca_cap = kzalloc(sz, GFP_KERNEL);
120-
if (!hca_cap)
121-
return -ENOMEM;
120+
query_cap = kzalloc(query_sz, GFP_KERNEL);
121+
hca_cap = kzalloc(set_sz, GFP_KERNEL);
122+
if (!hca_cap || !query_cap) {
123+
ret = -ENOMEM;
124+
goto out;
125+
}
126+
127+
ret = mlx5_vport_get_other_func_cap(dev, function_id, query_cap);
128+
if (ret)
129+
goto out;
122130

123131
cap = MLX5_ADDR_OF(set_hca_cap_in, hca_cap, capability);
132+
memcpy(cap, MLX5_ADDR_OF(query_hca_cap_out, query_cap, capability),
133+
MLX5_UN_SZ_BYTES(hca_cap_union));
124134
MLX5_SET(cmd_hca_cap, cap, dynamic_msix_table_size, msix_vec_count);
125135

126136
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,
130140
MLX5_SET(set_hca_cap_in, hca_cap, op_mod,
131141
MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE << 1);
132142
ret = mlx5_cmd_exec_in(dev, set_hca_cap, hca_cap);
143+
out:
133144
kfree(hca_cap);
145+
kfree(query_cap);
134146
return ret;
135147
}
136148

0 commit comments

Comments
 (0)