From: Jason Gunthorpe <jgg@ziepe.ca>
To: Jacob Moroni <jmoroni@google.com>
Cc: tatyana.e.nikolova@intel.com, krzysztof.czurylo@intel.com,
leon@kernel.org, linux-rdma@vger.kernel.org
Subject: Re: [RFC 2/2] RDMA/irdma: Add pinned revocable dmabuf support
Date: Tue, 24 Feb 2026 14:51:06 -0400 [thread overview]
Message-ID: <aZ3zGrWl19jrlL+w@ziepe.ca> (raw)
In-Reply-To: <20260223195333.438492-2-jmoroni@google.com>
On Mon, Feb 23, 2026 at 07:53:33PM +0000, Jacob Moroni wrote:
> +static void irdma_umem_dmabuf_revoke(void *priv)
> +{
> + struct irdma_mr *iwmr = priv;
> + int err;
> +
> + iwmr->revoked = true;
> +
> + if (!iwmr->is_hwreg)
> + return;
> +
> + /* Invalidate the key in hardware. This does not actually release the
> + * key for potential reuse - that only occurs when the region is fully
> + * deregistered.
> + */
> + err = irdma_hwdereg_mr(&iwmr->ibmr);
> + if (err) {
> + struct irdma_device *iwdev = to_iwdev(iwmr->ibmr.device);
> +
> + ibdev_err(&iwdev->ibdev, "dmabuf mr invalidate failed %d", err);
> + if (!iwdev->rf->reset) {
> + iwdev->rf->reset = true;
> + iwdev->rf->gen_ops.request_reset(iwdev->rf);
> + }
> + }
> +}
> +
> static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
> u64 len, u64 virt,
> int fd, int access,
> @@ -3607,31 +3627,45 @@ static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
> if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)
> return ERR_PTR(-EINVAL);
>
> - umem_dmabuf = ib_umem_dmabuf_get_pinned(pd->device, start, len, fd, access);
> + iwmr = kzalloc_obj(*iwmr);
> + if (!iwmr)
> + return ERR_PTR(-ENOMEM);
> +
> + umem_dmabuf =
> + ib_umem_dmabuf_get_pinned_revocable(pd->device, start, len, fd,
> + access,
> + irdma_umem_dmabuf_revoke,
> + iwmr);
> if (IS_ERR(umem_dmabuf)) {
> ibdev_dbg(&iwdev->ibdev, "Failed to get dmabuf umem[%pe]\n",
> umem_dmabuf);
> + kfree(iwmr);
> return ERR_CAST(umem_dmabuf);
> }
>
> - iwmr = irdma_alloc_iwmr(&umem_dmabuf->umem, pd, virt, IRDMA_MEMREG_TYPE_MEM);
> - if (IS_ERR(iwmr)) {
> - err = PTR_ERR(iwmr);
> + err = irdma_init_iwmr(iwmr, &umem_dmabuf->umem, pd, virt,
> + IRDMA_MEMREG_TYPE_MEM);
Is it OK to call irdma_hwdereg_mr() before this? Seems really sketchy
I think if revoke is being used you have to use a protocol where the
dmabuf reservation lock is left held for the caller to complete setup
so you don't have revoke races.
I guess this is some ib_umem_dmabuf_get_pinned_revocable_and_lock()
pattern
Maybe it can be some two step process:
ib_umem_dmabuf_get_pinned_locked()
[..]
ib_umem_dmabuf_set_pinned_revocable()
dma_buf__resv_unlock()
?
Then you don't need to restructure all the iwmr allocation (which
should be a seperated patch too)
Jason
next prev parent reply other threads:[~2026-02-24 18:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 19:53 [RFC 1/2] RDMA/umem: Add support for pinned revocable dmabuf import Jacob Moroni
2026-02-23 19:53 ` [RFC 2/2] RDMA/irdma: Add pinned revocable dmabuf support Jacob Moroni
2026-02-24 18:51 ` Jason Gunthorpe [this message]
2026-02-25 21:02 ` Jacob Moroni
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=aZ3zGrWl19jrlL+w@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=jmoroni@google.com \
--cc=krzysztof.czurylo@intel.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=tatyana.e.nikolova@intel.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