From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: David Hu <dhu@x6u.co>,
sumit.semwal@linaro.org, christian.koenig@amd.com,
alex@shazbot.org, ankita@nvidia.com, chriscli@google.com,
david.laight.linux@gmail.com, dri-devel@lists.freedesktop.org,
iommu@lists.linux.dev, jmoroni@google.com, kevin.tian@intel.com,
kpberry@google.com, linaro-mm-sig@lists.linaro.org,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
nicolinc@nvidia.com, praan@google.com, sashiko-bot@kernel.org,
stable@vger.kernel.org, viursachi@google.com,
xuehaohu@google.com
Subject: Re: [PATCH v8 2/2] dma-buf: Split sgl by largest page-aligned chunk
Date: Thu, 3 Sep 2026 19:36:12 +0300 [thread overview]
Message-ID: <20260903163612.GD24140@unreal> (raw)
In-Reply-To: <20260903134938.GI2890729@ziepe.ca>
On Thu, Sep 03, 2026 at 10:49:38AM -0300, Jason Gunthorpe wrote:
> On Wed, Sep 02, 2026 at 07:07:50PM -0400, David Hu wrote:
> > On Wed, Sep 2, 2026 at 8:08 AM Jason Gunthorpe <jgg@ziepe.ca> wrote:
> > >
> > > On Tue, Sep 01, 2026 at 05:08:49PM +0000, David Hu wrote:
> > > > From: David Hu <xuehaohu@google.com>
> > > >
> > > > Currently, `fill_sg_entry()` splits the scatterlist using `UINT_MAX`.
> > > > This creates a non-page-aligned DMA length (`0xFFFFFFFF`) for the
> > > > first entry, resulting in non-page-aligned DMA addresses for all
> > > > subsequent entries.
> > >
> > > This patch is fine, but pedenatically a scatterlist's entry limit
> > > should be bounded to dma_get_max_seg_size(), though I don't think it
> > > helps this. Operating scatterlists at the size limits has proven
> > > problematic in a number of places already...
> > >
> > > > In addition, a non-page-aligned sgl length will trigger an edge case
> > > > in `ib_umem_find_best_pgsz()`. In case of a discontinuity in later
> > > > buffers, we will have a `va` with lowest bit set to 1. That will lead
> > > > to `ib_umem_find_best_pgsz()` always return 0, and break the promise
> > > > to find best page size for the mapping on the NIC side.
> > >
> > > That's an IB side bug, the newer logic that joins adjacent SGLs should
> > > have avoided it?
> >
> > Hi Jason,
> >
> > Thank you for the review. I think you are right on both counts.
> > Regarding the IB side, the new SGL joining logic in
> > `ib_umem_find_best_pgsz()` indeed avoids the issue. `mask |= va` is
> > skipped for artifically split, contiguous SGLs. Since Christian has
> > already pulled v8 into drm-misc-next, I won't spin a v9 to avoid
> > creating unnecessary noise on the list. If you prefer a followup,
> > please let me know.
>
> Nope, I'm fine, it just explains why it wasn't seen in other
> tested. You were backporting and mix&matched things. It confirms the
> upstream kernel was fine from the start.
All that time, I wondered why our testing didn't uncover any issues like
this, given that the requirement to support large BARs was raised almost
immediately during testing.
Thanks
>
> There are other importers besides RDMA, so I still think that this is
> a good change regardless. Having each segment remain page aligned, and
> staying away from ULONG_MAX that might trigger overflows is a friendly
> and robust thing to do for less sophisticated importers.
>
> Jason
>
next prev parent reply other threads:[~2026-09-03 16:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 17:08 [PATCH v8 0/2] dma-buf: Fix silent overflow and alignment David Hu
2026-09-01 17:08 ` [PATCH v8 1/2] dma-buf: Fix silent overflow for phys vec to sgt David Hu
2026-09-01 17:30 ` sashiko-bot
2026-09-01 17:08 ` [PATCH v8 2/2] dma-buf: Split sgl by largest page-aligned chunk David Hu
2026-09-01 17:30 ` sashiko-bot
2026-09-02 12:08 ` Jason Gunthorpe
2026-09-02 23:07 ` David Hu
2026-09-03 13:49 ` Jason Gunthorpe
2026-09-03 16:36 ` Leon Romanovsky [this message]
2026-09-02 7:00 ` [PATCH v8 0/2] dma-buf: Fix silent overflow and alignment Christian König
2026-09-02 7:39 ` Leon Romanovsky
2026-09-02 7:56 ` Christian König
2026-09-02 8:32 ` Leon Romanovsky
2026-09-02 8:44 ` Christian König
2026-09-02 9:53 ` Leon Romanovsky
2026-09-02 10:00 ` Christian König
2026-09-02 10:59 ` Leon Romanovsky
2026-09-02 13:34 ` Christian König
2026-09-02 17:46 ` Jason Gunthorpe
2026-09-02 13:42 ` Pranjal Shrivastava
2026-09-02 12:03 ` 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=20260903163612.GD24140@unreal \
--to=leon@kernel.org \
--cc=alex@shazbot.org \
--cc=ankita@nvidia.com \
--cc=chriscli@google.com \
--cc=christian.koenig@amd.com \
--cc=david.laight.linux@gmail.com \
--cc=dhu@x6u.co \
--cc=dri-devel@lists.freedesktop.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=jmoroni@google.com \
--cc=kevin.tian@intel.com \
--cc=kpberry@google.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=praan@google.com \
--cc=sashiko-bot@kernel.org \
--cc=stable@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=viursachi@google.com \
--cc=xuehaohu@google.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