diff options
author | David S. Miller <davem@davemloft.net> | 2014-06-03 02:17:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-06-03 02:17:03 -0400 |
commit | 1299b3c49b7119ae534284e4129032441f40a422 (patch) | |
tree | 9f6b56c5dd8b707327864ecfdaf667cc4db29acb | |
parent | 74f43922dc985119fa84c19c648445f81d0c7706 (diff) | |
parent | 5943691442ae248977a2e3cac814ed5ac606903c (diff) |
Merge branch 'cnic'
Michael Chan says:
====================
cnic fixes
Fix 2 sleeping function from invalid context bugs and 1 missing iscsi netlink
message bug.
v2: Fixed typo in rcu_dereference_protected() and tested with CONFIG_PROVE_RCU
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/broadcom/cnic.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c index 09f3fefcbf9c..a4b25bc7113a 100644 --- a/drivers/net/ethernet/broadcom/cnic.c +++ b/drivers/net/ethernet/broadcom/cnic.c | |||
@@ -608,6 +608,10 @@ static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type) | |||
608 | pr_err("%s: Bad type %d\n", __func__, ulp_type); | 608 | pr_err("%s: Bad type %d\n", __func__, ulp_type); |
609 | return -EINVAL; | 609 | return -EINVAL; |
610 | } | 610 | } |
611 | |||
612 | if (ulp_type == CNIC_ULP_ISCSI) | ||
613 | cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); | ||
614 | |||
611 | mutex_lock(&cnic_lock); | 615 | mutex_lock(&cnic_lock); |
612 | if (rcu_dereference(cp->ulp_ops[ulp_type])) { | 616 | if (rcu_dereference(cp->ulp_ops[ulp_type])) { |
613 | RCU_INIT_POINTER(cp->ulp_ops[ulp_type], NULL); | 617 | RCU_INIT_POINTER(cp->ulp_ops[ulp_type], NULL); |
@@ -620,9 +624,7 @@ static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type) | |||
620 | } | 624 | } |
621 | mutex_unlock(&cnic_lock); | 625 | mutex_unlock(&cnic_lock); |
622 | 626 | ||
623 | if (ulp_type == CNIC_ULP_ISCSI) | 627 | if (ulp_type == CNIC_ULP_FCOE) |
624 | cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); | ||
625 | else if (ulp_type == CNIC_ULP_FCOE) | ||
626 | dev->fcoe_cap = NULL; | 628 | dev->fcoe_cap = NULL; |
627 | 629 | ||
628 | synchronize_rcu(); | 630 | synchronize_rcu(); |
@@ -1039,21 +1041,17 @@ static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages) | |||
1039 | struct cnic_local *cp = dev->cnic_priv; | 1041 | struct cnic_local *cp = dev->cnic_priv; |
1040 | struct cnic_uio_dev *udev; | 1042 | struct cnic_uio_dev *udev; |
1041 | 1043 | ||
1042 | read_lock(&cnic_dev_lock); | ||
1043 | list_for_each_entry(udev, &cnic_udev_list, list) { | 1044 | list_for_each_entry(udev, &cnic_udev_list, list) { |
1044 | if (udev->pdev == dev->pcidev) { | 1045 | if (udev->pdev == dev->pcidev) { |
1045 | udev->dev = dev; | 1046 | udev->dev = dev; |
1046 | if (__cnic_alloc_uio_rings(udev, pages)) { | 1047 | if (__cnic_alloc_uio_rings(udev, pages)) { |
1047 | udev->dev = NULL; | 1048 | udev->dev = NULL; |
1048 | read_unlock(&cnic_dev_lock); | ||
1049 | return -ENOMEM; | 1049 | return -ENOMEM; |
1050 | } | 1050 | } |
1051 | cp->udev = udev; | 1051 | cp->udev = udev; |
1052 | read_unlock(&cnic_dev_lock); | ||
1053 | return 0; | 1052 | return 0; |
1054 | } | 1053 | } |
1055 | } | 1054 | } |
1056 | read_unlock(&cnic_dev_lock); | ||
1057 | 1055 | ||
1058 | udev = kzalloc(sizeof(struct cnic_uio_dev), GFP_ATOMIC); | 1056 | udev = kzalloc(sizeof(struct cnic_uio_dev), GFP_ATOMIC); |
1059 | if (!udev) | 1057 | if (!udev) |
@@ -1067,9 +1065,7 @@ static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages) | |||
1067 | if (__cnic_alloc_uio_rings(udev, pages)) | 1065 | if (__cnic_alloc_uio_rings(udev, pages)) |
1068 | goto err_udev; | 1066 | goto err_udev; |
1069 | 1067 | ||
1070 | write_lock(&cnic_dev_lock); | ||
1071 | list_add(&udev->list, &cnic_udev_list); | 1068 | list_add(&udev->list, &cnic_udev_list); |
1072 | write_unlock(&cnic_dev_lock); | ||
1073 | 1069 | ||
1074 | pci_dev_get(udev->pdev); | 1070 | pci_dev_get(udev->pdev); |
1075 | 1071 | ||
@@ -5624,20 +5620,27 @@ static void cnic_rcv_netevent(struct cnic_local *cp, unsigned long event, | |||
5624 | { | 5620 | { |
5625 | int if_type; | 5621 | int if_type; |
5626 | 5622 | ||
5627 | rcu_read_lock(); | ||
5628 | for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) { | 5623 | for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) { |
5629 | struct cnic_ulp_ops *ulp_ops; | 5624 | struct cnic_ulp_ops *ulp_ops; |
5630 | void *ctx; | 5625 | void *ctx; |
5631 | 5626 | ||
5632 | ulp_ops = rcu_dereference(cp->ulp_ops[if_type]); | 5627 | mutex_lock(&cnic_lock); |
5633 | if (!ulp_ops || !ulp_ops->indicate_netevent) | 5628 | ulp_ops = rcu_dereference_protected(cp->ulp_ops[if_type], |
5629 | lockdep_is_held(&cnic_lock)); | ||
5630 | if (!ulp_ops || !ulp_ops->indicate_netevent) { | ||
5631 | mutex_unlock(&cnic_lock); | ||
5634 | continue; | 5632 | continue; |
5633 | } | ||
5635 | 5634 | ||
5636 | ctx = cp->ulp_handle[if_type]; | 5635 | ctx = cp->ulp_handle[if_type]; |
5637 | 5636 | ||
5637 | set_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]); | ||
5638 | mutex_unlock(&cnic_lock); | ||
5639 | |||
5638 | ulp_ops->indicate_netevent(ctx, event, vlan_id); | 5640 | ulp_ops->indicate_netevent(ctx, event, vlan_id); |
5641 | |||
5642 | clear_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]); | ||
5639 | } | 5643 | } |
5640 | rcu_read_unlock(); | ||
5641 | } | 5644 | } |
5642 | 5645 | ||
5643 | /* netdev event handler */ | 5646 | /* netdev event handler */ |