Re: [PATCH 1/3] drm: add gem ttm helpers
From: Daniel Vetter
Date: Wed Aug 07 2019 - 04:28:14 EST
On Wed, Aug 7, 2019 at 9:29 AM Gerd Hoffmann <kraxel@xxxxxxxxxx> wrote:
>
> > > +/**
> > > + * drm_gem_ttm_mmap_offset() - Returns a GEM ttm object's mmap offset
> > > + * @gbo: the GEM ttm object
> > > + *
> > > + * See drm_vma_node_offset_addr() for more information.
> > > + *
> > > + * Returns:
> > > + * The buffer object's offset for userspace mappings on success, or
> > > + * 0 if no offset is allocated.
> > > + */
> > > +u64 drm_gem_ttm_mmap_offset(struct ttm_buffer_object *bo)
> > > +{
> > > + return drm_vma_node_offset_addr(&bo->base.vma_node);
> >
> > Why do we need a new one here, can't we use the existing gem
> > implementation for this (there really should only be one I hope, but I
> > didn't check).
>
> Havn't found one.
It got reverted out again:
commit 415d2e9e07574d3de63b8df77dc686e0ebf64865
Author: Rob Herring <robh@xxxxxxxxxx>
Date: Wed Jul 3 16:38:50 2019 -0600
Revert "drm/gem: Rename drm_gem_dumb_map_offset() to drm_gem_map_offset()"
> But maybe we don't need this as separate function and can simply move
> the drm_vma_node_offset_addr() call into
> drm_gem_ttm_driver_dumb_mmap_offset().
>
> > > +int drm_gem_ttm_driver_dumb_mmap_offset(struct drm_file *file,
> > > + struct drm_device *dev,
> > > + uint32_t handle, uint64_t *offset)
> > > +{
> > > + struct drm_gem_object *gem;
> > > + struct ttm_buffer_object *bo;
> > > +
> > > + gem = drm_gem_object_lookup(file, handle);
> > > + if (!gem)
> > > + return -ENOENT;
> > > +
> > > + bo = drm_gem_ttm_of_gem(gem);
> > > + *offset = drm_gem_ttm_mmap_offset(bo);
> > > +
> > > + drm_gem_object_put_unlocked(gem);
> > > +
> > > + return 0;
> > > +}
> > > +EXPORT_SYMBOL(drm_gem_ttm_driver_dumb_mmap_offset);
> >
> > Same for this, you're just upcasting to ttm_bo and then downcasting to
> > gem_bo again ... I think just a series to roll out the existing gem
> > helpers everywhere should work?
>
> I don't think so. drm_gem_dumb_map_offset() calls
> drm_gem_create_mmap_offset(), which I think is not correct for ttm
> objects because ttm_bo_init() handles vma_node initialization.
More code to unify first? This should work exactly the same way for
all gem based drivers I think ... Only tricky bit is making sure
vmwgfx keeps working correctly.
-Daniel
>
> cheers,
> Gerd
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch