Skip to content

Commit c90005b

Browse files
mosheshemesh2kuba-moo
authored andcommitted
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: Moshe Shemesh <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d3dbdc9 commit c90005b

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -622,14 +622,8 @@ 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;
627625

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

635629
static int

net/core/devlink.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7757,6 +7757,7 @@ int devlink_health_report(struct devlink_health_reporter *reporter,
77577757
enum devlink_health_reporter_state prev_health_state;
77587758
struct devlink *devlink = reporter->devlink;
77597759
unsigned long recover_ts_threshold;
7760+
int ret;
77607761

77617762
/* write a log message of the current error */
77627763
WARN_ON(!msg);
@@ -7790,11 +7791,14 @@ int devlink_health_report(struct devlink_health_reporter *reporter,
77907791
mutex_unlock(&reporter->dump_lock);
77917792
}
77927793

7793-
if (reporter->auto_recover)
7794-
return devlink_health_reporter_recover(reporter,
7795-
priv_ctx, NULL);
7794+
if (!reporter->auto_recover)
7795+
return 0;
77967796

7797-
return 0;
7797+
devl_lock(devlink);
7798+
ret = devlink_health_reporter_recover(reporter, priv_ctx, NULL);
7799+
devl_unlock(devlink);
7800+
7801+
return ret;
77987802
}
77997803
EXPORT_SYMBOL_GPL(devlink_health_report);
78007804

@@ -9469,33 +9473,29 @@ static const struct genl_small_ops devlink_nl_ops[] = {
94699473
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
94709474
.doit = devlink_nl_cmd_health_reporter_get_doit,
94719475
.dumpit = devlink_nl_cmd_health_reporter_get_dumpit,
9472-
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT |
9473-
DEVLINK_NL_FLAG_NO_LOCK,
9476+
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
94749477
/* can be retrieved by unprivileged users */
94759478
},
94769479
{
94779480
.cmd = DEVLINK_CMD_HEALTH_REPORTER_SET,
94789481
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
94799482
.doit = devlink_nl_cmd_health_reporter_set_doit,
94809483
.flags = GENL_ADMIN_PERM,
9481-
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT |
9482-
DEVLINK_NL_FLAG_NO_LOCK,
9484+
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
94839485
},
94849486
{
94859487
.cmd = DEVLINK_CMD_HEALTH_REPORTER_RECOVER,
94869488
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
94879489
.doit = devlink_nl_cmd_health_reporter_recover_doit,
94889490
.flags = GENL_ADMIN_PERM,
9489-
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT |
9490-
DEVLINK_NL_FLAG_NO_LOCK,
9491+
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
94919492
},
94929493
{
94939494
.cmd = DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
94949495
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
94959496
.doit = devlink_nl_cmd_health_reporter_diagnose_doit,
94969497
.flags = GENL_ADMIN_PERM,
9497-
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT |
9498-
DEVLINK_NL_FLAG_NO_LOCK,
9498+
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
94999499
},
95009500
{
95019501
.cmd = DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET,
@@ -9509,16 +9509,14 @@ static const struct genl_small_ops devlink_nl_ops[] = {
95099509
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
95109510
.doit = devlink_nl_cmd_health_reporter_dump_clear_doit,
95119511
.flags = GENL_ADMIN_PERM,
9512-
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT |
9513-
DEVLINK_NL_FLAG_NO_LOCK,
9512+
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
95149513
},
95159514
{
95169515
.cmd = DEVLINK_CMD_HEALTH_REPORTER_TEST,
95179516
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
95189517
.doit = devlink_nl_cmd_health_reporter_test_doit,
95199518
.flags = GENL_ADMIN_PERM,
9520-
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT |
9521-
DEVLINK_NL_FLAG_NO_LOCK,
9519+
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
95229520
},
95239521
{
95249522
.cmd = DEVLINK_CMD_FLASH_UPDATE,

0 commit comments

Comments
 (0)