]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mlxsw: core: Register devlink instance before sub-objects
authorIdo Schimmel <idosch@nvidia.com>
Mon, 6 Feb 2023 15:39:23 +0000 (16:39 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 8 Feb 2023 04:18:50 +0000 (20:18 -0800)
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 82a3aef2e6af
("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: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/core.c

index a08aec243ad6927818903382ed44912528e0acd0..22db0bb15c4539dba4b77835721cf0dbb892485f 100644 (file)
@@ -2184,6 +2184,7 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
                        goto err_devlink_alloc;
                }
                devl_lock(devlink);
+               devl_register(devlink);
        }
 
        mlxsw_core = devlink_priv(devlink);
@@ -2267,10 +2268,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
                        goto err_driver_init;
        }
 
-       if (!reload) {
+       if (!reload)
                devl_unlock(devlink);
-               devlink_register(devlink);
-       }
        return 0;
 
 err_driver_init:
@@ -2302,6 +2301,7 @@ err_register_resources:
 err_bus_init:
        mlxsw_core_irq_event_handler_fini(mlxsw_core);
        if (!reload) {
+               devl_unregister(devlink);
                devl_unlock(devlink);
                devlink_free(devlink);
        }
@@ -2340,10 +2340,8 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
 {
        struct devlink *devlink = priv_to_devlink(mlxsw_core);
 
-       if (!reload) {
-               devlink_unregister(devlink);
+       if (!reload)
                devl_lock(devlink);
-       }
 
        if (devlink_is_reload_failed(devlink)) {
                if (!reload)
@@ -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_irq_event_handler_fini(mlxsw_core);
        if (!reload) {
+               devl_unregister(devlink);
                devl_unlock(devlink);
                devlink_free(devlink);
        }
@@ -2381,6 +2380,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
 reload_fail_deinit:
        mlxsw_core_params_unregister(mlxsw_core);
        devl_resources_unregister(devlink);
+       devl_unregister(devlink);
        devl_unlock(devlink);
        devlink_free(devlink);
 }