Skip to content

Commit bc39f67

Browse files
committed
Merge tag 'mlx5-fixes-2021-06-16' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5 fixes 2021-06-16 This series introduces some fixes to mlx5 driver. Please pull and let me know if there is any problem. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 7edcc68 + 0232fc2 commit bc39f67

File tree

8 files changed

+49
-14
lines changed

8 files changed

+49
-14
lines changed

drivers/net/ethernet/mellanox/mlx5/core/dev.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)
303303
int ret = 0, i;
304304

305305
mutex_lock(&mlx5_intf_mutex);
306+
priv->flags &= ~MLX5_PRIV_FLAGS_DETACH;
306307
for (i = 0; i < ARRAY_SIZE(mlx5_adev_devices); i++) {
307308
if (!priv->adev[i]) {
308309
bool is_supported = false;
@@ -320,6 +321,16 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)
320321
}
321322
} else {
322323
adev = &priv->adev[i]->adev;
324+
325+
/* Pay attention that this is not PCI driver that
326+
* mlx5_core_dev is connected, but auxiliary driver.
327+
*
328+
* Here we can race of module unload with devlink
329+
* reload, but we don't need to take extra lock because
330+
* we are holding global mlx5_intf_mutex.
331+
*/
332+
if (!adev->dev.driver)
333+
continue;
323334
adrv = to_auxiliary_drv(adev->dev.driver);
324335

325336
if (adrv->resume)
@@ -350,16 +361,22 @@ void mlx5_detach_device(struct mlx5_core_dev *dev)
350361
continue;
351362

352363
adev = &priv->adev[i]->adev;
364+
/* Auxiliary driver was unbind manually through sysfs */
365+
if (!adev->dev.driver)
366+
goto skip_suspend;
367+
353368
adrv = to_auxiliary_drv(adev->dev.driver);
354369

355370
if (adrv->suspend) {
356371
adrv->suspend(adev, pm);
357372
continue;
358373
}
359374

375+
skip_suspend:
360376
del_adev(&priv->adev[i]->adev);
361377
priv->adev[i] = NULL;
362378
}
379+
priv->flags |= MLX5_PRIV_FLAGS_DETACH;
363380
mutex_unlock(&mlx5_intf_mutex);
364381
}
365382

@@ -448,6 +465,8 @@ int mlx5_rescan_drivers_locked(struct mlx5_core_dev *dev)
448465
struct mlx5_priv *priv = &dev->priv;
449466

450467
lockdep_assert_held(&mlx5_intf_mutex);
468+
if (priv->flags & MLX5_PRIV_FLAGS_DETACH)
469+
return 0;
451470

452471
delete_drivers(dev);
453472
if (priv->flags & MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV)

drivers/net/ethernet/mellanox/mlx5/core/eswitch.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,12 @@ int mlx5_esw_vport_enable(struct mlx5_eswitch *esw, u16 vport_num,
10541054
goto err_vhca_mapping;
10551055
}
10561056

1057+
/* External controller host PF has factory programmed MAC.
1058+
* Read it from the device.
1059+
*/
1060+
if (mlx5_core_is_ecpf(esw->dev) && vport_num == MLX5_VPORT_PF)
1061+
mlx5_query_nic_vport_mac_address(esw->dev, vport_num, true, vport->info.mac);
1062+
10571063
esw_vport_change_handle_locked(vport);
10581064

10591065
esw->enabled_vports++;

drivers/net/ethernet/mellanox/mlx5/core/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ static int mlx5_load(struct mlx5_core_dev *dev)
11611161
err = mlx5_core_set_hca_defaults(dev);
11621162
if (err) {
11631163
mlx5_core_err(dev, "Failed to set hca defaults\n");
1164-
goto err_sriov;
1164+
goto err_set_hca;
11651165
}
11661166

11671167
mlx5_vhca_event_start(dev);
@@ -1194,6 +1194,7 @@ static int mlx5_load(struct mlx5_core_dev *dev)
11941194
mlx5_sf_hw_table_destroy(dev);
11951195
err_vhca:
11961196
mlx5_vhca_event_stop(dev);
1197+
err_set_hca:
11971198
mlx5_cleanup_fs(dev);
11981199
err_fs:
11991200
mlx5_accel_tls_cleanup(dev);

drivers/net/ethernet/mellanox/mlx5/core/mr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
5454
mkey_index = MLX5_GET(create_mkey_out, lout, mkey_index);
5555
mkey->iova = MLX5_GET64(mkc, mkc, start_addr);
5656
mkey->size = MLX5_GET64(mkc, mkc, len);
57-
mkey->key |= mlx5_idx_to_mkey(mkey_index);
57+
mkey->key = (u32)mlx5_mkey_variant(mkey->key) | mlx5_idx_to_mkey(mkey_index);
5858
mkey->pd = MLX5_GET(mkc, mkc, pd);
5959
init_waitqueue_head(&mkey->wait);
6060

drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ mlx5_sf_dev_state_change_handler(struct notifier_block *nb, unsigned long event_
163163
sf_index = event->function_id - base_id;
164164
sf_dev = xa_load(&table->devices, sf_index);
165165
switch (event->new_vhca_state) {
166+
case MLX5_VHCA_STATE_INVALID:
166167
case MLX5_VHCA_STATE_ALLOCATED:
167168
if (sf_dev)
168169
mlx5_sf_dev_del(table->dev, sf_dev, sf_index);

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,11 @@ static int dr_ste_v1_set_action_decap_l3_list(void *data,
694694
if (hw_action_sz / DR_STE_ACTION_DOUBLE_SZ < DR_STE_DECAP_L3_ACTION_NUM)
695695
return -EINVAL;
696696

697-
memcpy(padded_data, data, data_sz);
697+
inline_data_sz =
698+
MLX5_FLD_SZ_BYTES(ste_double_action_insert_with_inline_v1, inline_data);
699+
700+
/* Add an alignment padding */
701+
memcpy(padded_data + data_sz % inline_data_sz, data, data_sz);
698702

699703
/* Remove L2L3 outer headers */
700704
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,
706710
hw_action += DR_STE_ACTION_DOUBLE_SZ;
707711
used_actions++; /* Remove and NOP are a single double action */
708712

709-
inline_data_sz =
710-
MLX5_FLD_SZ_BYTES(ste_double_action_insert_with_inline_v1, inline_data);
713+
/* Point to the last dword of the header */
714+
data_ptr += (data_sz / inline_data_sz) * inline_data_sz;
711715

712-
/* Add the new header inline + 2 extra bytes */
716+
/* Add the new header using inline action 4Byte at a time, the header
717+
* is added in reversed order to the beginning of the packet to avoid
718+
* incorrect parsing by the HW. Since header is 14B or 18B an extra
719+
* two bytes are padded and later removed.
720+
*/
713721
for (i = 0; i < data_sz / inline_data_sz + 1; i++) {
714722
void *addr_inline;
715723

716724
MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, action_id,
717725
DR_STE_V1_ACTION_ID_INSERT_INLINE);
718726
/* The hardware expects here offset to words (2 bytes) */
719-
MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, start_offset,
720-
i * 2);
727+
MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, start_offset, 0);
721728

722729
/* Copy bytes one by one to avoid endianness problem */
723730
addr_inline = MLX5_ADDR_OF(ste_double_action_insert_with_inline_v1,
724731
hw_action, inline_data);
725-
memcpy(addr_inline, data_ptr, inline_data_sz);
732+
memcpy(addr_inline, data_ptr - i * inline_data_sz, inline_data_sz);
726733
hw_action += DR_STE_ACTION_DOUBLE_SZ;
727-
data_ptr += inline_data_sz;
728734
used_actions++;
729735
}
730736

731-
/* Remove 2 extra bytes */
737+
/* Remove first 2 extra bytes */
732738
MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, action_id,
733739
DR_STE_V1_ACTION_ID_REMOVE_BY_SIZE);
734-
MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, start_offset, data_sz / 2);
740+
MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, start_offset, 0);
735741
/* The hardware expects here size in words (2 bytes) */
736742
MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, remove_size, 1);
737743
used_actions++;

drivers/net/ethernet/mellanox/mlx5/core/vport.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,6 @@ int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
465465
void *in;
466466
int err;
467467

468-
if (!vport)
469-
return -EINVAL;
470468
if (!MLX5_CAP_GEN(mdev, vport_group_manager))
471469
return -EACCES;
472470

include/linux/mlx5/driver.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,10 @@ struct mlx5_core_roce {
542542
enum {
543543
MLX5_PRIV_FLAGS_DISABLE_IB_ADEV = 1 << 0,
544544
MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV = 1 << 1,
545+
/* Set during device detach to block any further devices
546+
* creation/deletion on drivers rescan. Unset during device attach.
547+
*/
548+
MLX5_PRIV_FLAGS_DETACH = 1 << 2,
545549
};
546550

547551
struct mlx5_adev {

0 commit comments

Comments
 (0)