Skip to contentSkip to conversation

RDMA/irdma: Add support for dmabuf pin memory regions

PATCH Superseded Zhu Yanjun 4 participants 7 messages Feb 1, 2023 – Feb 17, 2023

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Zhu Yanjun

author
#0 lore raw

PATCH v3 1/1 RDMA/irdma: Add support for dmabuf pin memory regions

From: Zhu Yanjun <[email protected]>

This is a followup to the EFA dmabuf[1]. Irdma driver currently does not support on-demand-paging(ODP). So it uses habanalabs as the dmabuf exporter, and irdma as the importer to allow for peer2peer access through libibverbs.

In this commit, the function ib_umem_dmabuf_get_pinned() is used. This function is introduced in EFA dmabuf[1] which allows the driver to get a dmabuf umem which is pinned and does not require move_notify callback implementation. The returned umem is pinned and DMA mapped like standard cpu umems, and is released through ib_umem_release().

[1]https://lore.kernel.org/lkml/[email protected]/t/

---

V2->V3: Remove unnecessary variable initialization;
        Use error handler;
V1->V2: Thanks Shiraz Saleem, he gave me a lot of good suggestions.
        This commit is based on the shared functions from refactored
        irdma_reg_user_mr.
---
 drivers/infiniband/hw/irdma/verbs.c | 45 +++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
drivers/infiniband/hw/irdma/verbs.c +45 -0
index 6982f38596c8..7525f4cdf6fb 100644
@@ -2977,6 +2977,50 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
 	return ERR_PTR(err);
 }
 
+static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
+					      u64 len, u64 virt,
+					      int fd, int access,
+					      struct ib_udata *udata)
+{
+	struct irdma_device *iwdev = to_iwdev(pd->device);
+	struct ib_umem_dmabuf *umem_dmabuf;
+	struct irdma_mr *iwmr;
+	int err;
+
+	if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)
+		return ERR_PTR(-EINVAL);
+
+	if (udata->inlen < IRDMA_MEM_REG_MIN_REQ_LEN)
+		return ERR_PTR(-EINVAL);
+
+	umem_dmabuf = ib_umem_dmabuf_get_pinned(pd->device, start, len, fd, access);
+	if (IS_ERR(umem_dmabuf)) {
+		err = PTR_ERR(umem_dmabuf);
+		ibdev_dbg(&iwdev->ibdev, "Failed to get dmabuf umem[%d]\n", err);
+		return ERR_PTR(err);
+	}
+
+	iwmr = irdma_alloc_iwmr(&umem_dmabuf->umem, pd, virt, IRDMA_MEMREG_TYPE_MEM);
+	if (IS_ERR(iwmr)) {
+		err = PTR_ERR(iwmr);
+		goto err_release;
+	}
+
+	err = irdma_reg_user_mr_type_mem(iwmr, access);
+	if (err)
+		goto err_iwmr;
+
+	return &iwmr->ibmr;
+
+err_iwmr:
+	irdma_free_iwmr(iwmr);
+
+err_release:
+	ib_umem_release(&umem_dmabuf->umem);
+
+	return ERR_PTR(err);
+}
+
 /**
  * irdma_reg_phys_mr - register kernel physical memory
  * @pd: ibpd pointer
@@ -4483,6 +4527,7 @@ static const struct ib_device_ops irdma_dev_ops = {
 	.query_port = irdma_query_port,
 	.query_qp = irdma_query_qp,
 	.reg_user_mr = irdma_reg_user_mr,
+	.reg_user_mr_dmabuf = irdma_reg_user_mr_dmabuf,
 	.req_notify_cq = irdma_req_notify_cq,
 	.resize_cq = irdma_resize_cq,
 	INIT_RDMA_OBJ_SIZE(ib_pd, irdma_pd, ibpd),
Signature · 1 line
2.27.0
#1 lore raw
Quoted 15 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

This is a followup to the EFA dmabuf[1]. Irdma driver currently does not support on-demand-paging(ODP). So it uses habanalabs as the dmabuf exporter, and irdma as the importer to allow for peer2peer access through libibverbs.

In this commit, the function ib_umem_dmabuf_get_pinned() is used. This function is introduced in EFA dmabuf[1] which allows the driver to get a dmabuf umem which is pinned and does not require move_notify callback implementation. The returned umem is pinned and DMA mapped like standard cpu umems, and is released through ib_umem_release().

[1]https://lore.kernel.org/lkml/[email protected]/t/

Quoted 7 lines

---

V2->V3: Remove unnecessary variable initialization;
         Use error handler;

V1->V2: Thanks Shiraz Saleem, he gave me a lot of good suggestions.
This commit is based on the shared functions from refactored irdma_reg_user_mr.

Shiraz Saleem is on vacation and returning to office on Feb.13, 2023. We can wait for him.

Zhu Yanjun

Quoted 67 lines
---
  drivers/infiniband/hw/irdma/verbs.c | 45 +++++++++++++++++++++++++++++
  1 file changed, 45 insertions(+)
drivers/infiniband/hw/irdma/verbs.c +45 -0
index 6982f38596c8..7525f4cdf6fb 100644
@@ -2977,6 +2977,50 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
  	return ERR_PTR(err);
  }
 
+static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
+					      u64 len, u64 virt,
+					      int fd, int access,
+					      struct ib_udata *udata)
+{
+	struct irdma_device *iwdev = to_iwdev(pd->device);
+	struct ib_umem_dmabuf *umem_dmabuf;
+	struct irdma_mr *iwmr;
+	int err;
+
+	if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)
+		return ERR_PTR(-EINVAL);
+
+	if (udata->inlen < IRDMA_MEM_REG_MIN_REQ_LEN)
+		return ERR_PTR(-EINVAL);
+
+	umem_dmabuf = ib_umem_dmabuf_get_pinned(pd->device, start, len, fd, access);
+	if (IS_ERR(umem_dmabuf)) {
+		err = PTR_ERR(umem_dmabuf);
+		ibdev_dbg(&iwdev->ibdev, "Failed to get dmabuf umem[%d]\n", err);
+		return ERR_PTR(err);
+	}
+
+	iwmr = irdma_alloc_iwmr(&umem_dmabuf->umem, pd, virt, IRDMA_MEMREG_TYPE_MEM);
+	if (IS_ERR(iwmr)) {
+		err = PTR_ERR(iwmr);
+		goto err_release;
+	}
+
+	err = irdma_reg_user_mr_type_mem(iwmr, access);
+	if (err)
+		goto err_iwmr;
+
+	return &iwmr->ibmr;
+
+err_iwmr:
+	irdma_free_iwmr(iwmr);
+
+err_release:
+	ib_umem_release(&umem_dmabuf->umem);
+
+	return ERR_PTR(err);
+}
+
  /**
   * irdma_reg_phys_mr - register kernel physical memory
   * @pd: ibpd pointer
@@ -4483,6 +4527,7 @@ static const struct ib_device_ops irdma_dev_ops = {
  	.query_port = irdma_query_port,
  	.query_qp = irdma_query_qp,
  	.reg_user_mr = irdma_reg_user_mr,
+	.reg_user_mr_dmabuf = irdma_reg_user_mr_dmabuf,
  	.req_notify_cq = irdma_req_notify_cq,
  	.resize_cq = irdma_resize_cq,
  	INIT_RDMA_OBJ_SIZE(ib_pd, irdma_pd, ibpd),
Reviewed-by on v3 1/1
#2 lore raw
In reply to Zhu Yanjun
Quoted 42 lines

Subject: [PATCHv3 for-next 1/1] RDMA/irdma: Add support for dmabuf pin memory regions

From: Zhu Yanjun <[email protected]>

This is a followup to the EFA dmabuf[1]. Irdma driver currently does not support on-demand-paging(ODP). So it uses habanalabs as the dmabuf exporter, and irdma as the importer to allow for peer2peer access through libibverbs.

In this commit, the function ib_umem_dmabuf_get_pinned() is used. This function is introduced in EFA dmabuf[1] which allows the driver to get a dmabuf umem which is pinned and does not require move_notify callback implementation. The returned umem is pinned and DMA mapped like standard cpu umems, and is released through ib_umem_release().

[1]https://lore.kernel.org/lkml/[email protected]/t/

---

V2->V3: Remove unnecessary variable initialization;
        Use error handler;
V1->V2: Thanks Shiraz Saleem, he gave me a lot of good suggestions.
        This commit is based on the shared functions from refactored
        irdma_reg_user_mr.
---
 drivers/infiniband/hw/irdma/verbs.c | 45 +++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
drivers/infiniband/hw/irdma/verbs.c +5 -0
index 6982f38596c8..7525f4cdf6fb 100644
@@ -2977,6 +2977,50 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd
 *pd, u64 start, u64 len,
 	return ERR_PTR(err);
 }
 
+static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
+					      u64 len, u64 virt,
+					      int fd, int access,
+					      struct ib_udata *udata)
+{

drivers/infiniband/hw/irdma/verbs.c static struct ib_mr *irdma_reg_user_mr(struct ib_pd · line 2995

Quoted 10 lines
drivers/infiniband/hw/irdma/verbs.c +10 -0
+	struct irdma_device *iwdev = to_iwdev(pd->device);
+	struct ib_umem_dmabuf *umem_dmabuf;
+	struct irdma_mr *iwmr;
+	int err;
+
+	if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)
+		return ERR_PTR(-EINVAL);
+
+	if (udata->inlen < IRDMA_MEM_REG_MIN_REQ_LEN)
+		return ERR_PTR(-EINVAL);

Do we need this? we don't copy anything from udata. There is no info passed via ABI struct irdma_mem_reg_req.

Quoted 36 lines
drivers/infiniband/hw/irdma/verbs.c +9 -0
+
+	umem_dmabuf = ib_umem_dmabuf_get_pinned(pd->device, start, len, fd,
 access);
+	if (IS_ERR(umem_dmabuf)) {
+		err = PTR_ERR(umem_dmabuf);
+		ibdev_dbg(&iwdev->ibdev, "Failed to get dmabuf umem[%d]\n",
 err);
+		return ERR_PTR(err);
+	}
+
+	iwmr = irdma_alloc_iwmr(&umem_dmabuf->umem, pd, virt,

IRDMA_MEMREG_TYPE_MEM);

drivers/infiniband/hw/irdma/verbs.c +20 -0
+	if (IS_ERR(iwmr)) {
+		err = PTR_ERR(iwmr);
+		goto err_release;
+	}
+
+	err = irdma_reg_user_mr_type_mem(iwmr, access);
+	if (err)
+		goto err_iwmr;
+
+	return &iwmr->ibmr;
+
+err_iwmr:
+	irdma_free_iwmr(iwmr);
+
+err_release:
+	ib_umem_release(&umem_dmabuf->umem);
+
+	return ERR_PTR(err);
+}
+
 /**
  * irdma_reg_phys_mr - register kernel physical memory
  * @pd: ibpd pointer

drivers/infiniband/hw/irdma/verbs.c static const struct ib_device_ops irdma_dev_ops = {

Quoted 8 lines
drivers/infiniband/hw/irdma/verbs.c +1 -1
@@ -4483,6 +4527,7 @@ static const struct ib_device_ops irdma_dev_ops = {
 	.query_port = irdma_query_port,
 	.query_qp = irdma_query_qp,
 	.reg_user_mr = irdma_reg_user_mr,
+	.reg_user_mr_dmabuf = irdma_reg_user_mr_dmabuf,
 	.req_notify_cq = irdma_req_notify_cq,
 	.resize_cq = irdma_resize_cq,
 	INIT_RDMA_OBJ_SIZE(ib_pd, irdma_pd, ibpd),
--
#3 lore raw
Quoted 37 lines · Shiraz
Quoted 37 lines

Subject: [PATCHv3 for-next 1/1] RDMA/irdma: Add support for dmabuf pin memory regions

From: Zhu Yanjun <[email protected]>

This is a followup to the EFA dmabuf[1]. Irdma driver currently does not support on-demand-paging(ODP). So it uses habanalabs as the dmabuf exporter, and irdma as the importer to allow for peer2peer access through libibverbs.

In this commit, the function ib_umem_dmabuf_get_pinned() is used. This function is introduced in EFA dmabuf[1] which allows the driver to get a dmabuf umem which is pinned and does not require move_notify callback implementation. The returned umem is pinned and DMA mapped like standard cpu umems, and is released through ib_umem_release().

[1]https://lore.kernel.org/lkml/[email protected]/t/

---

V2->V3: Remove unnecessary variable initialization;
         Use error handler;
V1->V2: Thanks Shiraz Saleem, he gave me a lot of good suggestions.
         This commit is based on the shared functions from refactored
         irdma_reg_user_mr.
---
  drivers/infiniband/hw/irdma/verbs.c | 45 +++++++++++++++++++++++++++++
  1 file changed, 45 insertions(+)
drivers/infiniband/hw/irdma/verbs.c +0 -0
index 6982f38596c8..7525f4cdf6fb 100644
@@ -2977,6 +2977,50 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd
 *pd, u64 start, u64 len,
  	return ERR_PTR(err);
  }
 
Quoted 16 lines
Quoted 5 lines
drivers/infiniband/hw/irdma/verbs.c +5 -0
+static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
+					      u64 len, u64 virt,
+					      int fd, int access,
+					      struct ib_udata *udata)
+{

drivers/infiniband/hw/irdma/verbs.c static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len, · line 2994

Quoted 10 lines
drivers/infiniband/hw/irdma/verbs.c +10 -0
+	struct irdma_device *iwdev = to_iwdev(pd->device);
+	struct ib_umem_dmabuf *umem_dmabuf;
+	struct irdma_mr *iwmr;
+	int err;
+
+	if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)
+		return ERR_PTR(-EINVAL);
+
+	if (udata->inlen < IRDMA_MEM_REG_MIN_REQ_LEN)
+		return ERR_PTR(-EINVAL);

Do we need this? we don't copy anything from udata. There is no info passed via ABI struct irdma_mem_reg_req.

Got it. I will remove the inlen test and send a new commit out.

Quoted 38 lines
Quoted 38 lines
drivers/infiniband/hw/irdma/verbs.c +9 -0
+
+	umem_dmabuf = ib_umem_dmabuf_get_pinned(pd->device, start, len, fd,
 access);
+	if (IS_ERR(umem_dmabuf)) {
+		err = PTR_ERR(umem_dmabuf);
+		ibdev_dbg(&iwdev->ibdev, "Failed to get dmabuf umem[%d]\n",
 err);
+		return ERR_PTR(err);
+	}
+
+	iwmr = irdma_alloc_iwmr(&umem_dmabuf->umem, pd, virt,

IRDMA_MEMREG_TYPE_MEM);

drivers/infiniband/hw/irdma/verbs.c +20 -0
+	if (IS_ERR(iwmr)) {
+		err = PTR_ERR(iwmr);
+		goto err_release;
+	}
+
+	err = irdma_reg_user_mr_type_mem(iwmr, access);
+	if (err)
+		goto err_iwmr;
+
+	return &iwmr->ibmr;
+
+err_iwmr:
+	irdma_free_iwmr(iwmr);
+
+err_release:
+	ib_umem_release(&umem_dmabuf->umem);
+
+	return ERR_PTR(err);
+}
+
  /**
   * irdma_reg_phys_mr - register kernel physical memory
   * @pd: ibpd pointer
@@ -4483,6 +4527,7 @@ static const struct ib_device_ops irdma_dev_ops = {
  	.query_port = irdma_query_port,
Quoted 8 lines

drivers/infiniband/hw/irdma/verbs.c static const struct ib_device_ops irdma_dev_ops = {

Quoted 7 lines
drivers/infiniband/hw/irdma/verbs.c +1 -1
  	.query_qp = irdma_query_qp,
  	.reg_user_mr = irdma_reg_user_mr,
+	.reg_user_mr_dmabuf = irdma_reg_user_mr_dmabuf,
  	.req_notify_cq = irdma_req_notify_cq,
  	.resize_cq = irdma_resize_cq,
  	INIT_RDMA_OBJ_SIZE(ib_pd, irdma_pd, ibpd),
--

Thanks.

Zhu Yanjun

Quoted 1 line
maintainer
#4 lore raw
In reply to Zhu Yanjun
Quoted 40 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

This is a followup to the EFA dmabuf[1]. Irdma driver currently does not support on-demand-paging(ODP). So it uses habanalabs as the dmabuf exporter, and irdma as the importer to allow for peer2peer access through libibverbs.

In this commit, the function ib_umem_dmabuf_get_pinned() is used. This function is introduced in EFA dmabuf[1] which allows the driver to get a dmabuf umem which is pinned and does not require move_notify callback implementation. The returned umem is pinned and DMA mapped like standard cpu umems, and is released through ib_umem_release().

[1]https://lore.kernel.org/lkml/[email protected]/t/

---

V2->V3: Remove unnecessary variable initialization;
        Use error handler;
V1->V2: Thanks Shiraz Saleem, he gave me a lot of good suggestions.
        This commit is based on the shared functions from refactored
        irdma_reg_user_mr.
---
 drivers/infiniband/hw/irdma/verbs.c | 45 +++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
drivers/infiniband/hw/irdma/verbs.c +5 -0
index 6982f38596c8..7525f4cdf6fb 100644
@@ -2977,6 +2977,50 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
 	return ERR_PTR(err);
 }
 
+static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
+					      u64 len, u64 virt,
+					      int fd, int access,
+					      struct ib_udata *udata)
+{

drivers/infiniband/hw/irdma/verbs.c static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len, · line 2994

Quoted 10 lines
drivers/infiniband/hw/irdma/verbs.c +10 -0
+	struct irdma_device *iwdev = to_iwdev(pd->device);
+	struct ib_umem_dmabuf *umem_dmabuf;
+	struct irdma_mr *iwmr;
+	int err;
+
+	if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)
+		return ERR_PTR(-EINVAL);
+
+	if (udata->inlen < IRDMA_MEM_REG_MIN_REQ_LEN)
+		return ERR_PTR(-EINVAL);

Shiraz is correct, I'm wondering how this even works. This is a new style uAPI without UVERBS_ATTR_UHW so inlen should always be 0.

How did you manage to test this??

Jason

#5 lore raw
Quoted 45 lines · Jason Gunthorpe
Quoted 44 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

This is a followup to the EFA dmabuf[1]. Irdma driver currently does not support on-demand-paging(ODP). So it uses habanalabs as the dmabuf exporter, and irdma as the importer to allow for peer2peer access through libibverbs.

In this commit, the function ib_umem_dmabuf_get_pinned() is used. This function is introduced in EFA dmabuf[1] which allows the driver to get a dmabuf umem which is pinned and does not require move_notify callback implementation. The returned umem is pinned and DMA mapped like standard cpu umems, and is released through ib_umem_release().

[1]https://lore.kernel.org/lkml/[email protected]/t/

---

V2->V3: Remove unnecessary variable initialization;
         Use error handler;
V1->V2: Thanks Shiraz Saleem, he gave me a lot of good suggestions.
         This commit is based on the shared functions from refactored
         irdma_reg_user_mr.
---
  drivers/infiniband/hw/irdma/verbs.c | 45 +++++++++++++++++++++++++++++
  1 file changed, 45 insertions(+)
drivers/infiniband/hw/irdma/verbs.c +9 -0
index 6982f38596c8..7525f4cdf6fb 100644
@@ -2977,6 +2977,50 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
  	return ERR_PTR(err);
  }
 
+static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
+					      u64 len, u64 virt,
+					      int fd, int access,
+					      struct ib_udata *udata)
+{
+	struct irdma_device *iwdev = to_iwdev(pd->device);
+	struct ib_umem_dmabuf *umem_dmabuf;
+	struct irdma_mr *iwmr;
+	int err;
Quoted 8 lines

drivers/infiniband/hw/irdma/verbs.c static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len, · line 2994

Quoted 6 lines
drivers/infiniband/hw/irdma/verbs.c +6 -0
+
+	if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)
+		return ERR_PTR(-EINVAL);
+
+	if (udata->inlen < IRDMA_MEM_REG_MIN_REQ_LEN)
+		return ERR_PTR(-EINVAL);

Shiraz is correct, I'm wondering how this even works. This is a new style uAPI without UVERBS_ATTR_UHW so inlen should always be 0.

Got it. Thanks Shiraz and Jason.

I will remove the test of inlen in the latest commit.

Best Regards,

Zhu Yanjun

Quoted 4 lines

How did you manage to test this??

Jason

maintainer
#6 lore raw
Quoted 55 lines · Zhu Yanjun
Quoted 44 lines · Jason Gunthorpe
Quoted 43 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

This is a followup to the EFA dmabuf[1]. Irdma driver currently does not support on-demand-paging(ODP). So it uses habanalabs as the dmabuf exporter, and irdma as the importer to allow for peer2peer access through libibverbs.

In this commit, the function ib_umem_dmabuf_get_pinned() is used. This function is introduced in EFA dmabuf[1] which allows the driver to get a dmabuf umem which is pinned and does not require move_notify callback implementation. The returned umem is pinned and DMA mapped like standard cpu umems, and is released through ib_umem_release().

[1]https://lore.kernel.org/lkml/[email protected]/t/

---

V2->V3: Remove unnecessary variable initialization;
         Use error handler;
V1->V2: Thanks Shiraz Saleem, he gave me a lot of good suggestions.
         This commit is based on the shared functions from refactored
         irdma_reg_user_mr.
---
  drivers/infiniband/hw/irdma/verbs.c | 45 +++++++++++++++++++++++++++++
  1 file changed, 45 insertions(+)
drivers/infiniband/hw/irdma/verbs.c +9 -0
index 6982f38596c8..7525f4cdf6fb 100644
@@ -2977,6 +2977,50 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
  	return ERR_PTR(err);
  }
+static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
+					      u64 len, u64 virt,
+					      int fd, int access,
+					      struct ib_udata *udata)
+{
+	struct irdma_device *iwdev = to_iwdev(pd->device);
+	struct ib_umem_dmabuf *umem_dmabuf;
+	struct irdma_mr *iwmr;
+	int err;
Quoted 8 lines

drivers/infiniband/hw/irdma/verbs.c static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len, · line 2994

Quoted 6 lines
drivers/infiniband/hw/irdma/verbs.c +6 -0
+
+	if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)
+		return ERR_PTR(-EINVAL);
+
+	if (udata->inlen < IRDMA_MEM_REG_MIN_REQ_LEN)
+		return ERR_PTR(-EINVAL);

Shiraz is correct, I'm wondering how this even works. This is a new style uAPI without UVERBS_ATTR_UHW so inlen should always be 0.

Quoted 3 lines

Got it. Thanks Shiraz and Jason.

I will remove the test of inlen in the latest commit.

Please answer how did you manage to test this?

Jason