Commit d3efc2a6 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

net: devlink: remove devlink_mutex

All accesses to devlink structure from userspace and drivers are locked
with devlink->lock instance mutex. Also, devlinks xa_array iteration is
taken care of by iteration helpers taking devlink reference.

Therefore, remove devlink_mutex as it is no longer needed.
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 644a66c6
...@@ -225,12 +225,6 @@ static DEFINE_XARRAY_FLAGS(devlinks, XA_FLAGS_ALLOC); ...@@ -225,12 +225,6 @@ static DEFINE_XARRAY_FLAGS(devlinks, XA_FLAGS_ALLOC);
#define ASSERT_DEVLINK_NOT_REGISTERED(d) \ #define ASSERT_DEVLINK_NOT_REGISTERED(d) \
WARN_ON_ONCE(xa_get_mark(&devlinks, (d)->index, DEVLINK_REGISTERED)) WARN_ON_ONCE(xa_get_mark(&devlinks, (d)->index, DEVLINK_REGISTERED))
/* devlink_mutex
*
* An overall lock guarding every operation coming from userspace.
*/
static DEFINE_MUTEX(devlink_mutex);
struct net *devlink_net(const struct devlink *devlink) struct net *devlink_net(const struct devlink *devlink)
{ {
return read_pnet(&devlink->_net); return read_pnet(&devlink->_net);
...@@ -776,12 +770,9 @@ static int devlink_nl_pre_doit(const struct genl_ops *ops, ...@@ -776,12 +770,9 @@ static int devlink_nl_pre_doit(const struct genl_ops *ops,
struct devlink *devlink; struct devlink *devlink;
int err; int err;
mutex_lock(&devlink_mutex);
devlink = devlink_get_from_attrs(genl_info_net(info), info->attrs); devlink = devlink_get_from_attrs(genl_info_net(info), info->attrs);
if (IS_ERR(devlink)) { if (IS_ERR(devlink))
mutex_unlock(&devlink_mutex);
return PTR_ERR(devlink); return PTR_ERR(devlink);
}
devl_lock(devlink); devl_lock(devlink);
info->user_ptr[0] = devlink; info->user_ptr[0] = devlink;
if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_PORT) { if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_PORT) {
...@@ -826,7 +817,6 @@ static int devlink_nl_pre_doit(const struct genl_ops *ops, ...@@ -826,7 +817,6 @@ static int devlink_nl_pre_doit(const struct genl_ops *ops,
unlock: unlock:
devl_unlock(devlink); devl_unlock(devlink);
devlink_put(devlink); devlink_put(devlink);
mutex_unlock(&devlink_mutex);
return err; return err;
} }
...@@ -843,7 +833,6 @@ static void devlink_nl_post_doit(const struct genl_ops *ops, ...@@ -843,7 +833,6 @@ static void devlink_nl_post_doit(const struct genl_ops *ops,
} }
devl_unlock(devlink); devl_unlock(devlink);
devlink_put(devlink); devlink_put(devlink);
mutex_unlock(&devlink_mutex);
} }
static struct genl_family devlink_nl_family; static struct genl_family devlink_nl_family;
...@@ -1408,7 +1397,6 @@ static int devlink_nl_cmd_rate_get_dumpit(struct sk_buff *msg, ...@@ -1408,7 +1397,6 @@ static int devlink_nl_cmd_rate_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err = 0; int err = 0;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
devl_lock(devlink); devl_lock(devlink);
list_for_each_entry(devlink_rate, &devlink->rate_list, list) { list_for_each_entry(devlink_rate, &devlink->rate_list, list) {
...@@ -1433,7 +1421,6 @@ static int devlink_nl_cmd_rate_get_dumpit(struct sk_buff *msg, ...@@ -1433,7 +1421,6 @@ static int devlink_nl_cmd_rate_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
if (err != -EMSGSIZE) if (err != -EMSGSIZE)
return err; return err;
...@@ -1504,7 +1491,6 @@ static int devlink_nl_cmd_get_dumpit(struct sk_buff *msg, ...@@ -1504,7 +1491,6 @@ static int devlink_nl_cmd_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err; int err;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
if (idx < start) { if (idx < start) {
idx++; idx++;
...@@ -1521,8 +1507,6 @@ static int devlink_nl_cmd_get_dumpit(struct sk_buff *msg, ...@@ -1521,8 +1507,6 @@ static int devlink_nl_cmd_get_dumpit(struct sk_buff *msg,
idx++; idx++;
} }
out: out:
mutex_unlock(&devlink_mutex);
cb->args[0] = idx; cb->args[0] = idx;
return msg->len; return msg->len;
} }
...@@ -1559,7 +1543,6 @@ static int devlink_nl_cmd_port_get_dumpit(struct sk_buff *msg, ...@@ -1559,7 +1543,6 @@ static int devlink_nl_cmd_port_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err; int err;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
devl_lock(devlink); devl_lock(devlink);
list_for_each_entry(devlink_port, &devlink->port_list, list) { list_for_each_entry(devlink_port, &devlink->port_list, list) {
...@@ -1583,8 +1566,6 @@ static int devlink_nl_cmd_port_get_dumpit(struct sk_buff *msg, ...@@ -1583,8 +1566,6 @@ static int devlink_nl_cmd_port_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
cb->args[0] = idx; cb->args[0] = idx;
return msg->len; return msg->len;
} }
...@@ -2238,7 +2219,6 @@ static int devlink_nl_cmd_linecard_get_dumpit(struct sk_buff *msg, ...@@ -2238,7 +2219,6 @@ static int devlink_nl_cmd_linecard_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err; int err;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
mutex_lock(&devlink->linecards_lock); mutex_lock(&devlink->linecards_lock);
list_for_each_entry(linecard, &devlink->linecard_list, list) { list_for_each_entry(linecard, &devlink->linecard_list, list) {
...@@ -2265,8 +2245,6 @@ static int devlink_nl_cmd_linecard_get_dumpit(struct sk_buff *msg, ...@@ -2265,8 +2245,6 @@ static int devlink_nl_cmd_linecard_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
cb->args[0] = idx; cb->args[0] = idx;
return msg->len; return msg->len;
} }
...@@ -2503,7 +2481,6 @@ static int devlink_nl_cmd_sb_get_dumpit(struct sk_buff *msg, ...@@ -2503,7 +2481,6 @@ static int devlink_nl_cmd_sb_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err; int err;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
devl_lock(devlink); devl_lock(devlink);
list_for_each_entry(devlink_sb, &devlink->sb_list, list) { list_for_each_entry(devlink_sb, &devlink->sb_list, list) {
...@@ -2527,8 +2504,6 @@ static int devlink_nl_cmd_sb_get_dumpit(struct sk_buff *msg, ...@@ -2527,8 +2504,6 @@ static int devlink_nl_cmd_sb_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
cb->args[0] = idx; cb->args[0] = idx;
return msg->len; return msg->len;
} }
...@@ -2648,7 +2623,6 @@ static int devlink_nl_cmd_sb_pool_get_dumpit(struct sk_buff *msg, ...@@ -2648,7 +2623,6 @@ static int devlink_nl_cmd_sb_pool_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err = 0; int err = 0;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
if (!devlink->ops->sb_pool_get) if (!devlink->ops->sb_pool_get)
goto retry; goto retry;
...@@ -2672,8 +2646,6 @@ static int devlink_nl_cmd_sb_pool_get_dumpit(struct sk_buff *msg, ...@@ -2672,8 +2646,6 @@ static int devlink_nl_cmd_sb_pool_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
if (err != -EMSGSIZE) if (err != -EMSGSIZE)
return err; return err;
...@@ -2865,7 +2837,6 @@ static int devlink_nl_cmd_sb_port_pool_get_dumpit(struct sk_buff *msg, ...@@ -2865,7 +2837,6 @@ static int devlink_nl_cmd_sb_port_pool_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err = 0; int err = 0;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
if (!devlink->ops->sb_port_pool_get) if (!devlink->ops->sb_port_pool_get)
goto retry; goto retry;
...@@ -2889,8 +2860,6 @@ static int devlink_nl_cmd_sb_port_pool_get_dumpit(struct sk_buff *msg, ...@@ -2889,8 +2860,6 @@ static int devlink_nl_cmd_sb_port_pool_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
if (err != -EMSGSIZE) if (err != -EMSGSIZE)
return err; return err;
...@@ -3110,7 +3079,6 @@ devlink_nl_cmd_sb_tc_pool_bind_get_dumpit(struct sk_buff *msg, ...@@ -3110,7 +3079,6 @@ devlink_nl_cmd_sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err = 0; int err = 0;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
if (!devlink->ops->sb_tc_pool_bind_get) if (!devlink->ops->sb_tc_pool_bind_get)
goto retry; goto retry;
...@@ -3135,8 +3103,6 @@ devlink_nl_cmd_sb_tc_pool_bind_get_dumpit(struct sk_buff *msg, ...@@ -3135,8 +3103,6 @@ devlink_nl_cmd_sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
if (err != -EMSGSIZE) if (err != -EMSGSIZE)
return err; return err;
...@@ -4908,7 +4874,6 @@ static int devlink_nl_cmd_selftests_get_dumpit(struct sk_buff *msg, ...@@ -4908,7 +4874,6 @@ static int devlink_nl_cmd_selftests_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err = 0; int err = 0;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
if (idx < start || !devlink->ops->selftest_check) if (idx < start || !devlink->ops->selftest_check)
goto inc; goto inc;
...@@ -4927,7 +4892,6 @@ static int devlink_nl_cmd_selftests_get_dumpit(struct sk_buff *msg, ...@@ -4927,7 +4892,6 @@ static int devlink_nl_cmd_selftests_get_dumpit(struct sk_buff *msg,
idx++; idx++;
devlink_put(devlink); devlink_put(devlink);
} }
mutex_unlock(&devlink_mutex);
if (err != -EMSGSIZE) if (err != -EMSGSIZE)
return err; return err;
...@@ -5393,7 +5357,6 @@ static int devlink_nl_cmd_param_get_dumpit(struct sk_buff *msg, ...@@ -5393,7 +5357,6 @@ static int devlink_nl_cmd_param_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err = 0; int err = 0;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
devl_lock(devlink); devl_lock(devlink);
list_for_each_entry(param_item, &devlink->param_list, list) { list_for_each_entry(param_item, &devlink->param_list, list) {
...@@ -5419,8 +5382,6 @@ static int devlink_nl_cmd_param_get_dumpit(struct sk_buff *msg, ...@@ -5419,8 +5382,6 @@ static int devlink_nl_cmd_param_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
if (err != -EMSGSIZE) if (err != -EMSGSIZE)
return err; return err;
...@@ -5621,7 +5582,6 @@ static int devlink_nl_cmd_port_param_get_dumpit(struct sk_buff *msg, ...@@ -5621,7 +5582,6 @@ static int devlink_nl_cmd_port_param_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err = 0; int err = 0;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
devl_lock(devlink); devl_lock(devlink);
list_for_each_entry(devlink_port, &devlink->port_list, list) { list_for_each_entry(devlink_port, &devlink->port_list, list) {
...@@ -5652,8 +5612,6 @@ static int devlink_nl_cmd_port_param_get_dumpit(struct sk_buff *msg, ...@@ -5652,8 +5612,6 @@ static int devlink_nl_cmd_port_param_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
if (err != -EMSGSIZE) if (err != -EMSGSIZE)
return err; return err;
...@@ -6208,7 +6166,6 @@ static int devlink_nl_cmd_region_get_dumpit(struct sk_buff *msg, ...@@ -6208,7 +6166,6 @@ static int devlink_nl_cmd_region_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err = 0; int err = 0;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
err = devlink_nl_cmd_region_get_devlink_dumpit(msg, cb, devlink, err = devlink_nl_cmd_region_get_devlink_dumpit(msg, cb, devlink,
&idx, start); &idx, start);
...@@ -6217,7 +6174,6 @@ static int devlink_nl_cmd_region_get_dumpit(struct sk_buff *msg, ...@@ -6217,7 +6174,6 @@ static int devlink_nl_cmd_region_get_dumpit(struct sk_buff *msg,
goto out; goto out;
} }
out: out:
mutex_unlock(&devlink_mutex);
cb->args[0] = idx; cb->args[0] = idx;
return msg->len; return msg->len;
} }
...@@ -6483,12 +6439,9 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb, ...@@ -6483,12 +6439,9 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
start_offset = *((u64 *)&cb->args[0]); start_offset = *((u64 *)&cb->args[0]);
mutex_lock(&devlink_mutex);
devlink = devlink_get_from_attrs(sock_net(cb->skb->sk), attrs); devlink = devlink_get_from_attrs(sock_net(cb->skb->sk), attrs);
if (IS_ERR(devlink)) { if (IS_ERR(devlink))
err = PTR_ERR(devlink); return PTR_ERR(devlink);
goto out_dev;
}
devl_lock(devlink); devl_lock(devlink);
...@@ -6588,8 +6541,6 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb, ...@@ -6588,8 +6541,6 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
genlmsg_end(skb, hdr); genlmsg_end(skb, hdr);
devl_unlock(devlink); devl_unlock(devlink);
devlink_put(devlink); devlink_put(devlink);
mutex_unlock(&devlink_mutex);
return skb->len; return skb->len;
nla_put_failure: nla_put_failure:
...@@ -6597,8 +6548,6 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb, ...@@ -6597,8 +6548,6 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
out_unlock: out_unlock:
devl_unlock(devlink); devl_unlock(devlink);
devlink_put(devlink); devlink_put(devlink);
out_dev:
mutex_unlock(&devlink_mutex);
return err; return err;
} }
...@@ -6747,7 +6696,6 @@ static int devlink_nl_cmd_info_get_dumpit(struct sk_buff *msg, ...@@ -6747,7 +6696,6 @@ static int devlink_nl_cmd_info_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err = 0; int err = 0;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
if (idx < start || !devlink->ops->info_get) if (idx < start || !devlink->ops->info_get)
goto inc; goto inc;
...@@ -6768,7 +6716,6 @@ static int devlink_nl_cmd_info_get_dumpit(struct sk_buff *msg, ...@@ -6768,7 +6716,6 @@ static int devlink_nl_cmd_info_get_dumpit(struct sk_buff *msg,
idx++; idx++;
devlink_put(devlink); devlink_put(devlink);
} }
mutex_unlock(&devlink_mutex);
if (err != -EMSGSIZE) if (err != -EMSGSIZE)
return err; return err;
...@@ -7847,18 +7794,13 @@ devlink_health_reporter_get_from_cb(struct netlink_callback *cb) ...@@ -7847,18 +7794,13 @@ devlink_health_reporter_get_from_cb(struct netlink_callback *cb)
struct nlattr **attrs = info->attrs; struct nlattr **attrs = info->attrs;
struct devlink *devlink; struct devlink *devlink;
mutex_lock(&devlink_mutex);
devlink = devlink_get_from_attrs(sock_net(cb->skb->sk), attrs); devlink = devlink_get_from_attrs(sock_net(cb->skb->sk), attrs);
if (IS_ERR(devlink)) if (IS_ERR(devlink))
goto unlock; return NULL;
reporter = devlink_health_reporter_get_from_attrs(devlink, attrs); reporter = devlink_health_reporter_get_from_attrs(devlink, attrs);
devlink_put(devlink); devlink_put(devlink);
mutex_unlock(&devlink_mutex);
return reporter; return reporter;
unlock:
mutex_unlock(&devlink_mutex);
return NULL;
} }
void void
...@@ -7924,7 +7866,6 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg, ...@@ -7924,7 +7866,6 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err; int err;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
mutex_lock(&devlink->reporters_lock); mutex_lock(&devlink->reporters_lock);
list_for_each_entry(reporter, &devlink->reporter_list, list_for_each_entry(reporter, &devlink->reporter_list,
...@@ -7976,8 +7917,6 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg, ...@@ -7976,8 +7917,6 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
cb->args[0] = idx; cb->args[0] = idx;
return msg->len; return msg->len;
} }
...@@ -8510,7 +8449,6 @@ static int devlink_nl_cmd_trap_get_dumpit(struct sk_buff *msg, ...@@ -8510,7 +8449,6 @@ static int devlink_nl_cmd_trap_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err; int err;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
devl_lock(devlink); devl_lock(devlink);
list_for_each_entry(trap_item, &devlink->trap_list, list) { list_for_each_entry(trap_item, &devlink->trap_list, list) {
...@@ -8534,8 +8472,6 @@ static int devlink_nl_cmd_trap_get_dumpit(struct sk_buff *msg, ...@@ -8534,8 +8472,6 @@ static int devlink_nl_cmd_trap_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
cb->args[0] = idx; cb->args[0] = idx;
return msg->len; return msg->len;
} }
...@@ -8730,7 +8666,6 @@ static int devlink_nl_cmd_trap_group_get_dumpit(struct sk_buff *msg, ...@@ -8730,7 +8666,6 @@ static int devlink_nl_cmd_trap_group_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err; int err;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
devl_lock(devlink); devl_lock(devlink);
list_for_each_entry(group_item, &devlink->trap_group_list, list_for_each_entry(group_item, &devlink->trap_group_list,
...@@ -8755,8 +8690,6 @@ static int devlink_nl_cmd_trap_group_get_dumpit(struct sk_buff *msg, ...@@ -8755,8 +8690,6 @@ static int devlink_nl_cmd_trap_group_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
cb->args[0] = idx; cb->args[0] = idx;
return msg->len; return msg->len;
} }
...@@ -9037,7 +8970,6 @@ static int devlink_nl_cmd_trap_policer_get_dumpit(struct sk_buff *msg, ...@@ -9037,7 +8970,6 @@ static int devlink_nl_cmd_trap_policer_get_dumpit(struct sk_buff *msg,
int idx = 0; int idx = 0;
int err; int err;
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) { devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
devl_lock(devlink); devl_lock(devlink);
list_for_each_entry(policer_item, &devlink->trap_policer_list, list_for_each_entry(policer_item, &devlink->trap_policer_list,
...@@ -9062,8 +8994,6 @@ static int devlink_nl_cmd_trap_policer_get_dumpit(struct sk_buff *msg, ...@@ -9062,8 +8994,6 @@ static int devlink_nl_cmd_trap_policer_get_dumpit(struct sk_buff *msg,
devlink_put(devlink); devlink_put(devlink);
} }
out: out:
mutex_unlock(&devlink_mutex);
cb->args[0] = idx; cb->args[0] = idx;
return msg->len; return msg->len;
} }
...@@ -12494,7 +12424,6 @@ static void __net_exit devlink_pernet_pre_exit(struct net *net) ...@@ -12494,7 +12424,6 @@ static void __net_exit devlink_pernet_pre_exit(struct net *net)
/* In case network namespace is getting destroyed, reload /* In case network namespace is getting destroyed, reload
* all devlink instances from this namespace into init_net. * all devlink instances from this namespace into init_net.
*/ */
mutex_lock(&devlink_mutex);
devlinks_xa_for_each_registered_get(net, index, devlink) { devlinks_xa_for_each_registered_get(net, index, devlink) {
WARN_ON(!(devlink->features & DEVLINK_F_RELOAD)); WARN_ON(!(devlink->features & DEVLINK_F_RELOAD));
mutex_lock(&devlink->lock); mutex_lock(&devlink->lock);
...@@ -12507,7 +12436,6 @@ static void __net_exit devlink_pernet_pre_exit(struct net *net) ...@@ -12507,7 +12436,6 @@ static void __net_exit devlink_pernet_pre_exit(struct net *net)
pr_warn("Failed to reload devlink instance into init_net\n"); pr_warn("Failed to reload devlink instance into init_net\n");
devlink_put(devlink); devlink_put(devlink);
} }
mutex_unlock(&devlink_mutex);
} }
static struct pernet_operations devlink_pernet_ops __net_initdata = { static struct pernet_operations devlink_pernet_ops __net_initdata = {
......
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