Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Kasireddy Vivek" <vivek.kasireddy@intel.com>,
	"Simona Vetter" <simona.vetter@ffwll.ch>,
	"Jason Gunthorpe" <jgg@nvidia.com>,
	dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org
Subject: [RFC PATCH v2 1/2] dma-buf: Add support for private interconnects
Date: Fri, 26 Sep 2025 10:46:23 +0200	[thread overview]
Message-ID: <20250926084624.2288-2-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20250926084624.2288-1-thomas.hellstrom@linux.intel.com>

Add a function to the dma_buf_attach_ops to indicate whether the
connection is a private interconnect. If so the function returns
the address to an interconnect-defined structure that can be
used for further negotiating.

Also add a field to the dma_buf_attachment that indicates whether
a private interconnect is used by the attachment.

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 include/linux/dma-buf.h | 51 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index d58e329ac0e7..25dbf1fea09a 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -442,6 +442,39 @@ struct dma_buf {
 #endif
 };
 
+/* RFC: Separate header for the interconnect defines? */
+
+/**
+ * struct dma_buf_interconnect - Private interconnect
+ * @name: The name of the interconnect
+ */
+struct dma_buf_interconnect {
+	const char *name;
+};
+
+/**
+ * struct dma_buf_interconnect_attach_ops - Interconnect attach ops base-class
+ *
+ * Declared for type-safety. Interconnect implementations should subclass to
+ * implement negotiation-specific ops.
+ */
+struct dma_buf_interconnect_attach_ops {
+};
+
+/**
+ * struct dma_buf_interconnect_attach - Interconnect state
+ * @interconnect: The struct dma_buf_interconnect identifying the interconnect
+ *
+ * Interconnect implementations subclass as needed for attachment state
+ * that can't be stored elsewhere. It could, for example, hold a pointer
+ * to a replacement of the sg-list after the attachment has been mapped.
+ * If no additional state is needed, an exporter could define a single
+ * static instance of this struct.
+ */
+struct dma_buf_interconnect_attach {
+	const struct dma_buf_interconnect *interconnect;
+};
+
 /**
  * struct dma_buf_attach_ops - importer operations for an attachment
  *
@@ -475,6 +508,21 @@ struct dma_buf_attach_ops {
 	 * point to the new location of the DMA-buf.
 	 */
 	void (*move_notify)(struct dma_buf_attachment *attach);
+
+	/**
+	 * @supports_interconnect: [optional] - Does the driver support a local interconnect?
+	 *
+	 * Does the importer support a private interconnect? The interconnect is
+	 * identified using a unique address defined instantiated either by the driver
+	 * if the interconnect is driver-private or globally
+	 * (RFC added to the dma-buf-interconnect.c file) if cross-driver.
+	 *
+	 * Return: A pointer to the interconnect-private attach_ops structure if supported,
+	 * %NULL otherwise.
+	 */
+	const struct dma_buf_interconnect_attach_ops *
+	(*supports_interconnect)(struct dma_buf_attachment *attach,
+				 const struct dma_buf_interconnect *interconnect);
 };
 
 /**
@@ -484,6 +532,8 @@ struct dma_buf_attach_ops {
  * @node: list of dma_buf_attachment, protected by dma_resv lock of the dmabuf.
  * @peer2peer: true if the importer can handle peer resources without pages.
  * @priv: exporter specific attachment data.
+ * @interconnect_attach: Private interconnect state for the connection if used,
+ * NULL otherwise.
  * @importer_ops: importer operations for this attachment, if provided
  * dma_buf_map/unmap_attachment() must be called with the dma_resv lock held.
  * @importer_priv: importer specific attachment data.
@@ -503,6 +553,7 @@ struct dma_buf_attachment {
 	struct list_head node;
 	bool peer2peer;
 	const struct dma_buf_attach_ops *importer_ops;
+	struct dma_buf_interconnect_attach *interconnect_attach;
 	void *importer_priv;
 	void *priv;
 };
-- 
2.51.0


  reply	other threads:[~2025-09-26  8:46 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 ` Thomas Hellström [this message]
2025-09-26 12:56   ` [RFC PATCH v2 1/2] dma-buf: Add support for private interconnects 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
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=20250926084624.2288-2-thomas.hellstrom@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=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=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