diff options
author | Bryan O'Sullivan <bos@pathscale.com> | 2006-09-28 12:00:04 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-09-28 14:16:35 -0400 |
commit | f3e93c7757043cd5d5c4879b8b92effcc7817c81 (patch) | |
tree | 0c0ea60bc3af804f34f400b5f63ac558e1d0c6bf /drivers | |
parent | aa4eaed702cb5d07babaaa04596436156b922249 (diff) |
IB/ipath: Count SRQs properly
Signed-off-by: Bryan O'Sullivan <bryan.osullivan@qlogic.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_srq.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_srq.c b/drivers/infiniband/hw/ipath/ipath_srq.c index 941e866d9517..94033503400c 100644 --- a/drivers/infiniband/hw/ipath/ipath_srq.c +++ b/drivers/infiniband/hw/ipath/ipath_srq.c | |||
@@ -104,11 +104,6 @@ struct ib_srq *ipath_create_srq(struct ib_pd *ibpd, | |||
104 | u32 sz; | 104 | u32 sz; |
105 | struct ib_srq *ret; | 105 | struct ib_srq *ret; |
106 | 106 | ||
107 | if (dev->n_srqs_allocated == ib_ipath_max_srqs) { | ||
108 | ret = ERR_PTR(-ENOMEM); | ||
109 | goto done; | ||
110 | } | ||
111 | |||
112 | if (srq_init_attr->attr.max_wr == 0) { | 107 | if (srq_init_attr->attr.max_wr == 0) { |
113 | ret = ERR_PTR(-EINVAL); | 108 | ret = ERR_PTR(-EINVAL); |
114 | goto done; | 109 | goto done; |
@@ -180,10 +175,17 @@ struct ib_srq *ipath_create_srq(struct ib_pd *ibpd, | |||
180 | spin_lock_init(&srq->rq.lock); | 175 | spin_lock_init(&srq->rq.lock); |
181 | srq->rq.wq->head = 0; | 176 | srq->rq.wq->head = 0; |
182 | srq->rq.wq->tail = 0; | 177 | srq->rq.wq->tail = 0; |
183 | srq->rq.max_sge = srq_init_attr->attr.max_sge; | ||
184 | srq->limit = srq_init_attr->attr.srq_limit; | 178 | srq->limit = srq_init_attr->attr.srq_limit; |
185 | 179 | ||
186 | dev->n_srqs_allocated++; | 180 | spin_lock(&dev->n_srqs_lock); |
181 | if (dev->n_srqs_allocated == ib_ipath_max_srqs) { | ||
182 | spin_unlock(&dev->n_srqs_lock); | ||
183 | ret = ERR_PTR(-ENOMEM); | ||
184 | goto bail_wq; | ||
185 | } | ||
186 | |||
187 | dev->n_srqs_allocated++; | ||
188 | spin_unlock(&dev->n_srqs_lock); | ||
187 | 189 | ||
188 | ret = &srq->ibsrq; | 190 | ret = &srq->ibsrq; |
189 | goto done; | 191 | goto done; |
@@ -351,8 +353,13 @@ int ipath_destroy_srq(struct ib_srq *ibsrq) | |||
351 | struct ipath_srq *srq = to_isrq(ibsrq); | 353 | struct ipath_srq *srq = to_isrq(ibsrq); |
352 | struct ipath_ibdev *dev = to_idev(ibsrq->device); | 354 | struct ipath_ibdev *dev = to_idev(ibsrq->device); |
353 | 355 | ||
356 | spin_lock(&dev->n_srqs_lock); | ||
354 | dev->n_srqs_allocated--; | 357 | dev->n_srqs_allocated--; |
355 | vfree(srq->rq.wq); | 358 | spin_unlock(&dev->n_srqs_lock); |
359 | if (srq->ip) | ||
360 | kref_put(&srq->ip->ref, ipath_release_mmap_info); | ||
361 | else | ||
362 | vfree(srq->rq.wq); | ||
356 | kfree(srq); | 363 | kfree(srq); |
357 | 364 | ||
358 | return 0; | 365 | return 0; |