mlx5 fixes 2021-10-12
Subsystems (5)
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.
Thanks,
Saeed.
---
The following changes since commit 4d4a223a86afe658cd878800f09458e8bb54415d:
ice: fix locking for Tx timestamp tracking flush (2021-10-12 12:10:39 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2021-10-12
for you to fetch changes up to 84c8a87402cf073ba7948dd62d4815a3f4a224c8:
net/mlx5e: Fix division by 0 in mlx5e_select_queue for representors (2021-10-12 13:52:03 -0700)
----------------------------------------------------------------
mlx5-fixes-2021-10-12
----------------------------------------------------------------
Aya Levin (1):
net/mlx5e: Mutually exclude RX-FCS and RX-port-timestamp
Maxim Mikityanskiy (1):
net/mlx5e: Fix division by 0 in mlx5e_select_queue for representors
Saeed Mahameed (1):
net/mlx5e: Switchdev representors are not vlan challenged
Shay Drory (1):
net/mlx5: Fix cleanup of bridge delayed work
Tariq Toukan (1):
net/mlx5e: Allow only complete TXQs partition in MQPRIO channel mode
Valentine Fatiev (1):
net/mlx5e: Fix memory leak in mlx5_core_destroy_cq() error path
drivers/net/ethernet/mellanox/mlx5/core/cq.c | 7 ++- .../ethernet/mellanox/mlx5/core/en/rep/bridge.c | 8 +-- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 61 +++++++++++++++++++--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 6 ++- include/linux/mlx5/mlx5_ifc.h | 10 +++- 5 files changed, 74 insertions(+), 18 deletions(-)
PATCH 1/6 net/mlx5: Fix cleanup of bridge delayed work
From: Shay Drory <[email protected]>
Currently, bridge cleanup is calling to cancel_delayed_work(). When this function is finished, there is a chance that the delayed work is still running. Also, the delayed work is queueing itself.
As a result, we might execute the delayed work after the bridge cleanup have finished and hit a null-ptr oops[1].
Fix it by using cancel_delayed_work_sync(), which is waiting until the work is done and will cancel the queue work.
[1]
[ 8202.143043 ] BUG: kernel NULL pointer dereference, address: 0000000000000000
[ 8202.144438 ] #PF: supervisor write access in kernel mode
[ 8202.145476 ] #PF: error_code(0x0002) - not-present page
[ 8202.146520 ] PGD 0 P4D 0
[ 8202.147126 ] Oops: 0002 [#1] SMP NOPTI
[ 8202.147899 ] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.14.0-rc6_for_upstream_min_debug_2021_08_25_16_06 #1 [ 8202.149741 ] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 [ 8202.151908 ] RIP: 0010:_raw_spin_lock+0xc/0x20
[ 8202.156234 ] RSP: 0018:ffff88846f885ea0 EFLAGS: 00010046
[ 8202.157289 ] RAX: 0000000000000000 RBX: ffff88846f880000 RCX: 0000000000000000
[ 8202.158731 ] RDX: 0000000000000001 RSI: ffff8881004000c8 RDI: 0000000000000000
[ 8202.160177 ] RBP: ffff8881fe684978 R08: ffff888100140000 R09: ffffffff824455b8
[ 8202.161569 ] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000001
[ 8202.163004 ] R13: 0000000000000012 R14: 0000000000000200 R15: ffff88812992d000
[ 8202.164018 ] FS: 0000000000000000(0000) GS:ffff88846f880000(0000) knlGS:0000000000000000
[ 8202.164960 ] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 8202.165634 ] CR2: 0000000000000000 CR3: 0000000108cac004 CR4: 0000000000370ea0
[ 8202.166450 ] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 8202.167807 ] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 8202.168852 ] Call Trace:
[ 8202.169421 ] <IRQ> [ 8202.169792 ] __queue_work+0xf2/0x3d0 [ 8202.170481 ] ? queue_work_node+0x40/0x40 [ 8202.171270 ] call_timer_fn+0x2b/0x100 [ 8202.171932 ] __run_timers.part.0+0x152/0x220 [ 8202.172717 ] ? __hrtimer_run_queues+0x171/0x290 [ 8202.173526 ] ? kvm_clock_get_cycles+0xd/0x10 [ 8202.174232 ] ? ktime_get+0x35/0x90 [ 8202.174943 ] run_timer_softirq+0x26/0x50 [ 8202.175745 ] __do_softirq+0xc7/0x271 [ 8202.176373 ] irq_exit_rcu+0x93/0xb0 [ 8202.176983 ] sysvec_apic_timer_interrupt+0x72/0x90 [ 8202.177755 ] </IRQ> [ 8202.178245 ] asm_sysvec_apic_timer_interrupt+0x12/0x20
--- drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c +4 -4
@@ -475,9 +475,6 @@ void mlx5e_rep_bridge_init(struct mlx5e_priv *priv)esw_warn (mdev,"Failed to allocate bridge offloads workqueue\n" ); goto err_alloc_wq; } -INIT_DELAYED_WORK (&br_offloads->update_work, mlx5_esw_bridge_update_work); -queue_delayed_work (br_offloads->wq, &br_offloads->update_work, -msecs_to_jiffies (MLX5_ESW_BRIDGE_UPDATE_INTERVAL )); br_offloads->nb.notifier_call = mlx5_esw_bridge_switchdev_event; err =register_switchdev_notifier (&br_offloads->nb);
@@ -500,6 +497,9 @@ void mlx5e_rep_bridge_init(struct mlx5e_priv *priv) err); goto err_register_netdev; } +INIT_DELAYED_WORK (&br_offloads->update_work, mlx5_esw_bridge_update_work); +queue_delayed_work (br_offloads->wq, &br_offloads->update_work, +msecs_to_jiffies (MLX5_ESW_BRIDGE_UPDATE_INTERVAL ));return ; err_register_netdev:
@@ -523,10 +523,10 @@ void mlx5e_rep_bridge_cleanup(struct mlx5e_priv *priv)if (!br_offloads)return ; +cancel_delayed_work_sync (&br_offloads->update_work);unregister_netdevice_notifier (&br_offloads->netdev_nb);unregister_switchdev_blocking_notifier (&br_offloads->nb_blk);unregister_switchdev_notifier (&br_offloads->nb); -cancel_delayed_work (&br_offloads->update_work);destroy_workqueue (br_offloads->wq);rtnl_lock ();mlx5_esw_bridge_cleanup (esw);
Signature · 1 line
2.31.1
Re: [net 1/6] net/mlx5: Fix cleanup of bridge delayed work
This series was applied to netdev/net.git (master) by Saeed Mahameed <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by Saeed Mahameed <[email protected]>:
Quoted 9 lines · On Tue, 12 Oct 2021 13:53:18 -0700 you wrote:
From: Shay Drory <[email protected]>
Currently, bridge cleanup is calling to
cancel_delayed_work(). When this function is finished, there is a chance that the delayed work is still running. Also, the delayed work is queueing itself.
As a result, we might execute the delayed work after the bridge cleanup have finished and hit a null-ptr oops[1].[...]
Here is the summary with links:
- [net,1/6] net/mlx5: Fix cleanup of bridge delayed work
https://git.kernel.org/netdev/net/c/2266bb1e122a - [net,2/6] net/mlx5e: Allow only complete TXQs partition in MQPRIO channel mode https://git.kernel.org/netdev/net/c/ca20dfda05ae - [net,3/6] net/mlx5e: Fix memory leak in mlx5_core_destroy_cq() error path https://git.kernel.org/netdev/net/c/94b960b9deff - [net,4/6] net/mlx5e: Switchdev representors are not vlan challenged https://git.kernel.org/netdev/net/c/b2107cdc43d8 - [net,5/6] net/mlx5e: Mutually exclude RX-FCS and RX-port-timestamp https://git.kernel.org/netdev/net/c/0bc73ad46a76 - [net,6/6] net/mlx5e: Fix division by 0 in mlx5e_select_queue for representors https://git.kernel.org/netdev/net/c/84c8a87402cf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
PATCH 2/6 net/mlx5e: Allow only complete TXQs partition in MQPRIO channel mode
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
Do not allow configurations of MQPRIO channel mode that do not fully define and utilize the channels txqs.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -2
@@ -2981,8 +2981,8 @@ static int mlx5e_mqprio_channel_validate(struct mlx5e_priv *priv, agg_count += mqprio->qopt.count[i]; } -if (priv->channels.params.num_channels < agg_count) { -netdev_err (netdev,"Num of queues (%d) exceeds available (%d)\n" , +if (priv->channels.params.num_channels != agg_count) { +netdev_err (netdev,"Num of queues (%d) does not match available (%d)\n" , agg_count, priv->channels.params.num_channels);return -EINVAL ; }
Signature · 1 line
2.31.1
PATCH 3/6 net/mlx5e: Fix memory leak in mlx5_core_destroy_cq() error path
In reply to Saeed MahameedFrom: Valentine Fatiev <[email protected]>
Prior to this patch in case mlx5_core_destroy_cq() failed it returns without completing all destroy operations and that leads to memory leak. Instead, complete the destroy flow before return error.
Also move mlx5_debug_cq_remove() to the beginning of mlx5_core_destroy_cq() to be symmetrical with mlx5_core_create_cq().
kmemleak complains on:
unreferenced object 0xc000000038625100 (size 64):
comm "ethtool", pid 28301, jiffies 4298062946 (age 785.380s) hex dump (first 32 bytes):
60 01 48 94 00 00 00 c0 b8 05 34 c3 00 00 00 c0 `.H.......4.....
02 00 00 00 00 00 00 00 00 db 7d c1 00 00 00 c0 ..........}.....
backtrace:
[<000000009e8643cb>] add_res_tree+0xd0/0x270 [mlx5_core]
[<00000000e7cb8e6c>] mlx5_debug_cq_add+0x5c/0xc0 [mlx5_core]
[<000000002a12918f>] mlx5_core_create_cq+0x1d0/0x2d0 [mlx5_core]
[<00000000cef0a696>] mlx5e_create_cq+0x210/0x3f0 [mlx5_core]
[<000000009c642c26>] mlx5e_open_cq+0xb4/0x130 [mlx5_core]
[<0000000058dfa578>] mlx5e_ptp_open+0x7f4/0xe10 [mlx5_core]
[<0000000081839561>] mlx5e_open_channels+0x9cc/0x13e0 [mlx5_core]
[<0000000009cf05d4>] mlx5e_switch_priv_channels+0xa4/0x230
[mlx5_core]
[<0000000042bbedd8>] mlx5e_safe_switch_params+0x14c/0x300
[mlx5_core]
[<0000000004bc9db8>] set_pflag_tx_port_ts+0x9c/0x160 [mlx5_core]
[<00000000a0553443>] mlx5e_set_priv_flags+0xd0/0x1b0 [mlx5_core]
[<00000000a8f3d84b>] ethnl_set_privflags+0x234/0x2d0
[<00000000fd27f27c>] genl_family_rcv_msg_doit+0x108/0x1d0
[<00000000f495e2bb>] genl_family_rcv_msg+0xe4/0x1f0
[<00000000646c5c2c>] genl_rcv_msg+0x78/0x120
[<00000000d53e384e>] netlink_rcv_skb+0x74/0x1a0--- drivers/net/ethernet/mellanox/mlx5/core/cq.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cq.c +3 -4
@@ -155,6 +155,8 @@ int mlx5_core_destroy_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq)u32 in[MLX5_ST_SZ_DW (destroy_cq_in)] = {};int err; +mlx5_debug_cq_remove (dev, cq); +mlx5_eq_del_cq (mlx5_get_async_eq (dev), cq);mlx5_eq_del_cq (&cq->eq->core, cq);
@@ -162,16 +164,13 @@ int mlx5_core_destroy_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq)MLX5_SET (destroy_cq_in, in, cqn, cq->cqn);MLX5_SET (destroy_cq_in, in, uid, cq->uid); err =mlx5_cmd_exec_in (dev, destroy_cq, in); -if (err) -return err;synchronize_irq (cq->irqn); -mlx5_debug_cq_remove (dev, cq);mlx5_cq_put (cq);wait_for_completion (&cq->free); -return 0 ; +return err; }EXPORT_SYMBOL (mlx5_core_destroy_cq);
Signature · 1 line
2.31.1
PATCH 4/6 net/mlx5e: Switchdev representors are not vlan challenged
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
Before this patch, mlx5 representors advertised the NETIF_F_VLAN_CHALLENGED bit, this could lead to missing features when using reps with vxlan/bridge and maybe other virtual interfaces, when such interfaces inherit this bit and block vlan usage in their topology.
Example:
$ip link add dev bridge type bridge
# add representor interface to the bridge $ip link set dev pf0hpf master $ip link add link bridge name vlan10 type vlan id 10 protocol 802.1q Error: 8021q: VLANs not supported on device.
Reps are perfectly capable of handling vlan traffic, although they don't implement vlan_{add,kill}_vid ndos, hence, remove NETIF_F_VLAN_CHALLENGED advertisement.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +0 -1
@@ -643,7 +643,6 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev, netdev->hw_features |=NETIF_F_RXCSUM ; netdev->features |= netdev->hw_features; - netdev->features |=NETIF_F_VLAN_CHALLENGED ; netdev->features |=NETIF_F_NETNS_LOCAL ; }
Signature · 1 line
2.31.1
PATCH 5/6 net/mlx5e: Mutually exclude RX-FCS and RX-port-timestamp
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Due to current HW arch limitations, RX-FCS (scattering FCS frame field to software) and RX-port-timestamp (improved timestamp accuracy on the receive side) can't work together.
RX-port-timestamp is not controlled by the user and it is enabled by default when supported by the HW/FW.
This patch sets RX-port-timestamp opposite to RX-FCS configuration.
--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 57 +++++++++++++++++-- include/linux/mlx5/mlx5_ifc.h | 10 +++- 2 files changed, 60 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +52 -5
@@ -3325,20 +3325,67 @@ static int set_feature_rx_all(struct net_device *netdev, bool enable)return mlx5_set_port_fcs (mdev, !enable); } +static int mlx5e_set_rx_port_ts (struct mlx5_core_dev *mdev,bool enable) +{ +u32 in[MLX5_ST_SZ_DW (pcmr_reg)] = {}; +bool supported, curr_state; +int err; + +if (!MLX5_CAP_GEN (mdev, ports_check)) +return 0 ; + + err =mlx5_query_ports_check (mdev, in,sizeof (in)); +if (err) +return err; + + supported =MLX5_GET (pcmr_reg, in, rx_ts_over_crc_cap); + curr_state =MLX5_GET (pcmr_reg, in, rx_ts_over_crc); + +if (!supported || enable == curr_state) +return 0 ; + +MLX5_SET (pcmr_reg, in, local_port,1 ); +MLX5_SET (pcmr_reg, in, rx_ts_over_crc, enable); + +return mlx5_set_ports_check (mdev, in,sizeof (in)); +} +static int set_feature_rx_fcs (struct net_device *netdev,bool enable) {struct mlx5e_priv *priv =netdev_priv (netdev); +struct mlx5e_channels *chs = &priv->channels; +struct mlx5_core_dev *mdev = priv->mdev;int err;mutex_lock (&priv->state_lock); - priv->channels.params.scatter_fcs_en = enable; - err =mlx5e_modify_channels_scatter_fcs (&priv->channels, enable); -if (err) - priv->channels.params.scatter_fcs_en = !enable; +if (enable) { + err =mlx5e_set_rx_port_ts (mdev, false); +if (err) + goto out; -mutex_unlock (&priv->state_lock); + chs->params.scatter_fcs_en = true; + err =mlx5e_modify_channels_scatter_fcs (chs, true); +if (err) { + chs->params.scatter_fcs_en = false; +mlx5e_set_rx_port_ts (mdev, true); + } + }else { + chs->params.scatter_fcs_en = false; + err =mlx5e_modify_channels_scatter_fcs (chs, false); +if (err) { + chs->params.scatter_fcs_en = true; + goto out; + } + err =mlx5e_set_rx_port_ts (mdev, true); +if (err) { +mlx5_core_warn (mdev,"Failed to set RX port timestamp %d\n" , err); + err =0 ; + } + } +out: +mutex_unlock (&priv->state_lock);return err; }
include/linux/mlx5/mlx5_ifc.h +8 -2
@@ -9475,16 +9475,22 @@ struct mlx5_ifc_pcmr_reg_bits {u8 reserved_at_0[0x8 ];u8 local_port[0x8 ];u8 reserved_at_10[0x10 ]; +u8 entropy_force_cap[0x1 ];u8 entropy_calc_cap[0x1 ];u8 entropy_gre_calc_cap[0x1 ]; -u8 reserved_at_23[0x1b ]; +u8 reserved_at_23[0xf ]; +u8 rx_ts_over_crc_cap[0x1 ]; +u8 reserved_at_33[0xb ];u8 fcs_cap[0x1 ];u8 reserved_at_3f[0x1 ]; +u8 entropy_force[0x1 ];u8 entropy_calc[0x1 ];u8 entropy_gre_calc[0x1 ]; -u8 reserved_at_43[0x1b ]; +u8 reserved_at_43[0xf ]; +u8 rx_ts_over_crc[0x1 ]; +u8 reserved_at_53[0xb ];u8 fcs_chk[0x1 ];u8 reserved_at_5f[0x1 ]; };
Signature · 1 line
2.31.1
PATCH 6/6 net/mlx5e: Fix division by 0 in mlx5e_select_queue for representors
In reply to Saeed MahameedFrom: Maxim Mikityanskiy <[email protected]>
Commit 846d6da1fcdb ("net/mlx5e: Fix division by 0 in mlx5e_select_queue") makes mlx5e_build_nic_params assign a non-zero initial value to priv->num_tc_x_num_ch, so that mlx5e_select_queue doesn't fail with division by 0 if called before the first activation of channels. However, the initialization flow of representors doesn't call mlx5e_build_nic_params, so this bug can still happen with representors.
This commit fixes the bug by adding the missing assignment to mlx5e_build_rep_params.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +5 -0
@@ -618,6 +618,11 @@ static void mlx5e_build_rep_params(struct net_device *netdev) params->mqprio.num_tc =1 ; params->tunneled_offload_en = false; +/* Set an initial non-zero value, so that mlx5e_select_queue won't +* divide by zero if called before first activating channels. +*/ + priv->num_tc_x_num_ch = params->num_channels * params->mqprio.num_tc; +mlx5_query_min_inline (mdev, ¶ms->tx_min_inline_mode); }
Signature · 1 line
2.31.1