Commit 9d9a90cd authored by Ido Schimmel's avatar Ido Schimmel Committed by Jakub Kicinski

mlxsw: core: Register devlink instance before sub-objects

Recent changes made it possible to register the devlink instance before
its sub-objects and under the instance lock. Among other things, it
allows us to avoid warnings such as this one [1]. The warning is
generated because a buggy firmware is generating a health event during
driver initialization, before the devlink instance is registered.

Move the registration of the devlink instance to the beginning of the
initialization flow to avoid such problems.

A similar change was implemented in netdevsim in commit 82a3aef2
("netdevsim: move devlink registration under the instance lock").

[1]
WARNING: CPU: 3 PID: 49 at net/devlink/leftover.c:7509 devlink_recover_notify.constprop.0+0xaf/0xc0
[...]
Call Trace:
 <TASK>
 devlink_health_report+0x45/0x1d0
 mlxsw_core_health_event_work+0x24/0x30 [mlxsw_core]
 process_one_work+0x1db/0x390
 worker_thread+0x49/0x3b0
 kthread+0xe5/0x110
 ret_from_fork+0x1f/0x30
 </TASK>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 74cbc3c0
...@@ -2184,6 +2184,7 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -2184,6 +2184,7 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
goto err_devlink_alloc; goto err_devlink_alloc;
} }
devl_lock(devlink); devl_lock(devlink);
devl_register(devlink);
} }
mlxsw_core = devlink_priv(devlink); mlxsw_core = devlink_priv(devlink);
...@@ -2267,10 +2268,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -2267,10 +2268,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
goto err_driver_init; goto err_driver_init;
} }
if (!reload) { if (!reload)
devl_unlock(devlink); devl_unlock(devlink);
devlink_register(devlink);
}
return 0; return 0;
err_driver_init: err_driver_init:
...@@ -2302,6 +2301,7 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -2302,6 +2301,7 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
err_bus_init: err_bus_init:
mlxsw_core_irq_event_handler_fini(mlxsw_core); mlxsw_core_irq_event_handler_fini(mlxsw_core);
if (!reload) { if (!reload) {
devl_unregister(devlink);
devl_unlock(devlink); devl_unlock(devlink);
devlink_free(devlink); devlink_free(devlink);
} }
...@@ -2340,10 +2340,8 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, ...@@ -2340,10 +2340,8 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
{ {
struct devlink *devlink = priv_to_devlink(mlxsw_core); struct devlink *devlink = priv_to_devlink(mlxsw_core);
if (!reload) { if (!reload)
devlink_unregister(devlink);
devl_lock(devlink); devl_lock(devlink);
}
if (devlink_is_reload_failed(devlink)) { if (devlink_is_reload_failed(devlink)) {
if (!reload) if (!reload)
...@@ -2372,6 +2370,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, ...@@ -2372,6 +2370,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
mlxsw_core->bus->fini(mlxsw_core->bus_priv); mlxsw_core->bus->fini(mlxsw_core->bus_priv);
mlxsw_core_irq_event_handler_fini(mlxsw_core); mlxsw_core_irq_event_handler_fini(mlxsw_core);
if (!reload) { if (!reload) {
devl_unregister(devlink);
devl_unlock(devlink); devl_unlock(devlink);
devlink_free(devlink); devlink_free(devlink);
} }
...@@ -2381,6 +2380,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, ...@@ -2381,6 +2380,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
reload_fail_deinit: reload_fail_deinit:
mlxsw_core_params_unregister(mlxsw_core); mlxsw_core_params_unregister(mlxsw_core);
devl_resources_unregister(devlink); devl_resources_unregister(devlink);
devl_unregister(devlink);
devl_unlock(devlink); devl_unlock(devlink);
devlink_free(devlink); devlink_free(devlink);
} }
......
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