dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Eric Engestrom <eric.engestrom@imgtec.com>
Cc: "Eric Engestrom" <eric@engestrom.ch>,
	linux-kernel@vger.kernel.org,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Rob Clark" <robdclark@gmail.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"David Airlie" <airlied@linux.ie>,
	"Xinliang Liu" <z.liuxinliang@hisilicon.com>,
	"Daniel Vetter" <daniel.vetter@intel.com>,
	"VMware Graphics" <linux-graphics-maintainer@vmware.com>,
	"Sinclair Yeh" <syeh@vmware.com>,
	"Thomas Hellstrom" <thellstrom@vmware.com>,
	"Tom St Denis" <tom.stdenis@amd.com>,
	"Michel Dänzer" <michel.daenzer@amd.com>,
	"Gustavo Padovan" <gustavo.padovan@collabora.co.uk>,
	"Emily Deng" <Emily.Deng@amd.com>,
	"Chunming Zhou" <David1.Zhou@amd.com>,
	"Flora Cui" <Flora.Cui@amd.com>
Subject: Re: [PATCH v2] drm: move allocation out of drm_get_format_name()
Date: Mon, 07 Nov 2016 19:38:25 +0200	[thread overview]
Message-ID: <87eg2n8a26.fsf@intel.com> (raw)
In-Reply-To: <20161107171244.GK25290@imgtec.com>

On Mon, 07 Nov 2016, Eric Engestrom <eric.engestrom@imgtec.com> wrote:
> On Monday, 2016-11-07 10:10:13 +0200, Jani Nikula wrote:
>> On Mon, 07 Nov 2016, Eric Engestrom <eric@engestrom.ch> wrote:
>> > Fixes: 90844f00049e9f42573fd31d7c32e8fd31d3fd07
>> >
>> >     drm: make drm_get_format_name thread-safe
>> >
>> >     Signed-off-by: Eric Engestrom <eric@engestrom.ch>
>> >     [danvet: Clarify that the returned pointer must be freed with
>> >     kfree().]
>> >     Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>> 
>> The Fixes: format is:
>> 
>> Fixes: 90844f00049e ("drm: make drm_get_format_name thread-safe")
>> 
>> But is this a fix, really, or just an improvement? What exactly is the
>> bug being fixed? The commit message is not sufficient.
>
> "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."
>
> Does this sound good?

It's fine; no need to go overboard. ;)

BR,
Jani.

>
>> > @@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);
>> >  int drm_format_vert_chroma_subsampling(uint32_t format);
>> >  int drm_format_plane_width(int width, uint32_t format, int plane);
>> >  int drm_format_plane_height(int height, uint32_t format, int plane);
>> > -char *drm_get_format_name(uint32_t format) __malloc;
>> > +char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf);
>> 
>> I wonder if it would be better to make that return "const char *". If
>> the user really wants to look under the hood, there's buf->str. *shrug*
>
> Good idea, I'll do that in v3 with the proper commit msg and tags. It'll
> have to wait another day though, -ENOTIME and all.
>
>> 
>> With the commit message improved,
>> 
>> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>
> Cheers :)
>   Eric

-- 
Jani Nikula, Intel Open Source Technology Center

  reply	other threads:[~2016-11-07 17:38 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-04 15:32 [PATCH] drm: make drm_get_format_name atomic/irq safe again Rob Clark
2016-11-04 15:45 ` Rob Clark
2016-11-04 16:27 ` Ville Syrjälä
2016-11-04 17:12   ` Rob Clark
2016-11-04 17:32     ` Eric Engestrom
2016-11-04 17:33       ` [PATCH variant 1] " Eric Engestrom
2016-11-04 17:50       ` [PATCH] " Rob Clark
2016-11-04 18:13         ` Ville Syrjälä
2016-11-05  1:23         ` Eric Engestrom
2016-11-05  1:33           ` [PATCH] drm: move allocation out of drm_get_format_name() Eric Engestrom
2016-11-05  6:56             ` Thomas Hellstrom
2016-11-05 12:11             ` Christian König
2016-11-05 16:38               ` Eric Engestrom
2016-11-05 16:49                 ` Rob Clark
2016-11-06  9:47                   ` Christian König
2016-11-06 13:03                     ` Rob Clark
2016-11-07  0:47                       ` Eric Engestrom
2016-11-07  0:48                         ` [PATCH v2] " Eric Engestrom
2016-11-07  7:46                           ` Christian König
2016-11-07  8:10                           ` Jani Nikula
2016-11-07 17:12                             ` Eric Engestrom
2016-11-07 17:38                               ` Jani Nikula [this message]
2016-11-08 10:15                                 ` [Intel-gfx] " Daniel Vetter
2016-11-09  0:17                                   ` [PATCH v3] " Eric Engestrom
2016-11-09  1:09                                     ` [Intel-gfx] " Daniel Vetter
2016-11-09  1:13                                       ` Daniel Vetter
2016-11-09 11:42                                         ` Eric Engestrom
2016-11-09 13:13                                           ` [Intel-gfx] " Daniel Vetter
2016-11-09 16:59                                             ` Eric Engestrom
2016-11-10 10:03                                               ` Laurent Pinchart
2016-11-10 10:30                                                 ` [Intel-gfx] " Jani Nikula
2016-11-10 10:59                                                   ` Laurent Pinchart
2016-11-10 11:03                                                     ` Jani Nikula
2016-11-11  9:26                                               ` Daniel Vetter
2016-11-12  1:12                                                 ` [PATCH v4] " Eric Engestrom
2016-11-07 14:45                           ` [PATCH v2] " Rob Clark
2016-11-07 18:12                           ` Sinclair Yeh
2016-11-05  1:52           ` [PATCH] drm: make drm_get_format_name atomic/irq safe again Rob Clark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eg2n8a26.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=David1.Zhou@amd.com \
    --cc=Emily.Deng@amd.com \
    --cc=Flora.Cui@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel.vetter@intel.com \
    --cc=eric.engestrom@imgtec.com \
    --cc=eric@engestrom.ch \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=linux-graphics-maintainer@vmware.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michel.daenzer@amd.com \
    --cc=robdclark@gmail.com \
    --cc=syeh@vmware.com \
    --cc=thellstrom@vmware.com \
    --cc=tom.stdenis@amd.com \
    --cc=ville.syrjala@linux.intel.com \
    --cc=z.liuxinliang@hisilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).