Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	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:16:30 +0200	[thread overview]
Message-ID: <f33a4344-545a-43f4-9a3b-24bf070d559c@amd.com> (raw)
In-Reply-To: <20250926160036.GE2617119@nvidia.com>

On 26.09.25 18:00, 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

The point is that the exporter manages all accesses to it's buffer and there can be more than one importer accessing it at the same time.

So when an exporter sees that it already has an importer which can only do DMA to system memory it will expose only DMA address to all other importers as well.

But in general if we start with the exporter or the importer list doesn't really matter I think.

> 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.

More or less matches my idea. I would just start with the exporter providing a list of how it's buffer is accessible because it knows about other importers and can pre-reduce the list if necessary.

It can also be that this list changes when new importers come along (that was one of the big motivations for the move_notify callback).

In other words we have use cases where we need to do scanout, render and V4L to the same buffer at the same time and all three of that are different devices with different requirements.

> 
> 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.

Agree, that should be somehow handled by the framework.

> 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.

That is actually something we try rather hard to avoid. E.g. the exporter should offer only one path to each importer.

We can of course do load balancing on a round robin bases.

Regards,
Christian.

> 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.
> 
> Jason


  parent reply	other threads:[~2025-09-29  8:16 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
2025-09-29  8:25                 ` Thomas Hellström
2025-09-29 12:27                   ` Jason Gunthorpe
2025-09-29  8:16             ` Christian König [this message]
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=f33a4344-545a-43f4-9a3b-24bf070d559c@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