Commit f0680ef0 authored by Moshe Shemesh's avatar Moshe Shemesh Committed by Paolo Abeni

devlink: Hold the instance lock in port_new / port_del callbacks

Let the core take the devlink instance lock around port_new and port_del
callbacks and remove the now redundant locking in the only driver that
currently use them.
Signed-off-by: default avatarMoshe Shemesh <moshe@nvidia.com>
Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 973598d4
......@@ -355,9 +355,7 @@ int mlx5_devlink_sf_port_new(struct devlink *devlink,
"Port add is only supported in eswitch switchdev mode or SF ports are disabled.");
return -EOPNOTSUPP;
}
devl_lock(devlink);
err = mlx5_sf_add(dev, table, new_attr, extack, new_port_index);
devl_unlock(devlink);
mlx5_sf_table_put(table);
return err;
}
......@@ -402,9 +400,7 @@ int mlx5_devlink_sf_port_del(struct devlink *devlink, unsigned int port_index,
goto sf_err;
}
devl_lock(devlink);
mlx5_esw_offloads_sf_vport_disable(esw, sf->hw_fn_id);
devl_unlock(devlink);
mlx5_sf_id_erase(table, sf);
mutex_lock(&table->sf_state_lock);
......
......@@ -1712,7 +1712,7 @@ static int devlink_port_new_notifiy(struct devlink *devlink,
if (!msg)
return -ENOMEM;
mutex_lock(&devlink->lock);
lockdep_assert_held(&devlink->lock);
devlink_port = devlink_port_get_by_index(devlink, port_index);
if (!devlink_port) {
err = -ENODEV;
......@@ -1725,11 +1725,9 @@ static int devlink_port_new_notifiy(struct devlink *devlink,
goto out;
err = genlmsg_reply(msg, info);
mutex_unlock(&devlink->lock);
return err;
out:
mutex_unlock(&devlink->lock);
nlmsg_free(msg);
return err;
}
......@@ -9067,13 +9065,11 @@ static const struct genl_small_ops devlink_nl_ops[] = {
.cmd = DEVLINK_CMD_PORT_NEW,
.doit = devlink_nl_cmd_port_new_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NO_LOCK,
},
{
.cmd = DEVLINK_CMD_PORT_DEL,
.doit = devlink_nl_cmd_port_del_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NO_LOCK,
},
{
.cmd = DEVLINK_CMD_LINECARD_GET,
......
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