On 26.09.25 10:46, Thomas Hellström wrote:
> 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 <[email protected]>
> ---
> 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);
This looks like it sits in the wrong structure. The dma_buf_attach_ops are the
operations provided by the importer, e.g. move notification.
When we want to check if using an interconnect is possible we need to do that
on the exporter, e.g. dma_buf_ops().
I think we should have an map_interconnect(connector type descriptor) that the
importer can use to establish a mapping for itself.
Additional to that we need an unmap_interconnect() to let the exporter know
that an importer doesn't need a specific mapping any more.
> };
>
> /**
> @@ -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;
We already have an importer and an exporter private void *. Do we really need
that?
Regards,
Christian.
> void *importer_priv;
> void *priv;
> };