public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: "Margolin, Michael" <mrgolin@amazon.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: <leon@kernel.org>, <linux-rdma@vger.kernel.org>,
	<sleybo@amazon.com>, <matua@amazon.com>, <gal.pressman@linux.dev>,
	Daniel Kranzdorf <dkkranzd@amazon.com>,
	Yonatan Nachum <ynachum@amazon.com>
Subject: Re: [PATCH for-next 2/2] RDMA/efa: Add CQ with external memory support
Date: Mon, 7 Jul 2025 20:07:43 +0300	[thread overview]
Message-ID: <40ae393c-f95b-41e2-81c1-d0d1e42e1eaf@amazon.com> (raw)
In-Reply-To: <20250704182804.GR1410929@nvidia.com>


On 7/4/2025 9:28 PM, Jason Gunthorpe wrote:
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
>
>
>
> On Tue, Jul 01, 2025 at 11:15:45PM +0000, Michael Margolin wrote:
>> +     if (umem) {
>> +             umem_sgl = ibcq->umem->sgt_append.sgt.sgl;
>> +             if (sg_dma_len(umem_sgl) < ib_umem_offset(umem) + cq->size) {
>> +                     ibdev_dbg(&dev->ibdev, "Non contiguous CQ unsupported\n");
>> +                     err = -EINVAL;
>> +                     goto err_free_mem;
>> +             }
> I'd rather see this call ib_umem_find_best_pgsz()
>
> Maybe like:
>    len = ib_umem_offset(umem) + cq->size
>    pgsz = roundup_pow_of_two(len);
>    ib_umem_find_best_pgoff(umem, pgsz, U64_MAX);
>    rdma_umem_for_each_dma_block(umem, biter, pgsz) {
>         dma = rdma_block_iter_dma_address(&biter) +  ib_umem_dma_offset(umem, pgsz);
>         break;
>    }
>
> It turns out the scatterlists can be irregular in some cases so this
> will handle that properly while the little test above cannot.
>
> And maybe the above thing could be a little helper:
>
> bool ib_umem_get_contiguous_dma(umem, &dma_addr)
>
> Also I am trying hard to keep scatterlist APIS out of the drivers.
>
> Jason

Some disadvantage of this approach is that if the provided memory 
is contiguous in its first "roundup_pow_of_two(len)" bytes but consists 
of additional smaller or unaligned sgl entries, we will refuse to use it.

I will try to compile some combination of the two approaches into a 
helper function.

Michael


  reply	other threads:[~2025-07-07 17:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-01 23:15 [PATCH for-next 0/2] RDMA: Support CQs with user memory Michael Margolin
2025-07-01 23:15 ` [PATCH for-next 1/2] RDMA/uverbs: Add a common way to create CQ with umem Michael Margolin
2025-07-04 18:14   ` Jason Gunthorpe
2025-07-08 20:13     ` Margolin, Michael
2025-07-01 23:15 ` [PATCH for-next 2/2] RDMA/efa: Add CQ with external memory support Michael Margolin
2025-07-04 18:28   ` Jason Gunthorpe
2025-07-07 17:07     ` Margolin, Michael [this message]
2025-07-07 17:16       ` 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=40ae393c-f95b-41e2-81c1-d0d1e42e1eaf@amazon.com \
    --to=mrgolin@amazon.com \
    --cc=dkkranzd@amazon.com \
    --cc=gal.pressman@linux.dev \
    --cc=jgg@nvidia.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=matua@amazon.com \
    --cc=sleybo@amazon.com \
    --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