Re: [PATCH 1/6] drm: Add helper to check exporting driver of a DMA-buf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 06, 2017 at 10:25:23PM +0200, Christian König wrote:
> Am 06.07.2017 um 22:16 schrieb Felix Kuehling:
> > This allows drivers to check if a DMA-buf contains a GEM object and
> > whether it comes from the same driver. It may be from the same or a
> > different device.
> > 
> > Signed-off-by: Felix Kuehling <Felix.Kuehling@xxxxxxx>
> 
> I think Daniel/Dave hadmore a function which returns the casted GEM object
> or NULL in mind, but that should o it as well.
> 
> Patch is Reviewed-by: Christian König <christian.koenig@xxxxxxx>

Yeah I think the try_to_cast is the much cleaner interface. Also, can we
pls cc the entire patch series to dri-devel, makes it much easier to see
th entire context? I can't really say whether this or try_to_cast is a
good idea without that ...
-Daniel

> 
> Regards,
> Christian.
> 
> > ---
> >   drivers/gpu/drm/drm_prime.c | 24 ++++++++++++++++++++++++
> >   include/drm/drmP.h          |  2 ++
> >   2 files changed, 26 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> > index 25aa455..a50baec 100644
> > --- a/drivers/gpu/drm/drm_prime.c
> > +++ b/drivers/gpu/drm/drm_prime.c
> > @@ -594,6 +594,30 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
> >   EXPORT_SYMBOL(drm_gem_prime_handle_to_fd);
> >   /**
> > + * drm_gem_prime_dmabuf_is_from_driver - check exporting driver of a dma-buf
> > + * @dma_buf: dma-buf object to check
> > + * @driver: driver that is the expected exporter of the dma-buf
> > + *
> > + * Returns true if @driver exported @dma_buf. Returns false if
> > + * @dma_buf was exported by a different driver.
> > + */
> > +bool drm_gem_prime_dmabuf_is_from_driver(const struct dma_buf *dma_buf,
> > +					 const struct drm_driver *driver)
> > +{
> > +	struct drm_gem_object *obj;
> > +
> > +	if (dma_buf->ops != &drm_gem_prime_dmabuf_ops)
> > +		return false;
> > +
> > +	obj = dma_buf->priv;
> > +	if (obj->dev->driver != driver)
> > +		return false;
> > +
> > +	return true;
> > +}
> > +EXPORT_SYMBOL(drm_gem_prime_dmabuf_is_from_driver);
> > +
> > +/**
> >    * drm_gem_prime_import - helper library implementation of the import callback
> >    * @dev: drm_device to import into
> >    * @dma_buf: dma-buf object to import
> > diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> > index 6105c05..052f747 100644
> > --- a/include/drm/drmP.h
> > +++ b/include/drm/drmP.h
> > @@ -767,6 +767,8 @@ extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
> >   extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
> >   		struct drm_file *file_priv, uint32_t handle, uint32_t flags,
> >   		int *prime_fd);
> > +extern bool drm_gem_prime_dmabuf_is_from_driver(const struct dma_buf *dma_buf,
> > +		const struct drm_driver *driver);
> >   extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
> >   		struct dma_buf *dma_buf);
> >   extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
> 
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux