From: Jason Gunthorpe <jgg@ziepe.ca>
To: Konstantin Taranov <kotaranov@microsoft.com>
Cc: Long Li <longli@microsoft.com>,
Konstantin Taranov <kotaranov@linux.microsoft.com>,
"leon@kernel.org" <leon@kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH rdma-next v1 1/1] RDMA/mana_ib: Fix bug in creation of dma regions
Date: Thu, 8 Feb 2024 20:31:15 -0400 [thread overview]
Message-ID: <20240209003115.GA31743@ziepe.ca> (raw)
In-Reply-To: <PAXPR83MB0557626F0EDEEE6D8E78C6D7B4442@PAXPR83MB0557.EURPRD83.prod.outlook.com>
> > > > > +
> > > > > + if (force_zero_offset) {
> > > > > + while (ib_umem_dma_offset(umem, page_sz) && page_sz >
> > > > > PAGE_SIZE)
> > > > > + page_sz /= 2;
> > > > > + if (ib_umem_dma_offset(umem, page_sz) != 0) {
> > > > > + ibdev_dbg(&dev->ib_dev, "failed to find page
> > > > > + size to
> > > > > force zero offset.\n");
> > > > > + return -ENOMEM;
> > > > > + }
> > > > > + }
> > > > > +
> >
> > Yes this doesn't look quite right..
> >
> > It should flow from the HW capability, the helper you call should be tightly
> > linked to what the HW can do.
> >
> > ib_umem_find_best_pgsz() is used for MRs that have the usual
> > offset = IOVA % pgsz
> >
> > We've always created other helpers for other restrictions.
> >
> > So you should move your "force_zero_offset" into another helper and
> > describe exactly how the HW works to support the calculation
> >
> > It is odd to have the offset loop and be using
> > ib_umem_find_best_pgsz() with some iova, usually you'd use
> > ib_umem_find_best_pgoff() in those cases, see the other callers.
>
> Hi Jason,
> Thanks for the comments.
>
> To be honest, I do not understand how I could employ ib_umem_find_best_pgoff
> for my purpose. As well as I do not see any mistake in the patch, and I think you neither.
It does exactly the same thing, it is just intended to be used by
things that are not doing the IOVA calculation. It is a matter of documentation.
> I can make a special helper, but I do not think that it will be useful to anyone. Plus,
> there is no better approach then halving the page size, so the helper will end up with that
> loop under the hood. As I see mlnx also uses a loop with halving page_sz, but for a different
> purpose, I do not see why our code cannot do the same without a special helper.
Are you sure you don't need the length check too? You have a granular
size but not a granular offset?
In that case yes, a helper does not seem necessary
However, you should still be calling ib_umem_find_best_pgoff() for
the initialize sizing as a matter of clarity since this is not a MR
and does not use IOVA addressing.
Jason
next prev parent reply other threads:[~2024-02-09 0:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-07 15:09 [PATCH rdma-next v1 1/1] RDMA/mana_ib: Fix bug in creation of dma regions Konstantin Taranov
2024-02-08 8:23 ` Leon Romanovsky
2024-02-08 8:49 ` Konstantin Taranov
2024-02-08 9:15 ` Leon Romanovsky
2024-02-08 18:42 ` Long Li
2024-02-08 18:53 ` Konstantin Taranov
2024-02-08 20:16 ` Jason Gunthorpe
2024-02-08 22:04 ` Konstantin Taranov
2024-02-09 0:31 ` Jason Gunthorpe [this message]
2024-02-09 21:04 ` Konstantin Taranov
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=20240209003115.GA31743@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=kotaranov@linux.microsoft.com \
--cc=kotaranov@microsoft.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.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