Batch of fixes to mlx5_ib
Subsystems (5)
cover Batch of fixes to mlx5_ib
From: Leon Romanovsky <[email protected]>
Hi,
This is batch of independent fixes related to mlx5_ib driver.
Thanks
Chris Mi (1):
RDMA/mlx5: Set local port to one when accessing counters
Maher Sanalla (1):
RDMA/mlx5: Rely on RoCE fw cap instead of devlink when setting profile
Maor Gottlieb (1):
RDMA/mlx5: Fix UMR cleanup on error flow of driver init
drivers/infiniband/hw/mlx5/mad.c | 6 +++++ drivers/infiniband/hw/mlx5/main.c | 2 +- drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 + drivers/infiniband/hw/mlx5/umr.c | 3 +++ .../net/ethernet/mellanox/mlx5/core/main.c | 23 +++++++++++++++++-- include/linux/mlx5/driver.h | 19 +++++++-------- 6 files changed, 42 insertions(+), 12 deletions(-)
Signature · 1 line
2.37.2
PATCH 1/3 RDMA/mlx5: Rely on RoCE fw cap instead of devlink when setting profile
From: Maher Sanalla <[email protected]>
When the RDMA auxiliary driver probes, it sets its profile based on devlink driverinit value. The latter might not be in sync with FW yet (In case devlink reload is not performed), thus causing a mismatch between RDMA driver and FW. This results in the following FW syndrome when the RDMA driver tries to adjust RoCE state, which fails the probe:
"0xC1F678 | modify_nic_vport_context: roce_en set on a vport that doesn't support roce"
To prevent this, select the PF profile based on FW RoCE capability instead of relying on devlink driverinit value.
To provide backward compatibility of the RoCE disable feature, on older FW's where roce_rw is not set (FW RoCE capability is read-only), keep the current behavior e.g., rely on devlink driverinit value.
--- drivers/infiniband/hw/mlx5/main.c | 2 +- .../net/ethernet/mellanox/mlx5/core/main.c | 23 +++++++++++++++++-- include/linux/mlx5/driver.h | 19 +++++++-------- 3 files changed, 32 insertions(+), 12 deletions(-)
drivers/infiniband/hw/mlx5/main.c +1 -1
@@ -4336,7 +4336,7 @@ static int mlx5r_probe(struct auxiliary_device *adev, dev->mdev = mdev; dev->num_ports = num_ports; -if (ll ==IB_LINK_LAYER_ETHERNET && !mlx5_is_roce_init_enabled (mdev)) +if (ll ==IB_LINK_LAYER_ETHERNET && !mlx5_get_roce_state (mdev)) profile = &raw_eth_profile;else profile = &pf_profile;
drivers/net/ethernet/mellanox/mlx5/core/main.c +21 -2
@@ -494,6 +494,24 @@ static int max_uc_list_get_devlink_param(struct mlx5_core_dev *dev)return err; } +bool mlx5_is_roce_on (struct mlx5_core_dev *dev) +{ +struct devlink *devlink =priv_to_devlink (dev); +union devlink_param_value val; +int err; + + err =devlink_param_driverinit_value_get (devlink, +DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE , + &val); + +if (!err) +return val.vbool; + +mlx5_core_dbg (dev,"Failed to get param. err = %d\n" , err); +return MLX5_CAP_GEN (dev, roce); +} +EXPORT_SYMBOL (mlx5_is_roce_on); +static int handle_hca_cap_2 (struct mlx5_core_dev *dev,void *set_ctx) {void *set_hca_cap;
@@ -597,7 +615,8 @@ static int handle_hca_cap(struct mlx5_core_dev *dev, void *set_ctx) MLX5_CAP_GEN_MAX(dev, num_total_dynamic_vf_msix));if (MLX5_CAP_GEN (dev, roce_rw_supported)) -MLX5_SET (cmd_hca_cap, set_hca_cap, roce,mlx5_is_roce_init_enabled (dev)); +MLX5_SET (cmd_hca_cap, set_hca_cap, roce, +mlx5_is_roce_on (dev)); max_uc_list =max_uc_list_get_devlink_param (dev);if (max_uc_list >0 )
@@ -623,7 +642,7 @@ static int handle_hca_cap(struct mlx5_core_dev *dev, void *set_ctx)*/ static bool is_roce_fw_disabled (struct mlx5_core_dev *dev) { -return (MLX5_CAP_GEN (dev, roce_rw_supported) && !mlx5_is_roce_init_enabled (dev)) || +return (MLX5_CAP_GEN (dev, roce_rw_supported) && !mlx5_is_roce_on (dev)) || (!MLX5_CAP_GEN (dev, roce_rw_supported) && !MLX5_CAP_GEN (dev, roce)); }
include/linux/mlx5/driver.h +10 -9
@@ -1279,16 +1279,17 @@ enum { MLX5_TRIGGERED_CMD_COMP = (u64)1 << 32, }; -static inline bool mlx5_is_roce_init_enabled (struct mlx5_core_dev *dev) +bool mlx5_is_roce_on (struct mlx5_core_dev *dev); + +static inline bool mlx5_get_roce_state (struct mlx5_core_dev *dev) { -struct devlink *devlink =priv_to_devlink (dev); -union devlink_param_value val; -int err; - - err =devlink_param_driverinit_value_get (devlink, -DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE , - &val); -return err ?MLX5_CAP_GEN (dev, roce) : val.vbool; +if (MLX5_CAP_GEN (dev, roce_rw_supported)) +return MLX5_CAP_GEN (dev, roce); + +/* If RoCE cap is read-only in FW, get RoCE state from devlink +* in order to support RoCE enable/disable feature +*/ +return mlx5_is_roce_on (dev); }#endif /* MLX5_DRIVER_H */
Signature · 1 line
2.37.2
PATCH 2/3 RDMA/mlx5: Set local port to one when accessing counters
In reply to Leon RomanovskyFrom: Chris Mi <[email protected]>
When accessing Ports Performance Counters Register (PPCNT), local port must be one if it is Function-Per-Port HCA that HCA_CAP.num_ports is 1.
The offending patch can change the local port to other values when accessing PPCNT after enabling switchdev mode. The following syndrome will be printed:
# cat /sys/class/infiniband/rdmap4s0f0/ports/2/counters/* # dmesg mlx5_core 0000:04:00.0: mlx5_cmd_check:756:(pid 12450): ACCESS_REG(0x805) op_mod(0x1) failed, status bad parameter(0x3), syndrome (0x1e5585)
Fix it by setting local port to one for Function-Per-Port HCA.
--- drivers/infiniband/hw/mlx5/mad.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/infiniband/hw/mlx5/mad.c +6 -0
@@ -166,6 +166,12 @@ static int process_pma_cmd(struct mlx5_ib_dev *dev, u32 port_num, mdev = dev->mdev; mdev_port_num =1 ; } +if (MLX5_CAP_GEN (dev->mdev, num_ports) ==1 ) { +/* set local port to one for Function-Per-Port HCA. */ + mdev = dev->mdev; + mdev_port_num =1 ; + } +/* Declaring support of extended counters */ if (in_mad->mad_hdr.attr_id ==IB_PMA_CLASS_PORT_INFO ) {struct ib_class_port_info cpi = {};
Signature · 1 line
2.37.2
PATCH 3/3 RDMA/mlx5: Fix UMR cleanup on error flow of driver init
In reply to Leon RomanovskyFrom: Maor Gottlieb <[email protected]>
The cited commit removed from the cleanup flow of umr the checks if the resources were created. This could lead to null-ptr-deref in case that we had failure in mlx5_ib_stage_ib_reg_init stage.
Fix it by adding new state to the umr that can say if the resources were created or not and check it in the umr cleanup flow before destroying the resources.
--- drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 + drivers/infiniband/hw/mlx5/umr.c | 3 +++ 2 files changed, 4 insertions(+)
drivers/infiniband/hw/mlx5/mlx5_ib.h +1 -0
@@ -708,6 +708,7 @@ struct mlx5_ib_umr_context { };enum { +MLX5_UMR_STATE_UNINIT ,MLX5_UMR_STATE_ACTIVE ,MLX5_UMR_STATE_RECOVER ,MLX5_UMR_STATE_ERR ,
drivers/infiniband/hw/mlx5/umr.c +3 -0
@@ -177,6 +177,7 @@ int mlx5r_umr_resource_init(struct mlx5_ib_dev *dev)sema_init (&dev->umrc.sem,MAX_UMR_WR );mutex_init (&dev->umrc.lock); + dev->umrc.state =MLX5_UMR_STATE_ACTIVE ;return 0 ;
@@ -191,6 +192,8 @@ int mlx5r_umr_resource_init(struct mlx5_ib_dev *dev)void mlx5r_umr_resource_cleanup (struct mlx5_ib_dev *dev) { +if (dev->umrc.state ==MLX5_UMR_STATE_UNINIT ) +return ;ib_destroy_qp (dev->umrc.qp);ib_free_cq (dev->umrc.cq);ib_dealloc_pd (dev->umrc.pd);
Signature · 1 line
2.37.2
Leon Romanovsky
AppliedQuoted 17 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
Hi,
This is batch of independent fixes related to
mlx5_ibdriver.Thanks
Chris Mi (1):
RDMA/mlx5: Set local port to one when accessing countersMaher Sanalla (1):
RDMA/mlx5: Rely on RoCE fw cap instead of devlink when setting profileMaor Gottlieb (1):
RDMA/mlx5: Fix UMR cleanup on error flow of driver init
Quoted 7 lines
drivers/infiniband/hw/mlx5/mad.c | 6 +++++ drivers/infiniband/hw/mlx5/main.c | 2 +- drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 + drivers/infiniband/hw/mlx5/umr.c | 3 +++ .../net/ethernet/mellanox/mlx5/core/main.c | 23 +++++++++++++++++-- include/linux/mlx5/driver.h | 19 +++++++-------- 6 files changed, 42 insertions(+), 12 deletions(-)
Thanks, applied to rdma-rc.
Quoted 4 lines
Signature · 2 lines
-- 2.37.2