RDMA/cxgb3: Don't ignore insert_handle() failures
Signed-off-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
This commit is contained in:
parent
a52bf98d99
commit
13a239330a
|
@ -39,7 +39,7 @@
|
||||||
#include "iwch.h"
|
#include "iwch.h"
|
||||||
#include "iwch_provider.h"
|
#include "iwch_provider.h"
|
||||||
|
|
||||||
static void iwch_finish_mem_reg(struct iwch_mr *mhp, u32 stag)
|
static int iwch_finish_mem_reg(struct iwch_mr *mhp, u32 stag)
|
||||||
{
|
{
|
||||||
u32 mmid;
|
u32 mmid;
|
||||||
|
|
||||||
|
@ -47,14 +47,15 @@ static void iwch_finish_mem_reg(struct iwch_mr *mhp, u32 stag)
|
||||||
mhp->attr.stag = stag;
|
mhp->attr.stag = stag;
|
||||||
mmid = stag >> 8;
|
mmid = stag >> 8;
|
||||||
mhp->ibmr.rkey = mhp->ibmr.lkey = stag;
|
mhp->ibmr.rkey = mhp->ibmr.lkey = stag;
|
||||||
insert_handle(mhp->rhp, &mhp->rhp->mmidr, mhp, mmid);
|
|
||||||
PDBG("%s mmid 0x%x mhp %p\n", __func__, mmid, mhp);
|
PDBG("%s mmid 0x%x mhp %p\n", __func__, mmid, mhp);
|
||||||
|
return insert_handle(mhp->rhp, &mhp->rhp->mmidr, mhp, mmid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php,
|
int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php,
|
||||||
struct iwch_mr *mhp, int shift)
|
struct iwch_mr *mhp, int shift)
|
||||||
{
|
{
|
||||||
u32 stag;
|
u32 stag;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (cxio_register_phys_mem(&rhp->rdev,
|
if (cxio_register_phys_mem(&rhp->rdev,
|
||||||
&stag, mhp->attr.pdid,
|
&stag, mhp->attr.pdid,
|
||||||
|
@ -66,9 +67,11 @@ int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php,
|
||||||
mhp->attr.pbl_size, mhp->attr.pbl_addr))
|
mhp->attr.pbl_size, mhp->attr.pbl_addr))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
iwch_finish_mem_reg(mhp, stag);
|
ret = iwch_finish_mem_reg(mhp, stag);
|
||||||
|
if (ret)
|
||||||
return 0;
|
cxio_dereg_mem(&rhp->rdev, mhp->attr.stag, mhp->attr.pbl_size,
|
||||||
|
mhp->attr.pbl_addr);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php,
|
int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php,
|
||||||
|
@ -77,6 +80,7 @@ int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php,
|
||||||
int npages)
|
int npages)
|
||||||
{
|
{
|
||||||
u32 stag;
|
u32 stag;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* We could support this... */
|
/* We could support this... */
|
||||||
if (npages > mhp->attr.pbl_size)
|
if (npages > mhp->attr.pbl_size)
|
||||||
|
@ -93,9 +97,12 @@ int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php,
|
||||||
mhp->attr.pbl_size, mhp->attr.pbl_addr))
|
mhp->attr.pbl_size, mhp->attr.pbl_addr))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
iwch_finish_mem_reg(mhp, stag);
|
ret = iwch_finish_mem_reg(mhp, stag);
|
||||||
|
if (ret)
|
||||||
|
cxio_dereg_mem(&rhp->rdev, mhp->attr.stag, mhp->attr.pbl_size,
|
||||||
|
mhp->attr.pbl_addr);
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int iwch_alloc_pbl(struct iwch_mr *mhp, int npages)
|
int iwch_alloc_pbl(struct iwch_mr *mhp, int npages)
|
||||||
|
|
|
@ -195,7 +195,11 @@ static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, int entries, int ve
|
||||||
spin_lock_init(&chp->lock);
|
spin_lock_init(&chp->lock);
|
||||||
atomic_set(&chp->refcnt, 1);
|
atomic_set(&chp->refcnt, 1);
|
||||||
init_waitqueue_head(&chp->wait);
|
init_waitqueue_head(&chp->wait);
|
||||||
insert_handle(rhp, &rhp->cqidr, chp, chp->cq.cqid);
|
if (insert_handle(rhp, &rhp->cqidr, chp, chp->cq.cqid)) {
|
||||||
|
cxio_destroy_cq(&chp->rhp->rdev, &chp->cq);
|
||||||
|
kfree(chp);
|
||||||
|
return ERR_PTR(-ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
if (ucontext) {
|
if (ucontext) {
|
||||||
struct iwch_mm_entry *mm;
|
struct iwch_mm_entry *mm;
|
||||||
|
@ -750,7 +754,11 @@ static struct ib_mw *iwch_alloc_mw(struct ib_pd *pd)
|
||||||
mhp->attr.stag = stag;
|
mhp->attr.stag = stag;
|
||||||
mmid = (stag) >> 8;
|
mmid = (stag) >> 8;
|
||||||
mhp->ibmw.rkey = stag;
|
mhp->ibmw.rkey = stag;
|
||||||
insert_handle(rhp, &rhp->mmidr, mhp, mmid);
|
if (insert_handle(rhp, &rhp->mmidr, mhp, mmid)) {
|
||||||
|
cxio_deallocate_window(&rhp->rdev, mhp->attr.stag);
|
||||||
|
kfree(mhp);
|
||||||
|
return ERR_PTR(-ENOMEM);
|
||||||
|
}
|
||||||
PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
|
PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
|
||||||
return &(mhp->ibmw);
|
return &(mhp->ibmw);
|
||||||
}
|
}
|
||||||
|
@ -778,37 +786,43 @@ static struct ib_mr *iwch_alloc_fast_reg_mr(struct ib_pd *pd, int pbl_depth)
|
||||||
struct iwch_mr *mhp;
|
struct iwch_mr *mhp;
|
||||||
u32 mmid;
|
u32 mmid;
|
||||||
u32 stag = 0;
|
u32 stag = 0;
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
php = to_iwch_pd(pd);
|
php = to_iwch_pd(pd);
|
||||||
rhp = php->rhp;
|
rhp = php->rhp;
|
||||||
mhp = kzalloc(sizeof(*mhp), GFP_KERNEL);
|
mhp = kzalloc(sizeof(*mhp), GFP_KERNEL);
|
||||||
if (!mhp)
|
if (!mhp)
|
||||||
return ERR_PTR(-ENOMEM);
|
goto err;
|
||||||
|
|
||||||
mhp->rhp = rhp;
|
mhp->rhp = rhp;
|
||||||
ret = iwch_alloc_pbl(mhp, pbl_depth);
|
ret = iwch_alloc_pbl(mhp, pbl_depth);
|
||||||
if (ret) {
|
if (ret)
|
||||||
kfree(mhp);
|
goto err1;
|
||||||
return ERR_PTR(ret);
|
|
||||||
}
|
|
||||||
mhp->attr.pbl_size = pbl_depth;
|
mhp->attr.pbl_size = pbl_depth;
|
||||||
ret = cxio_allocate_stag(&rhp->rdev, &stag, php->pdid,
|
ret = cxio_allocate_stag(&rhp->rdev, &stag, php->pdid,
|
||||||
mhp->attr.pbl_size, mhp->attr.pbl_addr);
|
mhp->attr.pbl_size, mhp->attr.pbl_addr);
|
||||||
if (ret) {
|
if (ret)
|
||||||
iwch_free_pbl(mhp);
|
goto err2;
|
||||||
kfree(mhp);
|
|
||||||
return ERR_PTR(ret);
|
|
||||||
}
|
|
||||||
mhp->attr.pdid = php->pdid;
|
mhp->attr.pdid = php->pdid;
|
||||||
mhp->attr.type = TPT_NON_SHARED_MR;
|
mhp->attr.type = TPT_NON_SHARED_MR;
|
||||||
mhp->attr.stag = stag;
|
mhp->attr.stag = stag;
|
||||||
mhp->attr.state = 1;
|
mhp->attr.state = 1;
|
||||||
mmid = (stag) >> 8;
|
mmid = (stag) >> 8;
|
||||||
mhp->ibmr.rkey = mhp->ibmr.lkey = stag;
|
mhp->ibmr.rkey = mhp->ibmr.lkey = stag;
|
||||||
insert_handle(rhp, &rhp->mmidr, mhp, mmid);
|
if (insert_handle(rhp, &rhp->mmidr, mhp, mmid))
|
||||||
|
goto err3;
|
||||||
|
|
||||||
PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
|
PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
|
||||||
return &(mhp->ibmr);
|
return &(mhp->ibmr);
|
||||||
|
err3:
|
||||||
|
cxio_dereg_mem(&rhp->rdev, stag, mhp->attr.pbl_size,
|
||||||
|
mhp->attr.pbl_addr);
|
||||||
|
err2:
|
||||||
|
iwch_free_pbl(mhp);
|
||||||
|
err1:
|
||||||
|
kfree(mhp);
|
||||||
|
err:
|
||||||
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ib_fast_reg_page_list *iwch_alloc_fastreg_pbl(
|
static struct ib_fast_reg_page_list *iwch_alloc_fastreg_pbl(
|
||||||
|
@ -961,7 +975,13 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
|
||||||
spin_lock_init(&qhp->lock);
|
spin_lock_init(&qhp->lock);
|
||||||
init_waitqueue_head(&qhp->wait);
|
init_waitqueue_head(&qhp->wait);
|
||||||
atomic_set(&qhp->refcnt, 1);
|
atomic_set(&qhp->refcnt, 1);
|
||||||
insert_handle(rhp, &rhp->qpidr, qhp, qhp->wq.qpid);
|
|
||||||
|
if (insert_handle(rhp, &rhp->qpidr, qhp, qhp->wq.qpid)) {
|
||||||
|
cxio_destroy_qp(&rhp->rdev, &qhp->wq,
|
||||||
|
ucontext ? &ucontext->uctx : &rhp->rdev.uctx);
|
||||||
|
kfree(qhp);
|
||||||
|
return ERR_PTR(-ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
if (udata) {
|
if (udata) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue