All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Michael Margolin <mrgolin@amazon.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: Fri, 4 Jul 2025 15:28:04 -0300	[thread overview]
Message-ID: <20250704182804.GR1410929@nvidia.com> (raw)
In-Reply-To: <20250701231545.14282-3-mrgolin@amazon.com>

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

  reply	other threads:[~2025-07-04 18:28 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 [this message]
2025-07-07 17:07     ` Margolin, Michael
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=20250704182804.GR1410929@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=dkkranzd@amazon.com \
    --cc=gal.pressman@linux.dev \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=matua@amazon.com \
    --cc=mrgolin@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.