All of lore.kernel.org
 help / color / mirror / Atom feed
From: daniel@ffwll.ch
Cc: kernel@pengutronix.de, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 5/8] drm/imx: parallel-display: use drm managed resources
Date: Thu, 23 Jul 2020 00:02:30 +0200	[thread overview]
Message-ID: <20200722220230.GL6419@phenom.ffwll.local> (raw)
In-Reply-To: <ac269aecd712d8740e334367afa0c2e5db3a85c9.camel@pengutronix.de>

On Wed, Jul 22, 2020 at 04:01:53PM +0200, Philipp Zabel wrote:
> On Wed, 2020-07-22 at 15:30 +0200, Philipp Zabel wrote:
> [...]
> > and use drmm_add_action_or_reset() to make sure drm_encoder_cleanup() is
> > called before the memory is freed.
> [...]
> > @@ -259,6 +259,13 @@ static const struct drm_bridge_funcs imx_pd_bridge_funcs = {
> >  	.atomic_get_output_bus_fmts = imx_pd_bridge_atomic_get_output_bus_fmts,
> >  };
> >  
> > +static void imx_pd_encoder_cleanup(struct drm_device *drm, void *ptr)
> > +{
> > +	struct drm_encoder *encoder = ptr;
> > +
> > +	drm_encoder_cleanup(encoder);
> > +}
> > +
> >  static int imx_pd_register(struct drm_device *drm,
> >  	struct imx_parallel_display *imxpd)
> >  {
> > @@ -276,7 +283,13 @@ static int imx_pd_register(struct drm_device *drm,
> >  	 */
> >  	imxpd->connector.dpms = DRM_MODE_DPMS_OFF;
> >  
> > -	drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_NONE);
> > +	ret = drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_NONE);
> > +	if (ret)
> > +		return ret;
> > +
> > +	ret = drmm_add_action_or_reset(drm, imx_pd_encoder_cleanup, encoder);
> > +	if (ret)
> > +		return ret;
> 
> This is only required because this is a component driver: our
> drmm_kzalloc() is called after drmm_mode_config_init(), so we can't rely
> on drm_mode_config_init_release() for cleanup. That is only called after
> drmres already freed our memory.

Yeah I know about the inversion, which is why I haven't yet started typing
the mass conversion for all the drm objects. I think the explicit
drmm_add_action_or_reset is indeed the way to go, except we probably want
some helpers to wrap the allocation, drm_foo_init and adding the reset
action all into one thing (plus you can stuff the reset action into the
allocation instead of the kfree action only, even nicer that way).

But that's maybe for later, and good to have some examples in drivers
already converted over as guidance.

On the series: Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

But way too late for solid review :-)

Cheers, Daniel

> 
> regards
> Philipp
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-07-22 22:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22 13:30 [PATCH 1/8] drm/imx: drop explicit drm_mode_config_cleanup Philipp Zabel
2020-07-22 13:30 ` [PATCH 2/8] drm/imx: dw_hdmi-imx: use drm managed resources, switch to dw_hdmi_probe Philipp Zabel
2020-07-22 13:30 ` [PATCH 3/8] drm/imx: imx-ldb: use drm managed resources Philipp Zabel
2020-07-22 13:30 ` [PATCH 4/8] drm/imx: imx-tve: " Philipp Zabel
2020-07-22 13:30 ` [PATCH 5/8] drm/imx: parallel-display: " Philipp Zabel
2020-07-22 14:01   ` Philipp Zabel
2020-07-22 22:02     ` daniel [this message]
2020-07-22 13:30 ` [PATCH 6/8] drm/imx: ipuv3-plane: " Philipp Zabel
2020-07-22 13:30 ` [PATCH 7/8] drm/imx: move call to ipu_plane_get_resources() into ipu_plane_init() Philipp Zabel
2020-07-22 13:30 ` [PATCH 8/8] drm/imx: ipuv3-crtc: use drm managed resources Philipp Zabel

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=20200722220230.GL6419@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@pengutronix.de \
    /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 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.