[PATCH v2 02/18] drm/vram: use embedded gem object

Daniel Vetter daniel at ffwll.ch
Fri Jun 28 07:50:49 UTC 2019


On Fri, Jun 28, 2019 at 9:30 AM Thomas Zimmermann <tzimmermann at suse.de> wrote:
>
> Hi
>
> Am 21.06.19 um 13:57 schrieb Gerd Hoffmann:
> > Drop drm_gem_object from drm_gem_vram_object, use the
> > ttm_buffer_object.base instead.
> >
> > Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
> > ---
> >  include/drm/drm_gem_vram_helper.h           |  3 +--
> >  drivers/gpu/drm/ast/ast_main.c              |  2 +-
> >  drivers/gpu/drm/drm_gem_vram_helper.c       | 16 ++++++++--------
> >  drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c |  2 +-
> >  drivers/gpu/drm/mgag200/mgag200_main.c      |  2 +-
> >  drivers/gpu/drm/vboxvideo/vbox_main.c       |  2 +-
> >  6 files changed, 13 insertions(+), 14 deletions(-)
> >
> > diff --git a/include/drm/drm_gem_vram_helper.h b/include/drm/drm_gem_vram_helper.h
> > index 9581ea0a4f7e..7b9f50ba3fce 100644
> > --- a/include/drm/drm_gem_vram_helper.h
> > +++ b/include/drm/drm_gem_vram_helper.h
> > @@ -36,7 +36,6 @@ struct vm_area_struct;
> >   * video memory becomes scarce.
> >   */
> >  struct drm_gem_vram_object {
> > -     struct drm_gem_object gem;
> >       struct ttm_buffer_object bo;
> >       struct ttm_bo_kmap_obj kmap;
> >
> > @@ -68,7 +67,7 @@ static inline struct drm_gem_vram_object *drm_gem_vram_of_bo(
> >  static inline struct drm_gem_vram_object *drm_gem_vram_of_gem(
> >       struct drm_gem_object *gem)
>
> To avoid ambiguities, I used the form <destination type name>_of_<field
> name>() to name these cast functions. The canonical name here would now
> be drm_gem_vram_of_bo_base(). But that's just nitpicking. If you don't
> want to change the name (and all its callers), maybe leave a FIXME comment.

Bikeshed: I think generally we call these
<source_type>_to_<destination_type>, with the source type left out if
you cast from the most generic version. E.g. this one here would just
be

static inline struct drm_gem_vram_object *drm_gem_to_vram_bo(struct
drm_gem_object *gem)

or something like that. I don't remember having seen the *_of_*
pattern anywhere.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the dri-devel mailing list