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: 604774add5
("net/mlx5: Dynamically assign MSI-X vectors count")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
parent
7c9f131f36
commit
75e8564e91
|
@ -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 mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id,
|
||||||
int msix_vec_count)
|
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;
|
int num_vf_msix, min_msix, max_msix;
|
||||||
void *hca_cap, *cap;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
num_vf_msix = MLX5_CAP_GEN_MAX(dev, num_total_dynamic_vf_msix);
|
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)
|
if (msix_vec_count > max_msix)
|
||||||
return -EOVERFLOW;
|
return -EOVERFLOW;
|
||||||
|
|
||||||
hca_cap = kzalloc(sz, GFP_KERNEL);
|
query_cap = kzalloc(query_sz, GFP_KERNEL);
|
||||||
if (!hca_cap)
|
hca_cap = kzalloc(set_sz, GFP_KERNEL);
|
||||||
return -ENOMEM;
|
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);
|
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(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);
|
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(set_hca_cap_in, hca_cap, op_mod,
|
||||||
MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE << 1);
|
MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE << 1);
|
||||||
ret = mlx5_cmd_exec_in(dev, set_hca_cap, hca_cap);
|
ret = mlx5_cmd_exec_in(dev, set_hca_cap, hca_cap);
|
||||||
|
out:
|
||||||
kfree(hca_cap);
|
kfree(hca_cap);
|
||||||
|
kfree(query_cap);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue