Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-rdma@vger.kernel.org, leon@kernel.org, mrgolin@amazon.com,
	gal.pressman@linux.dev, sleybo@amazon.com, parav@nvidia.com,
	mbloch@nvidia.com, yanjun.zhu@linux.dev,
	marco.crivellari@suse.com, roman.gushchin@linux.dev,
	phaddad@nvidia.com, lirongqing@baidu.com, ynachum@amazon.com,
	huangjunxian6@hisilicon.com, kalesh-anakkur.purayil@broadcom.com,
	ohartoov@nvidia.com, michaelgur@nvidia.com, shayd@nvidia.com,
	edwards@nvidia.com, sriharsha.basavapatna@broadcom.com,
	andrew.gospodarek@broadcom.com, selvin.xavier@broadcom.com
Subject: Re: [PATCH rdma-next v4 11/16] RDMA/mlx4: Use ib_umem_get_cq_buf() for user CQ buffer
Date: Wed, 13 May 2026 13:38:07 +0200	[thread overview]
Message-ID: <agRinwoVkaPujATb@FV6GYCPJ69> (raw)
In-Reply-To: <20260512182927.GJ7702@ziepe.ca>

Tue, May 12, 2026 at 08:29:27PM CEST, jgg@ziepe.ca wrote:
>On Thu, May 07, 2026 at 02:52:26PM +0200, Jiri Pirko wrote:
>> +	cq->umem = ib_umem_get_cq_buf(&dev->ib_dev, udata, entries * cqe_size,
>> +				      IB_ACCESS_LOCAL_WRITE);
>> +	if (IS_ERR(cq->umem)) {
>> +		err = PTR_ERR(cq->umem);
>>  		goto err_cq;
>>  	}
>> +	if (cq->umem) {
>> +		if (dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_SW_CQ_INIT) {
>> +			err = -EOPNOTSUPP;
>> +			goto err_umem;
>
>Huh. this is getting pretty hacky.. The driver wants to memset the
>user buf to 0xcc for some reason, and it already has a nice flow that
>if that fails it tells the FW it fails and presumably is Ok.
>
>The issue is it passes buf_addr around insead of having made an
>ib_umem_memset() (which can reject dmabuf).
>
>Looks easy enough, change sg_zero_buffer() to sg_fill_buffer() to
>accept the 0xcc, ib_umem_memset() trivially calls it, remove the
>buf_addr from the call chain, directly use the umem in the
>mlx4_init_user_cqes(), remove the if above, use the
>ib_umem_get_cq_buf_or_va() in the driver..
>
>Leaving it like this just means the driver won't work with the new
>uAPI with normal VA which is not desirable..

Agreed. I would like to fix this in a follow-up patchset which would
look more or less like this (Claude generated):

 1) lib/scatterlist: add sg_fill_buffer()
    Generalize sg_zero_buffer() to take a fill byte. Keep
    sg_zero_buffer() as a thin static inline wrapper around
    sg_fill_buffer(..., 0) so existing callers (nvmet, scsi_debug,
    ccree, jh7110-aes, krb5) don't have to change.
 2) RDMA/umem: add ib_umem_memset()
    Walks the umem's sg list via sg_fill_buffer(). Rejects dmabuf and
    ODP umems with -EOPNOTSUPP. Honors umem offset/length bounds.
 3) net/mlx4: drop buf_addr/user_cq from mlx4_cq_alloc()
    Replace "void *buf_addr, bool user_cq" with
    "struct mlx4_buf *kbuf, bool sw_cq_init". The function only owns
    the kernel-side init via mlx4_init_kernel_cqes(); user-side init
    becomes the caller's responsibility. mlx4_init_user_cqes() goes
    away. mlx4_en and the kernel mlx4_ib path are updated to the new
    signature.
 4) RDMA/mlx4: switch to ib_umem_get_cq_buf_or_va() and ib_umem_memset()
    The user-CQ create path collapses to a single
    ib_umem_get_cq_buf_or_va() followed by an
    ib_umem_memset(cq->umem, 0xcc, ...) before mlx4_cq_alloc(). If the
    memset succeeds, tell FW sw_cq_init=true; otherwise fall back to
    FW-side init. dmabuf / ODP umems fall back naturally via
    ib_umem_memset() returning -EOPNOTSUPP, and the explicit
    MLX4_DEV_CAP_FLAG2_SW_CQ_INIT -EOPNOTSUPP branch goes away.

Makes sense?


  reply	other threads:[~2026-05-13 11:38 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07 12:52 [PATCH rdma-next v4 00/16] RDMA: Introduce generic buffer descriptor infrastructure for umem Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 01/16] RDMA/umem: Rename ib_umem_get() to ib_umem_get_va() Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 02/16] RDMA/umem: Split ib_umem_get_va() into a thin wrapper around __ib_umem_get_va() Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 03/16] RDMA/core: Introduce generic buffer descriptor infrastructure for umem Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 04/16] RDMA/umem: Route ib_umem_get_va() through ib_umem_get() Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 05/16] RDMA/uverbs: Inline _uverbs_get_const_{signed,unsigned}() Jiri Pirko
2026-05-12 17:51   ` Jason Gunthorpe
2026-05-13 11:43     ` Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 06/16] RDMA/uverbs: Push out CQ buffer umem processing into a helper Jiri Pirko
2026-05-12 18:03   ` Jason Gunthorpe
2026-05-12 18:40     ` Jiri Pirko
2026-05-12 19:22       ` Jason Gunthorpe
2026-05-07 12:52 ` [PATCH rdma-next v4 07/16] RDMA/uverbs: Add CQ buffer UMEM attribute and driver helpers Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 08/16] RDMA/efa: Use ib_umem_get_cq_buf() for user CQ buffer Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 09/16] RDMA/mlx5: Use ib_umem_get_cq_buf_or_va() " Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 10/16] RDMA/bnxt_re: " Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 11/16] RDMA/mlx4: Use ib_umem_get_cq_buf() " Jiri Pirko
2026-05-12 18:29   ` Jason Gunthorpe
2026-05-13 11:38     ` Jiri Pirko [this message]
2026-05-07 12:52 ` [PATCH rdma-next v4 12/16] RDMA/uverbs: Remove legacy umem field from struct ib_cq Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 13/16] RDMA/uverbs: Use UMEM attributes for QP creation Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 14/16] RDMA/mlx5: Use UMEM attributes for QP buffers in create_qp Jiri Pirko
2026-05-07 12:52 ` [PATCH rdma-next v4 15/16] RDMA/mlx5: Use UMEM attribute for CQ doorbell record Jiri Pirko
2026-05-12 19:21   ` Jason Gunthorpe
2026-05-07 12:52 ` [PATCH rdma-next v4 16/16] RDMA/mlx5: Use UMEM attribute for QP " Jiri Pirko
2026-05-12 19:23 ` [PATCH rdma-next v4 00/16] RDMA: Introduce generic buffer descriptor infrastructure for umem Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=agRinwoVkaPujATb@FV6GYCPJ69 \
    --to=jiri@resnulli.us \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=edwards@nvidia.com \
    --cc=gal.pressman@linux.dev \
    --cc=huangjunxian6@hisilicon.com \
    --cc=jgg@ziepe.ca \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=marco.crivellari@suse.com \
    --cc=mbloch@nvidia.com \
    --cc=michaelgur@nvidia.com \
    --cc=mrgolin@amazon.com \
    --cc=ohartoov@nvidia.com \
    --cc=parav@nvidia.com \
    --cc=phaddad@nvidia.com \
    --cc=roman.gushchin@linux.dev \
    --cc=selvin.xavier@broadcom.com \
    --cc=shayd@nvidia.com \
    --cc=sleybo@amazon.com \
    --cc=sriharsha.basavapatna@broadcom.com \
    --cc=yanjun.zhu@linux.dev \
    --cc=ynachum@amazon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox