aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom/cnic.c
diff options
context:
space:
mode:
authorMichael Chan <mchan@broadcom.com>2014-06-03 02:08:46 -0400
committerDavid S. Miller <davem@davemloft.net>2014-06-03 02:16:41 -0400
commit20f30c2d5ea44925cb83b0fdae78b8600a76b66e (patch)
tree6645ecf039b795d6de8579e4c8ab4da22cedb181 /drivers/net/ethernet/broadcom/cnic.c
parent74f43922dc985119fa84c19c648445f81d0c7706 (diff)
cnic: Don't take rcu_read_lock in cnic_rcv_netevent()
Because the called function, such as bnx2fc_indicate_netevent(), can sleep, we cannot take rcu_lock(). To prevent the rcu protected ulp_ops from going away, we use the cnic_lock mutex and set the ULP_F_CALL_PENDING flag. The code already waits for ULP_F_CALL_PENDING flag to clear in cnic_unregister_device(). Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom/cnic.c')
-rw-r--r--drivers/net/ethernet/broadcom/cnic.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index 09f3fefcbf9c..a0aae722ffcf 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -5624,20 +5624,27 @@ static void cnic_rcv_netevent(struct cnic_local *cp, unsigned long event,
5624{ 5624{
5625 int if_type; 5625 int if_type;
5626 5626
5627 rcu_read_lock();
5628 for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) { 5627 for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) {
5629 struct cnic_ulp_ops *ulp_ops; 5628 struct cnic_ulp_ops *ulp_ops;
5630 void *ctx; 5629 void *ctx;
5631 5630
5632 ulp_ops = rcu_dereference(cp->ulp_ops[if_type]); 5631 mutex_lock(&cnic_lock);
5633 if (!ulp_ops || !ulp_ops->indicate_netevent) 5632 ulp_ops = rcu_dereference_protected(cp->ulp_ops[if_type],
5633 lockdep_is_held(&cnic_lock));
5634 if (!ulp_ops || !ulp_ops->indicate_netevent) {
5635 mutex_unlock(&cnic_lock);
5634 continue; 5636 continue;
5637 }
5635 5638
5636 ctx = cp->ulp_handle[if_type]; 5639 ctx = cp->ulp_handle[if_type];
5637 5640
5641 set_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]);
5642 mutex_unlock(&cnic_lock);
5643
5638 ulp_ops->indicate_netevent(ctx, event, vlan_id); 5644 ulp_ops->indicate_netevent(ctx, event, vlan_id);
5645
5646 clear_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]);
5639 } 5647 }
5640 rcu_read_unlock();
5641} 5648}
5642 5649
5643/* netdev event handler */ 5650/* netdev event handler */