From: "Christian König" <christian.koenig@amd.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: David Hu <dhu@x6u.co>,
sumit.semwal@linaro.org, alex@shazbot.org, ankita@nvidia.com,
chriscli@google.com, david.laight.linux@gmail.com,
dri-devel@lists.freedesktop.org, iommu@lists.linux.dev,
jgg@ziepe.ca, 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 0/2] dma-buf: Fix silent overflow and alignment
Date: Wed, 2 Sep 2026 12:00:25 +0200 [thread overview]
Message-ID: <65dc4ca1-6882-490d-baad-3e0abd708af3@amd.com> (raw)
In-Reply-To: <20260902095338.GU24140@unreal>
On 9/2/26 11:53, Leon Romanovsky wrote:
> On Wed, Sep 02, 2026 at 10:44:59AM +0200, Christian König wrote:
>> On 9/2/26 10:32, Leon Romanovsky wrote:
>>> On Wed, Sep 02, 2026 at 09:56:06AM +0200, Christian König wrote:
>>>> On 9/2/26 09:39, Leon Romanovsky wrote:
>>>>> On Wed, Sep 02, 2026 at 09:00:46AM +0200, Christian König wrote:
>>>>>> On 9/1/26 19:08, David Hu wrote:
>>>>>>> From: David Hu <xuehaohu@google.com>
>>>>>>>
>>>>>>> This series address two related issues in scatter-gather mapping,
>>>>>>> specifically for the MMIO based dma-buf mapping. The fixes ensure
>>>>>>> sgt mapping is correct, and proper for large MMIO regions.
>>>>>>>
>>>>>>> Patch 1 fixes a silent integer overflow for mapping length exceeding 4G
>>>>>>> (Previously submitted as [PATCH v7] dma-buf: Fix silent overflow for
>>>>>>> phys vec to sgt)
>>>>>>> https://lore.kernel.org/all/20260609164047.486227-1-xuehaohu@google.com/
>>>>>>>
>>>>>>> Patch 2 Splits sgl by largest page aligned chunk
>>>>>>> (Previously submitted as [PATCH v3] dma-buf: Split sgl by largest page-aligned chunk)
>>>>>>> https://lore.kernel.org/all/20260722233806.3922093-1-dhu@x6u.co/
>>>>>>
>>>>>> *sigh* such issues are exactly the reason why I didn't wanted the dma-mapping stuff inside DMA-buf. That clearly doesn't belong here.
>>>>>
>>>>> And this is why so many in the kernel community want to get rid of SG
>>>>> lists. It would be great if DMA-BUF could also eliminate the need to
>>>>> convert to an SGL, like Jason proposed.
>>>>>
>>>>> The DMA layer no longer needs SGL. These bugs belong to the DMA-BUF layer,
>>>>> which is the one that depends on it.
>>>>
>>>> I'm all fine using an array/xarray of dma_addr_t in DMA-buf, just phys_vec is a clear no-go.
>>>
>>> You are proposing the same thing as an SGL, just in a different format.
>>
>> Yes, because that is the right thing todo as far as I can see.
>>
>>> It does not address the issue that dma_addr_t is expected to hold a DMA
>>> address, while that is not always the case. For example, in the P2P case,
>>> the addresses are not DMA addresses.
>>
>> Yes they are. They must be DMA addresses because that is the only thing the importer needs to do it's DMA.
>
> They can perform DMA, but that still does not make them suitable for the
> dma_addr_t type. For the PCI_P2PDMA_MAP_BUS_ADDR flow, these addresses
> follow completely different rules: they are not unmapped, require no cache
> synchronization, are valid only for peer access, and require separate error
> handling.
The PCI_P2PDMA_MAP_BUS_ADDR is not supported by DMA-buf and as far as I can see is a complete dead end.
> All of this information is lost if only the dma_addr_t is stored.
Yes and that is fully intentional.
DMA-buf handles that cleanly on the buffer object level and not like PCI_P2PDMA_MAP_BUS_ADDR as a completely broken design on a per address/page basis.
Technical background is that the PCI_P2PDMA_MAP_BUS_ADDR approach can only be handled by a very very small subset of HW.
Regards,
Christian.
>
>>
>> It can be that those are DMA addresses on private interconnects between devices, but it should *never* be a phys_addr_t because that is limited to the address space the CPU can see.
>>
>>> Jason's proposal:
>>> https://lore.kernel.org/all/0-v1-b5cab63049c0+191af-dmabuf_map_type_jgg@nvidia.com/
>>
>> Yeah, I have commented quite a bit on that.
>
> Right, I posted it for reference.
>
> Thanks
>
>>
>> Regards,
>> Christian.
>>
>>>
>>> Thanks
>>>
>>>>
>>>> Regards,
>>>> Christian.
>>>>
>>>>>
>>>>> Thanks
>>>>
>>>>
>>
>>
next prev parent reply other threads:[~2026-09-02 10:00 UTC|newest]
Thread overview: 19+ 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:08 ` [PATCH v8 2/2] dma-buf: Split sgl by largest page-aligned chunk David Hu
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
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 [this message]
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=65dc4ca1-6882-490d-baad-3e0abd708af3@amd.com \
--to=christian.koenig@amd.com \
--cc=alex@shazbot.org \
--cc=ankita@nvidia.com \
--cc=chriscli@google.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=leon@kernel.org \
--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