On Thu, 30 Oct 2025 15:25:50 +0100
Christian König <[email protected]> wrote:

> On 10/30/25 15:05, Boris Brezillon wrote:
> > drm_gem_is_prime_exported_dma_buf() checks the dma_buf->ops against
> > drm_gem_prime_dmabuf_ops, which makes it impossible to use if the
> > driver implements custom dma_buf_ops. Instead of duplicating a bunch
> > of helpers to work around it, let's provide a way for drivers to
> > expose their custom dma_buf_ops so the core prime helpers can rely on
> > that instead of hardcoding &drm_gem_prime_dmabuf_ops.  
> 
> That's generally nice to have, I've re-implemented quite a number of 
> functions in amdgpu because of this as well.
> 
> > 
> > v5:
> > - New patch
> > 
> > Signed-off-by: Boris Brezillon <[email protected]>
> > ---
> >  drivers/gpu/drm/drm_prime.c | 14 +++++++++++---
> >  include/drm/drm_drv.h       |  8 ++++++++
> >  2 files changed, 19 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> > index 43a10b4af43a..3796844af418 100644
> > --- a/drivers/gpu/drm/drm_prime.c
> > +++ b/drivers/gpu/drm/drm_prime.c
> > @@ -903,6 +903,15 @@ unsigned long drm_prime_get_contiguous_size(struct 
> > sg_table *sgt)
> >  }
> >  EXPORT_SYMBOL(drm_prime_get_contiguous_size);
> >  
> > +static const struct dma_buf_ops *
> > +drm_gem_prime_get_dma_buf_ops(struct drm_device *dev)
> > +{
> > +   if (dev->driver->gem_prime_get_dma_buf_ops)
> > +           return dev->driver->gem_prime_get_dma_buf_ops(dev);  
> 
> I have strong doubts that a driver changes their dma_buf ops during their 
> runtime, so instead of a callback could we just have it as pointer in 
> drm_driver?

Sure thing, I considered doing that too actually.

Reply via email to