Re: [PATCH rdma v10 7/7] RDMA/zrdma: Implement context, PD, and mmap operations
From: Leon Romanovsky
Date: Thu Dec 03 2026 - 15:07:05 EST
On Thu, Dec 03, 2026 at 08:49:28PM +0800, Yanze Zhang wrote:
> Add implementation for allocation/deallocation of Protection Domains (PD),
> User Contexts, and memory mapping (mmap) for doorbells.
>
> The SRQ doorbell area is not page aligned on 16K and 64K page systems, so
> the mapping length is extended to the page boundary and the size
> reported to userspace is the very same length. The V1 and V2 contexts do
> not know the size of the SRQ doorbell area, so only the first page is
> mapped for them.
>
> Signed-off-by: Yanze Zhang <zhang.yanze@xxxxxxxxxx>
> ---
> drivers/infiniband/hw/zrdma/zrdma_verbs.c | 351 ++++++++++++++++++++++
> 1 file changed, 351 insertions(+)
<...>
> + if (err) {
> + pr_warn_ratelimited("zrdma: PD allocation failed err=%d\n",
> + err);
> + return err;
> + }
> +
> + sc_pd = &zpd->sc_pd;
> + if (udata) {
> + struct zxdh_ucontext *ucontext;
> +
> + ucontext = rdma_udata_to_drv_context(udata,
> + struct zxdh_ucontext,
> + ibucontext);
> +
> + zxdh_sc_pd_init(dev, sc_pd, pd_id, ucontext->abi_ver);
> + uresp.pd_id = pd_id;
> + if (ib_respond_udata(udata, uresp)) {
> + err = -EFAULT;
> + goto error;
> + }
> + } else {
> + /* A protection domain that the kernel allocates has no user
> + * context, it uses the default ABI version.
> + */
> + zxdh_sc_pd_init(dev, sc_pd, pd_id, ZXDH_ABI_VER);
> + }
<...>
> + struct zxdh_user_mmap_entry *entry =
> + kzalloc(sizeof(*entry), GFP_KERNEL);
I haven't reviewed the entire series, but a few things immediately caught
my attention:
First, the series is structured incorrectly. Add the callbacks at the
beginning, and make the final patch enable the driver for users by adding
a Kbuild entry or a driver_id.
Second, use kzalloc_obj instead of kzalloc.
Third, replace the pr_*() calls with ibdev_*() calls.
Finally, ABI does not apply to in-kernel users. I also strongly suspect
that it is not being used correctly for uverbs too.
Thanks