[Intel-gfx] [PATCH 2/2] drm/vgem: Replace opencoded version of drm_gem_dumb_map_offset()

Chris Wilson chris at chris-wilson.co.uk
Wed Jul 8 14:53:43 UTC 2020


Quoting Daniel Vetter (2020-07-08 10:56:19)
> On Tue, Jul 07, 2020 at 05:00:12PM +0100, Chris Wilson wrote:
> > drm_gem_dumb_map_offset() now exists and does everything
> > vgem_gem_dump_map does and *ought* to do.
> > 
> > Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> > ---
> >  drivers/gpu/drm/vgem/vgem_drv.c | 28 +---------------------------
> >  1 file changed, 1 insertion(+), 27 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
> > index eb3b7cdac941..866cff537f28 100644
> > --- a/drivers/gpu/drm/vgem/vgem_drv.c
> > +++ b/drivers/gpu/drm/vgem/vgem_drv.c
> > @@ -236,32 +236,6 @@ static int vgem_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
> >       return 0;
> >  }
> >  
> > -static int vgem_gem_dumb_map(struct drm_file *file, struct drm_device *dev,
> > -                          uint32_t handle, uint64_t *offset)
> > -{
> > -     struct drm_gem_object *obj;
> > -     int ret;
> > -
> > -     obj = drm_gem_object_lookup(file, handle);
> > -     if (!obj)
> > -             return -ENOENT;
> > -
> > -     if (!obj->filp) {
> > -             ret = -EINVAL;
> > -             goto unref;
> > -     }
> > -
> > -     ret = drm_gem_create_mmap_offset(obj);
> > -     if (ret)
> > -             goto unref;
> > -
> > -     *offset = drm_vma_node_offset_addr(&obj->vma_node);
> > -unref:
> > -     drm_gem_object_put_unlocked(obj);
> > -
> > -     return ret;
> > -}
> > -
> >  static struct drm_ioctl_desc vgem_ioctls[] = {
> >       DRM_IOCTL_DEF_DRV(VGEM_FENCE_ATTACH, vgem_fence_attach_ioctl, DRM_RENDER_ALLOW),
> >       DRM_IOCTL_DEF_DRV(VGEM_FENCE_SIGNAL, vgem_fence_signal_ioctl, DRM_RENDER_ALLOW),
> > @@ -455,7 +429,7 @@ static struct drm_driver vgem_driver = {
> >       .fops                           = &vgem_driver_fops,
> >  
> >       .dumb_create                    = vgem_gem_dumb_create,
> > -     .dumb_map_offset                = vgem_gem_dumb_map,
> > +     .dumb_map_offset                = drm_gem_dumb_map_offset,
> 
> Even better: Just delete it, it's the default. With that:
> 
> Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
> 
> Also maybe cc: stable, since this should stop the mmap attempts on
> imported dma-buf? Or will this break stuff ...

commit 90378e58919285637aa0f063c04ba0c6449d98b1 [v4.15]
Author: Noralf Trønnes <noralf at tronnes.org>
Date:   Thu Aug 17 18:21:30 2017 +0200

    drm/gem: drm_gem_dumb_map_offset(): reject dma-buf

and

commit db61152703c64133e42b8c720a83ff36e1824bb1 [v4.14]
Author: Noralf Trønnes <noralf at tronnes.org>
Date:   Sun Jul 23 21:16:17 2017 +0200

    drm/gem: Add drm_gem_dumb_map_offset()

It became default at the same time:

commit 0be8d63a840ab7cacb08f1af1f2395be0fe3b698 [v4.14]
Author: Noralf Trønnes <noralf at tronnes.org>
Date:   Sun Jul 23 21:16:18 2017 +0200

    drm/dumb-buffers: Add defaults for .dumb_map_offset and .dumb_destroy

The bug was in

commit af33a9190d0226251e9cbc137c88a707b0bbe356 [v4.13]
Author: Laura Abbott <labbott at redhat.com>
Date:   Thu May 4 11:45:48 2017 -0700

    drm/vgem: Enable dmabuf import interfaces

The drm_gem_dumb_map_offset is much older than I thought it was, and
while I suspected you might have suggested making it an automatic default,
I looked in the wrong place for the caller.

It's the cleaner fix, so this deserves the cc:stable more than the
first and covers the same lts.
-Chris


More information about the Intel-gfx mailing list