diff options
Diffstat (limited to 'drivers/infiniband/ulp/ipoib/ipoib_verbs.c')
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_verbs.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c index 7b717c648f72..3cb551b88756 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c | |||
@@ -168,35 +168,41 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca) | |||
168 | .qp_type = IB_QPT_UD | 168 | .qp_type = IB_QPT_UD |
169 | }; | 169 | }; |
170 | 170 | ||
171 | int ret, size; | ||
172 | |||
171 | priv->pd = ib_alloc_pd(priv->ca); | 173 | priv->pd = ib_alloc_pd(priv->ca); |
172 | if (IS_ERR(priv->pd)) { | 174 | if (IS_ERR(priv->pd)) { |
173 | printk(KERN_WARNING "%s: failed to allocate PD\n", ca->name); | 175 | printk(KERN_WARNING "%s: failed to allocate PD\n", ca->name); |
174 | return -ENODEV; | 176 | return -ENODEV; |
175 | } | 177 | } |
176 | 178 | ||
177 | priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev, | 179 | priv->mr = ib_get_dma_mr(priv->pd, IB_ACCESS_LOCAL_WRITE); |
178 | ipoib_sendq_size + ipoib_recvq_size + 1); | 180 | if (IS_ERR(priv->mr)) { |
181 | printk(KERN_WARNING "%s: ib_get_dma_mr failed\n", ca->name); | ||
182 | goto out_free_pd; | ||
183 | } | ||
184 | |||
185 | size = ipoib_sendq_size + ipoib_recvq_size + 1; | ||
186 | ret = ipoib_cm_dev_init(dev); | ||
187 | if (!ret) | ||
188 | size += ipoib_recvq_size; | ||
189 | |||
190 | priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev, size); | ||
179 | if (IS_ERR(priv->cq)) { | 191 | if (IS_ERR(priv->cq)) { |
180 | printk(KERN_WARNING "%s: failed to create CQ\n", ca->name); | 192 | printk(KERN_WARNING "%s: failed to create CQ\n", ca->name); |
181 | goto out_free_pd; | 193 | goto out_free_mr; |
182 | } | 194 | } |
183 | 195 | ||
184 | if (ib_req_notify_cq(priv->cq, IB_CQ_NEXT_COMP)) | 196 | if (ib_req_notify_cq(priv->cq, IB_CQ_NEXT_COMP)) |
185 | goto out_free_cq; | 197 | goto out_free_cq; |
186 | 198 | ||
187 | priv->mr = ib_get_dma_mr(priv->pd, IB_ACCESS_LOCAL_WRITE); | ||
188 | if (IS_ERR(priv->mr)) { | ||
189 | printk(KERN_WARNING "%s: ib_get_dma_mr failed\n", ca->name); | ||
190 | goto out_free_cq; | ||
191 | } | ||
192 | |||
193 | init_attr.send_cq = priv->cq; | 199 | init_attr.send_cq = priv->cq; |
194 | init_attr.recv_cq = priv->cq, | 200 | init_attr.recv_cq = priv->cq, |
195 | 201 | ||
196 | priv->qp = ib_create_qp(priv->pd, &init_attr); | 202 | priv->qp = ib_create_qp(priv->pd, &init_attr); |
197 | if (IS_ERR(priv->qp)) { | 203 | if (IS_ERR(priv->qp)) { |
198 | printk(KERN_WARNING "%s: failed to create QP\n", ca->name); | 204 | printk(KERN_WARNING "%s: failed to create QP\n", ca->name); |
199 | goto out_free_mr; | 205 | goto out_free_cq; |
200 | } | 206 | } |
201 | 207 | ||
202 | priv->dev->dev_addr[1] = (priv->qp->qp_num >> 16) & 0xff; | 208 | priv->dev->dev_addr[1] = (priv->qp->qp_num >> 16) & 0xff; |
@@ -212,12 +218,12 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca) | |||
212 | 218 | ||
213 | return 0; | 219 | return 0; |
214 | 220 | ||
215 | out_free_mr: | ||
216 | ib_dereg_mr(priv->mr); | ||
217 | |||
218 | out_free_cq: | 221 | out_free_cq: |
219 | ib_destroy_cq(priv->cq); | 222 | ib_destroy_cq(priv->cq); |
220 | 223 | ||
224 | out_free_mr: | ||
225 | ib_dereg_mr(priv->mr); | ||
226 | |||
221 | out_free_pd: | 227 | out_free_pd: |
222 | ib_dealloc_pd(priv->pd); | 228 | ib_dealloc_pd(priv->pd); |
223 | return -ENODEV; | 229 | return -ENODEV; |
@@ -235,12 +241,14 @@ void ipoib_transport_dev_cleanup(struct net_device *dev) | |||
235 | clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); | 241 | clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); |
236 | } | 242 | } |
237 | 243 | ||
238 | if (ib_dereg_mr(priv->mr)) | ||
239 | ipoib_warn(priv, "ib_dereg_mr failed\n"); | ||
240 | |||
241 | if (ib_destroy_cq(priv->cq)) | 244 | if (ib_destroy_cq(priv->cq)) |
242 | ipoib_warn(priv, "ib_cq_destroy failed\n"); | 245 | ipoib_warn(priv, "ib_cq_destroy failed\n"); |
243 | 246 | ||
247 | ipoib_cm_dev_cleanup(dev); | ||
248 | |||
249 | if (ib_dereg_mr(priv->mr)) | ||
250 | ipoib_warn(priv, "ib_dereg_mr failed\n"); | ||
251 | |||
244 | if (ib_dealloc_pd(priv->pd)) | 252 | if (ib_dealloc_pd(priv->pd)) |
245 | ipoib_warn(priv, "ib_dealloc_pd failed\n"); | 253 | ipoib_warn(priv, "ib_dealloc_pd failed\n"); |
246 | } | 254 | } |