summaryrefslogtreecommitdiff
path: root/drivers/infiniband/hw/ipath/ipath_qp.c
diff options
context:
space:
mode:
authorBryan O'Sullivan <bos@pathscale.com>2006-08-25 22:24:43 +0400
committerRoland Dreier <rolandd@cisco.com>2006-09-23 02:22:38 +0400
commit0b81e4f79af8322c7142701982f40d1431dedf19 (patch)
tree4d1161d8603471cbe8ece750980eb22767a91235 /drivers/infiniband/hw/ipath/ipath_qp.c
parentca4ce383acfb05b8035453cdbbfd4f8ae36c7a69 (diff)
downloadlinux-0b81e4f79af8322c7142701982f40d1431dedf19.tar.xz
IB/ipath: put a limit on the number of QPs that can be created
Signed-off-by: Bryan O'Sullivan <bryan.osullivan@qlogic.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_qp.c')
-rw-r--r--drivers/infiniband/hw/ipath/ipath_qp.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c
index 77391886d2f8..607ba72af2fa 100644
--- a/drivers/infiniband/hw/ipath/ipath_qp.c
+++ b/drivers/infiniband/hw/ipath/ipath_qp.c
@@ -833,9 +833,21 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
}
}
+ spin_lock(&dev->n_qps_lock);
+ if (dev->n_qps_allocated == ib_ipath_max_qps) {
+ spin_unlock(&dev->n_qps_lock);
+ ret = ERR_PTR(-ENOMEM);
+ goto bail_ip;
+ }
+
+ dev->n_qps_allocated++;
+ spin_unlock(&dev->n_qps_lock);
+
ret = &qp->ibqp;
goto bail;
+bail_ip:
+ kfree(qp->ip);
bail_rwq:
vfree(qp->r_rq.wq);
bail_qp:
@@ -864,6 +876,9 @@ int ipath_destroy_qp(struct ib_qp *ibqp)
spin_lock_irqsave(&qp->s_lock, flags);
qp->state = IB_QPS_ERR;
spin_unlock_irqrestore(&qp->s_lock, flags);
+ spin_lock(&dev->n_qps_lock);
+ dev->n_qps_allocated--;
+ spin_unlock(&dev->n_qps_lock);
/* Stop the sending tasklet. */
tasklet_kill(&qp->s_task);