From: Laurent Pinchart <laurent.pinchart@ideasonboard.com> To: Daniel Vetter <daniel@ffwll.ch> Cc: Thierry Reding <thierry.reding@gmail.com>, Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>, dri-devel@lists.freedesktop.org, linux-sh@vger.kernel.org, Daniel Vetter <daniel.vetter@ffwll.ch> Subject: Re: [PATCH] drm: rcar-du: Fix plane state free in plane reset handler Date: Tue, 18 Aug 2015 06:35:44 +0000 [thread overview] Message-ID: <19460030.7jS9GcTr8h@avalon> (raw) In-Reply-To: <20150814073015.GG17734@phenom.ffwll.local> Hi Daniel, On Friday 14 August 2015 09:30:15 Daniel Vetter wrote: > On Fri, Aug 14, 2015 at 12:19:03AM +0300, Laurent Pinchart wrote: > > On Friday 07 August 2015 17:30:08 Laurent Pinchart wrote: > > > On Friday 07 August 2015 14:53:22 Thierry Reding wrote: > > > > On Thu, Aug 06, 2015 at 03:23:00AM +0300, Laurent Pinchart wrote: > > > > > The plane reset handler frees the plane state and allocates a new > > > > > default state, but when doing so attempt to free the plane state > > > > > using the base plane state pointer instead of casting it to the > > > > > driver-specific state object that has been allocated. Fix it by > > > > > using the rcar_du_plane_atomic_destroy_state() function to destroy > > > > > the plane state instead of duplicating the code. > > > > > > > > > > Signed-off-by: Laurent Pinchart > > > > > <laurent.pinchart+renesas@ideasonboard.com> > > > > > --- > > > > > > > > > > drivers/gpu/drm/rcar-du/rcar_du_plane.c | 45 ++++++++++------------ > > > > > 1 file changed, 22 insertions(+), 23 deletions(-) > > > > > > > > > > Should the DRM core free the atomic state before calling the reset > > > > > operation ? That would simplify drivers. > > > > > > > > The core can't do that because drivers might have subclassed the > > > > state. > > > > > > But the core can call the .atomic_destroy_state() operation, can't it ? > > > > Thierry, Daniel, any comment on this ? > > Doesn't really help you since the kzalloc is still in the helper. Btw this > is all helper code, core won't do here anything at all ;-) Is it ? The .reset() and .atomic_destroy_state() are core plane operations, not helper operations. My point is that, as .reset() needs to allocate the state if no state exists, I'm wondering whether it wouldn't be simpler for drivers to free the state in the core using .atomic_destroy_state() before calling .reset() and always allocate a state in the driver's .reset() implementation. In peudo-code, drivers currently do (or at least should do) atomic_destroy_state(state) { driver_state = cast_to_driver_state(state); clean up driver_state; kfree(driver_state); } reset() { if (state) { driver_state = cast_to_driver_state(state); clean up driver_state; } else { driver_state = kzalloc(...); } set all fields of driver_state to default values; } Wouldn't it be simpler to have the core call .atomic_destroy_state() before .reset() and implement .reset() as reset() driver_state = kzalloc(...); set all fields of driver_state to default values; } ? > But we could still do it simply as a refactoring and to show drivers how > to implement their _reset with less copypasting. -- Regards, Laurent Pinchart
WARNING: multiple messages have this Message-ID (diff)
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com> To: Daniel Vetter <daniel@ffwll.ch> Cc: Thierry Reding <thierry.reding@gmail.com>, Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>, dri-devel@lists.freedesktop.org, linux-sh@vger.kernel.org, Daniel Vetter <daniel.vetter@ffwll.ch> Subject: Re: [PATCH] drm: rcar-du: Fix plane state free in plane reset handler Date: Tue, 18 Aug 2015 09:35:44 +0300 [thread overview] Message-ID: <19460030.7jS9GcTr8h@avalon> (raw) In-Reply-To: <20150814073015.GG17734@phenom.ffwll.local> Hi Daniel, On Friday 14 August 2015 09:30:15 Daniel Vetter wrote: > On Fri, Aug 14, 2015 at 12:19:03AM +0300, Laurent Pinchart wrote: > > On Friday 07 August 2015 17:30:08 Laurent Pinchart wrote: > > > On Friday 07 August 2015 14:53:22 Thierry Reding wrote: > > > > On Thu, Aug 06, 2015 at 03:23:00AM +0300, Laurent Pinchart wrote: > > > > > The plane reset handler frees the plane state and allocates a new > > > > > default state, but when doing so attempt to free the plane state > > > > > using the base plane state pointer instead of casting it to the > > > > > driver-specific state object that has been allocated. Fix it by > > > > > using the rcar_du_plane_atomic_destroy_state() function to destroy > > > > > the plane state instead of duplicating the code. > > > > > > > > > > Signed-off-by: Laurent Pinchart > > > > > <laurent.pinchart+renesas@ideasonboard.com> > > > > > --- > > > > > > > > > > drivers/gpu/drm/rcar-du/rcar_du_plane.c | 45 ++++++++++------------ > > > > > 1 file changed, 22 insertions(+), 23 deletions(-) > > > > > > > > > > Should the DRM core free the atomic state before calling the reset > > > > > operation ? That would simplify drivers. > > > > > > > > The core can't do that because drivers might have subclassed the > > > > state. > > > > > > But the core can call the .atomic_destroy_state() operation, can't it ? > > > > Thierry, Daniel, any comment on this ? > > Doesn't really help you since the kzalloc is still in the helper. Btw this > is all helper code, core won't do here anything at all ;-) Is it ? The .reset() and .atomic_destroy_state() are core plane operations, not helper operations. My point is that, as .reset() needs to allocate the state if no state exists, I'm wondering whether it wouldn't be simpler for drivers to free the state in the core using .atomic_destroy_state() before calling .reset() and always allocate a state in the driver's .reset() implementation. In peudo-code, drivers currently do (or at least should do) atomic_destroy_state(state) { driver_state = cast_to_driver_state(state); clean up driver_state; kfree(driver_state); } reset() { if (state) { driver_state = cast_to_driver_state(state); clean up driver_state; } else { driver_state = kzalloc(...); } set all fields of driver_state to default values; } Wouldn't it be simpler to have the core call .atomic_destroy_state() before .reset() and implement .reset() as reset() driver_state = kzalloc(...); set all fields of driver_state to default values; } ? > But we could still do it simply as a refactoring and to show drivers how > to implement their _reset with less copypasting. -- Regards, Laurent Pinchart
next prev parent reply other threads:[~2015-08-18 6:35 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-08-06 0:23 [PATCH] drm: rcar-du: Fix plane state free in plane reset handler Laurent Pinchart 2015-08-06 0:23 ` Laurent Pinchart 2015-08-07 12:53 ` Thierry Reding 2015-08-07 12:53 ` Thierry Reding 2015-08-07 14:30 ` Laurent Pinchart 2015-08-07 14:30 ` Laurent Pinchart 2015-08-13 21:19 ` Laurent Pinchart 2015-08-13 21:19 ` Laurent Pinchart 2015-08-14 7:30 ` Daniel Vetter 2015-08-14 7:30 ` Daniel Vetter 2015-08-18 6:35 ` Laurent Pinchart [this message] 2015-08-18 6:35 ` Laurent Pinchart 2015-08-25 7:15 ` Daniel Vetter 2015-08-25 7:15 ` Daniel Vetter 2015-10-19 22:40 ` Laurent Pinchart 2015-10-19 22:40 ` Laurent Pinchart 2015-10-20 7:25 ` Daniel Vetter 2015-10-20 7:25 ` Daniel Vetter
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=19460030.7jS9GcTr8h@avalon \ --to=laurent.pinchart@ideasonboard.com \ --cc=daniel.vetter@ffwll.ch \ --cc=daniel@ffwll.ch \ --cc=dri-devel@lists.freedesktop.org \ --cc=laurent.pinchart+renesas@ideasonboard.com \ --cc=linux-sh@vger.kernel.org \ --cc=thierry.reding@gmail.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.