mlx5 fixes 2021-06-16
Subsystems (4)
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 da5ac772cfe2a03058b0accfac03fad60c46c24d:
r8169: Avoid memcpy() over-reading of ETH_SS_STATS (2021-06-16 13:02:07 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2021-06-16
for you to fetch changes up to 0232fc2ddcf4ffe01069fd1aa07922652120f44a:
net/mlx5: Reset mkey index on creation (2021-06-16 15:36:49 -0700)
----------------------------------------------------------------
mlx5-fixes-2021-06-16
----------------------------------------------------------------
Alex Vesker (1):
net/mlx5: DR, Fix STEv1 incorrect L3 decapsulation padding
Aya Levin (1):
net/mlx5: Reset mkey index on creation
Dmytro Linkin (1):
net/mlx5e: Don't create devices during unload flow
Leon Romanovsky (2):
net/mlx5: Fix error path for set HCA defaults net/mlx5: Check that driver was probed prior attaching the device
Parav Pandit (3):
net/mlx5: E-Switch, Read PF mac address net/mlx5: E-Switch, Allow setting GUID for host PF vport net/mlx5: SF_DEV, remove SF device on invalid state
drivers/net/ethernet/mellanox/mlx5/core/dev.c | 19 ++++++++++++++++ drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 6 +++++ drivers/net/ethernet/mellanox/mlx5/core/main.c | 3 ++- drivers/net/ethernet/mellanox/mlx5/core/mr.c | 2 +- .../net/ethernet/mellanox/mlx5/core/sf/dev/dev.c | 1 + .../mellanox/mlx5/core/steering/dr_ste_v1.c | 26 +++++++++++++--------- drivers/net/ethernet/mellanox/mlx5/core/vport.c | 2 -- include/linux/mlx5/driver.h | 4 ++++ 8 files changed, 49 insertions(+), 14 deletions(-)
PATCH 1/8 net/mlx5: Fix error path for set HCA defaults
From: Leon Romanovsky <[email protected]>
In the case of the failure to execute mlx5_core_set_hca_defaults(), we used wrong goto label to execute error unwind flow.
--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +2 -1
@@ -1161,7 +1161,7 @@ static int mlx5_load(struct mlx5_core_dev *dev) err =mlx5_core_set_hca_defaults (dev);if (err) {mlx5_core_err (dev,"Failed to set hca defaults\n" ); - goto err_sriov; + goto err_set_hca; }mlx5_vhca_event_start (dev);
@@ -1194,6 +1194,7 @@ static int mlx5_load(struct mlx5_core_dev *dev)mlx5_sf_hw_table_destroy (dev); err_vhca:mlx5_vhca_event_stop (dev); +err_set_hca:mlx5_cleanup_fs (dev); err_fs:mlx5_accel_tls_cleanup (dev);
Signature · 1 line
2.31.1
Re: [net 1/8] net/mlx5: Fix error path for set HCA defaults
This series was applied to netdev/net.git (refs/heads/master):
Hello:
This series was applied to netdev/net.git (refs/heads/master):
Quoted 5 lines · On Wed, 16 Jun 2021 15:40:08 -0700 you wrote:
From: Leon Romanovsky <[email protected]>
In the case of the failure to execute
mlx5_core_set_hca_defaults(), we used wrong goto label to execute error unwind flow.
Quoted 8 lines
Fixes 5bef709d76a2 ("net/mlx5: Enable host PF HCA after eswitch is initialized")Reviewed-by Saeed Mahameed <[email protected]>Reviewed-by Moshe Shemesh <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Reviewed-by Parav Pandit <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>[...]
Here is the summary with links:
- [net,1/8] net/mlx5: Fix error path for set HCA defaults
https://git.kernel.org/netdev/net/c/94a4b8414d3e - [net,2/8] net/mlx5: Check that driver was probed prior attaching the device https://git.kernel.org/netdev/net/c/2058cc9c8041 - [net,3/8] net/mlx5: E-Switch, Read PF mac address https://git.kernel.org/netdev/net/c/bbc8222dc49d - [net,4/8] net/mlx5: E-Switch, Allow setting GUID for host PF vport https://git.kernel.org/netdev/net/c/ca36fc4d77b3 - [net,5/8] net/mlx5: SF_DEV, remove SF device on invalid state https://git.kernel.org/netdev/net/c/c7d6c19b3bde - [net,6/8] net/mlx5: DR, Fix STEv1 incorrect L3 decapsulation padding https://git.kernel.org/netdev/net/c/65fb7d109abe - [net,7/8] net/mlx5e: Don't create devices during unload flow https://git.kernel.org/netdev/net/c/a5ae8fc9058e - [net,8/8] net/mlx5: Reset mkey index on creation https://git.kernel.org/netdev/net/c/0232fc2ddcf4
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
PATCH 2/8 net/mlx5: Check that driver was probed prior attaching the device
In reply to Saeed MahameedFrom: Leon Romanovsky <[email protected]>
The device can be requested to be attached despite being not probed. This situation is possible if devlink reload races with module removal, and the following kernel panic is an outcome of such race.
mlx5_core 0000:00:09.0: firmware version: 4.7.9999
mlx5_core 0000:00:09.0: 0.000 Gb/s available PCIe bandwidth (8.0 GT/s PCIe x255 link)
BUG: unable to handle page fault for address: fffffffffffffff0 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 3218067 P4D 3218067 PUD 321a067 PMD 0 Oops: 0000 [#1] SMP KASAN NOPTI CPU: 7 PID: 250 Comm: devlink Not tainted 5.12.0-rc2+ #2836 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 RIP: 0010:mlx5_attach_device+0x80/0x280 [mlx5_core] Code: f8 48 c1 e8 03 42 80 3c 38 00 0f 85 80 01 00 00 48 8b 45 68 48 8d 78 f0 48 89 fe 48 c1 ee 03 42 80 3c 3e 00 0f 85 70 01 00 00 <48> 8b 40 f0 48 85 c0 74 0d 48 89 ef ff d0 85 c0 0f 85 84 05 0e 00 RSP: 0018:ffff8880129675f0 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000001 RCX: ffffffff827407f1 RDX: 1ffff110011336cf RSI: 1ffffffffffffffe RDI: fffffffffffffff0 RBP: ffff888008e0c000 R08: 0000000000000008 R09: ffffffffa0662ee7 R10: fffffbfff40cc5dc R11: 0000000000000000 R12: ffff88800ea002e0 R13: ffffed1001d459f7 R14: ffffffffa05ef4f8 R15: dffffc0000000000 FS: 00007f51dfeaf740(0000) GS:ffff88806d5c0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: fffffffffffffff0 CR3: 000000000bc82006 CR4: 0000000000370ea0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: mlx5_load_one+0x117/0x1d0 [mlx5_core] devlink_reload+0x2d5/0x520 ? devlink_remote_reload_actions_performed+0x30/0x30 ? mutex_trylock+0x24b/0x2d0 ? devlink_nl_cmd_reload+0x62b/0x1070 devlink_nl_cmd_reload+0x66d/0x1070 ? devlink_reload+0x520/0x520 ? devlink_nl_pre_doit+0x64/0x4d0 genl_family_rcv_msg_doit+0x1e9/0x2f0 ? mutex_lock_io_nested+0x1130/0x1130 ? genl_family_rcv_msg_attrs_parse.constprop.0+0x240/0x240 ? security_capable+0x51/0x90 genl_rcv_msg+0x27f/0x4a0 ? genl_get_cmd+0x3c0/0x3c0 ? lock_acquire+0x1a9/0x6d0 ? devlink_reload+0x520/0x520 ? lock_release+0x6c0/0x6c0 netlink_rcv_skb+0x11d/0x340 ? genl_get_cmd+0x3c0/0x3c0 ? netlink_ack+0x9f0/0x9f0 ? lock_release+0x1f9/0x6c0 genl_rcv+0x24/0x40 netlink_unicast+0x433/0x700 ? netlink_attachskb+0x730/0x730 ? _copy_from_iter_full+0x178/0x650 ? __alloc_skb+0x113/0x2b0 netlink_sendmsg+0x6f1/0xbd0 ? netlink_unicast+0x700/0x700 ? netlink_unicast+0x700/0x700 sock_sendmsg+0xb0/0xe0 __sys_sendto+0x193/0x240 ? __x64_sys_getpeername+0xb0/0xb0 ? copy_page_range+0x2300/0x2300 ? __up_read+0x1a1/0x7b0 ? do_user_addr_fault+0x219/0xdc0 __x64_sys_sendto+0xdd/0x1b0 ? syscall_enter_from_user_mode+0x1d/0x50 do_syscall_64+0x2d/0x40 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f51dffb514a Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb b8 0f 1f 00 f3 0f 1e fa 41 89 ca 64 8b 04 25 18 00 00 00 85 c0 75 15 b8 2c 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 76 c3 0f 1f 44 00 00 55 48 83 ec 30 44 89 4c RSP: 002b:00007ffcaef22e78 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f51dffb514a RDX: 0000000000000030 RSI: 000055750daf2440 RDI: 0000000000000003 RBP: 000055750daf2410 R08: 00007f51e0081200 R09: 000000000000000c R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Modules linked in: mlx5_core(-) ptp pps_core ib_ipoib rdma_ucm rdma_cm iw_cm ib_cm ib_umad ib_uverbs ib_core [last unloaded: mlx5_ib] CR2: fffffffffffffff0 ---[ end trace 7789831bfe74fa42 ]---
--- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/dev.c +15 -0
@@ -320,6 +320,16 @@ int mlx5_attach_device(struct mlx5_core_dev *dev) } }else { adev = &priv->adev[i]->adev; + +/* Pay attention that this is not PCI driver that +* mlx5_core_dev is connected, but auxiliary driver. +* +* Here we can race of module unload with devlink +* reload, but we don't need to take extra lock because +* we are holding global mlx5_intf_mutex. +*/ +if (!adev->dev.driver) +continue ; adrv =to_auxiliary_drv (adev->dev.driver);if (adrv->resume)
@@ -350,6 +360,10 @@ void mlx5_detach_device(struct mlx5_core_dev *dev)continue ; adev = &priv->adev[i]->adev; +/* Auxiliary driver was unbind manually through sysfs */ +if (!adev->dev.driver) + goto skip_suspend; + adrv =to_auxiliary_drv (adev->dev.driver);if (adrv->suspend) {
@@ -357,6 +371,7 @@ void mlx5_detach_device(struct mlx5_core_dev *dev)continue ; } +skip_suspend:del_adev (&priv->adev[i]->adev); priv->adev[i] =NULL ; }
Signature · 1 line
2.31.1
PATCH 3/8 net/mlx5: E-Switch, Read PF mac address
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
External controller PF's MAC address is not read from the device during vport setup. Fail to read this results in showing all zeros to user while the factory programmed MAC is a valid value.
$ devlink port show eth1 -jp
{
"port": {
"pci/0000:03:00.0/196608": {
"type": "eth",
"netdev": "eth1",
"flavour": "pcipf",
"controller": 1,
"pfnum": 0,
"splittable": false,
"function": {
"hw_addr": "00:00:00:00:00:00"
}
}
}
}Hence, read it when enabling a vport.
After the fix,
$ devlink port show eth1 -jp
{
"port": {
"pci/0000:03:00.0/196608": {
"type": "eth",
"netdev": "eth1",
"flavour": "pcipf",
"controller": 1,
"pfnum": 0,
"splittable": false,
"function": {
"hw_addr": "98:03:9b:a0:60:11"
}
}
}
}--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +6 -0
@@ -1054,6 +1054,12 @@ int mlx5_esw_vport_enable(struct mlx5_eswitch *esw, u16 vport_num, goto err_vhca_mapping; } +/* External controller host PF has factory programmed MAC. +* Read it from the device. +*/ +if (mlx5_core_is_ecpf (esw->dev) && vport_num ==MLX5_VPORT_PF ) +mlx5_query_nic_vport_mac_address (esw->dev, vport_num, true, vport->info.mac); +esw_vport_change_handle_locked (vport); esw->enabled_vports++;
Signature · 1 line
2.31.1
PATCH 4/8 net/mlx5: E-Switch, Allow setting GUID for host PF vport
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
E-switch should be able to set the GUID of host PF vport. Currently it returns an error. This results in below error when user attempts to configure MAC address of the PF of an external controller.
$ devlink port function set pci/0000:03:00.0/196608 \ hw_addr 00:00:00:11:22:33
mlx5_core 0000:03:00.0: mlx5_esw_set_vport_mac_locked:1876:(pid 6715):\
"Failed to set vport 0 node guid, err = -22.RDMA_CM will not function properly for this VF."
Check for zero vport is no longer needed.
--- drivers/net/ethernet/mellanox/mlx5/core/vport.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/vport.c +0 -2
@@ -465,8 +465,6 @@ int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,void *in;int err; -if (!vport) -return -EINVAL ;if (!MLX5_CAP_GEN (mdev, vport_group_manager))return -EACCES ;
Signature · 1 line
2.31.1
PATCH 5/8 net/mlx5: SF_DEV, remove SF device on invalid state
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
When auxiliary bus autoprobe is disabled and SF is in ACTIVE state, on SF port deletion it transitions from ACTIVE->ALLOCATED->INVALID.
When VHCA event handler queries the state, it is already transition to INVALID state.
In this scenario, event handler missed to delete the SF device.
Fix it by deleting the SF when SF state is INVALID.
--- drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c +1 -0
@@ -163,6 +163,7 @@ mlx5_sf_dev_state_change_handler(struct notifier_block *nb, unsigned long event_ sf_index = event->function_id - base_id; sf_dev =xa_load (&table->devices, sf_index);switch (event->new_vhca_state) { +case MLX5_VHCA_STATE_INVALID :case MLX5_VHCA_STATE_ALLOCATED :if (sf_dev)mlx5_sf_dev_del (table->dev, sf_dev, sf_index);
Signature · 1 line
2.31.1
PATCH 6/8 net/mlx5: DR, Fix STEv1 incorrect L3 decapsulation padding
In reply to Saeed MahameedFrom: Alex Vesker <[email protected]>
Decapsulation L3 on small inner packets which are less than 64 Bytes was done incorrectly. In small packets there is an extra padding added in L2 which should not be included in L3 length. The issue was that after decapL3 the extra L2 padding caused an update on the L3 length.
To avoid this issue the new header is pushed to the beginning of the packet (offset 0) which should not cause a HW reparse and update the L3 length.
--- .../mellanox/mlx5/core/steering/dr_ste_v1.c | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c +16 -10
@@ -694,7 +694,11 @@ static int dr_ste_v1_set_action_decap_l3_list(void *data,if (hw_action_sz /DR_STE_ACTION_DOUBLE_SZ <DR_STE_DECAP_L3_ACTION_NUM )return -EINVAL ; -memcpy (padded_data, data, data_sz); + inline_data_sz = +MLX5_FLD_SZ_BYTES (ste_double_action_insert_with_inline_v1, inline_data); + +/* Add an alignment padding */ +memcpy (padded_data + data_sz % inline_data_sz, data, data_sz);/* Remove L2L3 outer headers */ MLX5_SET(ste_single_action_remove_header_v1, hw_action, action_id,
@@ -706,32 +710,34 @@ static int dr_ste_v1_set_action_decap_l3_list(void *data, hw_action +=DR_STE_ACTION_DOUBLE_SZ ; used_actions++;/* Remove and NOP are a single double action */ - inline_data_sz = -MLX5_FLD_SZ_BYTES (ste_double_action_insert_with_inline_v1, inline_data); +/* Point to the last dword of the header */ + data_ptr += (data_sz / inline_data_sz) * inline_data_sz; -/* Add the new header inline + 2 extra bytes */ +/* Add the new header using inline action 4Byte at a time, the header +* is added in reversed order to the beginning of the packet to avoid +* incorrect parsing by the HW. Since header is 14B or 18B an extra +* two bytes are padded and later removed. +*/ for (i =0 ; i < data_sz / inline_data_sz +1 ; i++) {void *addr_inline;MLX5_SET (ste_double_action_insert_with_inline_v1, hw_action, action_id,DR_STE_V1_ACTION_ID_INSERT_INLINE );/* The hardware expects here offset to words (2 bytes) */ -MLX5_SET (ste_double_action_insert_with_inline_v1, hw_action, start_offset, - i *2 ); +MLX5_SET (ste_double_action_insert_with_inline_v1, hw_action, start_offset,0 );/* Copy bytes one by one to avoid endianness problem */ addr_inline =MLX5_ADDR_OF (ste_double_action_insert_with_inline_v1, hw_action, inline_data); -memcpy (addr_inline, data_ptr, inline_data_sz); +memcpy (addr_inline, data_ptr - i * inline_data_sz, inline_data_sz); hw_action +=DR_STE_ACTION_DOUBLE_SZ ; - data_ptr += inline_data_sz; used_actions++; } -/* Remove 2 extra bytes */ +/* Remove first 2 extra bytes */ MLX5_SET (ste_single_action_remove_header_size_v1, hw_action, action_id,DR_STE_V1_ACTION_ID_REMOVE_BY_SIZE ); -MLX5_SET (ste_single_action_remove_header_size_v1, hw_action, start_offset, data_sz /2 ); +MLX5_SET (ste_single_action_remove_header_size_v1, hw_action, start_offset,0 );/* The hardware expects here size in words (2 bytes) */ MLX5_SET (ste_single_action_remove_header_size_v1, hw_action, remove_size,1 ); used_actions++;
Signature · 1 line
2.31.1
PATCH 7/8 net/mlx5e: Don't create devices during unload flow
In reply to Saeed MahameedFrom: Dmytro Linkin <[email protected]>
Running devlink reload command for port in switchdev mode cause resources to corrupt: driver can't release allocated EQ and reclaim memory pages, because "rdma" auxiliary device had add CQs which blocks EQ from deletion.
Erroneous sequence happens during reload-down phase, and is following:
1. detach device - suspends auxiliary devices which support it, destroys others. During this step "eth-rep" and "rdma-rep" are destroyed, "eth" - suspended.
2. disable SRIOV - moves device to legacy mode; as part of disablement - rescans drivers. This step adds "rdma" auxiliary device.
3. destroy EQ table - <failure>.
Driver shouldn't create any device during unload flows. To handle that implement MLX5_PRIV_FLAGS_DETACH flag, set it on device detach and unset on device attach. If flag is set do no-op on drivers rescan.
--- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 4 ++++ include/linux/mlx5/driver.h | 4 ++++ 2 files changed, 8 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/dev.c +4 -0
@@ -303,6 +303,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)int ret =0 , i;mutex_lock (&mlx5_intf_mutex); + priv->flags &= ~MLX5_PRIV_FLAGS_DETACH ;for (i =0 ; i <ARRAY_SIZE (mlx5_adev_devices); i++) {if (!priv->adev[i]) {bool is_supported = false;
@@ -375,6 +376,7 @@ void mlx5_detach_device(struct mlx5_core_dev *dev)del_adev (&priv->adev[i]->adev); priv->adev[i] =NULL ; } + priv->flags |=MLX5_PRIV_FLAGS_DETACH ;mutex_unlock (&mlx5_intf_mutex); }
@@ -463,6 +465,8 @@ int mlx5_rescan_drivers_locked(struct mlx5_core_dev *dev)struct mlx5_priv *priv = &dev->priv;lockdep_assert_held (&mlx5_intf_mutex); +if (priv->flags &MLX5_PRIV_FLAGS_DETACH ) +return 0 ;delete_drivers (dev);if (priv->flags &MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV )
include/linux/mlx5/driver.h +4 -0
@@ -542,6 +542,10 @@ struct mlx5_core_roce {enum {MLX5_PRIV_FLAGS_DISABLE_IB_ADEV =1 <<0 ,MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV =1 <<1 , +/* Set during device detach to block any further devices +* creation/deletion on drivers rescan. Unset during device attach. +*/ +MLX5_PRIV_FLAGS_DETACH =1 <<2 , };struct mlx5_adev {
Signature · 1 line
2.31.1
PATCH 8/8 net/mlx5: Reset mkey index on creation
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Reset only the index part of the mkey and keep the variant part. On devlink reload, driver recreates mkeys, so the mkey index may change. Trying to preserve the variant part of the mkey, driver mistakenly merged the mkey index with current value. In case of a devlink reload, current value of index part is dirty, so the index may be corrupted.
--- drivers/net/ethernet/mellanox/mlx5/core/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/mr.c +1 -1
@@ -54,7 +54,7 @@ int mlx5_core_create_mkey(struct mlx5_core_dev *dev, mkey_index =MLX5_GET (create_mkey_out, lout, mkey_index); mkey->iova =MLX5_GET64 (mkc, mkc, start_addr); mkey->size =MLX5_GET64 (mkc, mkc, len); - mkey->key |=mlx5_idx_to_mkey (mkey_index); + mkey->key = (u32 )mlx5_mkey_variant (mkey->key) |mlx5_idx_to_mkey (mkey_index); mkey->pd =MLX5_GET (mkc, mkc, pd);init_waitqueue_head (&mkey->wait);
Signature · 1 line
2.31.1