All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: "Christian König" <christian.koenig@amd.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: Fri, 26 Sep 2025 11:41:28 -0300	[thread overview]
Message-ID: <20250926144128.GD2617119@nvidia.com> (raw)
In-Reply-To: <ef9f4fb1c55bf3e5e6423b2accdccee0607b95ef.camel@linux.intel.com>

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

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)

The exporter has a function to run down the list and return the first
compatible. Maybe something like

    struct dma_buf_interconnect_negotiation {
    	   struct dma_buf_interconnect *interconnect,
	   void *interconnect_args,
    };

    struct dma_buf_interconnect_negotiation importer_offer[2] = { // On stack
        [0] = {.interconnect = myself->xe_vram},
        [1] = {.interconnect = &dmabuf_generic_dma_addr_t, .interconnects_args = dev},
    };
    idx = dma_buf_negotiate(dmabuf, importer_offer, ARRAY_SIZE(importer_offer));
    if (idx < 0)
        return -EOPNOTSUPP;

Then you'd 'interconnect attach' with that compatible item and get
back an attach. Using container_of to get the specific ops which then
has a function to get the address list.

   attach = dma_buf_attach_interconnect(dmabuf, importer_offer[idx],  &dma_buf_attach_ops);

   if (idx == 0) {
          xe_vram_ops = container_of(attach->ops, ..);
          struct device_private_address *addrs = xe_vram_ops->map(attach);
	  [..]
	  xe_vram_ops->unmap(attach);
   }
   dma_buf_detach_interconnect(attach);

I can imagine some scheme where if the exporter does not support
interconnect then the core code will automatically look for
dmabuf_generic_dma_addr_t, select it, and supply some ops that call
existing dma_buf_dynamic_attach()/dma_buf_map_attachment()
transparently.

> So the above function mimics the dma_buf_attach_ops::allow_peer2peer
> bool, except it's not a single interconnect so we'd either use a set of
> bools, one for each potential interconnect, or a function like this.
> A function has the benefit that it can also provide any additional
> attach ops the interconnect might need.

allow_peer2peer seems to indicate if sg_page() can be used on the
sgt? It doesn't have any meaning for an importer only using
dma_addr_t?

In the above language it would be an interconnect exchanging 'struct
page *'.. I'm a little confused by this I thought touching the struct
page was forbidden?

> Is this to not overload the map_attachment() and unmap_attachment()
> functions that otherwise could be used? Is it because they return an
> sg_table?

It would be good to avoid going through APIs that use sg_table in the
design..

Jason

  reply	other threads:[~2025-09-26 14:41 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 [this message]
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
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=20250926144128.GD2617119@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.