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>
This commit is contained in:
Родитель
e8d4dd606b
Коммит
cbbbce1de2
|
@ -128,7 +128,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
|
||||||
void *vpage;
|
void *vpage;
|
||||||
u32 counter;
|
u32 counter;
|
||||||
u64 rpage, cqx_fec, h_ret;
|
u64 rpage, cqx_fec, h_ret;
|
||||||
int ipz_rc, ret, i;
|
int ipz_rc, i;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (cqe >= 0xFFFFFFFF - 64 - additional_cqe)
|
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,
|
||||||
adapter_handle = shca->ipz_hca_handle;
|
adapter_handle = shca->ipz_hca_handle;
|
||||||
param.eq_handle = shca->eq.ipz_eq_handle;
|
param.eq_handle = shca->eq.ipz_eq_handle;
|
||||||
|
|
||||||
do {
|
idr_preload(GFP_KERNEL);
|
||||||
if (!idr_pre_get(&ehca_cq_idr, GFP_KERNEL)) {
|
|
||||||
cq = ERR_PTR(-ENOMEM);
|
|
||||||
ehca_err(device, "Can't reserve idr nr. device=%p",
|
|
||||||
device);
|
|
||||||
goto create_cq_exit1;
|
|
||||||
}
|
|
||||||
|
|
||||||
write_lock_irqsave(&ehca_cq_idr_lock, flags);
|
write_lock_irqsave(&ehca_cq_idr_lock, flags);
|
||||||
ret = idr_get_new(&ehca_cq_idr, my_cq, &my_cq->token);
|
my_cq->token = idr_alloc(&ehca_cq_idr, my_cq, 0, 0x2000000, GFP_NOWAIT);
|
||||||
write_unlock_irqrestore(&ehca_cq_idr_lock, flags);
|
write_unlock_irqrestore(&ehca_cq_idr_lock, flags);
|
||||||
} while (ret == -EAGAIN);
|
idr_preload_end();
|
||||||
|
|
||||||
if (ret) {
|
if (my_cq->token < 0) {
|
||||||
cq = ERR_PTR(-ENOMEM);
|
cq = ERR_PTR(-ENOMEM);
|
||||||
ehca_err(device, "Can't allocate new idr entry. device=%p",
|
ehca_err(device, "Can't allocate new idr entry. device=%p",
|
||||||
device);
|
device);
|
||||||
goto create_cq_exit1;
|
goto create_cq_exit1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (my_cq->token > 0x1FFFFFF) {
|
|
||||||
cq = ERR_PTR(-ENOMEM);
|
|
||||||
ehca_err(device, "Invalid number of cq. device=%p", device);
|
|
||||||
goto create_cq_exit2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CQs maximum depth is 4GB-64, but we need additional 20 as buffer
|
* CQs maximum depth is 4GB-64, but we need additional 20 as buffer
|
||||||
* for receiving errors CQEs.
|
* for receiving errors CQEs.
|
||||||
|
|
|
@ -636,28 +636,24 @@ static struct ehca_qp *internal_create_qp(
|
||||||
my_qp->send_cq =
|
my_qp->send_cq =
|
||||||
container_of(init_attr->send_cq, struct ehca_cq, ib_cq);
|
container_of(init_attr->send_cq, struct ehca_cq, ib_cq);
|
||||||
|
|
||||||
do {
|
idr_preload(GFP_KERNEL);
|
||||||
if (!idr_pre_get(&ehca_qp_idr, GFP_KERNEL)) {
|
|
||||||
ret = -ENOMEM;
|
|
||||||
ehca_err(pd->device, "Can't reserve idr resources.");
|
|
||||||
goto create_qp_exit0;
|
|
||||||
}
|
|
||||||
|
|
||||||
write_lock_irqsave(&ehca_qp_idr_lock, flags);
|
write_lock_irqsave(&ehca_qp_idr_lock, flags);
|
||||||
ret = idr_get_new(&ehca_qp_idr, my_qp, &my_qp->token);
|
|
||||||
|
ret = idr_alloc(&ehca_qp_idr, my_qp, 0, 0x2000000, GFP_NOWAIT);
|
||||||
|
if (ret >= 0)
|
||||||
|
my_qp->token = ret;
|
||||||
|
|
||||||
write_unlock_irqrestore(&ehca_qp_idr_lock, flags);
|
write_unlock_irqrestore(&ehca_qp_idr_lock, flags);
|
||||||
} while (ret == -EAGAIN);
|
idr_preload_end();
|
||||||
|
if (ret < 0) {
|
||||||
if (ret) {
|
if (ret == -ENOSPC) {
|
||||||
ret = -ENOMEM;
|
|
||||||
ehca_err(pd->device, "Can't allocate new idr entry.");
|
|
||||||
goto create_qp_exit0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (my_qp->token > 0x1FFFFFF) {
|
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
ehca_err(pd->device, "Invalid number of qp");
|
ehca_err(pd->device, "Invalid number of qp");
|
||||||
goto create_qp_exit1;
|
} else {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
ehca_err(pd->device, "Can't allocate new idr entry.");
|
||||||
|
}
|
||||||
|
goto create_qp_exit0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_srq)
|
if (has_srq)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче