Re: [PATCH 6/6] drm/i915: Give meaningful names to all the planes

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

 



On Thu, Nov 12, 2015 at 05:38:48PM +0000, Emil Velikov wrote:
> Hi Ville,
> 
> On 12 November 2015 at 16:52,  <ville.syrjala@xxxxxxxxxxxxxxx> wrote:
> > From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> >
> > Let's name our planes in a way that makes sense wrt. the spec:
> > - skl+ -> "plane 1A", "plane 2A", "plane 1C", "cursor A" etc.
> > - g4x+ -> "primary A", "primary B", "sprite A", "cursor C" etc.
> > - pre-g4x -> "plane A", "cursor B" etc.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> > ---
> >  drivers/gpu/drm/i915/intel_display.c | 35 +++++++++++++++++++++++++++++++++--
> >  drivers/gpu/drm/i915/intel_sprite.c  | 14 ++++++++++++++
> >  2 files changed, 47 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> > index 2b5e81a..82b2f58 100644
> > --- a/drivers/gpu/drm/i915/intel_display.c
> > +++ b/drivers/gpu/drm/i915/intel_display.c
> > @@ -13788,7 +13788,15 @@ static void intel_finish_crtc_commit(struct drm_crtc *crtc,
> >  void intel_plane_destroy(struct drm_plane *plane)
> >  {
> >         struct intel_plane *intel_plane = to_intel_plane(plane);
> > +       char *name;
> > +
> > +       /*
> > +        * drm_plane_cleanup() zeroes the structure, so
> > +        * need an extra dance to avoid leaking the name.
> > +        */
> > +       name = plane->name;
> >         drm_plane_cleanup(plane);
> > +       kfree(name);
> >         kfree(intel_plane);
> >  }
> >
> > @@ -13838,6 +13846,21 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
> >         if (HAS_FBC(dev) && INTEL_INFO(dev)->gen < 4)
> >                 primary->plane = !pipe;
> >
> > +       if (INTEL_INFO(dev)->gen >= 9)
> > +               primary->base.name = kasprintf(GFP_KERNEL, "plane 1%c",
> > +                                              pipe_name(pipe));
> > +       else if (INTEL_INFO(dev)->gen >= 5 || IS_G4X(dev))
> > +               primary->base.name = kasprintf(GFP_KERNEL, "primary %c",
> > +                                              pipe_name(pipe));
> > +       else
> > +               primary->base.name = kasprintf(GFP_KERNEL, "plane %c",
> > +                                              plane_name(primary->plane));
> > +       if (!primary->base.name) {
> > +               kfree(state);
> > +               kfree(primary);
> > +               return NULL;
> Worth adding a label and doing all the teardown there ? (same goes for
> the rest of the patch)

Dunno. Was feeling lazy, and so didn't go the extra mile.

> 
> > +       }
> > +
> >         if (INTEL_INFO(dev)->gen >= 9) {
> >                 intel_primary_formats = skl_primary_formats;
> >                 num_formats = ARRAY_SIZE(skl_primary_formats);
> > @@ -13987,6 +14010,14 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
> >         cursor->commit_plane = intel_commit_cursor_plane;
> >         cursor->disable_plane = intel_disable_cursor_plane;
> >
> > +       cursor->base.name = kasprintf(GFP_KERNEL, "cursor %c",
> > +                                     pipe_name(pipe));
> > +       if (!cursor->base.name) {
> > +               kfree(state);
> > +               kfree(cursor);
> > +               return NULL;
> > +       }
> > +
> >         drm_universal_plane_init(dev, &cursor->base, 0,
> >                                  &intel_plane_funcs,
> >                                  intel_cursor_formats,
> > @@ -14113,9 +14144,9 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
> >
> >  fail:
> >         if (primary)
> > -               drm_plane_cleanup(primary);
> > +               intel_plane_destroy(primary);
> >         if (cursor)
> > -               drm_plane_cleanup(cursor);
> > +               intel_plane_destroy(cursor);
> Something feels strange here. We are either leaking memory before or
> we'll end up with double free after your patch. Worth
> checking/mentioning in the commit message ?

Yeah, I think we were leaking here. Forgot to add a note.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux