Skip to content

Commit d3dbdc9

Browse files
mosheshemesh2kuba-moo
authored andcommitted
net/mlx5: Lock mlx5 devlink health recovery callback
Change devlink instance locks in mlx5 driver to have devlink health recovery callback locked, while keeping all driver paths which lead to devl_ API functions called by the driver locked. Signed-off-by: Moshe Shemesh <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 60d7cee commit d3dbdc9

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,14 @@ mlx5_fw_fatal_reporter_recover(struct devlink_health_reporter *reporter,
622622
struct netlink_ext_ack *extack)
623623
{
624624
struct mlx5_core_dev *dev = devlink_health_reporter_priv(reporter);
625+
struct devlink *devlink = priv_to_devlink(dev);
626+
int ret;
625627

626-
return mlx5_health_try_recover(dev);
628+
devl_lock(devlink);
629+
ret = mlx5_health_try_recover(dev);
630+
devl_unlock(devlink);
631+
632+
return ret;
627633
}
628634

629635
static int
@@ -666,16 +672,20 @@ static void mlx5_fw_fatal_reporter_err_work(struct work_struct *work)
666672
struct mlx5_fw_reporter_ctx fw_reporter_ctx;
667673
struct mlx5_core_health *health;
668674
struct mlx5_core_dev *dev;
675+
struct devlink *devlink;
669676
struct mlx5_priv *priv;
670677

671678
health = container_of(work, struct mlx5_core_health, fatal_report_work);
672679
priv = container_of(health, struct mlx5_priv, health);
673680
dev = container_of(priv, struct mlx5_core_dev, priv);
681+
devlink = priv_to_devlink(dev);
674682

675683
enter_error_state(dev, false);
676684
if (IS_ERR_OR_NULL(health->fw_fatal_reporter)) {
685+
devl_lock(devlink);
677686
if (mlx5_health_try_recover(dev))
678687
mlx5_core_err(dev, "health recovery failed\n");
688+
devl_unlock(devlink);
679689
return;
680690
}
681691
fw_reporter_ctx.err_synd = health->synd;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,7 @@ MODULE_DEVICE_TABLE(pci, mlx5_core_pci_table);
19321932
void mlx5_disable_device(struct mlx5_core_dev *dev)
19331933
{
19341934
mlx5_error_sw_reset(dev);
1935-
mlx5_unload_one(dev);
1935+
mlx5_unload_one_devl_locked(dev);
19361936
}
19371937

19381938
int mlx5_recover_device(struct mlx5_core_dev *dev)
@@ -1943,7 +1943,7 @@ int mlx5_recover_device(struct mlx5_core_dev *dev)
19431943
return -EIO;
19441944
}
19451945

1946-
return mlx5_load_one(dev, true);
1946+
return mlx5_load_one_devl_locked(dev, true);
19471947
}
19481948

19491949
static struct pci_driver mlx5_core_driver = {

0 commit comments

Comments
 (0)