mlx5 fixes 2021-09-07
From: Saeed Mahameed <[email protected]>
Hi Dave, Jakub,
This series introduces some fixes to mlx5 driver. Please pull and let me know if there is any problem.
Included here, a patch which solves a build warning reported on linux-kernel mailing list [1]:
Fix commit ("net/mlx5: Bridge, fix uninitialized variable usage")
I hope this series can make it to rc1.
[1] https://www.spinics.net/lists/netdev/msg765481.html
Thanks,
Saeed.
---
The following changes since commit 0f77f2defaf682eb7e7ef623168e49c74ae529e3:
ieee802154: Remove redundant initialization of variable ret (2021-09-07 14:06:08 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2021-09-07
for you to fetch changes up to 8db6a54f3cae6a803b2cbf5390662bca641f7da8:
net/mlx5e: Fix condition when retrieving PTP-rqn (2021-09-07 14:17:02 -0700)
----------------------------------------------------------------
mlx5-fixes-2021-09-07
----------------------------------------------------------------
Aya Levin (2):
net/mlx5e: Fix mutual exclusion between CQE compression and HW TS net/mlx5e: Fix condition when retrieving PTP-rqn
Maor Gottlieb (1):
net/mlx5: Fix potential sleeping in atomic context
Mark Bloch (1):
net/mlx5: Lag, don't update lag if lag isn't supported
Parav Pandit (1):
net/mlx5: Fix rdma aux device on devlink reload
Saeed Mahameed (1):
net/mlx5: FWTrace, cancel work on alloc pd error flow
Vlad Buslov (1):
net/mlx5: Bridge, fix uninitialized variable usage
drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 7 ++----- drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c | 3 ++- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 11 ++++++----- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 5 ++--- drivers/net/ethernet/mellanox/mlx5/core/lag.c | 10 ++++++++-- 9 files changed, 26 insertions(+), 22 deletions(-)
PATCH 1/7 net/mlx5: Bridge, fix uninitialized variable usage
From: Vlad Buslov <[email protected]>
In some conditions variable 'err' is not assigned with value in mlx5_esw_bridge_port_obj_attr_set() and mlx5_esw_bridge_port_changeupper() functions after recent changes to support LAG. Initialize the variable with zero value in both cases.
--- drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c +2 -2
@@ -137,7 +137,7 @@ static int mlx5_esw_bridge_port_changeupper(struct notifier_block *nb, void *ptru16 vport_num, esw_owner_vhca_id;struct netlink_ext_ack *extack;int ifindex = upper->ifindex; -int err; +int err =0 ;if (!netif_is_bridge_master (upper))return 0 ;
@@ -244,7 +244,7 @@ mlx5_esw_bridge_port_obj_attr_set(struct net_device *dev,struct netlink_ext_ack *extack =switchdev_notifier_info_to_extack (&port_attr_info->info);const struct switchdev_attr *attr = port_attr_info->attr;u16 vport_num, esw_owner_vhca_id; -int err; +int err =0 ;if (!mlx5_esw_bridge_lower_rep_vport_num_vhca_id_get (dev, br_offloads->esw, &vport_num, &esw_owner_vhca_id))
Signature · 1 line
2.31.1
Re: [net 1/7] net/mlx5: Bridge, fix uninitialized variable usage
This series was applied to netdev/net.git (refs/heads/master):
Hello:
This series was applied to netdev/net.git (refs/heads/master):
Quoted 8 lines · On Tue, 7 Sep 2021 14:24:14 -0700 you wrote:
From: Vlad Buslov <[email protected]>
In some conditions variable 'err' is not assigned with value in
mlx5_esw_bridge_port_obj_attr_set()andmlx5_esw_bridge_port_changeupper()functions after recent changes to support LAG. Initialize the variable with zero value in both cases.[...]
Here is the summary with links:
- [net,1/7] net/mlx5: Bridge, fix uninitialized variable usage
https://git.kernel.org/netdev/net/c/8343268ec3cf - [net,2/7] net/mlx5: Fix rdma aux device on devlink reload https://git.kernel.org/netdev/net/c/897ae4b40e80 - [net,3/7] net/mlx5: Lag, don't update lag if lag isn't supported https://git.kernel.org/netdev/net/c/da8252d5805d - [net,4/7] net/mlx5: FWTrace, cancel work on alloc pd error flow https://git.kernel.org/netdev/net/c/dfe6fd72b5f1 - [net,5/7] net/mlx5: Fix potential sleeping in atomic context https://git.kernel.org/netdev/net/c/ee27e330a953 - [net,6/7] net/mlx5e: Fix mutual exclusion between CQE compression and HW TS https://git.kernel.org/netdev/net/c/c91c1da72b47 - [net,7/7] net/mlx5e: Fix condition when retrieving PTP-rqn https://git.kernel.org/netdev/net/c/8db6a54f3cae
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
PATCH 2/7 net/mlx5: Fix rdma aux device on devlink reload
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
RDMA auxdev parameter registration was skipped for eswitch manager PCI PF. Due to this when devlink parameter is read, it reads as false in below code flow.
$ devlink dev reload pci/0000:06:00.0
devlink_reload()
mlx5_load_one()
mlx5_attach_device()
is_ib_enabled()
devlink_param_driverinit_value_get()Due to this, is_ib_enabled() returns false for the RDMA auxiliary device. This results into a skipping RDMA auxiliary device creation on reload.
There is no need to check for eswitch manager capability to support RDMA auxiliary device. Hence, fix it by skipping eswitch manager capability.
--- drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +2 -5
@@ -658,11 +658,10 @@ static const struct devlink_param enable_rdma_param =static int mlx5_devlink_rdma_param_register (struct devlink *devlink) { -struct mlx5_core_dev *dev =devlink_priv (devlink);union devlink_param_value value;int err; -if (!IS_ENABLED (CONFIG_MLX5_INFINIBAND ) ||MLX5_ESWITCH_MANAGER (dev)) +if (!IS_ENABLED (CONFIG_MLX5_INFINIBAND ))return 0 ; err =devlink_param_register (devlink, &enable_rdma_param);
@@ -679,9 +678,7 @@ static int mlx5_devlink_rdma_param_register(struct devlink *devlink)static void mlx5_devlink_rdma_param_unregister (struct devlink *devlink) { -struct mlx5_core_dev *dev =devlink_priv (devlink); - -if (!IS_ENABLED (CONFIG_MLX5_INFINIBAND ) ||MLX5_ESWITCH_MANAGER (dev)) +if (!IS_ENABLED (CONFIG_MLX5_INFINIBAND ))return ;devlink_param_unpublish (devlink, &enable_rdma_param);
Signature · 1 line
2.31.1
PATCH 3/7 net/mlx5: Lag, don't update lag if lag isn't supported
In reply to Saeed MahameedFrom: Mark Bloch <[email protected]>
In NICs that don't support LAG, the LAG control structure won't be allocated. If it wasn't allocated it means LAG doesn't exists and can be skipped.
--- drivers/net/ethernet/mellanox/mlx5/core/lag.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lag.c +8 -2
@@ -927,9 +927,12 @@ void mlx5_lag_disable_change(struct mlx5_core_dev *dev)struct mlx5_core_dev *dev1;struct mlx5_lag *ldev; + ldev =mlx5_lag_dev (dev); +if (!ldev) +return ; +mlx5_dev_list_lock (); - ldev =mlx5_lag_dev (dev); dev0 = ldev->pf[MLX5_LAG_P1 ].dev; dev1 = ldev->pf[MLX5_LAG_P2 ].dev;
@@ -946,8 +949,11 @@ void mlx5_lag_enable_change(struct mlx5_core_dev *dev) {struct mlx5_lag *ldev; -mlx5_dev_list_lock (); ldev =mlx5_lag_dev (dev); +if (!ldev) +return ; + +mlx5_dev_list_lock (); ldev->mode_changes_in_progress--;mlx5_dev_list_unlock ();mlx5_queue_bond_work (ldev,0 );
Signature · 1 line
2.31.1
PATCH 4/7 net/mlx5: FWTrace, cancel work on alloc pd error flow
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
Handle error flow on mlx5_core_alloc_pd() failure, read_fw_strings_work must be canceled.
--- drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c +2 -1
@@ -1007,7 +1007,7 @@ int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer) err =mlx5_core_alloc_pd (dev, &tracer->buff.pdn);if (err) {mlx5_core_warn (dev,"FWTracer: Failed to allocate PD %d\n" , err); -return err; + goto err_cancel_work; } err =mlx5_fw_tracer_create_mkey (tracer);
@@ -1031,6 +1031,7 @@ int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer)mlx5_core_destroy_mkey (dev, &tracer->buff.mkey); err_dealloc_pd:mlx5_core_dealloc_pd (dev, tracer->buff.pdn); +err_cancel_work:cancel_work_sync (&tracer->read_fw_strings_work);return err; }
Signature · 1 line
2.31.1
Re: [net 4/7] net/mlx5: FWTrace, cancel work on alloc pd error flow
Quoted 6 lines · Saeed Mahameed
From: Saeed Mahameed <[email protected]>
Handle error flow on
mlx5_core_alloc_pd()failure,read_fw_strings_workmust be canceled.Fixes c71ad41ccb0c ("net/mlx5: FW tracer, events handling")
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 5/7 net/mlx5: Fix potential sleeping in atomic context
In reply to Saeed MahameedFrom: Maor Gottlieb <[email protected]>
Fixes the below flow of sleeping in atomic context by releasing the RCU lock before calling to free_match_list.
build_match_list() <- disables preempt
-> free_match_list()
-> tree_put_node()
-> down_write_ref_node() <- take write lock
--- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +2 -3
@@ -1682,14 +1682,13 @@ static int build_match_list(struct match_list *match_head, curr_match =kmalloc (sizeof (*curr_match),GFP_ATOMIC );if (!curr_match) { +rcu_read_unlock ();free_match_list (match_head, ft_locked); - err = -ENOMEM ; - goto out; +return -ENOMEM ; } curr_match->g = g;list_add_tail (&curr_match->list, &match_head->list); } -out:rcu_read_unlock ();return err; }
Signature · 1 line
2.31.1
PATCH 6/7 net/mlx5e: Fix mutual exclusion between CQE compression and HW TS
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Some profiles of the driver don't support a dedicated PTP-RQ, hence can't support HW TS and CQE compression simultaneously. When HW TS is enabled the COE compression is disabled, and should be restored when the HW TS is turned off. Add rx_filter as an input to modifying CQE compression to enforce this restriction.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 11 ++++++----- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -1
@@ -922,7 +922,7 @@ void mlx5e_set_rx_mode_work(struct work_struct *work);int mlx5e_hwstamp_set (struct mlx5e_priv *priv,struct ifreq *ifr);int mlx5e_hwstamp_get (struct mlx5e_priv *priv,struct ifreq *ifr); -int mlx5e_modify_rx_cqe_compression_locked (struct mlx5e_priv *priv,bool val); +int mlx5e_modify_rx_cqe_compression_locked (struct mlx5e_priv *priv,bool val,bool rx_filter);int mlx5e_vlan_rx_add_vid (struct net_device *dev,__always_unused __be16 proto,u16 vid);
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +6 -5
@@ -1884,7 +1884,7 @@ static int set_pflag_rx_cqe_based_moder(struct net_device *netdev, bool enable)return set_pflag_cqe_based_moder (netdev, enable, true); } -int mlx5e_modify_rx_cqe_compression_locked (struct mlx5e_priv *priv,bool new_val) +int mlx5e_modify_rx_cqe_compression_locked (struct mlx5e_priv *priv,bool new_val,bool rx_filter) {bool curr_val =MLX5E_GET_PFLAG (&priv->channels.params,MLX5E_PFLAG_RX_CQE_COMPRESS );struct mlx5e_params new_params;
@@ -1896,8 +1896,7 @@ int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool new_valif (curr_val == new_val)return 0 ; -if (new_val && !priv->profile->rx_ptp_support && - priv->tstamp.rx_filter !=HWTSTAMP_FILTER_NONE ) { +if (new_val && !priv->profile->rx_ptp_support && rx_filter) {netdev_err (priv->netdev,"Profile doesn't support enabling of CQE compression while hardware time-stamping is enabled.\n" );return -EINVAL ;
@@ -1905,7 +1904,7 @@ int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool new_val new_params = priv->channels.params;MLX5E_SET_PFLAG (&new_params,MLX5E_PFLAG_RX_CQE_COMPRESS , new_val); -if (priv->tstamp.rx_filter !=HWTSTAMP_FILTER_NONE ) +if (rx_filter) new_params.ptp_rx = new_val;if (new_params.ptp_rx == priv->channels.params.ptp_rx)
@@ -1928,12 +1927,14 @@ static int set_pflag_rx_cqe_compress(struct net_device *netdev, {struct mlx5e_priv *priv =netdev_priv (netdev);struct mlx5_core_dev *mdev = priv->mdev; +bool rx_filter;int err;if (!MLX5_CAP_GEN (mdev, cqe_compression))return -EOPNOTSUPP ; - err =mlx5e_modify_rx_cqe_compression_locked (priv, enable); + rx_filter = priv->tstamp.rx_filter !=HWTSTAMP_FILTER_NONE ; + err =mlx5e_modify_rx_cqe_compression_locked (priv, enable, rx_filter);if (err)return err;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -2
@@ -3554,14 +3554,14 @@ static int mlx5e_hwstamp_config_no_ptp_rx(struct mlx5e_priv *priv, bool rx_filteif (!rx_filter)/* Reset CQE compression to Admin default */ -return mlx5e_modify_rx_cqe_compression_locked (priv, rx_cqe_compress_def); +return mlx5e_modify_rx_cqe_compression_locked (priv, rx_cqe_compress_def, false);if (!MLX5E_GET_PFLAG (&priv->channels.params,MLX5E_PFLAG_RX_CQE_COMPRESS ))return 0 ;/* Disable CQE compression */ netdev_warn (priv->netdev,"Disabling RX cqe compression\n" ); - err =mlx5e_modify_rx_cqe_compression_locked (priv, false); + err =mlx5e_modify_rx_cqe_compression_locked (priv, false, true);if (err)netdev_err (priv->netdev,"Failed disabling cqe compression err=%d\n" , err);
Signature · 1 line
2.31.1
PATCH 7/7 net/mlx5e: Fix condition when retrieving PTP-rqn
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
When activating the PTP-RQ, redirect the RQT from drop-RQ to PTP-RQ. Use mlx5e_channels_get_ptp_rqn to retrieve the rqn. This helper returns a boolean (not status), hence caller should consider return value 0 as a fail. Change the caller interpretation of the return value.
--- drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c +1 -1
@@ -572,7 +572,7 @@ void mlx5e_rx_res_channels_activate(struct mlx5e_rx_res *res, struct mlx5e_channif (res->features &MLX5E_RX_RES_FEATURE_PTP ) {u32 rqn; -if (mlx5e_channels_get_ptp_rqn (chs, &rqn)) +if (!mlx5e_channels_get_ptp_rqn (chs, &rqn)) rqn = res->drop_rqn; err =mlx5e_rqt_redirect_direct (&res->ptp.rqt, rqn);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerRe: [net 7/7] net/mlx5e: Fix condition when retrieving PTP-rqn
Quoted 6 lines · On Tue, 7 Sep 2021 14:24:20 -0700 Saeed Mahameed wrote:
From: Aya Levin <[email protected]>
When activating the PTP-RQ, redirect the RQT from drop-RQ to PTP-RQ. Use
mlx5e_channels_get_ptp_rqnto retrieve the rqn. This helper returns a boolean (not status), hence caller should consider return value 0 as a fail. Change the caller interpretation of the return value.
It would be really great to turn down the dial on the abbreviations and add some user-visible impact, as is best practice (some would say a requirement) for fixes.
I've been following the PTP work in mlx5 a little bit but I have no idea what a RQT is and what kind of issues to expect without this patch.
Saeed Mahameed
maintainerRe: [net 7/7] net/mlx5e: Fix condition when retrieving PTP-rqn
Quoted 11 lines · Jakub Kicinski
Quoted 9 lines · On Tue, 7 Sep 2021 14:24:20 -0700 Saeed Mahameed wrote:
From: Aya Levin <[email protected]>
When activating the PTP-RQ, redirect the RQT from drop-RQ to PTP- RQ.
Usemlx5e_channels_get_ptp_rqnto retrieve the rqn. This helper returns
a boolean (not status), hence caller should consider return value 0 as a
fail. Change the caller interpretation of the return value.
Quoted 5 lines
It would be really great to turn down the dial on the abbreviations and
add some user-visible impact, as is best practice (some would say a requirement) for fixes.
Ack and agreed ! I will enforce this.
Quoted 3 lines
I've been following the PTP work in mlx5 a little bit but I have no idea
what a RQT is and what kind of issues to expect without this patch.
RQT is a simple RQ Table; where we group rq numbers in one table object so steering and RSS objects can point to a table of RQs.
To simplify driver code:
1. we use RQT objects also for single RQ destinations.
2. HW/FW do not allow destroying RQs when they are directly being
referenced by Steering rules. RQTs help keeping steering objects pointing to a valid RQT object while driver is destroying RQs, while re-configuring, we just swap the rq number in the RQT with the new configuration RQs, or when device is deactivated (ifconfig down) we just swap all RQ numbers in all RQTs with the "Drop RQ"