From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: David Airlie <airlied@linux.ie>,
linux-renesas-soc@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm: rcar-du: Use drmm_encoder_alloc() to manage encoder
Date: Thu, 14 Jan 2021 00:45:49 +0200 [thread overview]
Message-ID: <X/94HaYff+rNR2YD@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20210113170253.443820-1-kieran.bingham+renesas@ideasonboard.com>
Hi Kieran,
Thank you for the patch.
On Wed, Jan 13, 2021 at 05:02:53PM +0000, Kieran Bingham wrote:
> The encoder allocation was converted to a DRM managed resource at the
> same time as the addition of a new helper drmm_encoder_alloc() which
> simplifies the same process.
>
> Convert the custom drm managed resource allocation of the encoder
> with the helper to simplify the implementation, and prevent hitting a
> WARN_ON() due to the handling the drm_encoder_init() call directly
> without registering a .destroy() function op.
>
> Fixes: f5f16725edbc ("drm: rcar-du: Use DRM-managed allocation for encoders")
We could equally point to the patch that has added drmm_encoder_alloc(),
but I'm fine taking the blame :-)
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> ---
> drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 31 +++++------------------
> 1 file changed, 6 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> index ba8c6038cd63..ca3761772211 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> @@ -48,21 +48,12 @@ static unsigned int rcar_du_encoder_count_ports(struct device_node *node)
> static const struct drm_encoder_funcs rcar_du_encoder_funcs = {
> };
>
> -static void rcar_du_encoder_release(struct drm_device *dev, void *res)
> -{
> - struct rcar_du_encoder *renc = res;
> -
> - drm_encoder_cleanup(&renc->base);
> - kfree(renc);
> -}
> -
> int rcar_du_encoder_init(struct rcar_du_device *rcdu,
> enum rcar_du_output output,
> struct device_node *enc_node)
> {
> struct rcar_du_encoder *renc;
> struct drm_bridge *bridge;
> - int ret;
>
> /*
> * Locate the DRM bridge from the DT node. For the DPAD outputs, if the
> @@ -101,26 +92,16 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
> return -ENOLINK;
> }
>
> - renc = kzalloc(sizeof(*renc), GFP_KERNEL);
> - if (renc == NULL)
> - return -ENOMEM;
> -
> - renc->output = output;
> -
> dev_dbg(rcdu->dev, "initializing encoder %pOF for output %u\n",
> enc_node, output);
>
> - ret = drm_encoder_init(&rcdu->ddev, &renc->base, &rcar_du_encoder_funcs,
> - DRM_MODE_ENCODER_NONE, NULL);
> - if (ret < 0) {
> - kfree(renc);
> - return ret;
> - }
> + renc = drmm_encoder_alloc(&rcdu->ddev, struct rcar_du_encoder, base,
> + &rcar_du_encoder_funcs, DRM_MODE_ENCODER_NONE,
> + NULL);
> + if (!renc)
> + return -ENOMEM;
>
> - ret = drmm_add_action_or_reset(&rcdu->ddev, rcar_du_encoder_release,
> - renc);
> - if (ret)
> - return ret;
> + renc->output = output;
>
> /*
> * Attach the bridge to the encoder. The bridge will create the
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2021-01-13 22:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-13 17:02 [PATCH] drm: rcar-du: Use drmm_encoder_alloc() to manage encoder Kieran Bingham
2021-01-13 22:45 ` Laurent Pinchart [this message]
2021-01-15 13:27 ` Kieran Bingham
2021-01-14 10:00 ` Geert Uytterhoeven
2021-03-01 10:30 ` Geert Uytterhoeven
2021-03-01 11:52 ` Kieran Bingham
2021-03-02 21:23 ` Laurent Pinchart
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=X/94HaYff+rNR2YD@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=geert+renesas@glider.be \
--cc=kieran.bingham+renesas@ideasonboard.com \
--cc=linux-renesas-soc@vger.kernel.org \
/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).