diff options
author | Yossi Etigin <yosefe@voltaire.com> | 2009-04-20 16:58:08 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2009-04-20 16:58:08 -0400 |
commit | e028cc55cc5c90a1c57eefe560a0cbb4df1fed14 (patch) | |
tree | b1ef203c107a4589536a089737ae550e0b18451b /drivers/infiniband | |
parent | a939b96cccdb65df80a52447ec8e4a6d79c56dbb (diff) |
IPoIB: Disable NAPI while CQ is being drained
If NAPI is enabled while IPoIB's CQ is being drained, it creates a
race on priv->ibwc between ipoib_poll() and ipoib_drain_cq(), leading
to memory corruption.
The solution is to enable/disable NAPI in ipoib_ib_dev_{open/stop}()
instead of in ipoib_{open/stop}(), and sync NAPI on the INITIALIZED
flag instead on the ADMIN_UP flag. This way NAPI will be disabled when
ipoib_drain_cq() is called.
This fixes <https://bugs.openfabrics.org/show_bug.cgi?id=1587>.
Signed-off-by: Yossi Etigin <yosefe@voltaire.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_ib.c | 6 | ||||
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_main.c | 5 |
2 files changed, 5 insertions, 6 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index da6082739839..e7e5adf84e84 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c | |||
@@ -685,7 +685,8 @@ int ipoib_ib_dev_open(struct net_device *dev) | |||
685 | queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, | 685 | queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, |
686 | round_jiffies_relative(HZ)); | 686 | round_jiffies_relative(HZ)); |
687 | 687 | ||
688 | set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); | 688 | if (!test_and_set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) |
689 | napi_enable(&priv->napi); | ||
689 | 690 | ||
690 | return 0; | 691 | return 0; |
691 | } | 692 | } |
@@ -804,7 +805,8 @@ int ipoib_ib_dev_stop(struct net_device *dev, int flush) | |||
804 | struct ipoib_tx_buf *tx_req; | 805 | struct ipoib_tx_buf *tx_req; |
805 | int i; | 806 | int i; |
806 | 807 | ||
807 | clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); | 808 | if (test_and_clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) |
809 | napi_disable(&priv->napi); | ||
808 | 810 | ||
809 | ipoib_cm_dev_stop(dev); | 811 | ipoib_cm_dev_stop(dev); |
810 | 812 | ||
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 421a6640c9bd..ab2c192c76bc 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -106,8 +106,7 @@ int ipoib_open(struct net_device *dev) | |||
106 | 106 | ||
107 | ipoib_dbg(priv, "bringing up interface\n"); | 107 | ipoib_dbg(priv, "bringing up interface\n"); |
108 | 108 | ||
109 | if (!test_and_set_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) | 109 | set_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); |
110 | napi_enable(&priv->napi); | ||
111 | 110 | ||
112 | if (ipoib_pkey_dev_delay_open(dev)) | 111 | if (ipoib_pkey_dev_delay_open(dev)) |
113 | return 0; | 112 | return 0; |
@@ -143,7 +142,6 @@ err_stop: | |||
143 | ipoib_ib_dev_stop(dev, 1); | 142 | ipoib_ib_dev_stop(dev, 1); |
144 | 143 | ||
145 | err_disable: | 144 | err_disable: |
146 | napi_disable(&priv->napi); | ||
147 | clear_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); | 145 | clear_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); |
148 | 146 | ||
149 | return -EINVAL; | 147 | return -EINVAL; |
@@ -156,7 +154,6 @@ static int ipoib_stop(struct net_device *dev) | |||
156 | ipoib_dbg(priv, "stopping interface\n"); | 154 | ipoib_dbg(priv, "stopping interface\n"); |
157 | 155 | ||
158 | clear_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); | 156 | clear_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); |
159 | napi_disable(&priv->napi); | ||
160 | 157 | ||
161 | netif_stop_queue(dev); | 158 | netif_stop_queue(dev); |
162 | 159 | ||