aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArkadi Sharshevsky <arkadis@mellanox.com>2018-01-15 02:59:02 -0500
committerDavid S. Miller <davem@davemloft.net>2018-01-16 14:15:34 -0500
commit2406e7e546b223e8cf42c44ac7352d4d1fd1dbcd (patch)
treef52c791e9abfca5b0f239ba315d1381af950545f
parentd98c8ccdebda9de011d3ea29ffb5aac57cd2b69a (diff)
devlink: Add per devlink instance lock
This is a preparation before introducing resources and hot reload support. Currently there are two global lock where one protects all devlink access, and the second one protects devlink port access. This patch adds per devlink instance lock which protects the internal members which are the sb/dpipe/ resource/ports. By introducing this lock the global devlink port lock can be discarded. Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/devlink.h1
-rw-r--r--net/core/devlink.c136
2 files changed, 78 insertions, 59 deletions
diff --git a/include/net/devlink.h b/include/net/devlink.h
index b9654e133599..4d2c6fc94837 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -30,6 +30,7 @@ struct devlink {
30 const struct devlink_ops *ops; 30 const struct devlink_ops *ops;
31 struct device *dev; 31 struct device *dev;
32 possible_net_t _net; 32 possible_net_t _net;
33 struct mutex lock;
33 char priv[0] __aligned(NETDEV_ALIGN); 34 char priv[0] __aligned(NETDEV_ALIGN);
34}; 35};
35 36
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 7d430c1d9c3e..2f71734c4ff6 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -92,12 +92,6 @@ static LIST_HEAD(devlink_list);
92 */ 92 */
93static DEFINE_MUTEX(devlink_mutex); 93static DEFINE_MUTEX(devlink_mutex);
94 94
95/* devlink_port_mutex
96 *
97 * Shared lock to guard lists of ports in all devlink devices.
98 */
99static DEFINE_MUTEX(devlink_port_mutex);
100
101static struct net *devlink_net(const struct devlink *devlink) 95static struct net *devlink_net(const struct devlink *devlink)
102{ 96{
103 return read_pnet(&devlink->_net); 97 return read_pnet(&devlink->_net);
@@ -335,15 +329,18 @@ devlink_sb_tc_index_get_from_info(struct devlink_sb *devlink_sb,
335#define DEVLINK_NL_FLAG_NEED_DEVLINK BIT(0) 329#define DEVLINK_NL_FLAG_NEED_DEVLINK BIT(0)
336#define DEVLINK_NL_FLAG_NEED_PORT BIT(1) 330#define DEVLINK_NL_FLAG_NEED_PORT BIT(1)
337#define DEVLINK_NL_FLAG_NEED_SB BIT(2) 331#define DEVLINK_NL_FLAG_NEED_SB BIT(2)
338#define DEVLINK_NL_FLAG_LOCK_PORTS BIT(3) 332
339 /* port is not needed but we need to ensure they don't 333/* The per devlink instance lock is taken by default in the pre-doit
340 * change in the middle of command 334 * operation, yet several commands do not require this. The global
341 */ 335 * devlink lock is taken and protects from disruption by user-calls.
336 */
337#define DEVLINK_NL_FLAG_NO_LOCK BIT(3)
342 338
343static int devlink_nl_pre_doit(const struct genl_ops *ops, 339static int devlink_nl_pre_doit(const struct genl_ops *ops,
344 struct sk_buff *skb, struct genl_info *info) 340 struct sk_buff *skb, struct genl_info *info)
345{ 341{
346 struct devlink *devlink; 342 struct devlink *devlink;
343 int err;
347 344
348 mutex_lock(&devlink_mutex); 345 mutex_lock(&devlink_mutex);
349 devlink = devlink_get_from_info(info); 346 devlink = devlink_get_from_info(info);
@@ -351,44 +348,47 @@ static int devlink_nl_pre_doit(const struct genl_ops *ops,
351 mutex_unlock(&devlink_mutex); 348 mutex_unlock(&devlink_mutex);
352 return PTR_ERR(devlink); 349 return PTR_ERR(devlink);
353 } 350 }
351 if (~ops->internal_flags & DEVLINK_NL_FLAG_NO_LOCK)
352 mutex_lock(&devlink->lock);
354 if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_DEVLINK) { 353 if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_DEVLINK) {
355 info->user_ptr[0] = devlink; 354 info->user_ptr[0] = devlink;
356 } else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_PORT) { 355 } else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_PORT) {
357 struct devlink_port *devlink_port; 356 struct devlink_port *devlink_port;
358 357
359 mutex_lock(&devlink_port_mutex);
360 devlink_port = devlink_port_get_from_info(devlink, info); 358 devlink_port = devlink_port_get_from_info(devlink, info);
361 if (IS_ERR(devlink_port)) { 359 if (IS_ERR(devlink_port)) {
362 mutex_unlock(&devlink_port_mutex); 360 err = PTR_ERR(devlink_port);
363 mutex_unlock(&devlink_mutex); 361 goto unlock;
364 return PTR_ERR(devlink_port);
365 } 362 }
366 info->user_ptr[0] = devlink_port; 363 info->user_ptr[0] = devlink_port;
367 } 364 }
368 if (ops->internal_flags & DEVLINK_NL_FLAG_LOCK_PORTS) {
369 mutex_lock(&devlink_port_mutex);
370 }
371 if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_SB) { 365 if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_SB) {
372 struct devlink_sb *devlink_sb; 366 struct devlink_sb *devlink_sb;
373 367
374 devlink_sb = devlink_sb_get_from_info(devlink, info); 368 devlink_sb = devlink_sb_get_from_info(devlink, info);
375 if (IS_ERR(devlink_sb)) { 369 if (IS_ERR(devlink_sb)) {
376 if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_PORT) 370 err = PTR_ERR(devlink_sb);
377 mutex_unlock(&devlink_port_mutex); 371 goto unlock;
378 mutex_unlock(&devlink_mutex);
379 return PTR_ERR(devlink_sb);
380 } 372 }
381 info->user_ptr[1] = devlink_sb; 373 info->user_ptr[1] = devlink_sb;
382 } 374 }
383 return 0; 375 return 0;
376
377unlock:
378 if (~ops->internal_flags & DEVLINK_NL_FLAG_NO_LOCK)
379 mutex_unlock(&devlink->lock);
380 mutex_unlock(&devlink_mutex);
381 return err;
384} 382}
385 383
386static void devlink_nl_post_doit(const struct genl_ops *ops, 384static void devlink_nl_post_doit(const struct genl_ops *ops,
387 struct sk_buff *skb, struct genl_info *info) 385 struct sk_buff *skb, struct genl_info *info)
388{ 386{
389 if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_PORT || 387 struct devlink *devlink;
390 ops->internal_flags & DEVLINK_NL_FLAG_LOCK_PORTS) 388
391 mutex_unlock(&devlink_port_mutex); 389 devlink = devlink_get_from_info(info);
390 if (~ops->internal_flags & DEVLINK_NL_FLAG_NO_LOCK)
391 mutex_unlock(&devlink->lock);
392 mutex_unlock(&devlink_mutex); 392 mutex_unlock(&devlink_mutex);
393} 393}
394 394
@@ -614,10 +614,10 @@ static int devlink_nl_cmd_port_get_dumpit(struct sk_buff *msg,
614 int err; 614 int err;
615 615
616 mutex_lock(&devlink_mutex); 616 mutex_lock(&devlink_mutex);
617 mutex_lock(&devlink_port_mutex);
618 list_for_each_entry(devlink, &devlink_list, list) { 617 list_for_each_entry(devlink, &devlink_list, list) {
619 if (!net_eq(devlink_net(devlink), sock_net(msg->sk))) 618 if (!net_eq(devlink_net(devlink), sock_net(msg->sk)))
620 continue; 619 continue;
620 mutex_lock(&devlink->lock);
621 list_for_each_entry(devlink_port, &devlink->port_list, list) { 621 list_for_each_entry(devlink_port, &devlink->port_list, list) {
622 if (idx < start) { 622 if (idx < start) {
623 idx++; 623 idx++;
@@ -628,13 +628,15 @@ static int devlink_nl_cmd_port_get_dumpit(struct sk_buff *msg,
628 NETLINK_CB(cb->skb).portid, 628 NETLINK_CB(cb->skb).portid,
629 cb->nlh->nlmsg_seq, 629 cb->nlh->nlmsg_seq,
630 NLM_F_MULTI); 630 NLM_F_MULTI);
631 if (err) 631 if (err) {
632 mutex_unlock(&devlink->lock);
632 goto out; 633 goto out;
634 }
633 idx++; 635 idx++;
634 } 636 }
637 mutex_unlock(&devlink->lock);
635 } 638 }
636out: 639out:
637 mutex_unlock(&devlink_port_mutex);
638 mutex_unlock(&devlink_mutex); 640 mutex_unlock(&devlink_mutex);
639 641
640 cb->args[0] = idx; 642 cb->args[0] = idx;
@@ -801,6 +803,7 @@ static int devlink_nl_cmd_sb_get_dumpit(struct sk_buff *msg,
801 list_for_each_entry(devlink, &devlink_list, list) { 803 list_for_each_entry(devlink, &devlink_list, list) {
802 if (!net_eq(devlink_net(devlink), sock_net(msg->sk))) 804 if (!net_eq(devlink_net(devlink), sock_net(msg->sk)))
803 continue; 805 continue;
806 mutex_lock(&devlink->lock);
804 list_for_each_entry(devlink_sb, &devlink->sb_list, list) { 807 list_for_each_entry(devlink_sb, &devlink->sb_list, list) {
805 if (idx < start) { 808 if (idx < start) {
806 idx++; 809 idx++;
@@ -811,10 +814,13 @@ static int devlink_nl_cmd_sb_get_dumpit(struct sk_buff *msg,
811 NETLINK_CB(cb->skb).portid, 814 NETLINK_CB(cb->skb).portid,
812 cb->nlh->nlmsg_seq, 815 cb->nlh->nlmsg_seq,
813 NLM_F_MULTI); 816 NLM_F_MULTI);
814 if (err) 817 if (err) {
818 mutex_unlock(&devlink->lock);
815 goto out; 819 goto out;
820 }
816 idx++; 821 idx++;
817 } 822 }
823 mutex_unlock(&devlink->lock);
818 } 824 }
819out: 825out:
820 mutex_unlock(&devlink_mutex); 826 mutex_unlock(&devlink_mutex);
@@ -935,14 +941,18 @@ static int devlink_nl_cmd_sb_pool_get_dumpit(struct sk_buff *msg,
935 if (!net_eq(devlink_net(devlink), sock_net(msg->sk)) || 941 if (!net_eq(devlink_net(devlink), sock_net(msg->sk)) ||
936 !devlink->ops || !devlink->ops->sb_pool_get) 942 !devlink->ops || !devlink->ops->sb_pool_get)
937 continue; 943 continue;
944 mutex_lock(&devlink->lock);
938 list_for_each_entry(devlink_sb, &devlink->sb_list, list) { 945 list_for_each_entry(devlink_sb, &devlink->sb_list, list) {
939 err = __sb_pool_get_dumpit(msg, start, &idx, devlink, 946 err = __sb_pool_get_dumpit(msg, start, &idx, devlink,
940 devlink_sb, 947 devlink_sb,
941 NETLINK_CB(cb->skb).portid, 948 NETLINK_CB(cb->skb).portid,
942 cb->nlh->nlmsg_seq); 949 cb->nlh->nlmsg_seq);
943 if (err && err != -EOPNOTSUPP) 950 if (err && err != -EOPNOTSUPP) {
951 mutex_unlock(&devlink->lock);
944 goto out; 952 goto out;
953 }
945 } 954 }
955 mutex_unlock(&devlink->lock);
946 } 956 }
947out: 957out:
948 mutex_unlock(&devlink_mutex); 958 mutex_unlock(&devlink_mutex);
@@ -1123,22 +1133,24 @@ static int devlink_nl_cmd_sb_port_pool_get_dumpit(struct sk_buff *msg,
1123 int err; 1133 int err;
1124 1134
1125 mutex_lock(&devlink_mutex); 1135 mutex_lock(&devlink_mutex);
1126 mutex_lock(&devlink_port_mutex);
1127 list_for_each_entry(devlink, &devlink_list, list) { 1136 list_for_each_entry(devlink, &devlink_list, list) {
1128 if (!net_eq(devlink_net(devlink), sock_net(msg->sk)) || 1137 if (!net_eq(devlink_net(devlink), sock_net(msg->sk)) ||
1129 !devlink->ops || !devlink->ops->sb_port_pool_get) 1138 !devlink->ops || !devlink->ops->sb_port_pool_get)
1130 continue; 1139 continue;
1140 mutex_lock(&devlink->lock);
1131 list_for_each_entry(devlink_sb, &devlink->sb_list, list) { 1141 list_for_each_entry(devlink_sb, &devlink->sb_list, list) {
1132 err = __sb_port_pool_get_dumpit(msg, start, &idx, 1142 err = __sb_port_pool_get_dumpit(msg, start, &idx,
1133 devlink, devlink_sb, 1143 devlink, devlink_sb,
1134 NETLINK_CB(cb->skb).portid, 1144 NETLINK_CB(cb->skb).portid,
1135 cb->nlh->nlmsg_seq); 1145 cb->nlh->nlmsg_seq);
1136 if (err && err != -EOPNOTSUPP) 1146 if (err && err != -EOPNOTSUPP) {
1147 mutex_unlock(&devlink->lock);
1137 goto out; 1148 goto out;
1149 }
1138 } 1150 }
1151 mutex_unlock(&devlink->lock);
1139 } 1152 }
1140out: 1153out:
1141 mutex_unlock(&devlink_port_mutex);
1142 mutex_unlock(&devlink_mutex); 1154 mutex_unlock(&devlink_mutex);
1143 1155
1144 cb->args[0] = idx; 1156 cb->args[0] = idx;
@@ -1347,23 +1359,26 @@ devlink_nl_cmd_sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
1347 int err; 1359 int err;
1348 1360
1349 mutex_lock(&devlink_mutex); 1361 mutex_lock(&devlink_mutex);
1350 mutex_lock(&devlink_port_mutex);
1351 list_for_each_entry(devlink, &devlink_list, list) { 1362 list_for_each_entry(devlink, &devlink_list, list) {
1352 if (!net_eq(devlink_net(devlink), sock_net(msg->sk)) || 1363 if (!net_eq(devlink_net(devlink), sock_net(msg->sk)) ||
1353 !devlink->ops || !devlink->ops->sb_tc_pool_bind_get) 1364 !devlink->ops || !devlink->ops->sb_tc_pool_bind_get)
1354 continue; 1365 continue;
1366
1367 mutex_lock(&devlink->lock);
1355 list_for_each_entry(devlink_sb, &devlink->sb_list, list) { 1368 list_for_each_entry(devlink_sb, &devlink->sb_list, list) {
1356 err = __sb_tc_pool_bind_get_dumpit(msg, start, &idx, 1369 err = __sb_tc_pool_bind_get_dumpit(msg, start, &idx,
1357 devlink, 1370 devlink,
1358 devlink_sb, 1371 devlink_sb,
1359 NETLINK_CB(cb->skb).portid, 1372 NETLINK_CB(cb->skb).portid,
1360 cb->nlh->nlmsg_seq); 1373 cb->nlh->nlmsg_seq);
1361 if (err && err != -EOPNOTSUPP) 1374 if (err && err != -EOPNOTSUPP) {
1375 mutex_unlock(&devlink->lock);
1362 goto out; 1376 goto out;
1377 }
1363 } 1378 }
1379 mutex_unlock(&devlink->lock);
1364 } 1380 }
1365out: 1381out:
1366 mutex_unlock(&devlink_port_mutex);
1367 mutex_unlock(&devlink_mutex); 1382 mutex_unlock(&devlink_mutex);
1368 1383
1369 cb->args[0] = idx; 1384 cb->args[0] = idx;
@@ -2322,14 +2337,16 @@ static const struct genl_ops devlink_nl_ops[] = {
2322 .doit = devlink_nl_cmd_port_split_doit, 2337 .doit = devlink_nl_cmd_port_split_doit,
2323 .policy = devlink_nl_policy, 2338 .policy = devlink_nl_policy,
2324 .flags = GENL_ADMIN_PERM, 2339 .flags = GENL_ADMIN_PERM,
2325 .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, 2340 .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK |
2341 DEVLINK_NL_FLAG_NO_LOCK,
2326 }, 2342 },
2327 { 2343 {
2328 .cmd = DEVLINK_CMD_PORT_UNSPLIT, 2344 .cmd = DEVLINK_CMD_PORT_UNSPLIT,
2329 .doit = devlink_nl_cmd_port_unsplit_doit, 2345 .doit = devlink_nl_cmd_port_unsplit_doit,
2330 .policy = devlink_nl_policy, 2346 .policy = devlink_nl_policy,
2331 .flags = GENL_ADMIN_PERM, 2347 .flags = GENL_ADMIN_PERM,
2332 .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, 2348 .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK |
2349 DEVLINK_NL_FLAG_NO_LOCK,
2333 }, 2350 },
2334 { 2351 {
2335 .cmd = DEVLINK_CMD_SB_GET, 2352 .cmd = DEVLINK_CMD_SB_GET,
@@ -2397,8 +2414,7 @@ static const struct genl_ops devlink_nl_ops[] = {
2397 .policy = devlink_nl_policy, 2414 .policy = devlink_nl_policy,
2398 .flags = GENL_ADMIN_PERM, 2415 .flags = GENL_ADMIN_PERM,
2399 .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK | 2416 .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK |
2400 DEVLINK_NL_FLAG_NEED_SB | 2417 DEVLINK_NL_FLAG_NEED_SB,
2401 DEVLINK_NL_FLAG_LOCK_PORTS,
2402 }, 2418 },
2403 { 2419 {
2404 .cmd = DEVLINK_CMD_SB_OCC_MAX_CLEAR, 2420 .cmd = DEVLINK_CMD_SB_OCC_MAX_CLEAR,
@@ -2406,8 +2422,7 @@ static const struct genl_ops devlink_nl_ops[] = {
2406 .policy = devlink_nl_policy, 2422 .policy = devlink_nl_policy,
2407 .flags = GENL_ADMIN_PERM, 2423 .flags = GENL_ADMIN_PERM,
2408 .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK | 2424 .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK |
2409 DEVLINK_NL_FLAG_NEED_SB | 2425 DEVLINK_NL_FLAG_NEED_SB,
2410 DEVLINK_NL_FLAG_LOCK_PORTS,
2411 }, 2426 },
2412 { 2427 {
2413 .cmd = DEVLINK_CMD_ESWITCH_GET, 2428 .cmd = DEVLINK_CMD_ESWITCH_GET,
@@ -2488,6 +2503,7 @@ struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size)
2488 INIT_LIST_HEAD(&devlink->port_list); 2503 INIT_LIST_HEAD(&devlink->port_list);
2489 INIT_LIST_HEAD(&devlink->sb_list); 2504 INIT_LIST_HEAD(&devlink->sb_list);
2490 INIT_LIST_HEAD_RCU(&devlink->dpipe_table_list); 2505 INIT_LIST_HEAD_RCU(&devlink->dpipe_table_list);
2506 mutex_init(&devlink->lock);
2491 return devlink; 2507 return devlink;
2492} 2508}
2493EXPORT_SYMBOL_GPL(devlink_alloc); 2509EXPORT_SYMBOL_GPL(devlink_alloc);
@@ -2550,16 +2566,16 @@ int devlink_port_register(struct devlink *devlink,
2550 struct devlink_port *devlink_port, 2566 struct devlink_port *devlink_port,
2551 unsigned int port_index) 2567 unsigned int port_index)
2552{ 2568{
2553 mutex_lock(&devlink_port_mutex); 2569 mutex_lock(&devlink->lock);
2554 if (devlink_port_index_exists(devlink, port_index)) { 2570 if (devlink_port_index_exists(devlink, port_index)) {
2555 mutex_unlock(&devlink_port_mutex); 2571 mutex_unlock(&devlink->lock);
2556 return -EEXIST; 2572 return -EEXIST;
2557 } 2573 }
2558 devlink_port->devlink = devlink; 2574 devlink_port->devlink = devlink;
2559 devlink_port->index = port_index; 2575 devlink_port->index = port_index;
2560 devlink_port->registered = true; 2576 devlink_port->registered = true;
2561 list_add_tail(&devlink_port->list, &devlink->port_list); 2577 list_add_tail(&devlink_port->list, &devlink->port_list);
2562 mutex_unlock(&devlink_port_mutex); 2578 mutex_unlock(&devlink->lock);
2563 devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW); 2579 devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW);
2564 return 0; 2580 return 0;
2565} 2581}
@@ -2572,10 +2588,12 @@ EXPORT_SYMBOL_GPL(devlink_port_register);
2572 */ 2588 */
2573void devlink_port_unregister(struct devlink_port *devlink_port) 2589void devlink_port_unregister(struct devlink_port *devlink_port)
2574{ 2590{
2591 struct devlink *devlink = devlink_port->devlink;
2592
2575 devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_DEL); 2593 devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_DEL);
2576 mutex_lock(&devlink_port_mutex); 2594 mutex_lock(&devlink->lock);
2577 list_del(&devlink_port->list); 2595 list_del(&devlink_port->list);
2578 mutex_unlock(&devlink_port_mutex); 2596 mutex_unlock(&devlink->lock);
2579} 2597}
2580EXPORT_SYMBOL_GPL(devlink_port_unregister); 2598EXPORT_SYMBOL_GPL(devlink_port_unregister);
2581 2599
@@ -2651,7 +2669,7 @@ int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
2651 struct devlink_sb *devlink_sb; 2669 struct devlink_sb *devlink_sb;
2652 int err = 0; 2670 int err = 0;
2653 2671
2654 mutex_lock(&devlink_mutex); 2672 mutex_lock(&devlink->lock);
2655 if (devlink_sb_index_exists(devlink, sb_index)) { 2673 if (devlink_sb_index_exists(devlink, sb_index)) {
2656 err = -EEXIST; 2674 err = -EEXIST;
2657 goto unlock; 2675 goto unlock;
@@ -2670,7 +2688,7 @@ int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
2670 devlink_sb->egress_tc_count = egress_tc_count; 2688 devlink_sb->egress_tc_count = egress_tc_count;
2671 list_add_tail(&devlink_sb->list, &devlink->sb_list); 2689 list_add_tail(&devlink_sb->list, &devlink->sb_list);
2672unlock: 2690unlock:
2673 mutex_unlock(&devlink_mutex); 2691 mutex_unlock(&devlink->lock);
2674 return err; 2692 return err;
2675} 2693}
2676EXPORT_SYMBOL_GPL(devlink_sb_register); 2694EXPORT_SYMBOL_GPL(devlink_sb_register);
@@ -2679,11 +2697,11 @@ void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index)
2679{ 2697{
2680 struct devlink_sb *devlink_sb; 2698 struct devlink_sb *devlink_sb;
2681 2699
2682 mutex_lock(&devlink_mutex); 2700 mutex_lock(&devlink->lock);
2683 devlink_sb = devlink_sb_get_by_index(devlink, sb_index); 2701 devlink_sb = devlink_sb_get_by_index(devlink, sb_index);
2684 WARN_ON(!devlink_sb); 2702 WARN_ON(!devlink_sb);
2685 list_del(&devlink_sb->list); 2703 list_del(&devlink_sb->list);
2686 mutex_unlock(&devlink_mutex); 2704 mutex_unlock(&devlink->lock);
2687 kfree(devlink_sb); 2705 kfree(devlink_sb);
2688} 2706}
2689EXPORT_SYMBOL_GPL(devlink_sb_unregister); 2707EXPORT_SYMBOL_GPL(devlink_sb_unregister);
@@ -2699,9 +2717,9 @@ EXPORT_SYMBOL_GPL(devlink_sb_unregister);
2699int devlink_dpipe_headers_register(struct devlink *devlink, 2717int devlink_dpipe_headers_register(struct devlink *devlink,
2700 struct devlink_dpipe_headers *dpipe_headers) 2718 struct devlink_dpipe_headers *dpipe_headers)
2701{ 2719{
2702 mutex_lock(&devlink_mutex); 2720 mutex_lock(&devlink->lock);
2703 devlink->dpipe_headers = dpipe_headers; 2721 devlink->dpipe_headers = dpipe_headers;
2704 mutex_unlock(&devlink_mutex); 2722 mutex_unlock(&devlink->lock);
2705 return 0; 2723 return 0;
2706} 2724}
2707EXPORT_SYMBOL_GPL(devlink_dpipe_headers_register); 2725EXPORT_SYMBOL_GPL(devlink_dpipe_headers_register);
@@ -2715,9 +2733,9 @@ EXPORT_SYMBOL_GPL(devlink_dpipe_headers_register);
2715 */ 2733 */
2716void devlink_dpipe_headers_unregister(struct devlink *devlink) 2734void devlink_dpipe_headers_unregister(struct devlink *devlink)
2717{ 2735{
2718 mutex_lock(&devlink_mutex); 2736 mutex_lock(&devlink->lock);
2719 devlink->dpipe_headers = NULL; 2737 devlink->dpipe_headers = NULL;
2720 mutex_unlock(&devlink_mutex); 2738 mutex_unlock(&devlink->lock);
2721} 2739}
2722EXPORT_SYMBOL_GPL(devlink_dpipe_headers_unregister); 2740EXPORT_SYMBOL_GPL(devlink_dpipe_headers_unregister);
2723 2741
@@ -2783,9 +2801,9 @@ int devlink_dpipe_table_register(struct devlink *devlink,
2783 table->priv = priv; 2801 table->priv = priv;
2784 table->counter_control_extern = counter_control_extern; 2802 table->counter_control_extern = counter_control_extern;
2785 2803
2786 mutex_lock(&devlink_mutex); 2804 mutex_lock(&devlink->lock);
2787 list_add_tail_rcu(&table->list, &devlink->dpipe_table_list); 2805 list_add_tail_rcu(&table->list, &devlink->dpipe_table_list);
2788 mutex_unlock(&devlink_mutex); 2806 mutex_unlock(&devlink->lock);
2789 return 0; 2807 return 0;
2790} 2808}
2791EXPORT_SYMBOL_GPL(devlink_dpipe_table_register); 2809EXPORT_SYMBOL_GPL(devlink_dpipe_table_register);
@@ -2801,17 +2819,17 @@ void devlink_dpipe_table_unregister(struct devlink *devlink,
2801{ 2819{
2802 struct devlink_dpipe_table *table; 2820 struct devlink_dpipe_table *table;
2803 2821
2804 mutex_lock(&devlink_mutex); 2822 mutex_lock(&devlink->lock);
2805 table = devlink_dpipe_table_find(&devlink->dpipe_table_list, 2823 table = devlink_dpipe_table_find(&devlink->dpipe_table_list,
2806 table_name); 2824 table_name);
2807 if (!table) 2825 if (!table)
2808 goto unlock; 2826 goto unlock;
2809 list_del_rcu(&table->list); 2827 list_del_rcu(&table->list);
2810 mutex_unlock(&devlink_mutex); 2828 mutex_unlock(&devlink->lock);
2811 kfree_rcu(table, rcu); 2829 kfree_rcu(table, rcu);
2812 return; 2830 return;
2813unlock: 2831unlock:
2814 mutex_unlock(&devlink_mutex); 2832 mutex_unlock(&devlink->lock);
2815} 2833}
2816EXPORT_SYMBOL_GPL(devlink_dpipe_table_unregister); 2834EXPORT_SYMBOL_GPL(devlink_dpipe_table_unregister);
2817 2835