@@ -146,7 +146,6 @@ struct devlink_port {
initialized:1;
struct delayed_work type_warn_dw;
struct list_head reporter_list;
- struct mutex reporters_lock; /* Protects reporter_list */
struct devlink_rate *devlink_rate;
struct devlink_linecard *linecard;
@@ -246,7 +246,6 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,
lockdep_register_key(&devlink->lock_key);
mutex_init(&devlink->lock);
lockdep_set_class(&devlink->lock, &devlink->lock_key);
- mutex_init(&devlink->reporters_lock);
refcount_set(&devlink->refcount, 1);
return devlink;
@@ -268,7 +267,6 @@ void devlink_free(struct devlink *devlink)
{
ASSERT_DEVLINK_NOT_REGISTERED(devlink);
- mutex_destroy(&devlink->reporters_lock);
WARN_ON(!list_empty(&devlink->trap_policer_list));
WARN_ON(!list_empty(&devlink->trap_group_list));
WARN_ON(!list_empty(&devlink->trap_list));
@@ -32,7 +32,6 @@ struct devlink {
struct list_head param_list;
struct list_head region_list;
struct list_head reporter_list;
- struct mutex reporters_lock; /* protects reporter_list */
struct devlink_dpipe_headers *dpipe_headers;
struct list_head trap_list;
struct list_head trap_group_list;
@@ -7281,12 +7281,10 @@ EXPORT_SYMBOL_GPL(devlink_health_reporter_priv);
static struct devlink_health_reporter *
__devlink_health_reporter_find_by_name(struct list_head *reporter_list,
- struct mutex *list_lock,
const char *reporter_name)
{
struct devlink_health_reporter *reporter;
- lockdep_assert_held(list_lock);
list_for_each_entry(reporter, reporter_list, list)
if (!strcmp(reporter->ops->name, reporter_name))
return reporter;
@@ -7298,7 +7296,6 @@ devlink_health_reporter_find_by_name(struct devlink *devlink,
const char *reporter_name)
{
return __devlink_health_reporter_find_by_name(&devlink->reporter_list,
- &devlink->reporters_lock,
reporter_name);
}
@@ -7307,7 +7304,6 @@ devlink_port_health_reporter_find_by_name(struct devlink_port *devlink_port,
const char *reporter_name)
{
return __devlink_health_reporter_find_by_name(&devlink_port->reporter_list,
- &devlink_port->reporters_lock,
reporter_name);
}
@@ -7353,22 +7349,18 @@ devl_port_health_reporter_create(struct devlink_port *port,
struct devlink_health_reporter *reporter;
devl_assert_locked(port->devlink);
- mutex_lock(&port->reporters_lock);
+
if (__devlink_health_reporter_find_by_name(&port->reporter_list,
- &port->reporters_lock, ops->name)) {
- reporter = ERR_PTR(-EEXIST);
- goto unlock;
- }
+ ops->name))
+ return ERR_PTR(-EEXIST);
reporter = __devlink_health_reporter_create(port->devlink, ops,
graceful_period, priv);
if (IS_ERR(reporter))
- goto unlock;
+ return reporter;
reporter->devlink_port = port;
list_add_tail(&reporter->list, &port->reporter_list);
-unlock:
- mutex_unlock(&port->reporters_lock);
return reporter;
}
EXPORT_SYMBOL_GPL(devl_port_health_reporter_create);
@@ -7405,20 +7397,16 @@ devl_health_reporter_create(struct devlink *devlink,
struct devlink_health_reporter *reporter;
devl_assert_locked(devlink);
- mutex_lock(&devlink->reporters_lock);
- if (devlink_health_reporter_find_by_name(devlink, ops->name)) {
- reporter = ERR_PTR(-EEXIST);
- goto unlock;
- }
+
+ if (devlink_health_reporter_find_by_name(devlink, ops->name))
+ return ERR_PTR(-EEXIST);
reporter = __devlink_health_reporter_create(devlink, ops,
graceful_period, priv);
if (IS_ERR(reporter))
- goto unlock;
+ return reporter;
list_add_tail(&reporter->list, &devlink->reporter_list);
-unlock:
- mutex_unlock(&devlink->reporters_lock);
return reporter;
}
EXPORT_SYMBOL_GPL(devl_health_reporter_create);
@@ -7469,13 +7457,9 @@ __devlink_health_reporter_destroy(struct devlink_health_reporter *reporter)
void
devl_health_reporter_destroy(struct devlink_health_reporter *reporter)
{
- struct mutex *lock = &reporter->devlink->reporters_lock;
-
devl_assert_locked(reporter->devlink);
- mutex_lock(lock);
__devlink_health_reporter_destroy(reporter);
- mutex_unlock(lock);
}
EXPORT_SYMBOL_GPL(devl_health_reporter_destroy);
@@ -7498,13 +7482,9 @@ EXPORT_SYMBOL_GPL(devlink_health_reporter_destroy);
void
devl_port_health_reporter_destroy(struct devlink_health_reporter *reporter)
{
- struct mutex *lock = &reporter->devlink_port->reporters_lock;
-
devl_assert_locked(reporter->devlink);
- mutex_lock(lock);
__devlink_health_reporter_destroy(reporter);
- mutex_unlock(lock);
}
EXPORT_SYMBOL_GPL(devl_port_health_reporter_destroy);
@@ -7758,17 +7738,13 @@ devlink_health_reporter_get_from_attrs(struct devlink *devlink,
reporter_name = nla_data(attrs[DEVLINK_ATTR_HEALTH_REPORTER_NAME]);
devlink_port = devlink_port_get_from_attrs(devlink, attrs);
if (IS_ERR(devlink_port)) {
- mutex_lock(&devlink->reporters_lock);
reporter = devlink_health_reporter_find_by_name(devlink, reporter_name);
if (reporter)
refcount_inc(&reporter->refcount);
- mutex_unlock(&devlink->reporters_lock);
} else {
- mutex_lock(&devlink_port->reporters_lock);
reporter = devlink_port_health_reporter_find_by_name(devlink_port, reporter_name);
if (reporter)
refcount_inc(&reporter->refcount);
- mutex_unlock(&devlink_port->reporters_lock);
}
return reporter;
@@ -7868,8 +7844,6 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg,
if (!devl_is_registered(devlink))
goto next_devlink;
- mutex_lock(&devlink->reporters_lock);
-
list_for_each_entry(reporter, &devlink->reporter_list,
list) {
if (idx < state->idx) {
@@ -7881,7 +7855,6 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg,
NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
NLM_F_MULTI);
if (err) {
- mutex_unlock(&devlink->reporters_lock);
devl_unlock(devlink);
devlink_put(devlink);
state->idx = idx;
@@ -7889,10 +7862,8 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg,
}
idx++;
}
- mutex_unlock(&devlink->reporters_lock);
xa_for_each(&devlink->ports, port_index, port) {
- mutex_lock(&port->reporters_lock);
list_for_each_entry(reporter, &port->reporter_list, list) {
if (idx < state->idx) {
idx++;
@@ -7904,7 +7875,6 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI);
if (err) {
- mutex_unlock(&port->reporters_lock);
devl_unlock(devlink);
devlink_put(devlink);
state->idx = idx;
@@ -7912,7 +7882,6 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg,
}
idx++;
}
- mutex_unlock(&port->reporters_lock);
}
next_devlink:
devl_unlock(devlink);
@@ -9633,12 +9602,9 @@ int devl_port_register(struct devlink *devlink,
devlink_port->index = port_index;
spin_lock_init(&devlink_port->type_lock);
INIT_LIST_HEAD(&devlink_port->reporter_list);
- mutex_init(&devlink_port->reporters_lock);
err = xa_insert(&devlink->ports, port_index, devlink_port, GFP_KERNEL);
- if (err) {
- mutex_destroy(&devlink_port->reporters_lock);
+ if (err)
return err;
- }
INIT_DELAYED_WORK(&devlink_port->type_warn_dw, &devlink_port_type_warn);
devlink_port_type_warn_schedule(devlink_port);
@@ -9689,7 +9655,6 @@ void devl_port_unregister(struct devlink_port *devlink_port)
devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_DEL);
xa_erase(&devlink_port->devlink->ports, devlink_port->index);
WARN_ON(!list_empty(&devlink_port->reporter_list));
- mutex_destroy(&devlink_port->reporters_lock);
devlink_port->registered = false;
}
EXPORT_SYMBOL_GPL(devl_port_unregister);