[PATCH 3/6] dma-buf: add peer2peer flag

Daniel Vetter daniel at ffwll.ch
Tue Apr 23 08:18:51 UTC 2019


On Tue, Apr 23, 2019 at 10:16:50AM +0200, Daniel Vetter wrote:
> On Thu, Apr 18, 2019 at 02:09:25PM +0200, Christian König wrote:
> > Add a peer2peer flag noting that the importer can deal with device
> > resources which are not backed by pages.
> > 
> > Signed-off-by: Christian König <christian.koenig at amd.com>
> 
> Should we add something like "Such importers should also support dynamic
> dma_buf attachments." to the kerneldoc?
> 
> Either way lgtm
> 
> Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
> > ---
> >  drivers/dma-buf/dma-buf.c | 1 +
> >  include/linux/dma-buf.h   | 4 ++++
> >  2 files changed, 5 insertions(+)
> > 
> > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> > index f23ff8355505..3ab49b492017 100644
> > --- a/drivers/dma-buf/dma-buf.c
> > +++ b/drivers/dma-buf/dma-buf.c
> > @@ -563,6 +563,7 @@ struct dma_buf_attachment *dma_buf_attach(const struct dma_buf_attach_info *info
> >  
> >  	attach->dev = info->dev;
> >  	attach->dmabuf = dmabuf;
> > +	attach->peer2peer = info->peer2peer;
> >  	attach->importer_priv = info->importer_priv;
> >  	attach->invalidate = info->invalidate;
> >  
> > diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
> > index a615b74e5894..d2746bdfe92c 100644
> > --- a/include/linux/dma-buf.h
> > +++ b/include/linux/dma-buf.h
> > @@ -346,6 +346,7 @@ struct dma_buf {
> >   * @dmabuf: buffer for this attachment.
> >   * @dev: device attached to the buffer.
> >   * @node: list of dma_buf_attachment.
> > + * @peer2peer: true if the importer can handle peer resources without pages.
> >   * @priv: exporter specific attachment data.
> >   * @importer_priv: importer specific attachment data.
> >   *
> > @@ -362,6 +363,7 @@ struct dma_buf_attachment {
> >  	struct dma_buf *dmabuf;
> >  	struct device *dev;
> >  	struct list_head node;
> > +	bool peer2peer;
> >  	void *priv;
> >  	struct sg_table *sgt;
> >  	void *importer_priv;
> > @@ -427,6 +429,7 @@ struct dma_buf_export_info {
> >   * struct dma_buf_attach_info - holds information needed to attach to a dma_buf
> >   * @dmabuf:		the exported dma_buf
> >   * @dev:		the device which wants to import the attachment
> > + * @peer2peer:		true if the importer can handle peer resources without pages

And a bikeshed: inline kerneldoc style for this would be good (I think I
made that comment on the earlier series too), to avoid too much of a
pressure towards too terse kerneldoc. @invalidate definitely needs a lot
more text, and I think peer2peer would also benefit from a few pointers
(e.g. which sg table helpers you can use and which you can't because the
pages pointer is NULL).
-Daniel

> >   * @importer_priv:	private data of importer to this attachment
> >   * @invalidate:		callback to use for invalidating mappings
> >   *
> > @@ -436,6 +439,7 @@ struct dma_buf_export_info {
> >  struct dma_buf_attach_info {
> >  	struct dma_buf *dmabuf;
> >  	struct device *dev;
> > +	bool peer2peer;
> >  	void *importer_priv;
> >  	void (*invalidate)(struct dma_buf_attachment *attach);
> >  };
> > -- 
> > 2.17.1
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list