Commit 7a690ad4 authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Jakub Kicinski

devlink: Clean not-executed param notifications

The parameters are registered before devlink_register() and all the
notifications are delayed. This patch removes not-possible parameters
notifications along with addition of code annotation logic.
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 8bbeed48
...@@ -4675,6 +4675,7 @@ static void devlink_param_notify(struct devlink *devlink, ...@@ -4675,6 +4675,7 @@ static void devlink_param_notify(struct devlink *devlink,
WARN_ON(cmd != DEVLINK_CMD_PARAM_NEW && cmd != DEVLINK_CMD_PARAM_DEL && WARN_ON(cmd != DEVLINK_CMD_PARAM_NEW && cmd != DEVLINK_CMD_PARAM_DEL &&
cmd != DEVLINK_CMD_PORT_PARAM_NEW && cmd != DEVLINK_CMD_PORT_PARAM_NEW &&
cmd != DEVLINK_CMD_PORT_PARAM_DEL); cmd != DEVLINK_CMD_PORT_PARAM_DEL);
ASSERT_DEVLINK_REGISTERED(devlink);
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
...@@ -4946,7 +4947,6 @@ static int devlink_param_register_one(struct devlink *devlink, ...@@ -4946,7 +4947,6 @@ static int devlink_param_register_one(struct devlink *devlink,
param_item->param = param; param_item->param = param;
list_add_tail(&param_item->list, param_list); list_add_tail(&param_item->list, param_list);
devlink_param_notify(devlink, port_index, param_item, cmd);
return 0; return 0;
} }
...@@ -4960,7 +4960,6 @@ static void devlink_param_unregister_one(struct devlink *devlink, ...@@ -4960,7 +4960,6 @@ static void devlink_param_unregister_one(struct devlink *devlink,
param_item = devlink_param_find_by_name(param_list, param->name); param_item = devlink_param_find_by_name(param_list, param->name);
WARN_ON(!param_item); WARN_ON(!param_item);
devlink_param_notify(devlink, port_index, param_item, cmd);
list_del(&param_item->list); list_del(&param_item->list);
kfree(param_item); kfree(param_item);
} }
...@@ -10173,6 +10172,8 @@ int devlink_params_register(struct devlink *devlink, ...@@ -10173,6 +10172,8 @@ int devlink_params_register(struct devlink *devlink,
const struct devlink_param *params, const struct devlink_param *params,
size_t params_count) size_t params_count)
{ {
ASSERT_DEVLINK_NOT_REGISTERED(devlink);
return __devlink_params_register(devlink, 0, &devlink->param_list, return __devlink_params_register(devlink, 0, &devlink->param_list,
params, params_count, params, params_count,
DEVLINK_CMD_PARAM_NEW, DEVLINK_CMD_PARAM_NEW,
...@@ -10190,6 +10191,8 @@ void devlink_params_unregister(struct devlink *devlink, ...@@ -10190,6 +10191,8 @@ void devlink_params_unregister(struct devlink *devlink,
const struct devlink_param *params, const struct devlink_param *params,
size_t params_count) size_t params_count)
{ {
ASSERT_DEVLINK_NOT_REGISTERED(devlink);
return __devlink_params_unregister(devlink, 0, &devlink->param_list, return __devlink_params_unregister(devlink, 0, &devlink->param_list,
params, params_count, params, params_count,
DEVLINK_CMD_PARAM_DEL); DEVLINK_CMD_PARAM_DEL);
...@@ -10210,6 +10213,8 @@ int devlink_param_register(struct devlink *devlink, ...@@ -10210,6 +10213,8 @@ int devlink_param_register(struct devlink *devlink,
{ {
int err; int err;
ASSERT_DEVLINK_NOT_REGISTERED(devlink);
mutex_lock(&devlink->lock); mutex_lock(&devlink->lock);
err = __devlink_param_register_one(devlink, 0, &devlink->param_list, err = __devlink_param_register_one(devlink, 0, &devlink->param_list,
param, DEVLINK_CMD_PARAM_NEW); param, DEVLINK_CMD_PARAM_NEW);
...@@ -10226,6 +10231,8 @@ EXPORT_SYMBOL_GPL(devlink_param_register); ...@@ -10226,6 +10231,8 @@ EXPORT_SYMBOL_GPL(devlink_param_register);
void devlink_param_unregister(struct devlink *devlink, void devlink_param_unregister(struct devlink *devlink,
const struct devlink_param *param) const struct devlink_param *param)
{ {
ASSERT_DEVLINK_NOT_REGISTERED(devlink);
mutex_lock(&devlink->lock); mutex_lock(&devlink->lock);
devlink_param_unregister_one(devlink, 0, &devlink->param_list, param, devlink_param_unregister_one(devlink, 0, &devlink->param_list, param,
DEVLINK_CMD_PARAM_DEL); DEVLINK_CMD_PARAM_DEL);
...@@ -10287,6 +10294,8 @@ int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, ...@@ -10287,6 +10294,8 @@ int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
{ {
struct devlink_param_item *param_item; struct devlink_param_item *param_item;
ASSERT_DEVLINK_NOT_REGISTERED(devlink);
param_item = devlink_param_find_by_id(&devlink->param_list, param_id); param_item = devlink_param_find_by_id(&devlink->param_list, param_id);
if (!param_item) if (!param_item)
return -EINVAL; return -EINVAL;
...@@ -10300,8 +10309,6 @@ int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, ...@@ -10300,8 +10309,6 @@ int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
else else
param_item->driverinit_value = init_val; param_item->driverinit_value = init_val;
param_item->driverinit_value_valid = true; param_item->driverinit_value_valid = true;
devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_NEW);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(devlink_param_driverinit_value_set); EXPORT_SYMBOL_GPL(devlink_param_driverinit_value_set);
......
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