aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/ipath/ipath_cq.c
diff options
context:
space:
mode:
authorBryan O'Sullivan <bos@pathscale.com>2006-07-01 07:35:58 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-07-01 12:55:59 -0400
commitfe62546a6afa141c4ab9aef65f5978a1b36cb523 (patch)
tree44b317774fc0db45e90c394a1575bb19d08c00bb /drivers/infiniband/hw/ipath/ipath_cq.c
parente8a88f09f21c55a7e7f570290ecde570e2c37771 (diff)
[PATCH] IB/ipath: enforce device resource limits
These limits are somewhat artificial in that we don't actually have any device limits. However, the verbs layer expects that such limits exist and are enforced, so we make up arbitrary (but sensible) limits. Signed-off-by: Robert Walsh <robert.walsh@qlogic.com> Signed-off-by: Bryan O'Sullivan <bryan.osullivan@qlogic.com> Cc: "Michael S. Tsirkin" <mst@mellanox.co.il> Cc: Roland Dreier <rolandd@cisco.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_cq.c')
-rw-r--r--drivers/infiniband/hw/ipath/ipath_cq.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_cq.c b/drivers/infiniband/hw/ipath/ipath_cq.c
index 392eeb394637..3efee341c9bc 100644
--- a/drivers/infiniband/hw/ipath/ipath_cq.c
+++ b/drivers/infiniband/hw/ipath/ipath_cq.c
@@ -158,10 +158,21 @@ struct ib_cq *ipath_create_cq(struct ib_device *ibdev, int entries,
158 struct ib_ucontext *context, 158 struct ib_ucontext *context,
159 struct ib_udata *udata) 159 struct ib_udata *udata)
160{ 160{
161 struct ipath_ibdev *dev = to_idev(ibdev);
161 struct ipath_cq *cq; 162 struct ipath_cq *cq;
162 struct ib_wc *wc; 163 struct ib_wc *wc;
163 struct ib_cq *ret; 164 struct ib_cq *ret;
164 165
166 if (entries > ib_ipath_max_cqes) {
167 ret = ERR_PTR(-EINVAL);
168 goto bail;
169 }
170
171 if (dev->n_cqs_allocated == ib_ipath_max_cqs) {
172 ret = ERR_PTR(-ENOMEM);
173 goto bail;
174 }
175
165 /* 176 /*
166 * Need to use vmalloc() if we want to support large #s of 177 * Need to use vmalloc() if we want to support large #s of
167 * entries. 178 * entries.
@@ -197,6 +208,8 @@ struct ib_cq *ipath_create_cq(struct ib_device *ibdev, int entries,
197 208
198 ret = &cq->ibcq; 209 ret = &cq->ibcq;
199 210
211 dev->n_cqs_allocated++;
212
200bail: 213bail:
201 return ret; 214 return ret;
202} 215}
@@ -211,9 +224,11 @@ bail:
211 */ 224 */
212int ipath_destroy_cq(struct ib_cq *ibcq) 225int ipath_destroy_cq(struct ib_cq *ibcq)
213{ 226{
227 struct ipath_ibdev *dev = to_idev(ibcq->device);
214 struct ipath_cq *cq = to_icq(ibcq); 228 struct ipath_cq *cq = to_icq(ibcq);
215 229
216 tasklet_kill(&cq->comptask); 230 tasklet_kill(&cq->comptask);
231 dev->n_cqs_allocated--;
217 vfree(cq->queue); 232 vfree(cq->queue);
218 kfree(cq); 233 kfree(cq);
219 234