Mellanox, mlx5 fixes 2020-04-29
Hi Dave,
This series introduces some fixes to mlx5 driver.
Please pull and let me know if there is any problem.
v2:
- Dropped the ktls patch, Tariq has to check if it is fixable in the stack
For -stable v4.12
('net/mlx5: Fix forced completion access non initialized command entry') ('net/mlx5: Fix command entry leak in Internal Error State')
For -stable v5.4
('net/mlx5: DR, On creation set CQ's arm_db member to right value')
For -stable v5.6
('net/mlx5e: Fix q counters on uplink representors')
Thanks,
Saeed.
---
The following changes since commit 30724ccbfc8325cade4a2d36cd1f75b06341d9eb:
Merge branch 'wireguard-fixes' (2020-04-29 14:23:05 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2020-04-29
for you to fetch changes up to 67b38de646894c9a94fe4d6d17719e70cc6028eb:
net/mlx5e: Fix q counters on uplink representors (2020-04-30 09:20:33 -0700)
----------------------------------------------------------------
mlx5-fixes-2020-04-29
----------------------------------------------------------------
Erez Shitrit (1):
net/mlx5: DR, On creation set CQ's arm_db member to right value
Moshe Shemesh (2):
net/mlx5: Fix forced completion access non initialized command entry net/mlx5: Fix command entry leak in Internal Error State
Parav Pandit (3):
net/mlx5: E-switch, Fix error unwinding flow for steering init failure net/mlx5: E-switch, Fix printing wrong error value net/mlx5: E-switch, Fix mutex init order
Roi Dayan (1):
net/mlx5e: Fix q counters on uplink representors
drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 6 +++++- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 9 ++------- .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 18 +++++++++--------- .../net/ethernet/mellanox/mlx5/core/steering/dr_send.c | 14 +++++++++++++- 4 files changed, 29 insertions(+), 18 deletions(-)
PATCH v2 1/7 net/mlx5: E-switch, Fix error unwinding flow for steering init failure
From: Parav Pandit <[email protected]>
Error unwinding is done incorrectly in the cited commit. When steering init fails, there is no need to perform steering cleanup. When vport error exists, error cleanup should be mirror of the setup routine, i.e. to perform steering cleanup before metadata cleanup.
This avoids the call trace in accessing uninitialized objects which are skipped during steering_init() due to failure in steering_init().
Call trace:
mlx5_cmd_modify_header_alloc:805:(pid 21128): too many modify header actions 1, max supported 0
E-Switch: Failed to create restore mod header
BUG: kernel NULL pointer dereference, address: 00000000000000d0 [ 677.263079] mlx5_destroy_flow_group+0x13/0x80 [mlx5_core] [ 677.268921] esw_offloads_steering_cleanup+0x51/0xf0 [mlx5_core] [ 677.275281] esw_offloads_enable+0x1a5/0x800 [mlx5_core] [ 677.280949] mlx5_eswitch_enable_locked+0x155/0x860 [mlx5_core] [ 677.287227] mlx5_devlink_eswitch_mode_set+0x1af/0x320 [ 677.293741] devlink_nl_cmd_eswitch_set_doit+0x41/0xb0 [ 677.299217] genl_rcv_msg+0x1eb/0x430
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -2
@@ -2377,9 +2377,9 @@ int esw_offloads_enable(struct mlx5_eswitch *esw) err_vports:esw_offloads_unload_rep (esw,MLX5_VPORT_UPLINK ); err_uplink: -esw_set_passing_vport_metadata (esw, false); -err_steering_init:esw_offloads_steering_cleanup (esw); +err_steering_init: +esw_set_passing_vport_metadata (esw, false); err_vport_metadata:mlx5_rdma_disable_roce (esw->dev);mutex_destroy (&esw->offloads.termtbl_mutex);
Signature · 1 line
2.25.4
PATCH v2 2/7 net/mlx5: E-switch, Fix printing wrong error value
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
When mlx5_modify_header_alloc() fails, instead of printing the error value returned, current error log prints 0.
Fix by printing correct error value returned bymlx5_modify_header_alloc().
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +1 -1
@@ -1550,9 +1550,9 @@ static int esw_create_restore_table(struct mlx5_eswitch *esw)MLX5_FLOW_NAMESPACE_KERNEL ,1 , modact);if (IS_ERR (mod_hdr)) { + err =PTR_ERR (mod_hdr);esw_warn (dev,"Failed to create restore mod header, err: %d\n" , err); - err =PTR_ERR (mod_hdr); goto err_mod_hdr; }
Signature · 1 line
2.25.4
PATCH v2 3/7 net/mlx5: E-switch, Fix mutex init order
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
In cited patch mutex is initialized after its used. Below call trace is observed.
Fix the order to initialize the mutex early enough. Similarly follow mirror sequence during cleanup.
kernel: DEBUG_LOCKS_WARN_ON(lock->magic != lock)
kernel: WARNING: CPU: 5 PID: 45916 at kernel/locking/mutex.c:938 __mutex_lock+0x7d6/0x8a0
kernel: Call Trace:
kernel: ? esw_vport_tbl_get+0x3b/0x250 [mlx5_core]
kernel: ? mark_held_locks+0x55/0x70
kernel: ? __slab_free+0x274/0x400
kernel: ? lockdep_hardirqs_on+0x140/0x1d0
kernel: esw_vport_tbl_get+0x3b/0x250 [mlx5_core]
kernel: ? mlx5_esw_chains_create_fdb_prio+0xa57/0xc20 [mlx5_core]
kernel: mlx5_esw_vport_tbl_get+0x88/0xf0 [mlx5_core]
kernel: mlx5_esw_chains_create+0x2f3/0x3e0 [mlx5_core]
kernel: esw_create_offloads_fdb_tables+0x11d/0x580 [mlx5_core]
kernel: esw_offloads_enable+0x26d/0x540 [mlx5_core]
kernel: mlx5_eswitch_enable_locked+0x155/0x860 [mlx5_core]
kernel: mlx5_devlink_eswitch_mode_set+0x1af/0x320 [mlx5_core]
kernel: devlink_nl_cmd_eswitch_set_doit+0x41/0xb0
--- .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +6 -6
@@ -2219,10 +2219,12 @@ static int esw_offloads_steering_init(struct mlx5_eswitch *esw) total_vports = num_vfs +MLX5_SPECIAL_VPORTS (esw->dev);memset (&esw->fdb_table.offloads,0 ,sizeof (struct offloads_fdb )); +mutex_init (&esw->fdb_table.offloads.vports.lock); +hash_init (esw->fdb_table.offloads.vports.table); err =esw_create_uplink_offloads_acl_tables (esw);if (err) -return err; + goto create_acl_err; err =esw_create_offloads_table (esw, total_vports);if (err)
@@ -2240,9 +2242,6 @@ static int esw_offloads_steering_init(struct mlx5_eswitch *esw)if (err) goto create_fg_err; -mutex_init (&esw->fdb_table.offloads.vports.lock); -hash_init (esw->fdb_table.offloads.vports.table); -return 0 ; create_fg_err:
@@ -2253,18 +2252,19 @@ static int esw_offloads_steering_init(struct mlx5_eswitch *esw)esw_destroy_offloads_table (esw); create_offloads_err:esw_destroy_uplink_offloads_acl_tables (esw); - +create_acl_err: +mutex_destroy (&esw->fdb_table.offloads.vports.lock);return err; }static void esw_offloads_steering_cleanup (struct mlx5_eswitch *esw) { -mutex_destroy (&esw->fdb_table.offloads.vports.lock);esw_destroy_vport_rx_group (esw);esw_destroy_offloads_fdb_tables (esw);esw_destroy_restore_table (esw);esw_destroy_offloads_table (esw);esw_destroy_uplink_offloads_acl_tables (esw); +mutex_destroy (&esw->fdb_table.offloads.vports.lock); } static void
Signature · 1 line
2.25.4
PATCH v2 4/7 net/mlx5: DR, On creation set CQ's arm_db member to right value
In reply to Saeed MahameedFrom: Erez Shitrit <[email protected]>
In polling mode, set arm_db member to a value that will avoid CQ event recovery by the HW.
Otherwise we might get event without completion function. In addition,empty completion function to was added to protect from unexpected events.
--- .../ethernet/mellanox/mlx5/core/steering/dr_send.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c +13 -1
@@ -695,6 +695,12 @@ static void dr_cq_event(struct mlx5_core_cq *mcq,pr_info ("CQ event %u on CQ #%u\n" , event, mcq->cqn); } +static void dr_cq_complete (struct mlx5_core_cq *mcq, +struct mlx5_eqe *eqe) +{ +pr_err ("CQ completion CQ: #%u\n" , mcq->cqn); +} +static struct mlx5dr_cq *dr_create_cq (struct mlx5_core_dev *mdev,struct mlx5_uars_page *uar,size_t ncqe)
@@ -756,6 +762,7 @@ static struct mlx5dr_cq *dr_create_cq(struct mlx5_core_dev *mdev,mlx5_fill_page_frag_array (&cq->wq_ctrl.buf, pas); cq->mcq.event = dr_cq_event; + cq->mcq.comp = dr_cq_complete; err =mlx5_core_create_cq (mdev, &cq->mcq, in, inlen, out,sizeof (out));kvfree (in);
@@ -767,7 +774,12 @@ static struct mlx5dr_cq *dr_create_cq(struct mlx5_core_dev *mdev, cq->mcq.set_ci_db = cq->wq_ctrl.db.db; cq->mcq.arm_db = cq->wq_ctrl.db.db +1 ; *cq->mcq.set_ci_db =0 ; - *cq->mcq.arm_db =0 ; + +/* set no-zero value, in order to avoid the HW to run db-recovery on +* CQ that used in polling mode. +*/ + *cq->mcq.arm_db =cpu_to_be32 (2 <<28 ); + cq->mcq.vector =0 ; cq->mcq.irqn = irqn; cq->mcq.uar = uar;
Signature · 1 line
2.25.4
PATCH v2 5/7 net/mlx5: Fix forced completion access non initialized command entry
In reply to Saeed MahameedFrom: Moshe Shemesh <[email protected]>
mlx5_cmd_flush() will trigger forced completions to all valid command entries. Triggered by an asynch event such as fast teardown it can happen at any stage of the command, including command initialization. It will trigger forced completion and that can lead to completion on an uninitialized command entry.
Setting MLX5_CMD_ENT_STATE_PENDING_COMP only after command entry is initialized will ensure force completion is treated only if command entry is initialized.
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +1 -1
@@ -888,7 +888,6 @@ static void cmd_work_handler(struct work_struct *work) } cmd->ent_arr[ent->idx] = ent; -set_bit (MLX5_CMD_ENT_STATE_PENDING_COMP , &ent->state); lay =get_inst (cmd, ent->idx); ent->lay = lay;memset (lay,0 ,sizeof (*lay));
@@ -910,6 +909,7 @@ static void cmd_work_handler(struct work_struct *work)if (ent->callback)schedule_delayed_work (&ent->cb_timeout_work, cb_timeout); +set_bit (MLX5_CMD_ENT_STATE_PENDING_COMP , &ent->state);/* Skip sending command to fw if internal error */ if (pci_channel_offline(dev->pdev) ||
Signature · 1 line
2.25.4
PATCH v2 6/7 net/mlx5: Fix command entry leak in Internal Error State
In reply to Saeed MahameedFrom: Moshe Shemesh <[email protected]>
Processing commands by cmd_work_handler() while already in Internal Error State will result in entry leak, since the handler process force completion without doorbell. Forced completion doesn't release the entry and event completion will never arrive, so entry should be released.
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +4 -0
@@ -922,6 +922,10 @@ static void cmd_work_handler(struct work_struct *work)MLX5_SET (mbox_out, ent->out, syndrome, drv_synd);mlx5_cmd_comp_handler (dev,1UL << ent->idx, true); +/* no doorbell, no need to keep the entry */ +free_ent (cmd, ent->idx); +if (ent->callback) +free_cmd (ent);return ; }
Signature · 1 line
2.25.4
PATCH v2 7/7 net/mlx5e: Fix q counters on uplink representors
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Need to allocate the q counters before init_rx which needs them when creating the rq.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +2 -7
@@ -1773,19 +1773,14 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)static int mlx5e_init_ul_rep_rx (struct mlx5e_priv *priv) { -int err =mlx5e_init_rep_rx (priv); - -if (err) -return err; -mlx5e_create_q_counters (priv); -return 0 ; +return mlx5e_init_rep_rx (priv); }static void mlx5e_cleanup_ul_rep_rx (struct mlx5e_priv *priv) { -mlx5e_destroy_q_counters (priv);mlx5e_cleanup_rep_rx (priv); +mlx5e_destroy_q_counters (priv); }static int mlx5e_init_uplink_rep_tx (struct mlx5e_rep_priv *rpriv)
Signature · 1 line
2.25.4
From: Saeed Mahameed <[email protected]>
Date: Thu, 30 Apr 2020 09:25:44 -0700
Quoted 3 lines
This series introduces some fixes to mlx5 driver.
Please pull and let me know if there is any problem.
Pulled.
...
Quoted 9 lines
For -stable v4.12
('net/mlx5: Fix forced completion access non initialized command entry') ('net/mlx5: Fix command entry leak in Internal Error State')For -stable v5.4
('net/mlx5: DR, On creation set CQ'sarm_dbmember to right value')For -stable v5.6
('net/mlx5e: Fix q counters on uplink representors')
Queued up, thanks.