diff options
author | Eric Dumazet <edumazet@google.com> | 2016-06-09 10:45:12 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-06-09 16:28:37 -0400 |
commit | d3fff6c443fe8f8a5ef2bdcea45e2ff39db948c7 (patch) | |
tree | ec632344dab9ba6c7a3767aa4054e682ddf5871c | |
parent | 52fbb2907988aa0583c6d9d53a56aee090b2df7e (diff) |
net: add netdev_lockdep_set_classes() helper
It is time to add netdev_lockdep_set_classes() helper
so that lockdep annotations per device type are easier to manage.
This removes a lot of copies and missing annotations.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/bonding/bond_main.c | 24 | ||||
-rw-r--r-- | drivers/net/ppp/ppp_generic.c | 6 | ||||
-rw-r--r-- | drivers/net/team/team.c | 21 | ||||
-rw-r--r-- | include/linux/netdevice.h | 17 | ||||
-rw-r--r-- | net/bluetooth/6lowpan.c | 15 | ||||
-rw-r--r-- | net/ieee802154/6lowpan/core.c | 16 | ||||
-rw-r--r-- | net/l2tp/l2tp_eth.c | 6 |
7 files changed, 23 insertions, 82 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 681af31a60ed..90157e20357e 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -4607,28 +4607,6 @@ static int bond_check_params(struct bond_params *params) | |||
4607 | return 0; | 4607 | return 0; |
4608 | } | 4608 | } |
4609 | 4609 | ||
4610 | static struct lock_class_key bonding_netdev_xmit_lock_key; | ||
4611 | static struct lock_class_key bonding_netdev_addr_lock_key; | ||
4612 | static struct lock_class_key bonding_tx_busylock_key; | ||
4613 | static struct lock_class_key bonding_qdisc_running_key; | ||
4614 | |||
4615 | static void bond_set_lockdep_class_one(struct net_device *dev, | ||
4616 | struct netdev_queue *txq, | ||
4617 | void *_unused) | ||
4618 | { | ||
4619 | lockdep_set_class(&txq->_xmit_lock, | ||
4620 | &bonding_netdev_xmit_lock_key); | ||
4621 | } | ||
4622 | |||
4623 | static void bond_set_lockdep_class(struct net_device *dev) | ||
4624 | { | ||
4625 | lockdep_set_class(&dev->addr_list_lock, | ||
4626 | &bonding_netdev_addr_lock_key); | ||
4627 | netdev_for_each_tx_queue(dev, bond_set_lockdep_class_one, NULL); | ||
4628 | dev->qdisc_tx_busylock = &bonding_tx_busylock_key; | ||
4629 | dev->qdisc_running_key = &bonding_qdisc_running_key; | ||
4630 | } | ||
4631 | |||
4632 | /* Called from registration process */ | 4610 | /* Called from registration process */ |
4633 | static int bond_init(struct net_device *bond_dev) | 4611 | static int bond_init(struct net_device *bond_dev) |
4634 | { | 4612 | { |
@@ -4641,7 +4619,7 @@ static int bond_init(struct net_device *bond_dev) | |||
4641 | if (!bond->wq) | 4619 | if (!bond->wq) |
4642 | return -ENOMEM; | 4620 | return -ENOMEM; |
4643 | 4621 | ||
4644 | bond_set_lockdep_class(bond_dev); | 4622 | netdev_lockdep_set_classes(bond_dev); |
4645 | 4623 | ||
4646 | list_add_tail(&bond->bond_list, &bn->dev_list); | 4624 | list_add_tail(&bond->bond_list, &bn->dev_list); |
4647 | 4625 | ||
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index aeabaa42317f..17953ab15000 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c | |||
@@ -1312,13 +1312,9 @@ ppp_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats64) | |||
1312 | return stats64; | 1312 | return stats64; |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | static struct lock_class_key ppp_tx_busylock; | ||
1316 | static struct lock_class_key ppp_qdisc_running_key; | ||
1317 | |||
1318 | static int ppp_dev_init(struct net_device *dev) | 1315 | static int ppp_dev_init(struct net_device *dev) |
1319 | { | 1316 | { |
1320 | dev->qdisc_tx_busylock = &ppp_tx_busylock; | 1317 | netdev_lockdep_set_classes(dev); |
1321 | dev->qdisc_running_key = &ppp_qdisc_running_key; | ||
1322 | return 0; | 1318 | return 0; |
1323 | } | 1319 | } |
1324 | 1320 | ||
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 00eb38956a2c..0a1bb8387d96 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c | |||
@@ -1574,25 +1574,6 @@ static const struct team_option team_options[] = { | |||
1574 | }, | 1574 | }, |
1575 | }; | 1575 | }; |
1576 | 1576 | ||
1577 | static struct lock_class_key team_netdev_xmit_lock_key; | ||
1578 | static struct lock_class_key team_netdev_addr_lock_key; | ||
1579 | static struct lock_class_key team_tx_busylock_key; | ||
1580 | static struct lock_class_key team_qdisc_running_key; | ||
1581 | |||
1582 | static void team_set_lockdep_class_one(struct net_device *dev, | ||
1583 | struct netdev_queue *txq, | ||
1584 | void *unused) | ||
1585 | { | ||
1586 | lockdep_set_class(&txq->_xmit_lock, &team_netdev_xmit_lock_key); | ||
1587 | } | ||
1588 | |||
1589 | static void team_set_lockdep_class(struct net_device *dev) | ||
1590 | { | ||
1591 | lockdep_set_class(&dev->addr_list_lock, &team_netdev_addr_lock_key); | ||
1592 | netdev_for_each_tx_queue(dev, team_set_lockdep_class_one, NULL); | ||
1593 | dev->qdisc_tx_busylock = &team_tx_busylock_key; | ||
1594 | dev->qdisc_running_key = &team_qdisc_running_key; | ||
1595 | } | ||
1596 | 1577 | ||
1597 | static int team_init(struct net_device *dev) | 1578 | static int team_init(struct net_device *dev) |
1598 | { | 1579 | { |
@@ -1628,7 +1609,7 @@ static int team_init(struct net_device *dev) | |||
1628 | goto err_options_register; | 1609 | goto err_options_register; |
1629 | netif_carrier_off(dev); | 1610 | netif_carrier_off(dev); |
1630 | 1611 | ||
1631 | team_set_lockdep_class(dev); | 1612 | netdev_lockdep_set_classes(dev); |
1632 | 1613 | ||
1633 | return 0; | 1614 | return 0; |
1634 | 1615 | ||
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 541562333ba5..4f234b102892 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -1946,6 +1946,23 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev, | |||
1946 | f(dev, &dev->_tx[i], arg); | 1946 | f(dev, &dev->_tx[i], arg); |
1947 | } | 1947 | } |
1948 | 1948 | ||
1949 | #define netdev_lockdep_set_classes(dev) \ | ||
1950 | { \ | ||
1951 | static struct lock_class_key qdisc_tx_busylock_key; \ | ||
1952 | static struct lock_class_key qdisc_running_key; \ | ||
1953 | static struct lock_class_key qdisc_xmit_lock_key; \ | ||
1954 | static struct lock_class_key dev_addr_list_lock_key; \ | ||
1955 | unsigned int i; \ | ||
1956 | \ | ||
1957 | (dev)->qdisc_tx_busylock = &qdisc_tx_busylock_key; \ | ||
1958 | (dev)->qdisc_running_key = &qdisc_running_key; \ | ||
1959 | lockdep_set_class(&(dev)->addr_list_lock, \ | ||
1960 | &dev_addr_list_lock_key); \ | ||
1961 | for (i = 0; i < (dev)->num_tx_queues; i++) \ | ||
1962 | lockdep_set_class(&(dev)->_tx[i]._xmit_lock, \ | ||
1963 | &qdisc_xmit_lock_key); \ | ||
1964 | } | ||
1965 | |||
1949 | struct netdev_queue *netdev_pick_tx(struct net_device *dev, | 1966 | struct netdev_queue *netdev_pick_tx(struct net_device *dev, |
1950 | struct sk_buff *skb, | 1967 | struct sk_buff *skb, |
1951 | void *accel_priv); | 1968 | void *accel_priv); |
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 977a11e418d0..d020299baba4 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c | |||
@@ -627,22 +627,9 @@ static netdev_tx_t bt_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
627 | return err < 0 ? NET_XMIT_DROP : err; | 627 | return err < 0 ? NET_XMIT_DROP : err; |
628 | } | 628 | } |
629 | 629 | ||
630 | static struct lock_class_key bt_tx_busylock; | ||
631 | static struct lock_class_key bt_netdev_xmit_lock_key; | ||
632 | static struct lock_class_key bt_qdisc_running_key; | ||
633 | |||
634 | static void bt_set_lockdep_class_one(struct net_device *dev, | ||
635 | struct netdev_queue *txq, | ||
636 | void *_unused) | ||
637 | { | ||
638 | lockdep_set_class(&txq->_xmit_lock, &bt_netdev_xmit_lock_key); | ||
639 | } | ||
640 | |||
641 | static int bt_dev_init(struct net_device *dev) | 630 | static int bt_dev_init(struct net_device *dev) |
642 | { | 631 | { |
643 | netdev_for_each_tx_queue(dev, bt_set_lockdep_class_one, NULL); | 632 | netdev_lockdep_set_classes(dev); |
644 | dev->qdisc_tx_busylock = &bt_tx_busylock; | ||
645 | dev->qdisc_running_key = &bt_qdisc_running_key; | ||
646 | 633 | ||
647 | return 0; | 634 | return 0; |
648 | } | 635 | } |
diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c index 14aa5effd29a..4e2b30894224 100644 --- a/net/ieee802154/6lowpan/core.c +++ b/net/ieee802154/6lowpan/core.c | |||
@@ -58,23 +58,9 @@ static struct header_ops lowpan_header_ops = { | |||
58 | .create = lowpan_header_create, | 58 | .create = lowpan_header_create, |
59 | }; | 59 | }; |
60 | 60 | ||
61 | static struct lock_class_key lowpan_tx_busylock; | ||
62 | static struct lock_class_key lowpan_netdev_xmit_lock_key; | ||
63 | static struct lock_class_key lowpan_qdisc_running_key; | ||
64 | |||
65 | static void lowpan_set_lockdep_class_one(struct net_device *ldev, | ||
66 | struct netdev_queue *txq, | ||
67 | void *_unused) | ||
68 | { | ||
69 | lockdep_set_class(&txq->_xmit_lock, | ||
70 | &lowpan_netdev_xmit_lock_key); | ||
71 | } | ||
72 | |||
73 | static int lowpan_dev_init(struct net_device *ldev) | 61 | static int lowpan_dev_init(struct net_device *ldev) |
74 | { | 62 | { |
75 | netdev_for_each_tx_queue(ldev, lowpan_set_lockdep_class_one, NULL); | 63 | netdev_lockdep_set_classes(ldev); |
76 | ldev->qdisc_tx_busylock = &lowpan_tx_busylock; | ||
77 | ldev->qdisc_running_key = &lowpan_qdisc_running_key; | ||
78 | 64 | ||
79 | return 0; | 65 | return 0; |
80 | } | 66 | } |
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c index c00d72d182fa..57fc5a46ce06 100644 --- a/net/l2tp/l2tp_eth.c +++ b/net/l2tp/l2tp_eth.c | |||
@@ -67,9 +67,6 @@ static inline struct l2tp_eth_net *l2tp_eth_pernet(struct net *net) | |||
67 | return net_generic(net, l2tp_eth_net_id); | 67 | return net_generic(net, l2tp_eth_net_id); |
68 | } | 68 | } |
69 | 69 | ||
70 | static struct lock_class_key l2tp_eth_tx_busylock; | ||
71 | static struct lock_class_key l2tp_qdisc_running_key; | ||
72 | |||
73 | static int l2tp_eth_dev_init(struct net_device *dev) | 70 | static int l2tp_eth_dev_init(struct net_device *dev) |
74 | { | 71 | { |
75 | struct l2tp_eth *priv = netdev_priv(dev); | 72 | struct l2tp_eth *priv = netdev_priv(dev); |
@@ -77,8 +74,7 @@ static int l2tp_eth_dev_init(struct net_device *dev) | |||
77 | priv->dev = dev; | 74 | priv->dev = dev; |
78 | eth_hw_addr_random(dev); | 75 | eth_hw_addr_random(dev); |
79 | eth_broadcast_addr(dev->broadcast); | 76 | eth_broadcast_addr(dev->broadcast); |
80 | dev->qdisc_tx_busylock = &l2tp_eth_tx_busylock; | 77 | netdev_lockdep_set_classes(dev); |
81 | dev->qdisc_running_key = &l2tp_qdisc_running_key; | ||
82 | 78 | ||
83 | return 0; | 79 | return 0; |
84 | } | 80 | } |