diff mbox

[WIP,24/43] cxgb3: Allocate a provate page list in ib_alloc_mr

Message ID 1437548143-24893-25-git-send-email-sagig@mellanox.com (mailing list archive)
State RFC
Headers show

Commit Message

Sagi Grimberg July 22, 2015, 6:55 a.m. UTC
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
---
 drivers/infiniband/hw/cxgb3/iwch_provider.c | 9 +++++++++
 drivers/infiniband/hw/cxgb3/iwch_provider.h | 2 ++
 2 files changed, 11 insertions(+)
diff mbox

Patch

diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c
index af55b79..c9368e6 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c
@@ -463,6 +463,7 @@  static int iwch_dereg_mr(struct ib_mr *ib_mr)
 		return -EINVAL;
 
 	mhp = to_iwch_mr(ib_mr);
+	kfree(mhp->pl);
 	rhp = mhp->rhp;
 	mmid = mhp->attr.stag >> 8;
 	cxio_dereg_mem(&rhp->rdev, mhp->attr.stag, mhp->attr.pbl_size,
@@ -817,6 +818,12 @@  static struct ib_mr *iwch_alloc_mr(struct ib_pd *pd,
 	if (!mhp)
 		goto err;
 
+	mhp->pl = kcalloc(max_entries, sizeof(u64), GFP_KERNEL);
+	if (!mhp->pl) {
+		ret = -ENOMEM;
+		goto pl_err;
+	}
+
 	mhp->rhp = rhp;
 	ret = iwch_alloc_pbl(mhp, max_entries);
 	if (ret)
@@ -843,6 +850,8 @@  err3:
 err2:
 	iwch_free_pbl(mhp);
 err1:
+	kfree(mhp->pl);
+pl_err:
 	kfree(mhp);
 err:
 	return ERR_PTR(ret);
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.h b/drivers/infiniband/hw/cxgb3/iwch_provider.h
index 87c14b0..8e16da9 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.h
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.h
@@ -77,6 +77,8 @@  struct iwch_mr {
 	struct iwch_dev *rhp;
 	u64 kva;
 	struct tpt_attributes attr;
+	u64 *pl;
+	u32 npages;
 };
 
 typedef struct iwch_mw iwch_mw_handle;