aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/ehca
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-02-27 20:04:21 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:16 -0500
commitcbbbce1de2763cdf923b0e85c1a13877a6b61025 (patch)
tree224bd590bf07d2c081249583ac4b92afd597fc1a /drivers/infiniband/hw/ehca
parente8d4dd606bbd45bad2c4b867d5d91c284cd2828e (diff)
IB/ehca: convert to idr_alloc()
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Hoang-Nam Nguyen <hnguyen@de.ibm.com> Cc: Christoph Raisch <raisch@de.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/infiniband/hw/ehca')
-rw-r--r--drivers/infiniband/hw/ehca/ehca_cq.c27
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c34
2 files changed, 22 insertions, 39 deletions
diff --git a/drivers/infiniband/hw/ehca/ehca_cq.c b/drivers/infiniband/hw/ehca/ehca_cq.c
index 8f5290147e8a..212150c25ea0 100644
--- a/drivers/infiniband/hw/ehca/ehca_cq.c
+++ b/drivers/infiniband/hw/ehca/ehca_cq.c
@@ -128,7 +128,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
128 void *vpage; 128 void *vpage;
129 u32 counter; 129 u32 counter;
130 u64 rpage, cqx_fec, h_ret; 130 u64 rpage, cqx_fec, h_ret;
131 int ipz_rc, ret, i; 131 int ipz_rc, i;
132 unsigned long flags; 132 unsigned long flags;
133 133
134 if (cqe >= 0xFFFFFFFF - 64 - additional_cqe) 134 if (cqe >= 0xFFFFFFFF - 64 - additional_cqe)
@@ -163,32 +163,19 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
163 adapter_handle = shca->ipz_hca_handle; 163 adapter_handle = shca->ipz_hca_handle;
164 param.eq_handle = shca->eq.ipz_eq_handle; 164 param.eq_handle = shca->eq.ipz_eq_handle;
165 165
166 do { 166 idr_preload(GFP_KERNEL);
167 if (!idr_pre_get(&ehca_cq_idr, GFP_KERNEL)) { 167 write_lock_irqsave(&ehca_cq_idr_lock, flags);
168 cq = ERR_PTR(-ENOMEM); 168 my_cq->token = idr_alloc(&ehca_cq_idr, my_cq, 0, 0x2000000, GFP_NOWAIT);
169 ehca_err(device, "Can't reserve idr nr. device=%p", 169 write_unlock_irqrestore(&ehca_cq_idr_lock, flags);
170 device); 170 idr_preload_end();
171 goto create_cq_exit1;
172 }
173
174 write_lock_irqsave(&ehca_cq_idr_lock, flags);
175 ret = idr_get_new(&ehca_cq_idr, my_cq, &my_cq->token);
176 write_unlock_irqrestore(&ehca_cq_idr_lock, flags);
177 } while (ret == -EAGAIN);
178 171
179 if (ret) { 172 if (my_cq->token < 0) {
180 cq = ERR_PTR(-ENOMEM); 173 cq = ERR_PTR(-ENOMEM);
181 ehca_err(device, "Can't allocate new idr entry. device=%p", 174 ehca_err(device, "Can't allocate new idr entry. device=%p",
182 device); 175 device);
183 goto create_cq_exit1; 176 goto create_cq_exit1;
184 } 177 }
185 178
186 if (my_cq->token > 0x1FFFFFF) {
187 cq = ERR_PTR(-ENOMEM);
188 ehca_err(device, "Invalid number of cq. device=%p", device);
189 goto create_cq_exit2;
190 }
191
192 /* 179 /*
193 * CQs maximum depth is 4GB-64, but we need additional 20 as buffer 180 * CQs maximum depth is 4GB-64, but we need additional 20 as buffer
194 * for receiving errors CQEs. 181 * for receiving errors CQEs.
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index 149393915ae5..00d6861a6a18 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -636,30 +636,26 @@ static struct ehca_qp *internal_create_qp(
636 my_qp->send_cq = 636 my_qp->send_cq =
637 container_of(init_attr->send_cq, struct ehca_cq, ib_cq); 637 container_of(init_attr->send_cq, struct ehca_cq, ib_cq);
638 638
639 do { 639 idr_preload(GFP_KERNEL);
640 if (!idr_pre_get(&ehca_qp_idr, GFP_KERNEL)) { 640 write_lock_irqsave(&ehca_qp_idr_lock, flags);
641 ret = -ENOMEM;
642 ehca_err(pd->device, "Can't reserve idr resources.");
643 goto create_qp_exit0;
644 }
645 641
646 write_lock_irqsave(&ehca_qp_idr_lock, flags); 642 ret = idr_alloc(&ehca_qp_idr, my_qp, 0, 0x2000000, GFP_NOWAIT);
647 ret = idr_get_new(&ehca_qp_idr, my_qp, &my_qp->token); 643 if (ret >= 0)
648 write_unlock_irqrestore(&ehca_qp_idr_lock, flags); 644 my_qp->token = ret;
649 } while (ret == -EAGAIN);
650 645
651 if (ret) { 646 write_unlock_irqrestore(&ehca_qp_idr_lock, flags);
652 ret = -ENOMEM; 647 idr_preload_end();
653 ehca_err(pd->device, "Can't allocate new idr entry."); 648 if (ret < 0) {
649 if (ret == -ENOSPC) {
650 ret = -EINVAL;
651 ehca_err(pd->device, "Invalid number of qp");
652 } else {
653 ret = -ENOMEM;
654 ehca_err(pd->device, "Can't allocate new idr entry.");
655 }
654 goto create_qp_exit0; 656 goto create_qp_exit0;
655 } 657 }
656 658
657 if (my_qp->token > 0x1FFFFFF) {
658 ret = -EINVAL;
659 ehca_err(pd->device, "Invalid number of qp");
660 goto create_qp_exit1;
661 }
662
663 if (has_srq) 659 if (has_srq)
664 parms.srq_token = my_qp->token; 660 parms.srq_token = my_qp->token;
665 661