From: "Christian König" <christian.koenig@amd.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Jason Gunthorpe" <jgg@nvidia.com>
Cc: intel-xe@lists.freedesktop.org,
Matthew Brost <matthew.brost@intel.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Kasireddy Vivek <vivek.kasireddy@intel.com>,
Simona Vetter <simona.vetter@ffwll.ch>,
dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org
Subject: Re: [RFC PATCH v2 1/2] dma-buf: Add support for private interconnects
Date: Mon, 29 Sep 2025 10:20:28 +0200 [thread overview]
Message-ID: <a5ffd1ee-b0b5-40bd-b68f-3779ca70dcae@amd.com> (raw)
In-Reply-To: <d3cc5b7fe4189c6f529b532273ece34c9c0e975f.camel@linux.intel.com>
On 29.09.25 10:16, Thomas Hellström wrote:
> On Fri, 2025-09-26 at 13:00 -0300, Jason Gunthorpe wrote:
>> On Fri, Sep 26, 2025 at 04:51:29PM +0200, Christian König wrote:
>>> On 26.09.25 16:41, Jason Gunthorpe wrote:
>>>> On Fri, Sep 26, 2025 at 03:51:21PM +0200, Thomas Hellström wrote:
>>>>
>>>>> Well both exporter and exporter has specific information WRT
>>>>> this. The
>>>>> ultimate decision is done in the exporter attach() callback,
>>>>> just like
>>>>> pcie_p2p. And the exporter acknowledges that by setting the
>>>>> dma_buf_attachment::interconnect_attach field. In analogy with
>>>>> the
>>>>> dma_buf_attachment::peer2peer member.
>>>>
>>>> Having a single option seems too limited to me..
>>>
>>> Yeah, agree.
>>>
>>>> I think it would be nice if the importer could supply a list of
>>>> 'interconnects' it can accept, eg:
>>>>
>>>> - VRAM offset within this specific VRAM memory
>>>> - dma_addr_t for this struct device
>>>> - "IOVA" for this initiator on a private interconnect
>>>> - PCI bar slice
>>>> - phys_addr_t (used between vfio, kvm, iommufd)
>>>
>>> I would rather say that the exporter should provide the list of
>>> what
>>> interconnects the buffer might be accessible through.
>>
>> Either direction works, I sketched it like this because I thought
>> there were more importers than exporters, and in the flow it is easy
>> for the importer to provide a list on the stack
>>
>> I didn't sketch further, but I think the exporter and importer should
>> both be providing a compatible list and then in almost all cases the
>> core code should do the matching.
>>
>> If the importer works as I showed, then the exporter version would be
>> in an op:
>>
>> int exporter_negotiate_op(struct dma_buf *dmabuf,
>> struct dma_buf_interconnect_negotiation *importer_support, size_t
>> importer_len)
>> {
>> struct dma_buf_interconnect_negotiation exporter_support[2] = {
>> [0] = {.interconnect = myself->xe_vram},
>> [1] = {.interconnect = &dmabuf_generic_dma_addr_t,
>> .interconnect_args = exporter_dev},
>> };
>> return dma_buf_helper_negotiate(dmabuf, exporter_support,
>> ARRAY_SIZE(exporter_support), importer_support,
>> importer_len);
>> }
>>
>> Which the dma_buf_negotiate() calls.
>>
>> The core code does the matching generically, probably there is a
>> struct dma_buf_interconnect match() op it uses to help this process.
>>
>> I don't think importer or exporter should be open coding any
>> matching.
>>
>> For example, we have some systems with multipath PCI. This could
>> actually support those properly. The RDMA NIC has two struct devices
>> it operates with different paths, so it would write out two
>> &dmabuf_generic_dma_addr_t's - one for each.
>>
>> The GPU would do the same. The core code can have generic code to
>> evaluate if P2P is possible and estimate some QOR between the
>> options.
>
> This sounds OK with me. I have some additional questions, though,
>
> 1) Everybody agrees that the interconnect used is a property of the
> attachment? It should be negotiated during attach()?
Yes, attach allows the exporter to know who wants to access it's buffer.
Map/unmap then requests the actual location where the exporter has moved the buffer so that it is accessible by everybody.
> 2) dma-buf pcie-p2p allows transparent fallback to system memory dma-
> buf. I think that is a good thing to keep even for other interconnects
> (if possible). Like if someone wants to pull the network cable, we
> could trigger a move_notify() and on next map() we'd fall back. Any
> ideas around this?
We already do that if new importers come along.
E.g. you have a connection which can do PCIe P2P and then suddenly somebody attaches which can only do DMA to system memory. In that situation we use move_notify to move the buffer into system memory and imports re-map it to grasp the new location.
Regards,
Christian.
>
> Thanks,
> Thomas
>
>
>
>>
>> Jason
>
next prev parent reply other threads:[~2025-09-29 8:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 8:46 [RFC PATCH v2 0/2] dma-buf private interconnect POC Thomas Hellström
2025-09-26 8:46 ` [RFC PATCH v2 1/2] dma-buf: Add support for private interconnects Thomas Hellström
2025-09-26 12:56 ` Christian König
2025-09-26 13:51 ` Thomas Hellström
2025-09-26 14:41 ` Jason Gunthorpe
2025-09-26 14:51 ` Christian König
2025-09-26 16:00 ` Jason Gunthorpe
2025-09-29 8:16 ` Thomas Hellström
2025-09-29 8:20 ` Christian König [this message]
2025-09-29 8:25 ` Thomas Hellström
2025-09-29 12:27 ` Jason Gunthorpe
2025-09-29 8:16 ` Christian König
2025-09-29 12:45 ` Jason Gunthorpe
2025-09-29 16:02 ` Thomas Hellström
2025-09-29 16:13 ` Jason Gunthorpe
2025-09-26 8:46 ` [RFC PATCH v2 2/2] drm/xe/dma-buf: Add generic interconnect support framework Thomas Hellström
2025-09-26 9:34 ` ✗ CI.checkpatch: warning for dma-buf private interconnect POC (rev2) Patchwork
2025-09-26 9:35 ` ✓ CI.KUnit: success " Patchwork
2025-09-26 9:50 ` ✗ CI.checksparse: warning " Patchwork
2025-09-26 10:11 ` ✓ Xe.CI.BAT: success " Patchwork
2025-09-26 14:23 ` ✗ Xe.CI.Full: failure " Patchwork
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=a5ffd1ee-b0b5-40bd-b68f-3779ca70dcae@amd.com \
--to=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jgg@nvidia.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=simona.vetter@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=vivek.kasireddy@intel.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