Commit bc39f679 authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 7edcc682 0232fc2d
...@@ -303,6 +303,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev) ...@@ -303,6 +303,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)
int ret = 0, i; int ret = 0, i;
mutex_lock(&mlx5_intf_mutex); mutex_lock(&mlx5_intf_mutex);
priv->flags &= ~MLX5_PRIV_FLAGS_DETACH;
for (i = 0; i < ARRAY_SIZE(mlx5_adev_devices); i++) { for (i = 0; i < ARRAY_SIZE(mlx5_adev_devices); i++) {
if (!priv->adev[i]) { if (!priv->adev[i]) {
bool is_supported = false; bool is_supported = false;
...@@ -320,6 +321,16 @@ int mlx5_attach_device(struct mlx5_core_dev *dev) ...@@ -320,6 +321,16 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)
} }
} else { } else {
adev = &priv->adev[i]->adev; 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); adrv = to_auxiliary_drv(adev->dev.driver);
if (adrv->resume) if (adrv->resume)
...@@ -350,6 +361,10 @@ void mlx5_detach_device(struct mlx5_core_dev *dev) ...@@ -350,6 +361,10 @@ void mlx5_detach_device(struct mlx5_core_dev *dev)
continue; continue;
adev = &priv->adev[i]->adev; 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); adrv = to_auxiliary_drv(adev->dev.driver);
if (adrv->suspend) { if (adrv->suspend) {
...@@ -357,9 +372,11 @@ void mlx5_detach_device(struct mlx5_core_dev *dev) ...@@ -357,9 +372,11 @@ void mlx5_detach_device(struct mlx5_core_dev *dev)
continue; continue;
} }
skip_suspend:
del_adev(&priv->adev[i]->adev); del_adev(&priv->adev[i]->adev);
priv->adev[i] = NULL; priv->adev[i] = NULL;
} }
priv->flags |= MLX5_PRIV_FLAGS_DETACH;
mutex_unlock(&mlx5_intf_mutex); mutex_unlock(&mlx5_intf_mutex);
} }
...@@ -448,6 +465,8 @@ int mlx5_rescan_drivers_locked(struct mlx5_core_dev *dev) ...@@ -448,6 +465,8 @@ int mlx5_rescan_drivers_locked(struct mlx5_core_dev *dev)
struct mlx5_priv *priv = &dev->priv; struct mlx5_priv *priv = &dev->priv;
lockdep_assert_held(&mlx5_intf_mutex); lockdep_assert_held(&mlx5_intf_mutex);
if (priv->flags & MLX5_PRIV_FLAGS_DETACH)
return 0;
delete_drivers(dev); delete_drivers(dev);
if (priv->flags & MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV) if (priv->flags & MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV)
......
...@@ -1054,6 +1054,12 @@ int mlx5_esw_vport_enable(struct mlx5_eswitch *esw, u16 vport_num, ...@@ -1054,6 +1054,12 @@ int mlx5_esw_vport_enable(struct mlx5_eswitch *esw, u16 vport_num,
goto err_vhca_mapping; 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_vport_change_handle_locked(vport);
esw->enabled_vports++; esw->enabled_vports++;
......
...@@ -1161,7 +1161,7 @@ static int mlx5_load(struct mlx5_core_dev *dev) ...@@ -1161,7 +1161,7 @@ static int mlx5_load(struct mlx5_core_dev *dev)
err = mlx5_core_set_hca_defaults(dev); err = mlx5_core_set_hca_defaults(dev);
if (err) { if (err) {
mlx5_core_err(dev, "Failed to set hca defaults\n"); mlx5_core_err(dev, "Failed to set hca defaults\n");
goto err_sriov; goto err_set_hca;
} }
mlx5_vhca_event_start(dev); mlx5_vhca_event_start(dev);
...@@ -1194,6 +1194,7 @@ static int mlx5_load(struct mlx5_core_dev *dev) ...@@ -1194,6 +1194,7 @@ static int mlx5_load(struct mlx5_core_dev *dev)
mlx5_sf_hw_table_destroy(dev); mlx5_sf_hw_table_destroy(dev);
err_vhca: err_vhca:
mlx5_vhca_event_stop(dev); mlx5_vhca_event_stop(dev);
err_set_hca:
mlx5_cleanup_fs(dev); mlx5_cleanup_fs(dev);
err_fs: err_fs:
mlx5_accel_tls_cleanup(dev); mlx5_accel_tls_cleanup(dev);
......
...@@ -54,7 +54,7 @@ int mlx5_core_create_mkey(struct mlx5_core_dev *dev, ...@@ -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_index = MLX5_GET(create_mkey_out, lout, mkey_index);
mkey->iova = MLX5_GET64(mkc, mkc, start_addr); mkey->iova = MLX5_GET64(mkc, mkc, start_addr);
mkey->size = MLX5_GET64(mkc, mkc, len); 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); mkey->pd = MLX5_GET(mkc, mkc, pd);
init_waitqueue_head(&mkey->wait); init_waitqueue_head(&mkey->wait);
......
...@@ -163,6 +163,7 @@ mlx5_sf_dev_state_change_handler(struct notifier_block *nb, unsigned long event_ ...@@ -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_index = event->function_id - base_id;
sf_dev = xa_load(&table->devices, sf_index); sf_dev = xa_load(&table->devices, sf_index);
switch (event->new_vhca_state) { switch (event->new_vhca_state) {
case MLX5_VHCA_STATE_INVALID:
case MLX5_VHCA_STATE_ALLOCATED: case MLX5_VHCA_STATE_ALLOCATED:
if (sf_dev) if (sf_dev)
mlx5_sf_dev_del(table->dev, sf_dev, sf_index); mlx5_sf_dev_del(table->dev, sf_dev, sf_index);
......
...@@ -694,7 +694,11 @@ static int dr_ste_v1_set_action_decap_l3_list(void *data, ...@@ -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) if (hw_action_sz / DR_STE_ACTION_DOUBLE_SZ < DR_STE_DECAP_L3_ACTION_NUM)
return -EINVAL; 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 */ /* Remove L2L3 outer headers */
MLX5_SET(ste_single_action_remove_header_v1, hw_action, action_id, 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, ...@@ -706,32 +710,34 @@ static int dr_ste_v1_set_action_decap_l3_list(void *data,
hw_action += DR_STE_ACTION_DOUBLE_SZ; hw_action += DR_STE_ACTION_DOUBLE_SZ;
used_actions++; /* Remove and NOP are a single double action */ used_actions++; /* Remove and NOP are a single double action */
inline_data_sz = /* Point to the last dword of the header */
MLX5_FLD_SZ_BYTES(ste_double_action_insert_with_inline_v1, inline_data); 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++) { for (i = 0; i < data_sz / inline_data_sz + 1; i++) {
void *addr_inline; void *addr_inline;
MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, action_id, MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, action_id,
DR_STE_V1_ACTION_ID_INSERT_INLINE); DR_STE_V1_ACTION_ID_INSERT_INLINE);
/* The hardware expects here offset to words (2 bytes) */ /* The hardware expects here offset to words (2 bytes) */
MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, start_offset, MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, start_offset, 0);
i * 2);
/* Copy bytes one by one to avoid endianness problem */ /* Copy bytes one by one to avoid endianness problem */
addr_inline = MLX5_ADDR_OF(ste_double_action_insert_with_inline_v1, addr_inline = MLX5_ADDR_OF(ste_double_action_insert_with_inline_v1,
hw_action, inline_data); 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; hw_action += DR_STE_ACTION_DOUBLE_SZ;
data_ptr += inline_data_sz;
used_actions++; used_actions++;
} }
/* Remove 2 extra bytes */ /* Remove first 2 extra bytes */
MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, action_id, MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, action_id,
DR_STE_V1_ACTION_ID_REMOVE_BY_SIZE); 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) */ /* The hardware expects here size in words (2 bytes) */
MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, remove_size, 1); MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, remove_size, 1);
used_actions++; used_actions++;
......
...@@ -465,8 +465,6 @@ int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev, ...@@ -465,8 +465,6 @@ int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
void *in; void *in;
int err; int err;
if (!vport)
return -EINVAL;
if (!MLX5_CAP_GEN(mdev, vport_group_manager)) if (!MLX5_CAP_GEN(mdev, vport_group_manager))
return -EACCES; return -EACCES;
......
...@@ -542,6 +542,10 @@ struct mlx5_core_roce { ...@@ -542,6 +542,10 @@ struct mlx5_core_roce {
enum { enum {
MLX5_PRIV_FLAGS_DISABLE_IB_ADEV = 1 << 0, MLX5_PRIV_FLAGS_DISABLE_IB_ADEV = 1 << 0,
MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV = 1 << 1, 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 { struct mlx5_adev {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment