aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw
diff options
context:
space:
mode:
authorBryan O'Sullivan <bos@pathscale.com>2006-09-28 12:00:03 -0400
committerRoland Dreier <rolandd@cisco.com>2006-09-28 14:16:34 -0400
commitaa4eaed702cb5d07babaaa04596436156b922249 (patch)
treea191d501fe979fb9440859a4155bb1efac4a797e /drivers/infiniband/hw
parent11b054fe1d453954449a86de178bb98274bb86ef (diff)
IB/ipath: Lock and count allocated CQs properly
Signed-off-by: Bryan O'Sullivan <bryan.osullivan@qlogic.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r--drivers/infiniband/hw/ipath/ipath_cq.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_cq.c b/drivers/infiniband/hw/ipath/ipath_cq.c
index 049221bc590e..00440d5c91e0 100644
--- a/drivers/infiniband/hw/ipath/ipath_cq.c
+++ b/drivers/infiniband/hw/ipath/ipath_cq.c
@@ -177,11 +177,6 @@ struct ib_cq *ipath_create_cq(struct ib_device *ibdev, int entries,
177 goto done; 177 goto done;
178 } 178 }
179 179
180 if (dev->n_cqs_allocated == ib_ipath_max_cqs) {
181 ret = ERR_PTR(-ENOMEM);
182 goto done;
183 }
184
185 /* Allocate the completion queue structure. */ 180 /* Allocate the completion queue structure. */
186 cq = kmalloc(sizeof(*cq), GFP_KERNEL); 181 cq = kmalloc(sizeof(*cq), GFP_KERNEL);
187 if (!cq) { 182 if (!cq) {
@@ -237,6 +232,16 @@ struct ib_cq *ipath_create_cq(struct ib_device *ibdev, int entries,
237 } else 232 } else
238 cq->ip = NULL; 233 cq->ip = NULL;
239 234
235 spin_lock(&dev->n_cqs_lock);
236 if (dev->n_cqs_allocated == ib_ipath_max_cqs) {
237 spin_unlock(&dev->n_cqs_lock);
238 ret = ERR_PTR(-ENOMEM);
239 goto bail_wc;
240 }
241
242 dev->n_cqs_allocated++;
243 spin_unlock(&dev->n_cqs_lock);
244
240 /* 245 /*
241 * ib_create_cq() will initialize cq->ibcq except for cq->ibcq.cqe. 246 * ib_create_cq() will initialize cq->ibcq except for cq->ibcq.cqe.
242 * The number of entries should be >= the number requested or return 247 * The number of entries should be >= the number requested or return
@@ -253,7 +258,6 @@ struct ib_cq *ipath_create_cq(struct ib_device *ibdev, int entries,
253 258
254 ret = &cq->ibcq; 259 ret = &cq->ibcq;
255 260
256 dev->n_cqs_allocated++;
257 goto done; 261 goto done;
258 262
259bail_wc: 263bail_wc:
@@ -280,7 +284,9 @@ int ipath_destroy_cq(struct ib_cq *ibcq)
280 struct ipath_cq *cq = to_icq(ibcq); 284 struct ipath_cq *cq = to_icq(ibcq);
281 285
282 tasklet_kill(&cq->comptask); 286 tasklet_kill(&cq->comptask);
287 spin_lock(&dev->n_cqs_lock);
283 dev->n_cqs_allocated--; 288 dev->n_cqs_allocated--;
289 spin_unlock(&dev->n_cqs_lock);
284 if (cq->ip) 290 if (cq->ip)
285 kref_put(&cq->ip->ref, ipath_release_mmap_info); 291 kref_put(&cq->ip->ref, ipath_release_mmap_info);
286 else 292 else