aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-01-26 14:28:23 -0500
committerDavid S. Miller <davem@davemloft.net>2011-01-27 18:02:57 -0500
commit13707f9e5e46342b7b16c58be91ad93a476c3ffd (patch)
tree025764fd464f83300cab236da2ce4b26c5b9703c
parentccf434380d1a67df2dcb9113206b77d0cb0a1cef (diff)
drivers/net: remove some rcu sparse warnings
Add missing __rcu annotations and helpers. minor : Fix some rcu_dereference() calls in macvtap Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/bnx2.c6
-rw-r--r--drivers/net/bnx2.h2
-rw-r--r--drivers/net/bnx2x/bnx2x.h2
-rw-r--r--drivers/net/bnx2x/bnx2x_main.c3
-rw-r--r--drivers/net/cnic.c27
-rw-r--r--drivers/net/cnic.h2
-rw-r--r--drivers/net/hamradio/bpqether.c5
-rw-r--r--drivers/net/macvtap.c18
8 files changed, 40 insertions, 25 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 3dbaf58f681b..2a961b7f7e17 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -435,7 +435,8 @@ bnx2_cnic_stop(struct bnx2 *bp)
435 struct cnic_ctl_info info; 435 struct cnic_ctl_info info;
436 436
437 mutex_lock(&bp->cnic_lock); 437 mutex_lock(&bp->cnic_lock);
438 c_ops = bp->cnic_ops; 438 c_ops = rcu_dereference_protected(bp->cnic_ops,
439 lockdep_is_held(&bp->cnic_lock));
439 if (c_ops) { 440 if (c_ops) {
440 info.cmd = CNIC_CTL_STOP_CMD; 441 info.cmd = CNIC_CTL_STOP_CMD;
441 c_ops->cnic_ctl(bp->cnic_data, &info); 442 c_ops->cnic_ctl(bp->cnic_data, &info);
@@ -450,7 +451,8 @@ bnx2_cnic_start(struct bnx2 *bp)
450 struct cnic_ctl_info info; 451 struct cnic_ctl_info info;
451 452
452 mutex_lock(&bp->cnic_lock); 453 mutex_lock(&bp->cnic_lock);
453 c_ops = bp->cnic_ops; 454 c_ops = rcu_dereference_protected(bp->cnic_ops,
455 lockdep_is_held(&bp->cnic_lock));
454 if (c_ops) { 456 if (c_ops) {
455 if (!(bp->flags & BNX2_FLAG_USING_MSIX)) { 457 if (!(bp->flags & BNX2_FLAG_USING_MSIX)) {
456 struct bnx2_napi *bnapi = &bp->bnx2_napi[0]; 458 struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index f459fb2f9add..0132ea959995 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -6759,7 +6759,7 @@ struct bnx2 {
6759 u32 tx_wake_thresh; 6759 u32 tx_wake_thresh;
6760 6760
6761#ifdef BCM_CNIC 6761#ifdef BCM_CNIC
6762 struct cnic_ops *cnic_ops; 6762 struct cnic_ops __rcu *cnic_ops;
6763 void *cnic_data; 6763 void *cnic_data;
6764#endif 6764#endif
6765 6765
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 8e4183717d91..dfdb9b51ae53 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -1110,7 +1110,7 @@ struct bnx2x {
1110#define BNX2X_CNIC_FLAG_MAC_SET 1 1110#define BNX2X_CNIC_FLAG_MAC_SET 1
1111 void *t2; 1111 void *t2;
1112 dma_addr_t t2_mapping; 1112 dma_addr_t t2_mapping;
1113 struct cnic_ops *cnic_ops; 1113 struct cnic_ops __rcu *cnic_ops;
1114 void *cnic_data; 1114 void *cnic_data;
1115 u32 cnic_tag; 1115 u32 cnic_tag;
1116 struct cnic_eth_dev cnic_eth_dev; 1116 struct cnic_eth_dev cnic_eth_dev;
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index 8cdcf5b39d1e..a2a1bc43a1d2 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -9862,7 +9862,8 @@ static int bnx2x_cnic_ctl_send(struct bnx2x *bp, struct cnic_ctl_info *ctl)
9862 int rc = 0; 9862 int rc = 0;
9863 9863
9864 mutex_lock(&bp->cnic_mutex); 9864 mutex_lock(&bp->cnic_mutex);
9865 c_ops = bp->cnic_ops; 9865 c_ops = rcu_dereference_protected(bp->cnic_ops,
9866 lockdep_is_held(&bp->cnic_mutex));
9866 if (c_ops) 9867 if (c_ops)
9867 rc = c_ops->cnic_ctl(bp->cnic_data, ctl); 9868 rc = c_ops->cnic_ctl(bp->cnic_data, ctl);
9868 mutex_unlock(&bp->cnic_mutex); 9869 mutex_unlock(&bp->cnic_mutex);
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 7ff170cbc7dc..c82049635139 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -65,7 +65,14 @@ static LIST_HEAD(cnic_udev_list);
65static DEFINE_RWLOCK(cnic_dev_lock); 65static DEFINE_RWLOCK(cnic_dev_lock);
66static DEFINE_MUTEX(cnic_lock); 66static DEFINE_MUTEX(cnic_lock);
67 67
68static struct cnic_ulp_ops *cnic_ulp_tbl[MAX_CNIC_ULP_TYPE]; 68static struct cnic_ulp_ops __rcu *cnic_ulp_tbl[MAX_CNIC_ULP_TYPE];
69
70/* helper function, assuming cnic_lock is held */
71static inline struct cnic_ulp_ops *cnic_ulp_tbl_prot(int type)
72{
73 return rcu_dereference_protected(cnic_ulp_tbl[type],
74 lockdep_is_held(&cnic_lock));
75}
69 76
70static int cnic_service_bnx2(void *, void *); 77static int cnic_service_bnx2(void *, void *);
71static int cnic_service_bnx2x(void *, void *); 78static int cnic_service_bnx2x(void *, void *);
@@ -435,7 +442,7 @@ int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops)
435 return -EINVAL; 442 return -EINVAL;
436 } 443 }
437 mutex_lock(&cnic_lock); 444 mutex_lock(&cnic_lock);
438 if (cnic_ulp_tbl[ulp_type]) { 445 if (cnic_ulp_tbl_prot(ulp_type)) {
439 pr_err("%s: Type %d has already been registered\n", 446 pr_err("%s: Type %d has already been registered\n",
440 __func__, ulp_type); 447 __func__, ulp_type);
441 mutex_unlock(&cnic_lock); 448 mutex_unlock(&cnic_lock);
@@ -478,7 +485,7 @@ int cnic_unregister_driver(int ulp_type)
478 return -EINVAL; 485 return -EINVAL;
479 } 486 }
480 mutex_lock(&cnic_lock); 487 mutex_lock(&cnic_lock);
481 ulp_ops = cnic_ulp_tbl[ulp_type]; 488 ulp_ops = cnic_ulp_tbl_prot(ulp_type);
482 if (!ulp_ops) { 489 if (!ulp_ops) {
483 pr_err("%s: Type %d has not been registered\n", 490 pr_err("%s: Type %d has not been registered\n",
484 __func__, ulp_type); 491 __func__, ulp_type);
@@ -529,7 +536,7 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type,
529 return -EINVAL; 536 return -EINVAL;
530 } 537 }
531 mutex_lock(&cnic_lock); 538 mutex_lock(&cnic_lock);
532 if (cnic_ulp_tbl[ulp_type] == NULL) { 539 if (cnic_ulp_tbl_prot(ulp_type) == NULL) {
533 pr_err("%s: Driver with type %d has not been registered\n", 540 pr_err("%s: Driver with type %d has not been registered\n",
534 __func__, ulp_type); 541 __func__, ulp_type);
535 mutex_unlock(&cnic_lock); 542 mutex_unlock(&cnic_lock);
@@ -544,7 +551,7 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type,
544 551
545 clear_bit(ULP_F_START, &cp->ulp_flags[ulp_type]); 552 clear_bit(ULP_F_START, &cp->ulp_flags[ulp_type]);
546 cp->ulp_handle[ulp_type] = ulp_ctx; 553 cp->ulp_handle[ulp_type] = ulp_ctx;
547 ulp_ops = cnic_ulp_tbl[ulp_type]; 554 ulp_ops = cnic_ulp_tbl_prot(ulp_type);
548 rcu_assign_pointer(cp->ulp_ops[ulp_type], ulp_ops); 555 rcu_assign_pointer(cp->ulp_ops[ulp_type], ulp_ops);
549 cnic_hold(dev); 556 cnic_hold(dev);
550 557
@@ -2953,7 +2960,8 @@ static void cnic_ulp_stop(struct cnic_dev *dev)
2953 struct cnic_ulp_ops *ulp_ops; 2960 struct cnic_ulp_ops *ulp_ops;
2954 2961
2955 mutex_lock(&cnic_lock); 2962 mutex_lock(&cnic_lock);
2956 ulp_ops = cp->ulp_ops[if_type]; 2963 ulp_ops = rcu_dereference_protected(cp->ulp_ops[if_type],
2964 lockdep_is_held(&cnic_lock));
2957 if (!ulp_ops) { 2965 if (!ulp_ops) {
2958 mutex_unlock(&cnic_lock); 2966 mutex_unlock(&cnic_lock);
2959 continue; 2967 continue;
@@ -2977,7 +2985,8 @@ static void cnic_ulp_start(struct cnic_dev *dev)
2977 struct cnic_ulp_ops *ulp_ops; 2985 struct cnic_ulp_ops *ulp_ops;
2978 2986
2979 mutex_lock(&cnic_lock); 2987 mutex_lock(&cnic_lock);
2980 ulp_ops = cp->ulp_ops[if_type]; 2988 ulp_ops = rcu_dereference_protected(cp->ulp_ops[if_type],
2989 lockdep_is_held(&cnic_lock));
2981 if (!ulp_ops || !ulp_ops->cnic_start) { 2990 if (!ulp_ops || !ulp_ops->cnic_start) {
2982 mutex_unlock(&cnic_lock); 2991 mutex_unlock(&cnic_lock);
2983 continue; 2992 continue;
@@ -3041,7 +3050,7 @@ static void cnic_ulp_init(struct cnic_dev *dev)
3041 struct cnic_ulp_ops *ulp_ops; 3050 struct cnic_ulp_ops *ulp_ops;
3042 3051
3043 mutex_lock(&cnic_lock); 3052 mutex_lock(&cnic_lock);
3044 ulp_ops = cnic_ulp_tbl[i]; 3053 ulp_ops = cnic_ulp_tbl_prot(i);
3045 if (!ulp_ops || !ulp_ops->cnic_init) { 3054 if (!ulp_ops || !ulp_ops->cnic_init) {
3046 mutex_unlock(&cnic_lock); 3055 mutex_unlock(&cnic_lock);
3047 continue; 3056 continue;
@@ -3065,7 +3074,7 @@ static void cnic_ulp_exit(struct cnic_dev *dev)
3065 struct cnic_ulp_ops *ulp_ops; 3074 struct cnic_ulp_ops *ulp_ops;
3066 3075
3067 mutex_lock(&cnic_lock); 3076 mutex_lock(&cnic_lock);
3068 ulp_ops = cnic_ulp_tbl[i]; 3077 ulp_ops = cnic_ulp_tbl_prot(i);
3069 if (!ulp_ops || !ulp_ops->cnic_exit) { 3078 if (!ulp_ops || !ulp_ops->cnic_exit) {
3070 mutex_unlock(&cnic_lock); 3079 mutex_unlock(&cnic_lock);
3071 continue; 3080 continue;
diff --git a/drivers/net/cnic.h b/drivers/net/cnic.h
index b328f6c924c3..4456260c653c 100644
--- a/drivers/net/cnic.h
+++ b/drivers/net/cnic.h
@@ -220,7 +220,7 @@ struct cnic_local {
220#define ULP_F_INIT 0 220#define ULP_F_INIT 0
221#define ULP_F_START 1 221#define ULP_F_START 1
222#define ULP_F_CALL_PENDING 2 222#define ULP_F_CALL_PENDING 2
223 struct cnic_ulp_ops *ulp_ops[MAX_CNIC_ULP_TYPE]; 223 struct cnic_ulp_ops __rcu *ulp_ops[MAX_CNIC_ULP_TYPE];
224 224
225 unsigned long cnic_local_flags; 225 unsigned long cnic_local_flags;
226#define CNIC_LCL_FL_KWQ_INIT 0x0 226#define CNIC_LCL_FL_KWQ_INIT 0x0
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index ac1d323c5eb5..8931168d3e74 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -400,13 +400,14 @@ static void *bpq_seq_start(struct seq_file *seq, loff_t *pos)
400static void *bpq_seq_next(struct seq_file *seq, void *v, loff_t *pos) 400static void *bpq_seq_next(struct seq_file *seq, void *v, loff_t *pos)
401{ 401{
402 struct list_head *p; 402 struct list_head *p;
403 struct bpqdev *bpqdev = v;
403 404
404 ++*pos; 405 ++*pos;
405 406
406 if (v == SEQ_START_TOKEN) 407 if (v == SEQ_START_TOKEN)
407 p = rcu_dereference(bpq_devices.next); 408 p = rcu_dereference(list_next_rcu(&bpq_devices));
408 else 409 else
409 p = rcu_dereference(((struct bpqdev *)v)->bpq_list.next); 410 p = rcu_dereference(list_next_rcu(&bpqdev->bpq_list));
410 411
411 return (p == &bpq_devices) ? NULL 412 return (p == &bpq_devices) ? NULL
412 : list_entry(p, struct bpqdev, bpq_list); 413 : list_entry(p, struct bpqdev, bpq_list);
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 5933621ac3ff..2300e4599520 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -39,7 +39,7 @@ struct macvtap_queue {
39 struct socket sock; 39 struct socket sock;
40 struct socket_wq wq; 40 struct socket_wq wq;
41 int vnet_hdr_sz; 41 int vnet_hdr_sz;
42 struct macvlan_dev *vlan; 42 struct macvlan_dev __rcu *vlan;
43 struct file *file; 43 struct file *file;
44 unsigned int flags; 44 unsigned int flags;
45}; 45};
@@ -141,7 +141,8 @@ static void macvtap_put_queue(struct macvtap_queue *q)
141 struct macvlan_dev *vlan; 141 struct macvlan_dev *vlan;
142 142
143 spin_lock(&macvtap_lock); 143 spin_lock(&macvtap_lock);
144 vlan = rcu_dereference(q->vlan); 144 vlan = rcu_dereference_protected(q->vlan,
145 lockdep_is_held(&macvtap_lock));
145 if (vlan) { 146 if (vlan) {
146 int index = get_slot(vlan, q); 147 int index = get_slot(vlan, q);
147 148
@@ -219,7 +220,8 @@ static void macvtap_del_queues(struct net_device *dev)
219 /* macvtap_put_queue can free some slots, so go through all slots */ 220 /* macvtap_put_queue can free some slots, so go through all slots */
220 spin_lock(&macvtap_lock); 221 spin_lock(&macvtap_lock);
221 for (i = 0; i < MAX_MACVTAP_QUEUES && vlan->numvtaps; i++) { 222 for (i = 0; i < MAX_MACVTAP_QUEUES && vlan->numvtaps; i++) {
222 q = rcu_dereference(vlan->taps[i]); 223 q = rcu_dereference_protected(vlan->taps[i],
224 lockdep_is_held(&macvtap_lock));
223 if (q) { 225 if (q) {
224 qlist[j++] = q; 226 qlist[j++] = q;
225 rcu_assign_pointer(vlan->taps[i], NULL); 227 rcu_assign_pointer(vlan->taps[i], NULL);
@@ -569,7 +571,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q,
569 } 571 }
570 572
571 rcu_read_lock_bh(); 573 rcu_read_lock_bh();
572 vlan = rcu_dereference(q->vlan); 574 vlan = rcu_dereference_bh(q->vlan);
573 if (vlan) 575 if (vlan)
574 macvlan_start_xmit(skb, vlan->dev); 576 macvlan_start_xmit(skb, vlan->dev);
575 else 577 else
@@ -583,7 +585,7 @@ err_kfree:
583 585
584err: 586err:
585 rcu_read_lock_bh(); 587 rcu_read_lock_bh();
586 vlan = rcu_dereference(q->vlan); 588 vlan = rcu_dereference_bh(q->vlan);
587 if (vlan) 589 if (vlan)
588 vlan->dev->stats.tx_dropped++; 590 vlan->dev->stats.tx_dropped++;
589 rcu_read_unlock_bh(); 591 rcu_read_unlock_bh();
@@ -631,7 +633,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
631 ret = skb_copy_datagram_const_iovec(skb, 0, iv, vnet_hdr_len, len); 633 ret = skb_copy_datagram_const_iovec(skb, 0, iv, vnet_hdr_len, len);
632 634
633 rcu_read_lock_bh(); 635 rcu_read_lock_bh();
634 vlan = rcu_dereference(q->vlan); 636 vlan = rcu_dereference_bh(q->vlan);
635 if (vlan) 637 if (vlan)
636 macvlan_count_rx(vlan, len, ret == 0, 0); 638 macvlan_count_rx(vlan, len, ret == 0, 0);
637 rcu_read_unlock_bh(); 639 rcu_read_unlock_bh();
@@ -727,7 +729,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
727 729
728 case TUNGETIFF: 730 case TUNGETIFF:
729 rcu_read_lock_bh(); 731 rcu_read_lock_bh();
730 vlan = rcu_dereference(q->vlan); 732 vlan = rcu_dereference_bh(q->vlan);
731 if (vlan) 733 if (vlan)
732 dev_hold(vlan->dev); 734 dev_hold(vlan->dev);
733 rcu_read_unlock_bh(); 735 rcu_read_unlock_bh();
@@ -736,7 +738,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
736 return -ENOLINK; 738 return -ENOLINK;
737 739
738 ret = 0; 740 ret = 0;
739 if (copy_to_user(&ifr->ifr_name, q->vlan->dev->name, IFNAMSIZ) || 741 if (copy_to_user(&ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
740 put_user(q->flags, &ifr->ifr_flags)) 742 put_user(q->flags, &ifr->ifr_flags))
741 ret = -EFAULT; 743 ret = -EFAULT;
742 dev_put(vlan->dev); 744 dev_put(vlan->dev);