Re: [Intel-gfx] [PATCH v3] drm: move allocation out of drm_get_format_name()

From: Daniel Vetter
Date: Tue Nov 08 2016 - 20:13:35 EST


On Wed, Nov 09, 2016 at 02:09:16AM +0100, Daniel Vetter wrote:
> On Wed, Nov 09, 2016 at 12:17:52AM +0000, Eric Engestrom wrote:
> > The function's behaviour was changed in 90844f00049e, without changing
> > its signature, causing people to keep using it the old way without
> > realising they were now leaking memory.
> > Rob Clark also noticed it was also allocating GFP_KERNEL memory in
> > atomic contexts, breaking them.
> >
> > Instead of having to allocate GFP_ATOMIC memory and fixing the callers
> > to make them cleanup the memory afterwards, let's change the function's
> > signature by having the caller take care of the memory and passing it to
> > the function.
> > The new parameter is a single-field struct in order to enforce the size
> > of its buffer and help callers to correctly manage their memory.
> >
> > Fixes: 90844f00049e ("drm: make drm_get_format_name thread-safe")
> > Cc: Rob Clark <robdclark@xxxxxxxxx>
> > Cc: Christian KÃnig <christian.koenig@xxxxxxx>
> > Acked-by: Christian KÃnig <christian.koenig@xxxxxxx>
> > Acked-by: Rob Clark <robdclark@xxxxxxxxx>
> > Acked-by: Sinclair Yeh <syeh@xxxxxxxxxx> (vmwgfx)
> > Reviewed-by: Jani Nikula <jani.nikula@xxxxxxxxx>
> > Suggested-by: Ville SyrjÃlà <ville.syrjala@xxxxxxxxxxxxxxx>
> > Signed-off-by: Eric Engestrom <eric@xxxxxxxxxxxx>
> > ---
> > v3 - fix "Fixes" tag, replace it with an actual commit message
> > - collect ack & r-b
> >
> > v2 - use single-field struct instead of typedef to let the compiler
> > enforce the type (Christian KÃnig)
>
> Applied to drm-misc, thanks.

Well, had to drop it again since it didn't compile:


CC [M] drivers/gpu/drm/drm_blend.o
drivers/gpu/drm/drm_atomic.c: In function âdrm_atomic_plane_print_stateâ:
drivers/gpu/drm/drm_atomic.c:920:5: error: too few arguments to function âdrm_get_format_nameâ
drm_get_format_name(fb->pixel_format));
^~~~~~~~~~~~~~~~~~~
In file included from ./include/drm/drmP.h:71:0,
from drivers/gpu/drm/drm_atomic.c:29:
./include/drm/drm_fourcc.h:65:7: note: declared here
char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf);
^~~~~~~~~~~~~~~~~~~

Can you pls rebase onto drm-misc or linux-next or something?

Thanks, Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch