Commit c90005b5 authored by Moshe Shemesh's avatar Moshe Shemesh Committed by Jakub Kicinski

devlink: Hold the instance lock in health callbacks

Let the core take the devlink instance lock around health callbacks and
remove the now redundant locking in the drivers.
Signed-off-by: default avatarMoshe Shemesh <moshe@nvidia.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d3dbdc9f
...@@ -622,14 +622,8 @@ mlx5_fw_fatal_reporter_recover(struct devlink_health_reporter *reporter, ...@@ -622,14 +622,8 @@ mlx5_fw_fatal_reporter_recover(struct devlink_health_reporter *reporter,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct mlx5_core_dev *dev = devlink_health_reporter_priv(reporter); struct mlx5_core_dev *dev = devlink_health_reporter_priv(reporter);
struct devlink *devlink = priv_to_devlink(dev);
int ret;
devl_lock(devlink); return mlx5_health_try_recover(dev);
ret = mlx5_health_try_recover(dev);
devl_unlock(devlink);
return ret;
} }
static int static int
......
...@@ -7757,6 +7757,7 @@ int devlink_health_report(struct devlink_health_reporter *reporter, ...@@ -7757,6 +7757,7 @@ int devlink_health_report(struct devlink_health_reporter *reporter,
enum devlink_health_reporter_state prev_health_state; enum devlink_health_reporter_state prev_health_state;
struct devlink *devlink = reporter->devlink; struct devlink *devlink = reporter->devlink;
unsigned long recover_ts_threshold; unsigned long recover_ts_threshold;
int ret;
/* write a log message of the current error */ /* write a log message of the current error */
WARN_ON(!msg); WARN_ON(!msg);
...@@ -7790,11 +7791,14 @@ int devlink_health_report(struct devlink_health_reporter *reporter, ...@@ -7790,11 +7791,14 @@ int devlink_health_report(struct devlink_health_reporter *reporter,
mutex_unlock(&reporter->dump_lock); mutex_unlock(&reporter->dump_lock);
} }
if (reporter->auto_recover) if (!reporter->auto_recover)
return devlink_health_reporter_recover(reporter, return 0;
priv_ctx, NULL);
return 0; devl_lock(devlink);
ret = devlink_health_reporter_recover(reporter, priv_ctx, NULL);
devl_unlock(devlink);
return ret;
} }
EXPORT_SYMBOL_GPL(devlink_health_report); EXPORT_SYMBOL_GPL(devlink_health_report);
...@@ -9469,8 +9473,7 @@ static const struct genl_small_ops devlink_nl_ops[] = { ...@@ -9469,8 +9473,7 @@ static const struct genl_small_ops devlink_nl_ops[] = {
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_health_reporter_get_doit, .doit = devlink_nl_cmd_health_reporter_get_doit,
.dumpit = devlink_nl_cmd_health_reporter_get_dumpit, .dumpit = devlink_nl_cmd_health_reporter_get_dumpit,
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT | .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
DEVLINK_NL_FLAG_NO_LOCK,
/* can be retrieved by unprivileged users */ /* can be retrieved by unprivileged users */
}, },
{ {
...@@ -9478,24 +9481,21 @@ static const struct genl_small_ops devlink_nl_ops[] = { ...@@ -9478,24 +9481,21 @@ static const struct genl_small_ops devlink_nl_ops[] = {
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_health_reporter_set_doit, .doit = devlink_nl_cmd_health_reporter_set_doit,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT | .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
DEVLINK_NL_FLAG_NO_LOCK,
}, },
{ {
.cmd = DEVLINK_CMD_HEALTH_REPORTER_RECOVER, .cmd = DEVLINK_CMD_HEALTH_REPORTER_RECOVER,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_health_reporter_recover_doit, .doit = devlink_nl_cmd_health_reporter_recover_doit,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT | .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
DEVLINK_NL_FLAG_NO_LOCK,
}, },
{ {
.cmd = DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE, .cmd = DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_health_reporter_diagnose_doit, .doit = devlink_nl_cmd_health_reporter_diagnose_doit,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT | .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
DEVLINK_NL_FLAG_NO_LOCK,
}, },
{ {
.cmd = DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET, .cmd = DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET,
...@@ -9509,16 +9509,14 @@ static const struct genl_small_ops devlink_nl_ops[] = { ...@@ -9509,16 +9509,14 @@ static const struct genl_small_ops devlink_nl_ops[] = {
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_health_reporter_dump_clear_doit, .doit = devlink_nl_cmd_health_reporter_dump_clear_doit,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT | .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
DEVLINK_NL_FLAG_NO_LOCK,
}, },
{ {
.cmd = DEVLINK_CMD_HEALTH_REPORTER_TEST, .cmd = DEVLINK_CMD_HEALTH_REPORTER_TEST,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_health_reporter_test_doit, .doit = devlink_nl_cmd_health_reporter_test_doit,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT | .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
DEVLINK_NL_FLAG_NO_LOCK,
}, },
{ {
.cmd = DEVLINK_CMD_FLASH_UPDATE, .cmd = DEVLINK_CMD_FLASH_UPDATE,
......
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